new BusinessObjectDataKey(manifest.getNamespace(), manifest.getBusinessObjectDefinitionName(), manifest.getBusinessObjectFormatUsage(), manifest.getBusinessObjectFormatFileType(), Integer.valueOf(manifest.getBusinessObjectFormatVersion()), manifest.getPartitionValue(), manifest.getSubPartitionValues(), null));
/** * Validates an uploader input manifest instance. * * @param expectedUploaderInputManifest the expected uploader input manifest instance * @param actualUploaderInputManifest the actual instance of the uploader input manifest to be validated */ private void assertUploaderManifest(UploaderInputManifestDto expectedUploaderInputManifest, UploaderInputManifestDto actualUploaderInputManifest) { // Validate all regular fields. assertEquals(expectedUploaderInputManifest.getBusinessObjectDefinitionName(), actualUploaderInputManifest.getBusinessObjectDefinitionName()); assertEquals(expectedUploaderInputManifest.getBusinessObjectFormatUsage(), actualUploaderInputManifest.getBusinessObjectFormatUsage()); assertEquals(expectedUploaderInputManifest.getBusinessObjectFormatFileType(), actualUploaderInputManifest.getBusinessObjectFormatFileType()); assertEquals(expectedUploaderInputManifest.getBusinessObjectFormatVersion(), actualUploaderInputManifest.getBusinessObjectFormatVersion()); assertEquals(expectedUploaderInputManifest.getPartitionKey(), actualUploaderInputManifest.getPartitionKey()); assertEquals(expectedUploaderInputManifest.getPartitionValue(), actualUploaderInputManifest.getPartitionValue()); // Validate the files by comparing two file list ignoring the order. assertTrue(expectedUploaderInputManifest.getManifestFiles().containsAll(actualUploaderInputManifest.getManifestFiles())); assertTrue(actualUploaderInputManifest.getManifestFiles().containsAll(expectedUploaderInputManifest.getManifestFiles())); // Validate the attributes. assertEquals(expectedUploaderInputManifest.getAttributes(), actualUploaderInputManifest.getAttributes()); // Validate the business object data parents. assertEquals(expectedUploaderInputManifest.getBusinessObjectDataParents(), actualUploaderInputManifest.getBusinessObjectDataParents()); } }
Assert.hasText(manifest.getBusinessObjectFormatVersion(), "Manifest business object format version must be specified."); Assert.notEmpty(manifest.getManifestFiles(), "Manifest must contain at least 1 file."); for (ManifestFile manifestFile : manifest.getManifestFiles()) if (manifest.getAttributes() != null) for (Map.Entry<String, String> entry : manifest.getAttributes().entrySet()) if (manifest.getBusinessObjectDataParents() != null) for (BusinessObjectDataKey businessObjectDataKey : manifest.getBusinessObjectDataParents())
uploaderInputManifestDto.setBusinessObjectDefinitionName(BLANK_TEXT); try uploaderInputManifestDto.setBusinessObjectFormatUsage(BLANK_TEXT); try uploaderInputManifestDto.setBusinessObjectFormatFileType(BLANK_TEXT); try uploaderInputManifestDto.setBusinessObjectFormatVersion(BLANK_TEXT); try uploaderInputManifestDto.setPartitionKey(BLANK_TEXT); try uploaderInputManifestDto.setPartitionValue(BLANK_TEXT); try uploaderInputManifestDto.setManifestFiles(new ArrayList<ManifestFile>()); try uploaderInputManifestDto.getAttributes().put(BLANK_TEXT, ATTRIBUTE_VALUE_1); try
@Test public void testReadJsonManifestNoAttributeValue() throws IOException { UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); HashMap<String, String> attributes = new HashMap<>(); uploaderInputManifestDto.setAttributes(attributes); attributes.put(ATTRIBUTE_NAME_1_MIXED_CASE, null); attributes.put(ATTRIBUTE_NAME_2_MIXED_CASE, ""); attributes.put(ATTRIBUTE_NAME_3_MIXED_CASE, BLANK_TEXT); UploaderInputManifestDto resultManifest = uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto)); // Validate the results. assertUploaderManifest(uploaderInputManifestDto, resultManifest); assertEquals(attributes.size(), resultManifest.getAttributes().size()); assertEquals(null, resultManifest.getAttributes().get(ATTRIBUTE_NAME_1_MIXED_CASE)); assertEquals("", resultManifest.getAttributes().get(ATTRIBUTE_NAME_2_MIXED_CASE)); assertEquals(BLANK_TEXT, resultManifest.getAttributes().get(ATTRIBUTE_NAME_3_MIXED_CASE)); }
manifest.setStorageName(storageName); List<File> sourceFiles = getValidatedLocalFiles(params.getLocalPath(), manifest.getManifestFiles());
List<ManifestFile> localFiles = manifest.getManifestFiles();
@Test public void testReadJsonManifestDuplicateParents() throws IOException { // Add a duplicate business object data parents to the manifest. UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); BusinessObjectDataKey parent = new BusinessObjectDataKey(); uploaderInputManifestDto.getBusinessObjectDataParents().add(parent); parent.setNamespace(NAMESPACE_CD.toLowerCase()); parent.setBusinessObjectDefinitionName(TEST_BUSINESS_OBJECT_DEFINITION.toLowerCase()); parent.setBusinessObjectFormatUsage(TEST_BUSINESS_OBJECT_FORMAT_USAGE.toLowerCase()); parent.setBusinessObjectFormatFileType(TEST_BUSINESS_OBJECT_FORMAT_FILE_TYPE.toLowerCase()); parent.setBusinessObjectFormatVersion(TEST_BUSINESS_OBJECT_FORMAT_VERSION); parent.setPartitionValue(TEST_PARENT_PARTITION_VALUE); parent.setBusinessObjectDataVersion(TEST_DATA_VERSION_V0); try { // Try to read and validate a JSON manifest file that has duplicate business object data parents. uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto)); fail("Suppose to throw an IllegalArgumentException when the uploader manifest file contains duplicate business object data parents."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate manifest business object data parent found: {namespace: \"%s\", " + "businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d, businessObjectDataPartitionValue: \"%s\", businessObjectDataSubPartitionValues: \"\", " + "businessObjectDataVersion: %d}", parent.getNamespace(), parent.getBusinessObjectDefinitionName(), parent.getBusinessObjectFormatUsage(), parent.getBusinessObjectFormatFileType(), parent.getBusinessObjectFormatVersion(), parent.getPartitionValue(), parent.getBusinessObjectDataVersion()), e.getMessage()); } }
List<ManifestFile> localFiles = manifest.getManifestFiles();
request.setNamespace(manifest.getNamespace()); request.setBusinessObjectDefinitionName(manifest.getBusinessObjectDefinitionName()); request.setBusinessObjectFormatUsage(manifest.getBusinessObjectFormatUsage()); request.setBusinessObjectFormatFileType(manifest.getBusinessObjectFormatFileType()); request.setBusinessObjectFormatVersion(Integer.parseInt(manifest.getBusinessObjectFormatVersion())); request.setPartitionKey(manifest.getPartitionKey()); request.setPartitionValue(manifest.getPartitionValue()); request.setSubPartitionValues(manifest.getSubPartitionValues()); request.setCreateNewVersion(createNewVersion); request.setStatus(BusinessObjectDataStatusEntity.UPLOADING); if (manifest.getAttributes() != null) for (Map.Entry<String, String> entry : manifest.getAttributes().entrySet()) request.setBusinessObjectDataParents(manifest.getBusinessObjectDataParents());
@Test public void testReadJsonManifestNoRowCount() throws IOException { // Get an instance of uploader input manifest object. UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); // Make all the row counts null. for (ManifestFile manifestFile : uploaderInputManifestDto.getManifestFiles()) { manifestFile.setRowCount(null); } // Create and read a uploaderInputManifestDto file. UploaderInputManifestDto resultManifest = uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto)); // Validate the results. assertUploaderManifest(uploaderInputManifestDto, resultManifest); }
request.setNamespace(manifest.getNamespace()); request.setBusinessObjectDefinitionName(manifest.getBusinessObjectDefinitionName()); request.setBusinessObjectFormatUsage(manifest.getBusinessObjectFormatUsage()); request.setBusinessObjectFormatFileType(manifest.getBusinessObjectFormatFileType()); request.setBusinessObjectFormatVersion(Integer.parseInt(manifest.getBusinessObjectFormatVersion())); request.setPartitionKey(manifest.getPartitionKey()); request.setPartitionValue(manifest.getPartitionValue()); request.setSubPartitionValues(manifest.getSubPartitionValues()); request.setCreateNewVersion(createNewVersion); request.setStatus(BusinessObjectDataStatusEntity.UPLOADING); if (manifest.getAttributes() != null) for (Map.Entry<String, String> entry : manifest.getAttributes().entrySet()) request.setBusinessObjectDataParents(manifest.getBusinessObjectDataParents());
private BusinessObjectData toBusinessObjectData(final UploaderInputManifestDto uploaderInputManifestDto) { BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setNamespace(uploaderInputManifestDto.getNamespace()); businessObjectData.setBusinessObjectDefinitionName(uploaderInputManifestDto.getBusinessObjectDefinitionName()); businessObjectData.setBusinessObjectFormatUsage(uploaderInputManifestDto.getBusinessObjectFormatUsage()); businessObjectData.setBusinessObjectFormatFileType(uploaderInputManifestDto.getBusinessObjectFormatFileType()); businessObjectData.setBusinessObjectFormatVersion(Integer.valueOf(uploaderInputManifestDto.getBusinessObjectFormatVersion())); businessObjectData.setPartitionKey(uploaderInputManifestDto.getPartitionKey()); businessObjectData.setPartitionValue(uploaderInputManifestDto.getPartitionValue()); businessObjectData.setSubPartitionValues(uploaderInputManifestDto.getSubPartitionValues()); businessObjectData.setVersion(TEST_DATA_VERSION_V0); businessObjectData .setStorageUnits(Arrays.asList(new StorageUnit(new Storage(StorageEntity.MANAGED_STORAGE, null, null), null, null, null, null, null, null))); return businessObjectData; } }