Search in sources :

Example 6 with UploaderInputManifestDto

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

Example 7 with UploaderInputManifestDto

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

Example 8 with UploaderInputManifestDto

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

Example 9 with UploaderInputManifestDto

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

Example 10 with UploaderInputManifestDto

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