Search in sources :

Example 91 with ObjectNotFoundException

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());
    }
}
Also used : JobUpdateRequest(org.finra.herd.model.api.xml.JobUpdateRequest) Task(org.activiti.engine.task.Task) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test)

Example 92 with ObjectNotFoundException

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) DataProviderKey(org.finra.herd.model.api.xml.DataProviderKey) Test(org.junit.Test)

Example 93 with ObjectNotFoundException

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 94 with ObjectNotFoundException

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 95 with ObjectNotFoundException

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());
    }
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Aggregations

ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)216 Test (org.junit.Test)193 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)36 ArrayList (java.util.ArrayList)18 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)16 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 BusinessObjectDataAttributeKey (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey)14 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)12 TagKey (org.finra.herd.model.api.xml.TagKey)11 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)10 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)10 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)9 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)8 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)7 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)7 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)6 BusinessObjectDefinitionColumnKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey)6 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5