@Test public void testExecuteFunctionForBusinessObjectDefinitionEntities() { // Create a list of business object definition entities. final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Collections.unmodifiableList(Arrays.asList( businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes()), businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()))); businessObjectDefinitionEntities.forEach(entity -> { entity.setDescriptiveBusinessObjectFormat(new BusinessObjectFormatEntity()); entity.getDescriptiveBusinessObjectFormat().setSchemaColumns(new ArrayList<>()); entity.setSubjectMatterExperts(new ArrayList<>()); }); // Mock the external calls. when(jsonHelper.objectToJson(any())).thenReturn(JSON_STRING); // Execute a function for all business object definition entities. businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, SEARCH_INDEX_DOCUMENT_TYPE, businessObjectDefinitionEntities, (indexName, documentType, id, json) -> { }); // Verify the external calls. verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }
@Test public void testProcessTagSearchScoreMultiplierTagsEmpty() { // Create a business object definition entity final BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2()); // Associate business object definition entity with no tag entities List<BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntities = new ArrayList<>(); businessObjectDefinitionEntity.setBusinessObjectDefinitionTags(businessObjectDefinitionTagEntities); // Call the method under test businessObjectDefinitionHelper.processTagSearchScoreMultiplier(businessObjectDefinitionEntity); // Validate the result assertEquals(businessObjectDefinitionEntity.getTagSearchScoreMultiplier(), BigDecimal.ONE.setScale(3, RoundingMode.HALF_UP)); } }
@Test public void testUpdateBusinessObjectDefinitionDuplicateOriginalAttributes() throws Exception { // Create and persist a business object definition entity with duplicate attributes. businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays .asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1), new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1_UPDATED))); // Try to update a business object definition that has duplicate attributes. try { businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2())); fail("Should throw an IllegalStateException when business object definition contains duplicate attributes."); } catch (IllegalStateException e) { assertEquals(String .format("Found duplicate attribute with name \"%s\" for business object definition {namespace: \"%s\", businessObjectDefinitionName: \"%s\"}.", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), NAMESPACE, BDEF_NAME), e.getMessage()); } }
@Test public void testUpdateBusinessObjectFormatAttributes() { List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes2(); BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(); businessObjectFormat.setAttributes(attributes); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION); BusinessObjectFormatAttributesUpdateRequest request = new BusinessObjectFormatAttributesUpdateRequest(attributes); when(businessObjectFormatService.updateBusinessObjectFormatAttributes(businessObjectFormatKey, request)).thenReturn(businessObjectFormat); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatRestController .updateBusinessObjectFormatAttributes(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, request); // Verify the external calls. verify(businessObjectFormatService).updateBusinessObjectFormatAttributes(businessObjectFormatKey, request); verifyNoMoreInteractions(businessObjectFormatService); // Validate the returned object. assertEquals(businessObjectFormat, updatedBusinessObjectFormat); }
@Test public void testExecuteFunctionForBusinessObjectDefinitionEntitiesJsonParseException() { // Create a list of business object definition entities. final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Collections.unmodifiableList(Arrays.asList( businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes()), businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()))); businessObjectDefinitionEntities.forEach(entity -> { entity.setDescriptiveBusinessObjectFormat(new BusinessObjectFormatEntity()); entity.getDescriptiveBusinessObjectFormat().setSchemaColumns(new ArrayList<>()); entity.setSubjectMatterExperts(new ArrayList<>()); }); // Mock the external calls. when(jsonHelper.objectToJson(any())) .thenThrow(new IllegalStateException(new JsonParseException("Failed to Parse", new JsonLocation("SRC", 100L, 1, 2)))); // Execute a function for all business object definition entities. businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, SEARCH_INDEX_DOCUMENT_TYPE, businessObjectDefinitionEntities, (indexName, documentType, id, json) -> { }); // Verify the external calls. verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }
@Test public void testUpdateBusinessObjectFormatRemoveSchema() { // Create an initial version of a business object format with a description and a schema. BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(); // Perform an update to remove the business object format schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, FORMAT_DOCUMENT_SCHEMA_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_SCHEMA); BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(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_2, FORMAT_DOCUMENT_SCHEMA_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), NO_SCHEMA, resultBusinessObjectFormat); }
@Test public void testUpdateStorageAttributes() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage storage = storageService.createStorage(request); // Update attributes for the storage. Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2())); // Validate the results. assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), businessObjectDefinitionServiceTestHelper.getNewAttributes2()), result); }
@Test public void testUpdateBusinessObjectFormatNoChangesToDescriptionDocumentSchemaAndSchema() { // Create an initial version of a business object format with format description and schema information. BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(); // Perform an update without making any changes to format description and schema information. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(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, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat); }
@Test public void testUpdateBusinessObjectDefinitionNoExists() throws Exception { // Try to update a non-existing business object definition. try { businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2())); fail("Should throw an ObjectNotFoundException when business object definition doesn't exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", BDEF_NAME, NAMESPACE), e.getMessage()); } }
@Test public void testUpdateBusinessObjectFormatDocumentSchemaToNull() { // Create an initial version of a business object format with some document schema BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, null, true, PARTITION_KEY); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); // Perform an update by changing the document schema to null BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION, NO_FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, NO_FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_ATTRIBUTE_DEFINITIONS, businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat); }
@Test public void testProcessTagSearchScoreMultiplier() { // Create a business object definition entity final BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2()); // Create two tag entities TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, null); TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER_NULL, TAG_DESCRIPTION, null); // Assocaite tag entities with business object definition entity List<BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntities = Arrays .asList(businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity1), businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity2)); businessObjectDefinitionEntity.setBusinessObjectDefinitionTags(businessObjectDefinitionTagEntities); // Call the method under test businessObjectDefinitionHelper.processTagSearchScoreMultiplier(businessObjectDefinitionEntity); // Validate the result assertEquals(businessObjectDefinitionEntity.getTagSearchScoreMultiplier(), TAG_SEARCH_SCORE_MULTIPLIER.setScale(3, RoundingMode.HALF_UP)); }
@Test public void testUpdateBusinessObjectFormatNoInitialDescriptionAndSchema() { // Create an initial version of a business object format without description and schema. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, null, FORMAT_DOCUMENT_SCHEMA, true, PARTITION_KEY); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); // Perform an update by changing the description and schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION_2, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_ATTRIBUTE_DEFINITIONS, businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat); }
@Test public void testUpdateBusinessObjectFormatNoInitialDocumentSchema() { // Create an initial version of a business object format without document schema. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, null, true, PARTITION_KEY); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); // Perform an update by changing the document schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(businessObjectFormatEntity.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, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_ATTRIBUTE_DEFINITIONS, businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat); }
@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); }
@Test public void testUpdateStorageAttributesStorageHasDuplicateAttributes() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage storage = storageService.createStorage(request); // Add a duplicate attribute to the storage. StorageEntity storageEntity = storageDao.getStorageByName(storage.getName()); StorageAttributeEntity storageAttributeEntity = new StorageAttributeEntity(); storageAttributeEntity.setStorage(storageEntity); storageAttributeEntity.setName(request.getAttributes().get(0).getName().toUpperCase()); storageEntity.getAttributes().add(storageAttributeEntity); storageDao.saveAndRefresh(storageEntity); // Try to update attributes for the storage. try { storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2())); } catch (IllegalStateException e) { assertEquals(String.format("Found duplicate attribute with name \"%s\" for \"%s\" storage.", request.getAttributes().get(0).getName().toLowerCase(), storage.getName()), e.getMessage()); } }
@Test public void testUpdateBusinessObjectFormat() { // Create an initial version of a business object format with format description and schema information. BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes()); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); // Perform an update by changing the description and schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, FORMAT_DOCUMENT_SCHEMA_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(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_2, FORMAT_DOCUMENT_SCHEMA_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat); }
@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()); } }
@Test public void testUpdateBusinessObjectFormatWithMissingGlobalAttributes() { globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME); //create one non-format level global attribute globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL + "_1", GLOBAL_ATTRIBUTE_DEFINITON_NAME); List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes(); attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, "test attribute 1")); // Create an initial version of a business object format. BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); try { // Perform an update by changing the description and schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, FORMAT_DOCUMENT_SCHEMA_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); fail("should throw exception before"); } catch (IllegalArgumentException ex) { assertEquals(String.format("The business object format has a required attribute \"%s\" which was not specified or has a value which is blank.", GLOBAL_ATTRIBUTE_DEFINITON_NAME), ex.getMessage()); } }
@Test public void testUpdateBusinessObjectFormatInitialSchemaPresentAndDataIsRegistered() { // Create an initial version of a business object format with format description and schema information. businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(); // Retrieve the business object format entity. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey( new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION)); // Create a new partition key group for the update request. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2); // Create a business object data entity associated with the business object format. businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, INITIAL_DATA_VERSION, true, BDATA_STATUS); // Perform an update by changing the schema. BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper .createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2()); BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService .updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, true, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat); }
@Test public void testUpdateBusinessObjectFormatAttributes() { // Create an initial version of a business object format with format description and schema information. BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes()); List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes2(); BusinessObjectFormatAttributesUpdateRequest request = new BusinessObjectFormatAttributesUpdateRequest(attributes); // Perform an update by changing the description and schema. BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributes( 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, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat); }