Search in sources :

Example 6 with BusinessObjectFormatKeys

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

the class BusinessObjectFormatRestControllerTest method testGetBusinessObjectFormats.

@Test
public void testGetBusinessObjectFormats() {
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys(Arrays.asList(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, INITIAL_FORMAT_VERSION), new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION, INITIAL_FORMAT_VERSION)));
    when(businessObjectFormatService.getBusinessObjectFormats(businessObjectDefinitionKey, false)).thenReturn(businessObjectFormatKeys);
    // Retrieve a list of business object format keys for the specified business object definition.
    BusinessObjectFormatKeys resultKeys = businessObjectFormatRestController.getBusinessObjectFormats(NAMESPACE, BDEF_NAME, false);
    // Verify the external calls.
    verify(businessObjectFormatService).getBusinessObjectFormats(businessObjectDefinitionKey, false);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormatKeys, resultKeys);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatKeys(org.finra.herd.model.api.xml.BusinessObjectFormatKeys) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 7 with BusinessObjectFormatKeys

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

the class BusinessObjectFormatServiceTest method testGetBusinessObjectFormatsWithFilters.

@Test
public void testGetBusinessObjectFormatsWithFilters() {
    // Create and persist the relative business object definitions.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    // Create and persist business object format entities.
    for (BusinessObjectFormatKey key : businessObjectFormatDaoTestHelper.getTestBusinessObjectFormatKeys()) {
        businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(), key.getBusinessObjectFormatUsage(), key.getBusinessObjectFormatFileType(), key.getBusinessObjectFormatVersion(), FORMAT_DESCRIPTION, false, PARTITION_KEY);
    }
    String filteredFormatUsage = FORMAT_USAGE_CODE;
    // Retrieve a list of business object format keys for the specified business object definition.
    BusinessObjectFormatKeys resultKeys = businessObjectFormatService.getBusinessObjectFormatsWithFilters(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), " " + filteredFormatUsage.toLowerCase() + " ", false);
    // Need to filter format usage
    List<BusinessObjectFormatKey> expectedKeyList = businessObjectFormatDaoTestHelper.getExpectedBusinessObjectFormatKeys();
    expectedKeyList = expectedKeyList.stream().filter(formatKey -> (formatKey.getBusinessObjectFormatUsage().equalsIgnoreCase(filteredFormatUsage))).collect(Collectors.toList());
    // Validate the returned object.
    assertEquals(expectedKeyList, resultKeys.getBusinessObjectFormatKeys());
    // Retrieve a list of the latest version business object format keys for the specified business object definition.
    resultKeys = businessObjectFormatService.getBusinessObjectFormatsWithFilters(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), " " + filteredFormatUsage.toLowerCase() + " ", true);
    expectedKeyList = businessObjectFormatDaoTestHelper.getExpectedBusinessObjectFormatLatestVersionKeys();
    expectedKeyList = expectedKeyList.stream().filter(formatKey -> (formatKey.getBusinessObjectFormatUsage().equalsIgnoreCase(filteredFormatUsage))).collect(Collectors.toList());
    // Validate the returned object.
    assertEquals(expectedKeyList, resultKeys.getBusinessObjectFormatKeys());
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatKeys(org.finra.herd.model.api.xml.BusinessObjectFormatKeys) Test(org.junit.Test)

Example 8 with BusinessObjectFormatKeys

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

the class BusinessObjectFormatServiceImpl method getBusinessObjectFormatsWithFilters.

@Override
public BusinessObjectFormatKeys getBusinessObjectFormatsWithFilters(BusinessObjectDefinitionKey businessObjectDefinitionKey, String businessObjectFormatUsage, boolean latestBusinessObjectFormatVersion) {
    // Perform validation and trim.
    businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey);
    // Perform Validation and trim of businessObjectFormatUsage
    businessObjectFormatUsage = alternateKeyHelper.validateStringParameter("business object format usage", businessObjectFormatUsage);
    // Ensure that a business object definition already exists with the specified name.
    businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
    // Gets the list of keys and return them.
    BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys();
    businessObjectFormatKeys.getBusinessObjectFormatKeys().addAll(businessObjectFormatDao.getBusinessObjectFormatsWithFilters(businessObjectDefinitionKey, businessObjectFormatUsage, latestBusinessObjectFormatVersion));
    return businessObjectFormatKeys;
}
Also used : BusinessObjectFormatKeys(org.finra.herd.model.api.xml.BusinessObjectFormatKeys)

Example 9 with BusinessObjectFormatKeys

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

the class BusinessObjectFormatServiceTest method testGetBusinessObjectFormatsUpperCaseParameters.

@Test
public void testGetBusinessObjectFormatsUpperCaseParameters() {
    // Create and persist the relative business object definitions.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    // Create and persist business object format entities.
    for (BusinessObjectFormatKey key : businessObjectFormatDaoTestHelper.getTestBusinessObjectFormatKeys()) {
        businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(), key.getBusinessObjectFormatUsage(), key.getBusinessObjectFormatFileType(), key.getBusinessObjectFormatVersion(), FORMAT_DESCRIPTION, false, PARTITION_KEY);
    }
    // Retrieve a list of business object format keys for the specified business object definition using upper case input parameters
    BusinessObjectFormatKeys resultKeys = businessObjectFormatService.getBusinessObjectFormats(new BusinessObjectDefinitionKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase()), false);
    // Validate the returned object.
    assertEquals(businessObjectFormatDaoTestHelper.getExpectedBusinessObjectFormatKeys(), resultKeys.getBusinessObjectFormatKeys());
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatKeys(org.finra.herd.model.api.xml.BusinessObjectFormatKeys) Test(org.junit.Test)

Example 10 with BusinessObjectFormatKeys

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

the class BusinessObjectFormatServiceTest method testGetBusinessObjectFormatsTrimParameters.

@Test
public void testGetBusinessObjectFormatsTrimParameters() {
    // Create and persist the relative business object definitions.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
    // Create and persist business object format entities.
    for (BusinessObjectFormatKey key : businessObjectFormatDaoTestHelper.getTestBusinessObjectFormatKeys()) {
        businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(), key.getBusinessObjectFormatUsage(), key.getBusinessObjectFormatFileType(), key.getBusinessObjectFormatVersion(), FORMAT_DESCRIPTION, false, PARTITION_KEY);
    }
    // Retrieve a list of business object format keys for the specified business object definition using input parameters with leading and trailing empty spaces.
    BusinessObjectFormatKeys resultKeys = businessObjectFormatService.getBusinessObjectFormats(new BusinessObjectDefinitionKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME)), false);
    // Validate the returned object.
    assertEquals(businessObjectFormatDaoTestHelper.getExpectedBusinessObjectFormatKeys(), resultKeys.getBusinessObjectFormatKeys());
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatKeys(org.finra.herd.model.api.xml.BusinessObjectFormatKeys) Test(org.junit.Test)

Aggregations

BusinessObjectFormatKeys (org.finra.herd.model.api.xml.BusinessObjectFormatKeys)10 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)8 Test (org.junit.Test)8 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2