Search in sources :

Example 11 with BusinessObjectDataVersions

use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataMissingOptionalParameters.

@Test
public void testGetBusinessObjectDataMissingOptionalParameters() {
    // Create and persist a business object data entities without subpartition values.
    createTestDatabaseEntities(NO_SUBPARTITION_VALUES);
    // Retrieve business object data versions without specifying any of the optional parameters including the subpartition values.
    BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, PARTITION_VALUE, null, null));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(NUMBER_OF_FORMAT_VERSIONS * NUMBER_OF_DATA_VERSIONS_PER_FORMAT_VERSION, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 12 with BusinessObjectDataVersions

use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataUpperCaseParameters.

@Test
public void testGetBusinessObjectDataUpperCaseParameters() {
    // Create and persist test database entities.
    createTestDatabaseEntities(SUBPARTITION_VALUES);
    // Retrieve business object data versions using upper case input parameters (except for case-sensitive partition values).
    BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(1, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 13 with BusinessObjectDataVersions

use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataInvalidParameters.

@Test
public void testGetBusinessObjectDataInvalidParameters() {
    // Create and persist test database entities.
    createTestDatabaseEntities(SUBPARTITION_VALUES);
    // Validate that we can retrieve all business object data versions.
    BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(1, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid namespace.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid business object definition name.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid format usage.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid format file type.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid partition value.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid subpartition value.
    for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) {
        List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
        testSubPartitionValues.set(i, "I_DO_NOT_EXIST");
        resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, INITIAL_DATA_VERSION));
        // Validate the returned object.
        assertNotNull(resultBusinessObjectDataVersions);
        assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    }
    // Try to get business object data versions using too many subpartition values.
    try {
        List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
        testSubPartitionValues.add("EXTRA_SUBPARTITION_VALUE");
        businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, INITIAL_DATA_VERSION));
        fail("Should throw an IllegalArgumentException when passing too many subpartition values.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Exceeded maximum number of allowed subpartitions: %d.", BusinessObjectDataEntity.MAX_SUBPARTITIONS), e.getMessage());
    }
    // Try to get business object data versions using invalid business object format version.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
    // Try to get business object data versions using invalid business object data version.
    resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION));
    // Validate the returned object.
    assertNotNull(resultBusinessObjectDataVersions);
    assertEquals(0, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
Also used : ArrayList(java.util.ArrayList) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataVersions (org.finra.herd.model.api.xml.BusinessObjectDataVersions)13 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)12 Test (org.junit.Test)9 BusinessObjectDataVersion (org.finra.herd.model.api.xml.BusinessObjectDataVersion)3 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 HttpGet (org.apache.http.client.methods.HttpGet)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1