Search in sources :

Example 1 with BusinessObjectDataAttributeCreateRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest in project herd by FINRAOS.

the class BusinessObjectDataAttributeServiceTest method testBusinessObjectDataAttributeServiceMethodsNewTransactionPropagation.

/**
 * This method is to get coverage for the business object data attribute service methods that have an explicit annotation for transaction propagation.
 */
@Test
public void testBusinessObjectDataAttributeServiceMethodsNewTransactionPropagation() {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data attribute key.
    BusinessObjectDataAttributeKey businessObjectDataAttributeKey = businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Try to create a business object data attribute when specified business object format does not exist.
    try {
        businessObjectDataAttributeServiceImpl.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(businessObjectDataAttributeKey, ATTRIBUTE_VALUE_1));
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to retrieve a business object data attribute when specified business object data instance does not exist.
    try {
        businessObjectDataAttributeServiceImpl.getBusinessObjectDataAttribute(businessObjectDataAttributeKey);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectDataKey, NO_BDATA_STATUS), e.getMessage());
    }
    // Try to update a business object data attribute when specified business object format does not exist.
    try {
        businessObjectDataAttributeServiceImpl.updateBusinessObjectDataAttribute(businessObjectDataAttributeKey, new BusinessObjectDataAttributeUpdateRequest(ATTRIBUTE_VALUE_2));
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to delete a business object data attribute when specified business object format does not exist.
    try {
        businessObjectDataAttributeServiceImpl.deleteBusinessObjectDataAttribute(businessObjectDataAttributeKey);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to retrieve keys for all business object data attributes for a non-existing business object data.
    try {
        assertTrue(CollectionUtils.isEmpty(businessObjectDataAttributeServiceImpl.getBusinessObjectDataAttributes(businessObjectDataKey).getBusinessObjectDataAttributeKeys()));
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectDataKey, NO_BDATA_STATUS), e.getMessage());
    }
}
Also used : BusinessObjectDataAttributeCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataAttributeUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeUpdateRequest) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 2 with BusinessObjectDataAttributeCreateRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest in project herd by FINRAOS.

the class BusinessObjectDataAttributeServiceTestHelper method createBusinessObjectDataAttributeCreateRequest.

/**
 * Creates a business object data attribute create request.
 *
 * @return the newly created business object data attribute create request
 */
public BusinessObjectDataAttributeCreateRequest createBusinessObjectDataAttributeCreateRequest(String namespaceCode, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String businessObjectDataPartitionValue, List<String> businessObjectDataSubPartitionValues, Integer businessObjectDataVersion, String businessObjectDataAttributeName, String businessObjectDataAttributeValue) {
    BusinessObjectDataAttributeCreateRequest request = new BusinessObjectDataAttributeCreateRequest();
    request.setBusinessObjectDataAttributeKey(new BusinessObjectDataAttributeKey(namespaceCode, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, businessObjectDataPartitionValue, businessObjectDataSubPartitionValues, businessObjectDataVersion, businessObjectDataAttributeName));
    request.setBusinessObjectDataAttributeValue(businessObjectDataAttributeValue);
    return request;
}
Also used : BusinessObjectDataAttributeCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey)

Example 3 with BusinessObjectDataAttributeCreateRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest in project herd by FINRAOS.

the class BusinessObjectDataAttributeRestControllerTest method testCreateBusinessObjectDataAttribute.

@Test
public void testCreateBusinessObjectDataAttribute() {
    // Create a business object data attribute key.
    BusinessObjectDataAttributeKey businessObjectDataAttributeKey = new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Create a business object data create request.
    BusinessObjectDataAttributeCreateRequest businessObjectDataAttributeCreateRequest = new BusinessObjectDataAttributeCreateRequest(businessObjectDataAttributeKey, ATTRIBUTE_VALUE_1);
    // Create a business object data attribute.
    BusinessObjectDataAttribute businessObjectDataAttribute = new BusinessObjectDataAttribute(ID, businessObjectDataAttributeKey, ATTRIBUTE_VALUE_1);
    // Mock the external calls.
    when(businessObjectDataAttributeService.createBusinessObjectDataAttribute(businessObjectDataAttributeCreateRequest)).thenReturn(businessObjectDataAttribute);
    // Call the method under test.
    BusinessObjectDataAttribute result = businessObjectDataAttributeRestController.createBusinessObjectDataAttribute(businessObjectDataAttributeCreateRequest);
    // Verify the external calls.
    verify(businessObjectDataAttributeService).createBusinessObjectDataAttribute(businessObjectDataAttributeCreateRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataAttribute, result);
}
Also used : BusinessObjectDataAttribute(org.finra.herd.model.api.xml.BusinessObjectDataAttribute) BusinessObjectDataAttributeCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey) Test(org.junit.Test)

Example 4 with BusinessObjectDataAttributeCreateRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest in project herd by FINRAOS.

the class CreateBusinessObjectDataAttribute method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String namespace = activitiHelper.getExpressionVariableAsString(this.namespace, execution);
    String businessObjectDefinitionName = activitiHelper.getExpressionVariableAsString(this.businessObjectDefinitionName, execution);
    String businessObjectFormatUsage = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatUsage, execution);
    String businessObjectFormatFileType = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatFileType, execution);
    Integer businessObjectFormatVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectFormatVersion, execution, "businessObjectFormatVersion", false);
    String partitionValue = activitiHelper.getExpressionVariableAsString(this.partitionValue, execution);
    String subPartitionValuesString = activitiHelper.getExpressionVariableAsString(this.subPartitionValues, execution);
    List<String> subPartitionValues = daoHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValuesString);
    Integer businessObjectDataVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectDataVersion, execution, "businessObjectDataVersion", false);
    String businessObjectDataAttributeName = activitiHelper.getExpressionVariableAsString(this.businessObjectDataAttributeName, execution);
    String businessObjectDataAttributeValue = activitiHelper.getExpressionVariableAsString(this.businessObjectDataAttributeValue, execution);
    BusinessObjectDataAttributeKey businessObjectDataAttributeKey = new BusinessObjectDataAttributeKey();
    businessObjectDataAttributeKey.setNamespace(namespace);
    businessObjectDataAttributeKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    businessObjectDataAttributeKey.setBusinessObjectFormatUsage(businessObjectFormatUsage);
    businessObjectDataAttributeKey.setBusinessObjectFormatFileType(businessObjectFormatFileType);
    businessObjectDataAttributeKey.setBusinessObjectFormatVersion(businessObjectFormatVersion);
    businessObjectDataAttributeKey.setPartitionValue(partitionValue);
    businessObjectDataAttributeKey.setSubPartitionValues(subPartitionValues);
    businessObjectDataAttributeKey.setBusinessObjectDataVersion(businessObjectDataVersion);
    businessObjectDataAttributeKey.setBusinessObjectDataAttributeName(businessObjectDataAttributeName);
    BusinessObjectDataAttributeCreateRequest businessObjectDataAttributeCreateRequest = new BusinessObjectDataAttributeCreateRequest();
    businessObjectDataAttributeCreateRequest.setBusinessObjectDataAttributeKey(businessObjectDataAttributeKey);
    businessObjectDataAttributeCreateRequest.setBusinessObjectDataAttributeValue(businessObjectDataAttributeValue);
    BusinessObjectDataAttribute businessObjectDataAttribute = businessObjectDataAttributeService.createBusinessObjectDataAttribute(businessObjectDataAttributeCreateRequest);
    setJsonResponseAsWorkflowVariable(businessObjectDataAttribute, execution);
}
Also used : BusinessObjectDataAttribute(org.finra.herd.model.api.xml.BusinessObjectDataAttribute) BusinessObjectDataAttributeCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey)

Example 5 with BusinessObjectDataAttributeCreateRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest in project herd by FINRAOS.

the class BusinessObjectDataAttributeServiceTest method testCreateBusinessObjectDataAttributeInvalidParameters.

@Test
public void testCreateBusinessObjectDataAttributeInvalidParameters() {
    // Try to create a business object data attribute when namespace contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(addSlash(BDEF_NAMESPACE), BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when namespace contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when business object definition name contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, addSlash(BDEF_NAME), FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when business object definition name contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when business object format usage contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, addSlash(FORMAT_USAGE_CODE), FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when business object format usage contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Business object format usage can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when business object format file type contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, addSlash(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when business object format file type contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Business object format file type can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when partition value contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, addSlash(PARTITION_VALUE), SUBPARTITION_VALUES, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when partition value contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Partition value can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when a sub-partition value contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(addSlash(PARTITION_VALUE_2)), DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when sub-partition value contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Subpartition value can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a business object data attribute when attribute name contains a forward slash character.
    try {
        businessObjectDataAttributeService.createBusinessObjectDataAttribute(new BusinessObjectDataAttributeCreateRequest(new BusinessObjectDataAttributeKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, addSlash(ATTRIBUTE_NAME_1_MIXED_CASE)), ATTRIBUTE_VALUE_1));
        fail("Should throw an IllegalArgumentException when attribute name contains a forward slash character.");
    } catch (IllegalArgumentException e) {
        assertEquals("Business object data attribute name can not contain a forward slash character.", e.getMessage());
    }
}
Also used : BusinessObjectDataAttributeCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataAttributeCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataAttributeCreateRequest)5 BusinessObjectDataAttributeKey (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey)5 Test (org.junit.Test)3 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDataAttributeUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataAttributeUpdateRequest)1 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)1