/** * Gets a new storage object with the specified information. * * @param storageName the storage name. * * @return the newly created storage. */ private Storage getNewStorage(String storageName) { Storage storage = new Storage(); storage.setName(storageName); storage.setStoragePlatformName(StoragePlatformEntity.S3); List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); /* * Set the KMS key attribute if the storage name contains ignore case the word "KMS" (ex. S3_MANAGED_KMS) */ if (storageName.toLowerCase().contains("kms")) { attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "testKmsKeyId")); } storage.setAttributes(attributes); return storage; }
storage.setAttributes(storageAttributes); for (StorageAttributeEntity storageAttributeEntity : storageEntity.getAttributes())
storage.setAttributes(storageAttributes); for (StorageAttributeEntity storageAttributeEntity : storageEntity.getAttributes())
@Test public void testGetStorageAttributeValueByNameFromStorage() { final String testStorageName = "MY_TEST_STORAGE"; final String testAttributeNameNoExists = "I_DO_NOT_EXIST"; Storage testStorage = new Storage(); testStorage.setName(testStorageName); testStorage.setAttributes(businessObjectDefinitionServiceTestHelper.getNewAttributes()); assertEquals(ATTRIBUTE_VALUE_1, storageHelper.getStorageAttributeValueByName(ATTRIBUTE_NAME_1_MIXED_CASE, testStorage, Boolean.FALSE)); assertEquals(ATTRIBUTE_VALUE_2, storageHelper.getStorageAttributeValueByName(ATTRIBUTE_NAME_2_MIXED_CASE, testStorage, Boolean.TRUE)); // Testing attribute name case insensitivity. assertEquals(ATTRIBUTE_VALUE_1, storageHelper.getStorageAttributeValueByName(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), testStorage, Boolean.TRUE)); assertEquals(ATTRIBUTE_VALUE_1, storageHelper.getStorageAttributeValueByName(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), testStorage, Boolean.TRUE)); assertNull(storageHelper.getStorageAttributeValueByName(testAttributeNameNoExists, testStorage, Boolean.FALSE)); // Try to get a required attribute value what does not exist. try { storageHelper.getStorageAttributeValueByName(testAttributeNameNoExists, testStorage, Boolean.TRUE); fail("Suppose to throw a RuntimeException when required storage attribute does not exist or has a blank value."); } catch (RuntimeException e) { assertEquals(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", testAttributeNameNoExists, testStorage.getName()), e.getMessage()); } }
copy.attributes = null; if (copyAttributes!= null) { copy.setAttributes(copyAttributes);
copy.attributes = null; if (copyAttributes!= null) { copy.setAttributes(copyAttributes);
copy.attributes = null; if (copyAttributes!= null) { copy.setAttributes(copyAttributes);