/** * 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; }
storageUnit.setStorage(storage); storage.setName("TEST_STORAGE"); List<StorageFile> storageFiles = new ArrayList<>(); storageUnit.setStorageFiles(storageFiles);
storage.setName(storageEntity.getName()); storage.setStoragePlatformName(storageEntity.getStoragePlatform().getName());
storage.setName(storageEntity.getName()); storage.setStoragePlatformName(storageEntity.getStoragePlatform().getName());
@Test public void getStorageUnitByStorageName() { // Create business object data with several test storage units. BusinessObjectData businessObjectData = new BusinessObjectData(); List<String> testStorageNames = Arrays.asList("Storage_1", "storage-2", "STORAGE3"); List<StorageUnit> storageUnits = new ArrayList<>(); businessObjectData.setStorageUnits(storageUnits); for (String testStorageName : testStorageNames) { StorageUnit storageUnit = new StorageUnit(); storageUnits.add(storageUnit); Storage storage = new Storage(); storageUnit.setStorage(storage); storage.setName(testStorageName); } // Validate that we can find all storage units regardless of the storage name case. for (String testStorageName : testStorageNames) { assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName).getStorage().getName()); assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName.toUpperCase()).getStorage().getName()); assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName.toLowerCase()).getStorage().getName()); } }
@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()); } }
sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) {
sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) {
sourceName = this.getName(); String copyName = ((String) strategy.copy(LocatorUtils.property(locator, "name", sourceName), sourceName, (this.name!= null))); copy.setName(copyName); } else { if (nameShouldBeCopiedAndSet == Boolean.FALSE) {