@Test public void testUpdateBusinessObjectFormatAttributeDefinitionsDuplicateAttributeDefinitions() { List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes(); BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes); List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2(); // Check for the duplicate attribute definition. attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE)); BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions); try { businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); fail("Should throw an IllegalArgumentException."); } catch (IllegalArgumentException ex) { assertEquals(String.format("Duplicate attribute definition name \"%s\" found.", ATTRIBUTE_NAME_1_MIXED_CASE), ex.getMessage()); } }
@Test public void testUpdateBusinessObjectFormatAttributeDefinitionsBusinessObjectFormatNoExists() { BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2()); try { businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); fail("Business object format does not exist: No update con be performed if the format does not exists."); } catch (ObjectNotFoundException ex) { assertEquals(String.format( "Business object format with namespace \"%s\", business object definition name \"%s\", format usage \"%s\", format file type \"%s\", and format version \"%s\" doesn't exist.", NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), ex.getMessage()); } }
@Test public void testUpdateBusinessObjectFormatAttributeDefinitions() { List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes(); // Create an initial version of a business object format with format description and schema information. // Attributes are passed rather attribute definations as this method also set attribute definition by default and no need to create another method BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes); List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2(); BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions); // Perform an update by changing the description and schema. BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(originalBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, attributes, attributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat); }