agave-apps/apps-core/src/test/java/org/iplantc/service/apps/model/GSoftwareIT.java
/**
     * Tests that the software default parameters used in job submission have the proper sanity checking against
     * the batch queue max values.
     * @param batchQueueField
     * @param batchQueueValue
     * @param softwareField
     * @param softwareValue
     * @param useDefaultQueue
     * @param message
     * @param expectExceptionThrown
     * @throws Exception
     */
Tests that the software default parameters used in job submission have the proper sanity checking against
the batch queue max values.
Tests that the software default parameters used in job submission have the proper sanity checking against the batch queue max values .
@Test (groups="model", dataProvider="defaultProcessorsSanityChecksProvider")
    public void defaultDefaultParametersSanityChecks(String batchQueueField,
    										  Object batchQueueValue, 
    										  String softwareField,
    										  Object softwareValue, 
    										  boolean useDefaultQueue, 
    										  String message, 
    										  boolean expectExceptionThrown)
	throws Exception 
    {
    	SystemDao systemDao = new SystemDao();
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode node = (ObjectNode)mapper.readTree(jsonTreeSoftwareBase.toString());
        ExecutionSystem executionSystem = null;
        boolean exceptionOccurred = false;
        String exceptionMsg = message;
        try 
        {
        	JSONObject executionJson = jtd.getTestDataObject("target/test-classes/systems/execution/execute.example.com.json");
        	executionSystem = (ExecutionSystem) systemDao.findBySystemId("sanitychecksystem");
        	if (executionSystem != null) 
        	{
        		systemDao.remove(executionSystem);
        	}
        	executionSystem = ExecutionSystem.fromJSON(executionJson);
        	executionSystem.setSystemId("sanitychecksystem");
        	executionSystem.setOwner(JSONTestDataUtil.TEST_OWNER);
        	executionSystem.getBatchQueues().clear();
	        JSONObject jsonQueue = executionJson.getJSONArray("queues").getJSONObject(0);
        	jsonQueue.put("name", "sanitycheckqueue");
        	jsonQueue.put("defaultNodes", -1);
        	jsonQueue.put("defaultProcessorsPerNode", -1);
        	jsonQueue.put("defaultMemoryPerNode", -1);
        	jsonQueue.put("defaultNodes", -1);
        	jsonQueue.put("default", useDefaultQueue);
        	jsonQueue.put(batchQueueField, batchQueueValue);
        	BatchQueue testQueue = BatchQueue.fromJSON(jsonQueue);
        	executionSystem.addBatchQueue(testQueue);
        	systemDao.persist(executionSystem);
            if (!useDefaultQueue) {
            	node.put("defaultQueue", testQueue.getName());
            }
            node.put("executionSystem", executionSystem.getSystemId());
            node.remove("executionType");
            node.put("executionType", executionSystem.getExecutionType().name());
            if (softwareValue instanceof Long)
            	node.put(softwareField, (Long)softwareValue);
            else 
            	node.put(softwareField, (String)softwareValue);
	        Software.fromJSON(new JSONObject(mapper.writeValueAsString(node)), JSONTestDataUtil.TEST_OWNER);
        }
        catch(SoftwareException e)
        {
            exceptionOccurred = true;
            exceptionMsg = "Invalid iPlant JSON submitted, attribute defaultProcessorsPerNode " + message + " \n"
            		+ "\"app." + softwareField + "\" = \"" + softwareValue + "\"\n"
            		+ "\"executionSystem.queue." + batchQueueField + "\" = \"" + batchQueueValue + "\"\n" 
            		+ e.getMessage();
        }
        catch(JSONException e)
        {
            exceptionOccurred  = true;
            exceptionMsg = "Malformed JSON parsing exception attribute defaultProcessorsPerNode " + message + " \n"
            		+ "\"app." + softwareField + "\" = \"" + softwareValue + "\"\n"
            		+ "\"executionSystem.queue." + batchQueueField + "\" = \"" + batchQueueValue + "\"\n" 
            		+ e.getMessage();
            if (!expectExceptionThrown)
                e.printStackTrace();
        }
        finally {
        	try { systemDao.remove(executionSystem); } catch (Throwable ignored) {}
        }
        Assert.assertEquals(exceptionOccurred, expectExceptionThrown, exceptionMsg);
    }
@ Test ( groups = "model" , dataProvider = "defaultProcessorsSanityChecksProvider" ) public void defaultDefaultParametersSanityChecks ( String batchQueueField , Object batchQueueValue , String softwareField , Object softwareValue , boolean useDefaultQueue , String message , boolean expectExceptionThrown ) throws Exception { SystemDao systemDao = new SystemDao ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; ObjectNode node = ( ObjectNode ) mapper . readTree ( jsonTreeSoftwareBase . toString ( ) ) ; ExecutionSystem executionSystem = null ; boolean exceptionOccurred = false ; String exceptionMsg = message ; try { JSONObject executionJson = jtd . getTestDataObject ( "target/test-classes/systems/execution/execute.example.com.json" ) ; executionSystem = ( ExecutionSystem ) systemDao . findBySystemId ( "sanitychecksystem" ) ; if ( executionSystem != null ) { systemDao . remove ( executionSystem ) ; } executionSystem = ExecutionSystem . fromJSON ( executionJson ) ; executionSystem . setSystemId ( "sanitychecksystem" ) ; executionSystem . setOwner ( JSONTestDataUtil . TEST_OWNER ) ; executionSystem . getBatchQueues ( ) . clear ( ) ; JSONObject jsonQueue = executionJson . getJSONArray ( "queues" ) . getJSONObject ( 0 ) ; jsonQueue . put ( "name" , "sanitycheckqueue" ) ; jsonQueue . put ( "defaultNodes" , - 1 ) ; jsonQueue . put ( "defaultProcessorsPerNode" , - 1 ) ; jsonQueue . put ( "defaultMemoryPerNode" , - 1 ) ; jsonQueue . put ( "defaultNodes" , - 1 ) ; jsonQueue . put ( "default" , useDefaultQueue ) ; jsonQueue . put ( batchQueueField , batchQueueValue ) ; BatchQueue testQueue = BatchQueue . fromJSON ( jsonQueue ) ; executionSystem . addBatchQueue ( testQueue ) ; systemDao . persist ( executionSystem ) ; if ( ! useDefaultQueue ) { node . put ( "defaultQueue" , testQueue . getName ( ) ) ; } node . put ( "executionSystem" , executionSystem . getSystemId ( ) ) ; node . remove ( "executionType" ) ; node . put ( "executionType" , executionSystem . getExecutionType ( ) . name ( ) ) ; if ( softwareValue instanceof Long ) node . put ( softwareField , ( Long ) softwareValue ) ; else node . put ( softwareField , ( String ) softwareValue ) ; Software . fromJSON ( new JSONObject ( mapper . writeValueAsString ( node ) ) , JSONTestDataUtil . TEST_OWNER ) ; } catch ( SoftwareException e ) { exceptionOccurred = true ; exceptionMsg = "Invalid iPlant JSON submitted, attribute defaultProcessorsPerNode " + message + " \n" + "\"app." + softwareField + "\" = \"" + softwareValue + "\"\n" + "\"executionSystem.queue." + batchQueueField + "\" = \"" + batchQueueValue + "\"\n" + e . getMessage ( ) ; } catch ( JSONException e ) { exceptionOccurred = true ; exceptionMsg = "Malformed JSON parsing exception attribute defaultProcessorsPerNode " + message + " \n" + "\"app." + softwareField + "\" = \"" + softwareValue + "\"\n" + "\"executionSystem.queue." + batchQueueField + "\" = \"" + batchQueueValue + "\"\n" + e . getMessage ( ) ; if ( ! expectExceptionThrown ) e . printStackTrace ( ) ; } finally { try { systemDao . remove ( executionSystem ) ; } catch ( Throwable ignored ) { } } Assert . assertEquals ( exceptionOccurred , expectExceptionThrown , exceptionMsg ) ; }
Tests that the software default parameters used in job submission have the proper sanity checking against
 the batch queue max values.
Tests that the software default parameters used in job submission have the proper sanity checking against the batch queue max values .
// create a new system for these tests //node.put("defaultProcessorsPerNode", softwareDefaultProcessorsPerNode);