use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestEmptyAttributesMap.
@Test
public void testReadJsonManifestEmptyAttributesMap() throws IOException {
// Get an instance of uploader input manifest object.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
// Create and read the uploaderInputManifestDto file with an empty list of attributes.
uploaderInputManifestDto.setAttributes(new HashMap<String, String>());
UploaderInputManifestDto resultManifest = uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
// Validate the results.
assertUploaderManifest(uploaderInputManifestDto, resultManifest);
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestAttributeNameTooLong.
@Test
public void testReadJsonManifestAttributeNameTooLong() throws IOException {
// Try to create and read the uploader input manifest that contains an attribute name which is too long.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
HashMap<String, String> attributes = new HashMap<>();
uploaderInputManifestDto.setAttributes(attributes);
// Returns "*...*key"
String attributeKey = StringUtils.leftPad("value", UploaderManifestReader.MAX_ATTRIBUTE_NAME_LENGTH + 1, '*');
assertTrue(attributeKey.length() == UploaderManifestReader.MAX_ATTRIBUTE_NAME_LENGTH + 1);
attributes.put(attributeKey, ATTRIBUTE_VALUE_1);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when an attribute name is too long.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Manifest attribute name is longer than %d characters.", UploaderManifestReader.MAX_ATTRIBUTE_NAME_LENGTH), e.getMessage());
}
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestDuplicateParents.
@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());
}
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestMissingRequiredParameters.
@Test
public void testReadJsonManifestMissingRequiredParameters() throws IOException {
UploaderInputManifestDto uploaderInputManifestDto;
// Try to create and read the uploader input manifest when business object definition name is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setBusinessObjectDefinitionName(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object definition name must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when business object format usage is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setBusinessObjectFormatUsage(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object format usage must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when business object format file type is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setBusinessObjectFormatFileType(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object format file type must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when business object format version is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setBusinessObjectFormatVersion(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when business object format version is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object format version must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when partition key is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setPartitionKey(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when partition key is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object format partition key must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when partition value is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setPartitionValue(BLANK_TEXT);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when partition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest business object data partition value must be specified.", e.getMessage());
}
// Try to create and read the uploader input manifest when manifest files list is empty.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setManifestFiles(new ArrayList<ManifestFile>());
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when partition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest must contain at least 1 file.", e.getMessage());
}
// Try to create and read the uploader input manifest when an attribute name is not specified.
uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.getAttributes().put(BLANK_TEXT, ATTRIBUTE_VALUE_1);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when an attribute name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Manifest attribute name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestNullAttributesMap.
@Test
public void testReadJsonManifestNullAttributesMap() throws IOException {
// Get an instance of uploader input manifest object.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
// Create and read the uploaderInputManifestDto file with the list of attributes set to null.
uploaderInputManifestDto.setAttributes(null);
UploaderInputManifestDto resultManifest = uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
// Validate the results.
assertUploaderManifest(uploaderInputManifestDto, resultManifest);
}
Aggregations