Search in sources :

Example 16 with SystemJobRunRequest

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

the class SystemJobRestControllerTest method testRunSystemJobStoragePolicySelector.

@Test
public void testRunSystemJobStoragePolicySelector() throws Exception {
    // Create the system job run request.
    SystemJobRunRequest systemJobRunRequest = new SystemJobRunRequest(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.getKey(), String.valueOf(INTEGER_VALUE))));
    SystemJobRunResponse systemJobRunResponse = new SystemJobRunResponse(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.getKey(), String.valueOf(INTEGER_VALUE))));
    when(systemJobService.runSystemJob(systemJobRunRequest)).thenReturn(systemJobRunResponse);
    // Request to run the system job.
    SystemJobRunResponse resultSystemJobRunResponse = systemJobRestController.runSystemJob(systemJobRunRequest);
    // Verify the external calls.
    verify(systemJobService).runSystemJob(systemJobRunRequest);
    verifyNoMoreInteractions(systemJobService);
    // Validate the returned object.
    assertEquals(systemJobRunResponse, 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 17 with SystemJobRunRequest

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

the class SystemJobServiceTest method testRunSystemJobFileUploadCleanupInvalidParameters.

@Test
public void testRunSystemJobFileUploadCleanupInvalidParameters() throws Exception {
    // Try to run a system job when too many parameters are specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1), new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2))));
        fail("Should throw an IllegalArgumentException when too many parameters are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Too many parameters are specified for \"%s\" system job.", FileUploadCleanupJob.JOB_NAME), e.getMessage());
    }
    // Try to run a system job when invalid parameter name is specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1))));
        fail("Should throw an IllegalArgumentException when invalid parameter name is specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Parameter \"%s\" is not supported by \"%s\" system job.", ATTRIBUTE_NAME_1_MIXED_CASE, FileUploadCleanupJob.JOB_NAME), e.getMessage());
    }
    // Try to run a system job when invalid parameter value is specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey(), "NOT_AN_INTEGER"))));
        fail("Should throw an IllegalArgumentException when invalid parameter value is specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Parameter \"%s\" specifies a non-integer value \"NOT_AN_INTEGER\".", ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey()), 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 18 with SystemJobRunRequest

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

the class SystemJobServiceTest method testRunSystemJobSystemJobNoExists.

@Test
public void testRunSystemJobSystemJobNoExists() throws Exception {
    String testSystemJobName = "I_DO_NOT_EXIST";
    // Try to run a system job when specified system job name does not exist.
    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 19 with SystemJobRunRequest

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

the class SystemJobServiceTest method testRunSystemJobStoragePolicySelector.

// Storage policy selector system job
@Test
public void testRunSystemJobStoragePolicySelector() throws Exception {
    // Create the system job run request.
    SystemJobRunRequest systemJobRunRequest = new SystemJobRunRequest(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.getKey(), String.valueOf(INTEGER_VALUE))));
    // Request to run the system job.
    SystemJobRunResponse resultSystemJobRunResponse = systemJobService.runSystemJob(systemJobRunRequest);
    // Validate the returned object.
    assertEquals(new SystemJobRunResponse(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.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)

Example 20 with SystemJobRunRequest

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

the class SystemJobServiceTest method testRunSystemJobStoragePolicySelectorInvalidParameters.

@Test
public void testRunSystemJobStoragePolicySelectorInvalidParameters() throws Exception {
    // Try to run a system job when too many parameters are specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1), new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2))));
        fail("Should throw an IllegalArgumentException when too many parameters are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Too many parameters are specified for \"%s\" system job.", StoragePolicySelectorJob.JOB_NAME), e.getMessage());
    }
    // Try to run a system job when invalid parameter name is specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1))));
        fail("Should throw an IllegalArgumentException when invalid parameter name is specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Parameter \"%s\" is not supported by \"%s\" system job.", ATTRIBUTE_NAME_1_MIXED_CASE, StoragePolicySelectorJob.JOB_NAME), e.getMessage());
    }
    // Try to run a system job when invalid parameter value is specified.
    try {
        systemJobService.runSystemJob(new SystemJobRunRequest(StoragePolicySelectorJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.getKey(), "NOT_AN_INTEGER"))));
        fail("Should throw an IllegalArgumentException when invalid parameter value is specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Parameter \"%s\" specifies a non-integer value \"NOT_AN_INTEGER\".", ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_MAX_BDATA_INSTANCES.getKey()), e.getMessage());
    }
}
Also used : SystemJobRunRequest(org.finra.herd.model.api.xml.SystemJobRunRequest) Parameter(org.finra.herd.model.api.xml.Parameter) 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