use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class JobServiceTest method testUpdateJobInvalidParameters.
@Test
public void testUpdateJobInvalidParameters() throws Exception {
// Create a test job definition.
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_USER_TASK_WITH_CLASSPATH);
// Create and start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Job should be waiting at User task.
// Get the running job with non verbose.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Try to update a job using invalid job id.
try {
jobService.updateJob("I_DO_NOT_EXIST", new JobUpdateRequest(JobActionEnum.SUSPEND));
fail();
} catch (ObjectNotFoundException e) {
assertEquals("Job with ID \"I_DO_NOT_EXIST\" does not exist or is already completed.", e.getMessage());
}
// Try to resume an already running job.
try {
jobService.updateJob(job.getId(), new JobUpdateRequest(JobActionEnum.RESUME));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Job with ID \"%s\" is already in an active state.", job.getId()), e.getMessage());
}
// Suspend the job.
jobService.updateJob(job.getId(), new JobUpdateRequest(JobActionEnum.SUSPEND));
// Validate that the job is suspended.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.SUSPENDED, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Try to suspend an already suspended job.
try {
jobService.updateJob(job.getId(), new JobUpdateRequest(JobActionEnum.SUSPEND));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Job with ID \"%s\" is already in a suspended state.", job.getId()), e.getMessage());
}
// Resume the job.
jobService.updateJob(job.getId(), new JobUpdateRequest(JobActionEnum.RESUME));
// Validate that the job is running.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Query the pending task and complete it
List<Task> tasks = activitiTaskService.createTaskQuery().processInstanceId(job.getId()).list();
activitiTaskService.complete(tasks.get(0).getId());
// Job should have been completed.
// Get the completed job with non verbose.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.COMPLETED, jobGet.getStatus());
assertNotNull(jobGet.getStartTime());
assertNotNull(jobGet.getEndTime());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertNull(jobGet.getCurrentWorkflowStep());
// Try to update a completed job.
try {
jobService.updateJob(job.getId(), new JobUpdateRequest(JobActionEnum.SUSPEND));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Job with ID \"%s\" does not exist or is already completed.", job.getId()), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class DataProviderServiceTest method testDeleteDataProviderNoExists.
@Test
public void testDeleteDataProviderNoExists() throws Exception {
// Try to delete a non-existing data provider.
try {
dataProviderService.deleteDataProvider(new DataProviderKey(DATA_PROVIDER_NAME));
fail("Should throw an ObjectNotFoundException when data provider doesn't exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", DATA_PROVIDER_NAME), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinitionEmrClusterDefinitionNoExists.
@Test
public void testDeleteEmrClusterDefinitionEmrClusterDefinitionNoExists() throws Exception {
// Try to perform a delete using a non-existing EMR cluster definition name.
String testEmrClusterDefinitionName = "I_DO_NOT_EXIST";
try {
emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, testEmrClusterDefinitionName));
fail("Should throw an ObjectNotFoundException when EMR cluster definition does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("EMR cluster definition with name \"%s\" doesn't exist for namespace \"%s\".", testEmrClusterDefinitionName, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionEmrClusterDefinitionNoExists.
@Test
public void testUpdateEmrClusterDefinitionEmrClusterDefinitionNoExists() throws Exception {
// Try to perform an update using a non-existing EMR cluster definition name.
String testEmrClusterDefinitionName = "I_DO_NOT_EXIST";
try {
emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, testEmrClusterDefinitionName), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
fail("Should throw an ObjectNotFoundException when EMR cluster definition does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("EMR cluster definition with name \"%s\" doesn't exist for namespace \"%s\".", testEmrClusterDefinitionName, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesStorageNoExists.
@Test
public void testCreateBusinessObjectDataStorageFilesStorageNoExists() {
createData(null, false);
// Try to add storage files to a non-existing storage.
try {
businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, "I_DO_NOT_EXIST", Arrays.asList(createFile(FILE_PATH_2, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES));
fail("Should throw an ObjectNotFoundException when using non-existing storage.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Could not find storage unit in \"I_DO_NOT_EXIST\" storage for the business object data {%s}.", businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION)), e.getMessage());
}
}
Aggregations