use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestNullParentsList.
@Test
public void testReadJsonManifestNullParentsList() throws IOException {
// Create and read the uploaderInputManifestDto file with the list of parents set to null.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setBusinessObjectDataParents(null);
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 testReadJsonManifestDuplicateAttributeNames.
@Test
public void testReadJsonManifestDuplicateAttributeNames() throws IOException {
// Try to create and read the uploader input manifest that contains duplicate attribute names.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
HashMap<String, String> attributes = new HashMap<>();
uploaderInputManifestDto.setAttributes(attributes);
attributes.put(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1);
attributes.put(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_2);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when manifest contains duplicate attribute names");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate manifest attribute name found: %s", ATTRIBUTE_NAME_1_MIXED_CASE).toUpperCase(), e.getMessage().toUpperCase());
}
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestNoAttributeValue.
@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));
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestNoRowCount.
@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);
}
use of org.finra.herd.model.dto.UploaderInputManifestDto in project herd by FINRAOS.
the class UploaderManifestReaderTest method testReadJsonManifestAttributeValueTooLong.
@Test
public void testReadJsonManifestAttributeValueTooLong() throws IOException {
// Try to create and read the uploader input manifest that contains an attribute value which is too long.
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
HashMap<String, String> attributes = new HashMap<>();
uploaderInputManifestDto.setAttributes(attributes);
// Returns "*...*value"
String attributeValue = StringUtils.leftPad("value", UploaderManifestReader.MAX_ATTRIBUTE_VALUE_LENGTH + 1, '*');
assertTrue(attributeValue.length() == UploaderManifestReader.MAX_ATTRIBUTE_VALUE_LENGTH + 1);
attributes.put(ATTRIBUTE_NAME_1_MIXED_CASE, attributeValue);
try {
uploaderManifestReader.readJsonManifest(createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto));
fail("Should throw an IllegalArgumentException when an attribute value is too long.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Manifest attribute value is longer than %s characters.", UploaderManifestReader.MAX_ATTRIBUTE_VALUE_LENGTH), e.getMessage());
}
}
Aggregations