if (manifest.getBusinessObjectDataParents() != null) for (BusinessObjectDataKey businessObjectDataKey : manifest.getBusinessObjectDataParents())
request.setBusinessObjectDataParents(manifest.getBusinessObjectDataParents());
request.setBusinessObjectDataParents(manifest.getBusinessObjectDataParents());
@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()); } }
/** * 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()); } }