Search in sources :

Example 86 with ObjectNotFoundException

use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.

the class ObjectNotFoundExceptionTest method testExceptionMessageConstructor.

@Test
public void testExceptionMessageConstructor() throws Exception {
    ObjectNotFoundException exception = new ObjectNotFoundException(TEST_MESSAGE_1);
    assertTrue(exception.getMessage().equals(TEST_MESSAGE_1));
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 87 with ObjectNotFoundException

use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.

the class ObjectNotFoundExceptionTest method testExceptionThrowableConstructor.

@Test
public void testExceptionThrowableConstructor() throws Exception {
    Exception exception = new Exception(TEST_MESSAGE_2);
    ObjectNotFoundException ObjectNotFoundException = new ObjectNotFoundException(exception);
    assertTrue(ObjectNotFoundException.getCause().getMessage().equals(TEST_MESSAGE_2));
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 88 with ObjectNotFoundException

use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.

the class NamespaceServiceTest method testDeleteNamespaceNoExists.

@Test
public void testDeleteNamespaceNoExists() throws Exception {
    // Try to get a non-existing namespace.
    try {
        namespaceService.deleteNamespace(new NamespaceKey(NAMESPACE));
        fail("Should throw an ObjectNotFoundException when namespace doesn't exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Namespace \"%s\" doesn't exist.", NAMESPACE), e.getMessage());
    }
}
Also used : NamespaceKey(org.finra.herd.model.api.xml.NamespaceKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 89 with ObjectNotFoundException

use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.

the class JobServiceTest method testCreateJobWithS3PropertiesDefinitionObjectKeyNotFoundThrows.

/**
 * Creates a job where the definition's S3 object key does not exist. It should throw a not found exception.
 *
 * @throws Exception
 */
@Test
public void testCreateJobWithS3PropertiesDefinitionObjectKeyNotFoundThrows() throws Exception {
    Parameter jobDefinitionS3Parameter = new Parameter("name1", "value1");
    Parameter jobCreateRequestS3Parameter = new Parameter("name2", "value2");
    String s3BucketName = "s3BucketName";
    S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
    S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreationObjectKey", jobCreateRequestS3Parameter);
    jobDefinitionS3PropertiesLocation.setKey("NOT_FOUND");
    try {
        createJobWithParameters(jobDefinitionS3PropertiesLocation, null, jobCreateRequestS3PropertiesLocation, null);
        Assert.fail("expected ObjectNotFoundException, but no exception was thrown");
    } catch (Exception e) {
        Assert.assertEquals("thrown exception type", ObjectNotFoundException.class, e.getClass());
        Assert.assertEquals("thrown exception message", "Specified S3 object key '" + jobDefinitionS3PropertiesLocation.getKey() + "' does not exist.", e.getMessage());
    }
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Parameter(org.finra.herd.model.api.xml.Parameter) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Test(org.junit.Test)

Example 90 with ObjectNotFoundException

use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.

the class JobServiceTest method testSignalJobNoExists.

@Test
public void testSignalJobNoExists() throws Exception {
    // Signal job with job id that does not exist.
    try {
        jobService.signalJob(new JobSignalRequest("job_does_not_exist", "receivetask1", null, null));
        fail("Should throw an ObjectNotFoundException.");
    } catch (ObjectNotFoundException ex) {
        assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", "job_does_not_exist", "receivetask1"), ex.getMessage());
    }
    // Signal job with receive task that does not exist.
    jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
    // Start the job.
    Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
    try {
        // Job should be waiting at Receive task.
        Job jobGet = jobService.getJob(job.getId(), false);
        assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
        assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
        jobService.signalJob(new JobSignalRequest(job.getId(), "receivetask_does_not_exist", null, null));
        fail("Should throw an ObjectNotFoundException.");
    } catch (ObjectNotFoundException ex) {
        assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", job.getId(), "receivetask_does_not_exist"), ex.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) JobSignalRequest(org.finra.herd.model.api.xml.JobSignalRequest) Job(org.finra.herd.model.api.xml.Job) 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