UploadDownloadHelper { public void validateAndTrimBusinessObjectDataStorageFileKey(BusinessObjectDataStorageFileKey businessObjectDataStorageFileKey) { Assert.notNull(businessObjectDataStorageFileKey, "A business object data storage file key must be specified."); businessObjectDataStorageFileKey .setNamespace(alternateKeyHelper.validateStringParameter("namespace", businessObjectDataStorageFileKey.getNamespace())); businessObjectDataStorageFileKey.setBusinessObjectDefinitionName(alternateKeyHelper .validateStringParameter("business object definition name", businessObjectDataStorageFileKey.getBusinessObjectDefinitionName())); businessObjectDataStorageFileKey.setBusinessObjectFormatUsage(alternateKeyHelper .validateStringParameter("business object format usage", businessObjectDataStorageFileKey.getBusinessObjectFormatUsage())); businessObjectDataStorageFileKey.setBusinessObjectFormatFileType(alternateKeyHelper .validateStringParameter("business object format file type", businessObjectDataStorageFileKey.getBusinessObjectFormatFileType())); Assert.notNull(businessObjectDataStorageFileKey.getBusinessObjectFormatVersion(), "A business object format version must be specified."); businessObjectDataStorageFileKey.setPartitionValue(alternateKeyHelper .validateStringParameter("partition value", businessObjectDataStorageFileKey.getPartitionValue())); List<String> subPartitionValues = Lists.newArrayList(); if (CollectionUtils.isNotEmpty(businessObjectDataStorageFileKey.getSubPartitionValues())) { for (String subPartitionValue : businessObjectDataStorageFileKey.getSubPartitionValues()) { subPartitionValues.add(alternateKeyHelper.validateStringParameter("sub partition value", subPartitionValue)); } } businessObjectDataStorageFileKey.setSubPartitionValues(subPartitionValues); Assert.notNull(businessObjectDataStorageFileKey.getBusinessObjectDataVersion(), "A business object data version must be specified."); businessObjectDataStorageFileKey.setStorageName(alternateKeyHelper .validateStringParameter("storage name", businessObjectDataStorageFileKey.getStorageName())); Assert.hasText(businessObjectDataStorageFileKey.getFilePath(), "A file path must be specified."); businessObjectDataStorageFileKey.setFilePath(businessObjectDataStorageFileKey.getFilePath().trim()); }  void validateAndTrimDownloadBusinessObjectDataStorageFileSingleInitiationRequest(
        DownloadBusinessObjectDataStorageFileSingleInitiationRequest downloadBusinessObjectDataStorageFileSingleInitiationRequest); void validateAndTrimBusinessObjectDataStorageFileKey(BusinessObjectDataStorageFileKey businessObjectDataStorageFileKey);  }
@Test public void testValidateAndTrimBusinessObjectStorageFileKey() { BusinessObjectDataStorageFileKey businessObjectDataStorageFileKey = new BusinessObjectDataStorageFileKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME, TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE + " "); when(alternateKeyHelper.validateStringParameter("namespace", NAMESPACE)).thenReturn(NAMESPACE_2); when(alternateKeyHelper.validateStringParameter("business object definition name", BDEF_NAME)).thenReturn(BDEF_NAME_2); when(alternateKeyHelper.validateStringParameter("business object format usage", FORMAT_USAGE_CODE)).thenReturn(FORMAT_USAGE_CODE_2); when(alternateKeyHelper.validateStringParameter("business object format file type", FORMAT_FILE_TYPE_CODE)).thenReturn(FORMAT_FILE_TYPE_CODE_2); when(alternateKeyHelper.validateStringParameter("partition value", PARTITION_VALUE)).thenReturn(PARTITION_VALUE_2); for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) { when(alternateKeyHelper.validateStringParameter("sub partition value", SUBPARTITION_VALUES.get(i))).thenReturn(SUBPARTITION_VALUES_2.get(i)); } when(alternateKeyHelper.validateStringParameter("storage name", STORAGE_NAME)).thenReturn(STORAGE_NAME_2); uploadDownloadHelper.validateAndTrimBusinessObjectDataStorageFileKey(businessObjectDataStorageFileKey); assertEquals( new BusinessObjectDataStorageFileKey(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES_2, DATA_VERSION, STORAGE_NAME_2, TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE), businessObjectDataStorageFileKey); verify(alternateKeyHelper).validateStringParameter("namespace", 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); for (String subPartitionValue : SUBPARTITION_VALUES) { verify(alternateKeyHelper).validateStringParameter("sub partition value", subPartitionValue); } verify(alternateKeyHelper).validateStringParameter("storage name", STORAGE_NAME); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimBusinessObjectStorageFileKeyIsNull() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A business object data storage file key must be specified."); uploadDownloadHelper.validateAndTrimBusinessObjectDataStorageFileKey(null); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimBusinessObjectStorageFileKeyWithNullSubPartitionValues() { BusinessObjectDataStorageFileKey businessObjectDataStorageFileKey = new BusinessObjectDataStorageFileKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, STORAGE_NAME, TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE + " "); when(alternateKeyHelper.validateStringParameter("namespace", NAMESPACE)).thenReturn(NAMESPACE_2); when(alternateKeyHelper.validateStringParameter("business object definition name", BDEF_NAME)).thenReturn(BDEF_NAME_2); when(alternateKeyHelper.validateStringParameter("business object format usage", FORMAT_USAGE_CODE)).thenReturn(FORMAT_USAGE_CODE_2); when(alternateKeyHelper.validateStringParameter("business object format file type", FORMAT_FILE_TYPE_CODE)).thenReturn(FORMAT_FILE_TYPE_CODE_2); when(alternateKeyHelper.validateStringParameter("partition value", PARTITION_VALUE)).thenReturn(PARTITION_VALUE_2); when(alternateKeyHelper.validateStringParameter("storage name", STORAGE_NAME)).thenReturn(STORAGE_NAME_2); uploadDownloadHelper.validateAndTrimBusinessObjectDataStorageFileKey(businessObjectDataStorageFileKey); assertEquals( new BusinessObjectDataStorageFileKey(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION, PARTITION_VALUE_2, Lists.newArrayList(), DATA_VERSION, STORAGE_NAME_2, TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE), businessObjectDataStorageFileKey); verify(alternateKeyHelper).validateStringParameter("namespace", 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(alternateKeyHelper).validateStringParameter("storage name", STORAGE_NAME); verifyNoMoreInteractions(alternateKeyHelper); }