Search in sources :

Example 96 with ObjectNotFoundException

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

the class BusinessObjectDefinitionTagServiceTest method testDeleteBusinessObjectDefinitionTagTagNoExists.

@Test
public void testDeleteBusinessObjectDefinitionTagTagNoExists() {
    // Try to create a non-existing business object definition tag.
    try {
        businessObjectDefinitionTagService.deleteBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE)));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Tag with tag type \"%s\" and code \"%s\" does not exist for business object definition {%s}.", TAG_TYPE, TAG_CODE, businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionKeyAsString(BDEF_NAMESPACE, BDEF_NAME)), e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 97 with ObjectNotFoundException

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

the class EmrServiceTest method testEmrServiceMethodsNewTx.

/**
 * This method is to get the coverage for the emr service method that starts the new transaction.
 */
@Test
public void testEmrServiceMethodsNewTx() throws Exception {
    EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
    try {
        emrServiceImpl.createCluster(request);
        fail("Should throw a ObjectNotFoundException.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Namespace \"" + NAMESPACE + "\" doesn't exist.", e.getMessage());
    }
    try {
        EmrShellStepAddRequest stepRequest = getNewEmrShellStepAddRequest(request.getEmrClusterName());
        emrServiceImpl.addStepToCluster(stepRequest);
        fail("Should throw a ObjectNotFoundException.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Namespace \"" + NAMESPACE + "\" doesn't exist.", e.getMessage());
    }
    try {
        EmrMasterSecurityGroupAddRequest emrMasterSecurityGroupAddRequest = getNewEmrAddSecurityGroupMasterRequest(request.getEmrClusterName());
        emrServiceImpl.addSecurityGroupsToClusterMaster(emrMasterSecurityGroupAddRequest);
        fail("Should throw a ObjectNotFoundException.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Namespace \"" + NAMESPACE + "\" doesn't exist.", e.getMessage());
    }
    try {
        EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = EmrClusterAlternateKeyDto.builder().withNamespace(NAMESPACE).withEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME).withEmrClusterName("test_cluster").build();
        emrServiceImpl.getCluster(emrClusterAlternateKeyDto, null, null, false, null, false);
        fail("Should throw a ObjectNotFoundException.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Namespace \"" + NAMESPACE + "\" doesn't exist.", e.getMessage());
    }
    try {
        EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = EmrClusterAlternateKeyDto.builder().withNamespace(NAMESPACE).withEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME).withEmrClusterName("test_cluster").build();
        emrServiceImpl.terminateCluster(emrClusterAlternateKeyDto, false, null, null);
        fail("Should throw a ObjectNotFoundException.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Namespace \"" + NAMESPACE + "\" doesn't exist.", e.getMessage());
    }
}
Also used : EmrMasterSecurityGroupAddRequest(org.finra.herd.model.api.xml.EmrMasterSecurityGroupAddRequest) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) EmrShellStepAddRequest(org.finra.herd.model.api.xml.EmrShellStepAddRequest) EmrClusterAlternateKeyDto(org.finra.herd.model.dto.EmrClusterAlternateKeyDto) Test(org.junit.Test)

Example 98 with ObjectNotFoundException

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

the class EmrServiceWithAccountIdTest method testCreateEmrClusterWithAccountIdAccountNoExists.

@Test
public void testCreateEmrClusterWithAccountIdAccountNoExists() throws Exception {
    // Create the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    String definitionXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
    EmrClusterDefinition expectedEmrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, definitionXml);
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, definitionXml);
    // Create a new EMR cluster create request and add an account id to the EMR cluster definition override.
    EmrClusterCreateRequest emrClusterCreateRequest = getNewEmrClusterCreateRequestWithAccountId();
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    emrClusterCreateRequest.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
    emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
    // Try to create an EMR cluster using a non-existing AWS account.
    try {
        emrService.createCluster(emrClusterCreateRequest);
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Trusting AWS account with id \"%s\" doesn't exist.", AWS_ACCOUNT_ID), e.getMessage());
    }
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 99 with ObjectNotFoundException

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

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesPartitionKeyGroupNoExists.

@Test
public void testCreateExpectedPartitionValuesPartitionKeyGroupNoExists() {
    // Try to perform a create using a non-existing partition key group name.
    ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest("I_DO_NOT_EXIST", expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    try {
        expectedPartitionValueService.createExpectedPartitionValues(request);
        fail("Should throw an IllegalArgumentException when partition key group does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Partition key group \"%s\" doesn't exist.", request.getPartitionKeyGroupKey().getPartitionKeyGroupName()), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 100 with ObjectNotFoundException

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

the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesPartitionKeyGroupNoExists.

@Test
public void testDeleteExpectedPartitionValuesPartitionKeyGroupNoExists() {
    // Try to perform a delete using a non-existing partition key group name.
    ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest("I_DO_NOT_EXIST", expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    try {
        expectedPartitionValueService.deleteExpectedPartitionValues(request);
        fail("Should throw an IllegalArgumentException when partition key group does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Partition key group \"%s\" doesn't exist.", request.getPartitionKeyGroupKey().getPartitionKeyGroupName()), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) 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