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);
}
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());
}
}
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());
}
}
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);
}
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());
}
}
Aggregations