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());
}
}
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;
}
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);
}
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);
}
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());
}
}
Aggregations