use of org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinition.
@Test
public void testUpdateBusinessObjectDefinition() throws Exception {
// Create and persist a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
// Perform an update by changing the description and updating the attributes.
BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
// Retrieve the business object definition with include update history flag set to true.
BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
// Create business object definition change event.
List<BusinessObjectDefinitionChangeEvent> businessObjectDefinitionChangeEvents = new ArrayList<>();
businessObjectDefinitionChangeEvents.add(new BusinessObjectDefinitionChangeEvent(BDEF_DISPLAY_NAME_2, BDEF_DESCRIPTION_2, NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT_UPDATE_REQUEST, resultBusinessObjectDefinition.getBusinessObjectDefinitionChangeEvents().get(0).getEventTime(), resultBusinessObjectDefinition.getBusinessObjectDefinitionChangeEvents().get(0).getUserId()));
// Validate the result.
assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), businessObjectDefinitionChangeEvents), resultBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testGetBusinessObjectDefinitionNewTransaction.
/**
* This method is to get coverage for the business object definition service method that starts a new transaction.
*/
@Test
public void testGetBusinessObjectDefinitionNewTransaction() throws Exception {
try {
businessObjectDefinitionServiceImpl.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest());
fail();
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDefinitionServiceImpl.deleteBusinessObjectDefinition(new BusinessObjectDefinitionKey());
fail();
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDefinitionServiceImpl.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(), NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
fail();
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDefinitionServiceImpl.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(), new BusinessObjectDefinitionUpdateRequest());
fail();
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest());
fail();
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
businessObjectDefinitionServiceImpl.updateSearchIndexDocumentBusinessObjectDefinition(new SearchIndexUpdateDto(SearchIndexUpdateDto.MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, new ArrayList<>(), SearchIndexUpdateDto.SEARCH_INDEX_UPDATE_TYPE_CREATE));
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionUpperCaseParameters.
@Test
public void testUpdateBusinessObjectDefinitionUpperCaseParameters() {
// Create and persist a business object definition entity using lower case values.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), DATA_PROVIDER_NAME.toLowerCase(), BDEF_DESCRIPTION.toLowerCase(), BDEF_DISPLAY_NAME.toLowerCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase())));
// Perform an update using upper case input parameters.
BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase()), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2.toUpperCase(), BDEF_DISPLAY_NAME_2.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toUpperCase()))));
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), DATA_PROVIDER_NAME.toLowerCase(), BDEF_DESCRIPTION_2.toUpperCase(), NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toUpperCase())), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionNoOriginalAttributes.
@Test
public void testUpdateBusinessObjectDefinitionNoOriginalAttributes() throws Exception {
// Create and persist a business object definition entity without any attributes.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
// Perform an update by changing the description and adding the new attributes.
BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionMissingRequiredParameters.
@Test
public void testUpdateBusinessObjectDefinitionMissingRequiredParameters() {
// Try to update a business object definition instance when object definition name is not specified.
try {
businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BLANK_TEXT), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object definition name must be specified.", e.getMessage());
}
// Try to update a business object definition instance when attribute name is not specified.
try {
businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, Arrays.asList(new Attribute(BLANK_TEXT, ATTRIBUTE_VALUE_1))));
fail("Should throw an IllegalArgumentException when attribute name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("An attribute name must be specified.", e.getMessage());
}
}
Aggregations