Search in sources :

Example 1 with BusinessObjectDataVersions

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

the class BusinessObjectDataServiceImpl method getBusinessObjectDataVersions.

@NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey) {
    // Validate and trim the business object data key.
    businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, false, false);
    // Get the business object data versions based on the specified parameters.
    List<BusinessObjectDataEntity> businessObjectDataEntities = businessObjectDataDao.getBusinessObjectDataEntities(businessObjectDataKey);
    // Create the response.
    BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
    for (BusinessObjectDataEntity businessObjectDataEntity : businessObjectDataEntities) {
        BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
        BusinessObjectDataKey businessObjectDataVersionKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
        businessObjectDataVersion.setBusinessObjectDataKey(businessObjectDataVersionKey);
        businessObjectDataVersion.setStatus(businessObjectDataEntity.getStatus().getCode());
        businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
    }
    return businessObjectDataVersions;
}
Also used : BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 2 with BusinessObjectDataVersions

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

the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataVersions.

@Test
public void testGetBusinessObjectDataVersions() {
    // Create and persist test database entities.
    createTestDatabaseEntities(SUBPARTITION_VALUES);
    // Retrieve the relative business object data version by specifying values for all input parameters.
    for (int businessObjectFormatVersion = INITIAL_FORMAT_VERSION; businessObjectFormatVersion < NUMBER_OF_FORMAT_VERSIONS; businessObjectFormatVersion++) {
        for (int businessObjectDataVersion = INITIAL_DATA_VERSION; businessObjectDataVersion < NUMBER_OF_DATA_VERSIONS_PER_FORMAT_VERSION; businessObjectDataVersion++) {
            BusinessObjectDataVersions businessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, businessObjectFormatVersion, PARTITION_VALUE, SUBPARTITION_VALUES, businessObjectDataVersion));
            // Validate the returned object.
            assertNotNull(businessObjectDataVersions);
            assertEquals(1, businessObjectDataVersions.getBusinessObjectDataVersions().size());
            businessObjectDataServiceTestHelper.validateBusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, businessObjectFormatVersion, PARTITION_VALUE, SUBPARTITION_VALUES, businessObjectDataVersion, businessObjectDataVersions.getBusinessObjectDataVersions().get(0).getBusinessObjectDataKey());
            assertEquals(BDATA_STATUS, businessObjectDataVersions.getBusinessObjectDataVersions().get(0).getStatus());
        }
    }
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 3 with BusinessObjectDataVersions

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

the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataAttributeTrimParameters.

@Test
public void testGetBusinessObjectDataAttributeTrimParameters() {
    // Create and persist test database entities.
    createTestDatabaseEntities(SUBPARTITION_VALUES);
    // Retrieve the business object data versions using input parameters with leading and trailing empty spaces.
    BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), INITIAL_FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(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 4 with BusinessObjectDataVersions

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

the class MockHttpClientOperationsImpl method buildGetBusinessObjectDataVersionsResponse.

/**
 * Builds a business object data get versions response.
 *
 * @param response the response.
 * @param uri the URI of the incoming request.
 *
 * @throws JAXBException if a JAXB error occurred.
 */
private void buildGetBusinessObjectDataVersionsResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
    Pattern pattern = Pattern.compile("/herd-app/rest/businessObjectData(/namespaces/(?<namespace>.*?))?" + "/businessObjectDefinitionNames/(?<businessObjectDefinitionName>.*?)/businessObjectFormatUsages/(?<businessObjectFormatUsage>.*?)" + "/businessObjectFormatFileTypes/(?<businessObjectFormatFileType>.*?)" + "/versions");
    Matcher matcher = pattern.matcher(uri.getPath());
    if (matcher.find()) {
        BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
        if (HOSTNAME_LATEST_BDATA_VERSION_EXISTS.equals(uri.getHost()) || HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost())) {
            BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
            businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
            businessObjectDataVersion.setBusinessObjectDataKey(new BusinessObjectDataKey(getGroup(matcher, "namespace"), getGroup(matcher, "businessObjectDefinitionName"), getGroup(matcher, "businessObjectFormatUsage"), getGroup(matcher, "businessObjectFormatFileType"), 0, "2014-01-31", null, 0));
            businessObjectDataVersion.setStatus(HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost()) ? BusinessObjectDataStatusEntity.UPLOADING : BusinessObjectDataStatusEntity.VALID);
        }
        response.setEntity(getHttpEntity(businessObjectDataVersions));
    }
}
Also used : Pattern(java.util.regex.Pattern) BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) Matcher(java.util.regex.Matcher) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 5 with BusinessObjectDataVersions

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

the class BusinessObjectDataRestControllerTest method testGetBusinessObjectDataVersions.

@Test
public void testGetBusinessObjectDataVersions() {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a list of business object data versions.
    BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions(Arrays.asList(new BusinessObjectDataVersion()));
    // Mock the external calls.
    when(businessObjectDataService.getBusinessObjectDataVersions(businessObjectDataKey)).thenReturn(businessObjectDataVersions);
    // Call the method under test.
    BusinessObjectDataVersions result = businessObjectDataRestController.getBusinessObjectDataVersions(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_VALUE, getDelimitedFieldValues(SUBPARTITION_VALUES), FORMAT_VERSION, DATA_VERSION);
    // Verify the external calls.
    verify(businessObjectDataService).getBusinessObjectDataVersions(businessObjectDataKey);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataVersions, result);
}
Also used : BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) 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