StorageUnitHelper { public void validateBusinessObjectDataStorageUnitKey(BusinessObjectDataStorageUnitKey key) { Assert.notNull(key, "A business object data storage unit key must be specified."); key.setNamespace(alternateKeyHelper.validateStringParameter("namespace", key.getNamespace())); key.setBusinessObjectDefinitionName( alternateKeyHelper.validateStringParameter("business object definition name", key.getBusinessObjectDefinitionName())); key.setBusinessObjectFormatUsage(alternateKeyHelper.validateStringParameter("business object format usage", key.getBusinessObjectFormatUsage())); key.setBusinessObjectFormatFileType( alternateKeyHelper.validateStringParameter("business object format file type", key.getBusinessObjectFormatFileType())); Assert.notNull(key.getBusinessObjectFormatVersion(), "A business object format version must be specified."); key.setPartitionValue(alternateKeyHelper.validateStringParameter("partition value", key.getPartitionValue())); businessObjectDataHelper.validateSubPartitionValues(key.getSubPartitionValues()); Assert.notNull(key.getBusinessObjectDataVersion(), "A business object data version must be specified."); key.setStorageName(alternateKeyHelper.validateStringParameter("storage name", key.getStorageName())); }  BusinessObjectDataStorageUnitKey createBusinessObjectDataStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName); BusinessObjectDataStorageUnitKey createStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName); BusinessObjectDataStorageUnitKey createStorageUnitKeyFromEntity(StorageUnitEntity storageUnitEntity); List<StorageUnitAvailabilityDto> excludeBusinessObjectDataStatus(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
        String excludedBusinessObjectDataStatus); List<StorageUnitAvailabilityDto> excludePartitions(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
        List<List<String>> excludedPartitions); BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey); List<Integer> getStorageUnitIds(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos); void validateBusinessObjectDataStorageUnitKey(BusinessObjectDataStorageUnitKey key);  }
@Test public void testValidateBusinessObjectDataStorageUnitKey() { BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); when(alternateKeyHelper.validateStringParameter("namespace", BDEF_NAMESPACE)).thenReturn(BDEF_NAMESPACE); when(alternateKeyHelper.validateStringParameter("business object definition name", BDEF_NAME)).thenReturn(BDEF_NAME); when(alternateKeyHelper.validateStringParameter("business object format usage", FORMAT_USAGE_CODE)).thenReturn(FORMAT_USAGE_CODE); when(alternateKeyHelper.validateStringParameter("business object format file type", FORMAT_FILE_TYPE_CODE)).thenReturn(FORMAT_FILE_TYPE_CODE); when(alternateKeyHelper.validateStringParameter("partition value", PARTITION_VALUE)).thenReturn(PARTITION_VALUE); when(alternateKeyHelper.validateStringParameter("storage name", STORAGE_NAME)).thenReturn(STORAGE_NAME); storageUnitHelper.validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey); verify(alternateKeyHelper).validateStringParameter("namespace", BDEF_NAMESPACE); verify(alternateKeyHelper).validateStringParameter("business object definition name", BDEF_NAME); verify(alternateKeyHelper).validateStringParameter("business object format usage", FORMAT_USAGE_CODE); verify(alternateKeyHelper).validateStringParameter("business object format file type", FORMAT_FILE_TYPE_CODE); verify(alternateKeyHelper).validateStringParameter("partition value", PARTITION_VALUE); verify(businessObjectDataHelper).validateSubPartitionValues(SUBPARTITION_VALUES); verify(alternateKeyHelper).validateStringParameter("storage name", STORAGE_NAME); verifyNoMoreInteractionsHelper(); }
@Test public void testValidateBusinessObjectDataStorageUnitKeyInvalidParameters() { try { storageUnitHelper.validateBusinessObjectDataStorageUnitKey(null); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data storage unit key must be specified.", e.getMessage()); } try { storageUnitHelper.validateBusinessObjectDataStorageUnitKey( new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME)); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object format version must be specified.", e.getMessage()); } try { storageUnitHelper.validateBusinessObjectDataStorageUnitKey( new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION, STORAGE_NAME)); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data version must be specified.", e.getMessage()); } }