agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/managers/JobRequestParameterProcessorIT.java
/**
     * Generic method to setup and run the {@link JobRequestParameterProcessor#process(Map)} and test for the expected
     * {@link JobProcessingException} to be thrown.
     *
     * @param softwareParameters the software parameters to add to the mock {@link Software} object for use when processing the response
     * @param key                the key of the parameter under test
     * @param json               the json object representing the job request's "parameters" value. The object should contain the test data as key and value of the object.
     * @return the processed job parameters
     * @throws JobProcessingException the processing exception thrown during the test
     */
Generic method to setup and run the  JobRequestParameterProcessor#process(Map) and test for the expected
JobProcessingException to be thrown.

@param softwareParameters the software parameters to add to the mock  Software object for use when processing the response
@param key                the key of the parameter under test
@param json               the json object representing the job request's "parameters" value. The object should contain the test data as key and value of the object.
@return the processed job parameters
@throws JobProcessingException the processing exception thrown during the test
Generic method to setup and run the JobRequestParameterProcessor#process ( Map ) and test for the expected JobProcessingException to be thrown . @param softwareParameters the software parameters to add to the mock Software object for use when processing the response @param key the key of the parameter under test @param json the json object representing the job request ' s " parameters " value . The object should contain the test data as key and value of the object . @return the processed job parameters @throws JobProcessingException the processing exception thrown during the test
private ObjectNode _genericProcess(List<SoftwareParameter> softwareParameters, String key, ObjectNode json) throws JobProcessingException {
        JobRequestParameterProcessor jobRequestParameterProcessor = mock(JobRequestParameterProcessor.class);
        Software software = mock(Software.class);
        when(software.getParameters()).thenReturn(softwareParameters);
        when(jobRequestParameterProcessor.getSoftware()).thenReturn(software);
        doCallRealMethod().when(jobRequestParameterProcessor).process(any());
        ObjectMapper mapper = new ObjectMapper();
        when(jobRequestParameterProcessor.getMapper()).thenReturn(mapper);
        jobRequestParameterProcessor.jobParameters = mapper.createObjectNode();
        doNothing().when(jobRequestParameterProcessor).setJobParameters(any());
        when(jobRequestParameterProcessor.getJobParameters()).thenCallRealMethod();
        HashMap<String, Object> parameterMap = jsonObjectToMap(key, json);
        jobRequestParameterProcessor.process(parameterMap);
        return jobRequestParameterProcessor.getJobParameters();
    }
private ObjectNode _genericProcess ( List < SoftwareParameter > softwareParameters , String key , ObjectNode json ) throws JobProcessingException { JobRequestParameterProcessor jobRequestParameterProcessor = mock ( JobRequestParameterProcessor . class ) ; Software software = mock ( Software . class ) ; when ( software . getParameters ( ) ) . thenReturn ( softwareParameters ) ; when ( jobRequestParameterProcessor . getSoftware ( ) ) . thenReturn ( software ) ; doCallRealMethod ( ) . when ( jobRequestParameterProcessor ) . process ( any ( ) ) ; ObjectMapper mapper = new ObjectMapper ( ) ; when ( jobRequestParameterProcessor . getMapper ( ) ) . thenReturn ( mapper ) ; jobRequestParameterProcessor . jobParameters = mapper . createObjectNode ( ) ; doNothing ( ) . when ( jobRequestParameterProcessor ) . setJobParameters ( any ( ) ) ; when ( jobRequestParameterProcessor . getJobParameters ( ) ) . thenCallRealMethod ( ) ; HashMap < String , Object > parameterMap = jsonObjectToMap ( key , json ) ; jobRequestParameterProcessor . process ( parameterMap ) ; return jobRequestParameterProcessor . getJobParameters ( ) ; }
Generic method to setup and run the {@link JobRequestParameterProcessor#process(Map)} and test for the expected
 {@link JobProcessingException} to be thrown.
Generic method to setup and run the { @link JobRequestParameterProcessor#process ( Map ) } and test for the expected { @link JobProcessingException } to be thrown .
// mock out the class under test so we control the scope of things under test // mock the software object and have it return our test parameters // mock out the call to get the job's software. we return our mock with the parameters under test // mock out the mapper method so we have a valid instance in the mocked class // mock out the job parameters so we can check them after the test // convert the json request object into a map // run the test // return whatever came back