Search in sources :

Example 21 with UploaderInputManifestDto

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);
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) Test(org.junit.Test)

Example 22 with UploaderInputManifestDto

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());
    }
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 23 with UploaderInputManifestDto

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());
    }
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 24 with UploaderInputManifestDto

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());
    }
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) ManifestFile(org.finra.herd.model.dto.ManifestFile) Test(org.junit.Test)

Example 25 with UploaderInputManifestDto

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);
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) Test(org.junit.Test)

Aggregations

UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)28 Test (org.junit.Test)20 HashMap (java.util.HashMap)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 ManifestFile (org.finra.herd.model.dto.ManifestFile)7 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)6 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)5 File (java.io.File)4 IOException (java.io.IOException)3 RegServerAccessParamsDto (org.finra.herd.model.dto.RegServerAccessParamsDto)3 ArrayList (java.util.ArrayList)2 Command (org.finra.herd.core.Command)2 BusinessObjectDataStorageFilesCreateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 URISyntaxException (java.net.URISyntaxException)1 JAXBException (javax.xml.bind.JAXBException)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 AwsCredential (org.finra.herd.model.api.xml.AwsCredential)1 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)1 Storage (org.finra.herd.model.api.xml.Storage)1