use of org.finra.herd.model.dto.ManifestFile in project herd by FINRAOS.
the class DataBridgeWebClientTest method getUploaderInputManifestDto.
/**
* Creates a UploaderInputManifestDto.
*
* @return the created UploaderInputManifestDto instance
*/
private UploaderInputManifestDto getUploaderInputManifestDto() {
UploaderInputManifestDto manifest = new UploaderInputManifestDto();
manifest.setNamespace("testNamespace");
manifest.setBusinessObjectDefinitionName("testBusinessObjectDefinitionName");
manifest.setBusinessObjectFormatUsage("testBusinessObjectFormatUsage");
manifest.setBusinessObjectFormatFileType("testBusinessObjectFormatFileType");
manifest.setBusinessObjectFormatVersion("0");
manifest.setPartitionKey("testPartitionKey");
manifest.setPartitionValue("testPartitionValue");
manifest.setSubPartitionValues(Arrays.asList("testSubPartitionValue1", "testSubPartitionValue2"));
List<ManifestFile> manifestFiles = new ArrayList<>();
{
ManifestFile manifestFile = new ManifestFile();
manifestFile.setFileName("testFileName");
manifestFile.setFileSizeBytes(1l);
manifestFile.setRowCount(2l);
manifestFiles.add(manifestFile);
}
manifest.setManifestFiles(manifestFiles);
HashMap<String, String> attributes = new HashMap<>();
{
attributes.put("testName", "testValue");
}
manifest.setAttributes(attributes);
return manifest;
}
use of org.finra.herd.model.dto.ManifestFile 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());
}
}
Aggregations