BusinessObjectDataHelper { public StorageUnit getStorageUnitByStorageName(BusinessObjectData businessObjectData, String storageName) throws IllegalStateException { StorageUnit resultStorageUnit = null; for (StorageUnit storageUnit : businessObjectData.getStorageUnits()) { if (storageUnit.getStorage().getName().equalsIgnoreCase(storageName)) { resultStorageUnit = storageUnit; break; } } if (resultStorageUnit == null) { throw new IllegalStateException(String.format("Business object data has no storage unit with storage name \"%s\".", storageName)); } return resultStorageUnit; }  void assertBusinessObjectDataStatusEquals(String expectedBusinessObjectDataStatusCode, BusinessObjectDataEntity businessObjectDataEntity); String businessObjectDataEntityAltKeyToString(BusinessObjectDataEntity businessObjectDataEntity); String businessObjectDataKeyToString(BusinessObjectDataKey businessObjectDataKey); String businessObjectDataKeyToString(String namespace, String businessObjectDefinitionName, String businessObjectFormatUsage,
        String businessObjectFormatFileType, int businessObjectFormatVersion, String businessObjectDataPartitionValue,
        List<String> businessObjectDataSubPartitionValues, int businessObjectDataVersion); BusinessObjectDataCreateRequest createBusinessObjectDataCreateRequest(BusinessObjectFormatEntity businessObjectFormatEntity, String uuid,
        String businessObjectDataStatus, List<Attribute> attributes, StorageEntity storageEntity, String storageDirectoryPath, String storageFilePath,
        Long storageFileSizeBytes, Long storageFileRowCount); BusinessObjectData createBusinessObjectDataFromEntity(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectData createBusinessObjectDataFromEntity(BusinessObjectDataEntity businessObjectDataEntity,
        Boolean includeBusinessObjectDataStatusHistory, Boolean includeStorageUnitStatusHistory, Boolean excludeBusinessObjectDataStorageFiles); BusinessObjectDataKey createBusinessObjectDataKey(BusinessObjectData businessObjectData); BusinessObjectDataKey createBusinessObjectDataKeyFromEntity(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectDataKey createBusinessObjectDataKeyFromStorageUnitKey(BusinessObjectDataStorageUnitKey storageUnitKey); BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectData businessObjectData); Date getDateFromString(String dateString); List<String> getPartitionFilter(BusinessObjectDataKey businessObjectDataKey, List<String> samplePartitionFilter); String getPartitionValue(BusinessObjectDataEntity businessObjectDataEntity, int partitionColumnPosition); List<String> getPrimaryAndSubPartitionValues(BusinessObjectDataKey businessObjectDataKey); List<String> getPrimaryAndSubPartitionValues(BusinessObjectData businessObjectData); List<String> getPrimaryAndSubPartitionValues(BusinessObjectDataEntity businessObjectDataEntity); StorageUnit getStorageUnitByStorageName(BusinessObjectData businessObjectData, String storageName); List<String> getSubPartitionValues(BusinessObjectDataEntity businessObjectDataEntity); void validateBusinessObjectDataKey(BusinessObjectDataKey key, boolean businessObjectFormatVersionRequired, boolean businessObjectDataVersionRequired); void validatePartitionValueFilters(List<PartitionValueFilter> partitionValueFilters, PartitionValueFilter standalonePartitionValueFilter,
        boolean allowPartitionValueTokens); void validateRegistrationDateRangeFilter(RegistrationDateRangeFilter registrationDateRangeFilter); void validateSubPartitionValues(List<String> subPartitionValues);  }
@Test public void getStorageUnitByStorageName() { 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); } 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 getStorageUnitByStorageNameStorageUnitNoExists() { String testStorageName = "I_DO_NOT_EXIST"; try { businessObjectDataHelper.getStorageUnitByStorageName( new BusinessObjectData(INTEGER_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, NO_STORAGE_UNITS, NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, NO_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_RETENTION_EXPIRATION_DATE), testStorageName); fail("Should throw a IllegalStateException when storage unit does not exist."); } catch (IllegalStateException e) { assertEquals(String.format("Business object data has no storage unit with storage name \"%s\".", testStorageName), e.getMessage()); } }