/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
/** * Create an instance of {@link Attribute } * */ public Attribute createAttribute() { return new Attribute(); }
public Object createNewInstance() { return new Attribute(); }
public Object createNewInstance() { return new Attribute(); }
public Object createNewInstance() { return new Attribute(); }
/** * Gets a new list of attributes. * * @return the list of attributes. */ public List<Attribute> getNewAttributes() { List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_1)); attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_2_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_2)); attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_3_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_3)); return attributes; }
/** * Gets a second set of test attributes. * * @return the list of attributes */ public List<Attribute> getNewAttributes2() { List<Attribute> attributes = new ArrayList<>(); // Attribute 1 has a new value compared to the first set of test attributes. attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_1_UPDATED)); // Attribute 2 is missing compared to the first set of the test attributes. // Attribute 3 is identical to the one from the first set of the test attributes. attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_3_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_3)); // Attribute 4 is not present in the first set of the test attributes. attributes.add(new Attribute(AbstractServiceTest.ATTRIBUTE_NAME_4_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_VALUE_4)); return attributes; }
/** * Gets storage attributes required for relational table registration unit tests. * * @return the list of attributes */ List<Attribute> getStorageAttributes() { // The storage attributes specify JDBC connection to point to the in-memory database setup as part of DAO mocks. // For simplify validation, the attributes are listed alphabetically by attribute name ascending. return Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_URL), AbstractServiceTest.JDBC_URL), new Attribute(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_USER_CREDENTIAL_NAME), AbstractServiceTest.EMPTY_STRING), new Attribute(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_USERNAME), AbstractServiceTest.EMPTY_STRING)); } }
/** * Creates and persists a new storage entity with an attribute. * * @param storageName the storage name * @param storagePlatformCode the storage platform code * @param attributeName the attribute name * @param attributeValue the attribute value * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, String storagePlatformCode, String attributeName, String attributeValue) { List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(attributeName, attributeValue)); return createStorageEntity(storageName, storagePlatformCode, attributes); }
private StorageEntity createTestStorageEntity(String storageName, String bucketName) throws Exception { List<Attribute> attributes = new ArrayList<>(); // If specified, populate bucket name attribute for this storage. if (StringUtils.isNotBlank(bucketName)) { attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), bucketName)); } return storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); }
@Test public void testCreateBusinessObjectDefinitionDuplicateAttributes() { // Try to create a business object definition instance when duplicate attributes are specified. try { businessObjectDefinitionService.createBusinessObjectDefinition( new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays .asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)))); fail("Should throw an IllegalArgumentException when duplicate attributes are specified."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage()); } }
@Test public void testUpdateBusinessObjectDefinitionDuplicateAttributes() { // Try to update a business object definition instance when duplicate attributes are specified. try { businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, Arrays .asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)))); fail("Should throw an IllegalArgumentException when duplicate attributes are specified."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage()); } }
/** * Creates a storage from it's entity object. * * @param storageEntity the storage entity * * @return the storage */ private Storage createStorageFromEntity(StorageEntity storageEntity) { // Create a list of attributes. List<Attribute> attributes = new ArrayList<>(); for (StorageAttributeEntity attributeEntity : storageEntity.getAttributes()) { attributes.add(new Attribute(attributeEntity.getName(), attributeEntity.getValue())); } return new Storage(storageEntity.getName(), storageEntity.getStoragePlatform().getName(), attributes); }
/** * Creates a storage from it's entity object. * * @param storageEntity the storage entity * * @return the storage */ private Storage createStorageFromEntity(StorageEntity storageEntity) { // Create a list of attributes. List<Attribute> attributes = new ArrayList<>(); for (StorageAttributeEntity attributeEntity : storageEntity.getAttributes()) { attributes.add(new Attribute(attributeEntity.getName(), attributeEntity.getValue())); } return new Storage(storageEntity.getName(), storageEntity.getStoragePlatform().getName(), attributes); }
@Test public void testValidateAttributesAgainstBusinessObjectDataAttributeDefinitionsAttributeNamesEqualIgnoreCase() { // Create a business object data attribute definition for a required attribute with attribute name in upper case. BusinessObjectDataAttributeDefinitionEntity businessObjectDataAttributeDefinitionEntity = new BusinessObjectDataAttributeDefinitionEntity(); businessObjectDataAttributeDefinitionEntity.setName(ATTRIBUTE_NAME.toUpperCase()); // Call the method under test with the attribute name specified in lowercase. attributeDaoHelper .validateAttributesAgainstBusinessObjectDataAttributeDefinitions(Arrays.asList(new Attribute(ATTRIBUTE_NAME.toLowerCase(), ATTRIBUTE_VALUE)), Arrays.asList(businessObjectDataAttributeDefinitionEntity)); // Verify the external calls. verifyNoMoreInteractionsHelper(); }
@Test public void testCreateBusinessObjectFormatDuplicateAttributes() { // Try to create a business object format instance when duplicate attributes are specified. try { businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper .createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema())); fail("Should throw an IllegalArgumentException when duplicate attributes are specified."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage()); } }
@Test public void testCreateBusinessObjectFormatWithGlobalAttributesAndAllowedAttributeValues() { GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntityWithAllowedAttributeValues(); List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes(); attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME.toLowerCase(), ALLOWED_ATTRIBUTE_VALUE_2)); // Create an initial version of a business object format. BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, attributes, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), businessObjectFormat); }
@Test public void testCreateDownloaderOutputManifestDtoAssertOutputAttributesSetWhenBdataAttributesSet() { BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setAttributes(new ArrayList<>()); businessObjectData.getAttributes().add(new Attribute("name", "value")); StorageUnit storageUnit = new StorageUnit(new Storage("storageName", null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); String s3KeyPrefix = "s3KeyPrefix"; DownloaderOutputManifestDto actual = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals(1, actual.getAttributes().size()); assertEquals("value", actual.getAttributes().get("name")); }
@Test public void testCreateBusinessObjectFormatWithGlobalAttributes() { 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); // Validate the returned object. businessObjectFormatServiceTestHelper .validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, attributes, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), businessObjectFormat); }