Search in sources :

Example 21 with SystemJobRunRequest

use of org.finra.herd.model.api.xml.SystemJobRunRequest in project herd by FINRAOS.

the class SystemJobServiceTest method testRunSystemJobJobNameCaseSensitivity.

// Job name case sensitivity test for all system jobs
@Test
public void testRunSystemJobJobNameCaseSensitivity() throws Exception {
    // Try to run a system job when specified system job name does not match due to case sensitivity.
    for (String systemJobName : Arrays.asList(FileUploadCleanupJob.JOB_NAME, JmsPublishingJob.JOB_NAME, StoragePolicySelectorJob.JOB_NAME)) {
        String testSystemJobName = systemJobName.toUpperCase();
        try {
            systemJobService.runSystemJob(new SystemJobRunRequest(testSystemJobName, null));
            fail("Should throw an ObjectNotFoundException when specified system job name does not exist.");
        } catch (ObjectNotFoundException ex) {
            assertEquals(String.format("System job with name \"%s\" doesn't exist.", testSystemJobName), ex.getMessage());
        }
    }
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 22 with SystemJobRunRequest

use of org.finra.herd.model.api.xml.SystemJobRunRequest in project herd by FINRAOS.

the class SystemJobServiceTest method testRunSystemJobFileUploadCleanupUpperCaseParameters.

@Test
public void testRunSystemJobFileUploadCleanupUpperCaseParameters() throws Exception {
    // Create a system job run request using upper case input parameters (except for case-sensitive job name).
    SystemJobRunRequest systemJobRunRequest = new SystemJobRunRequest(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey().toUpperCase(), String.valueOf(INTEGER_VALUE))));
    // Request to run the system job.
    SystemJobRunResponse resultSystemJobRunResponse = systemJobService.runSystemJob(systemJobRunRequest);
    // Validate the returned object.
    assertEquals(new SystemJobRunResponse(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey().toUpperCase(), String.valueOf(INTEGER_VALUE)))), resultSystemJobRunResponse);
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) Parameter(org.finra.herd.model.api.xml.Parameter) SystemJobRunResponse(org.finra.herd.model.api.xml.SystemJobRunResponse) Test(org.junit.Test)

Example 23 with SystemJobRunRequest

use of org.finra.herd.model.api.xml.SystemJobRunRequest in project herd by FINRAOS.

the class SystemJobServiceTest method testRunSystemJobJmsPublishingInvalidParameters.

@Test
public void testRunSystemJobJmsPublishingInvalidParameters() throws Exception {
    // Try to run the system job with the specified parameters.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(JmsPublishingJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1))));
        fail("Should throw an IllegalArgumentException when parameters are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("\"%s\" system job does not except parameters.", JmsPublishingJob.JOB_NAME), e.getMessage());
    }
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 24 with SystemJobRunRequest

use of org.finra.herd.model.api.xml.SystemJobRunRequest in project herd by FINRAOS.

the class SystemJobServiceTest method testRunSystemJobDuplicateParameters.

@Test
public void testRunSystemJobDuplicateParameters() throws Exception {
    // Try to run a system job when duplicate parameters are specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1), new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_2))));
        fail("Should throw an IllegalArgumentException when duplicate parameters are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate parameter name found: %s", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase()), e.getMessage());
    }
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 25 with SystemJobRunRequest

use of org.finra.herd.model.api.xml.SystemJobRunRequest in project herd by FINRAOS.

the class SystemJobServiceTest method testRunSystemJobFileUploadCleanupTrimParameters.

@Test
public void testRunSystemJobFileUploadCleanupTrimParameters() throws Exception {
    // Create a system job run request using input parameters with leading
    // and trailing empty spaces (except for  parameter values that do not get trimmed).
    SystemJobRunRequest systemJobRunRequest = new SystemJobRunRequest(addWhitespace(FileUploadCleanupJob.JOB_NAME), Arrays.asList(new Parameter(addWhitespace(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey()), String.valueOf(INTEGER_VALUE))));
    // Request to run the system job.
    SystemJobRunResponse resultSystemJobRunResponse = systemJobService.runSystemJob(systemJobRunRequest);
    // Validate the returned object.
    assertEquals(new SystemJobRunResponse(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey(), String.valueOf(INTEGER_VALUE)))), resultSystemJobRunResponse);
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) Parameter(org.finra.herd.model.api.xml.Parameter) SystemJobRunResponse(org.finra.herd.model.api.xml.SystemJobRunResponse) Test(org.junit.Test)

Aggregations

SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)27 Test (org.junit.Test)27 Parameter (org.finra.herd.model.api.xml.Parameter)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)19 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2