Search in sources :

Example 76 with BusinessObjectDefinitionKey

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

the class BusinessObjectDefinitionTagServiceTest method testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition.

@Test
public void testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition() {
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
    // Create tag keys.
    List<TagKey> tagKeys = Arrays.asList(new TagKey(TAG_TYPE, TAG_CODE), new TagKey(TAG_TYPE_2, TAG_CODE_2));
    // Create and persist business object definition tag entities.
    for (TagKey tagKey : tagKeys) {
        businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionKey, tagKey);
    }
    // Get business object definition tags by business object definition.
    BusinessObjectDefinitionTagKeys result = businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(businessObjectDefinitionKey);
    // Validate the returned object.
    assertNotNull(result);
    assertEquals(Arrays.asList(new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, tagKeys.get(0)), new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, tagKeys.get(1))), result.getBusinessObjectDefinitionTagKeys());
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKeys(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 77 with BusinessObjectDefinitionKey

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

the class BusinessObjectDefinitionTagServiceTest method testGetBusinessObjectDefinitionTagsByBusinessObjectDefinitionMissingRequiredParameters.

@Test
public void testGetBusinessObjectDefinitionTagsByBusinessObjectDefinitionMissingRequiredParameters() {
    // Try to get business object definition tags by business object definition when business object definition namespace is not specified.
    try {
        businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(new BusinessObjectDefinitionKey(BLANK_TEXT, BDEF_NAME));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to get business object definition tags by business object definition when business object definition name is not specified.
    try {
        businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BLANK_TEXT));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Test(org.junit.Test)

Example 78 with BusinessObjectDefinitionKey

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

the class IndexSearchServiceTest method testIndexSearchWithResultTypeFilter.

@Test
public void testIndexSearchWithResultTypeFilter() {
    // Create an index search key
    final IndexSearchKey indexSearchKey = new IndexSearchKey();
    // Create a tag key
    final IndexSearchResultTypeKey resultTypeKey = new IndexSearchResultTypeKey(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
    indexSearchKey.setIndexSearchResultTypeKey(resultTypeKey);
    // Create an index search keys list and add the previously defined key to it
    final List<IndexSearchKey> indexSearchKeys = Collections.singletonList(indexSearchKey);
    // Create an index search filter with the keys previously defined
    final IndexSearchFilter indexSearchFilter = new IndexSearchFilter(EXCLUSION_SEARCH_FILTER, indexSearchKeys);
    List<IndexSearchFilter> indexSearchFilters = Collections.singletonList(indexSearchFilter);
    // Create index search request
    final IndexSearchRequest indexSearchRequest = new IndexSearchRequest(SEARCH_TERM, indexSearchFilters, null, false);
    // Create a set of fields.
    final Set<String> fields = Sets.newHashSet(FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
    // Create a new index search result key and populate it with a tag key
    final IndexSearchResultKey indexSearchResultKeyBusinessObjectDefinition = new IndexSearchResultKey(null, new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    // Create a new index search result key and populate it with a tag key
    final IndexSearchResultKey indexSearchResultKeyTag = new IndexSearchResultKey(new TagKey(TAG_TYPE, TAG_CODE), null);
    // Create a new index search results
    final IndexSearchResult indexSearchResultBusinessObjectDefinition = new IndexSearchResult(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name(), new SearchIndexKey(BUSINESS_OBJECT_DEFINITION_SEARCH_INDEX_NAME), indexSearchResultKeyBusinessObjectDefinition, BDEF_DISPLAY_NAME, BDEF_SHORT_DESCRIPTION, null);
    final IndexSearchResult indexSearchResultTag = new IndexSearchResult(SearchIndexTypeEntity.SearchIndexTypes.TAG.name(), new SearchIndexKey(TAG_SEARCH_INDEX_NAME), indexSearchResultKeyTag, TAG_DISPLAY_NAME, TAG_DESCRIPTION, null);
    // Create a list to contain the index search results
    final List<IndexSearchResult> indexSearchResults = new ArrayList<>();
    indexSearchResults.add(indexSearchResultBusinessObjectDefinition);
    indexSearchResults.add(indexSearchResultTag);
    // Construct an index search response
    final IndexSearchResponse indexSearchResponse = new IndexSearchResponse(TOTAL_INDEX_SEARCH_RESULTS, indexSearchResults, null);
    // Mock the call to the index search service
    when(alternateKeyHelper.validateStringParameter("An", "index search result type", SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name())).thenReturn(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
    when(searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name())).thenReturn(SEARCH_INDEX_NAME);
    when(searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.TAG.name())).thenReturn(SEARCH_INDEX_NAME_2);
    when(indexSearchDao.indexSearch(indexSearchRequest, fields, NO_MATCH, SEARCH_INDEX_NAME, SEARCH_INDEX_NAME_2)).thenReturn(indexSearchResponse);
    // Call the method under test.
    IndexSearchResponse result = indexSearchService.indexSearch(indexSearchRequest, fields, NO_MATCH);
    // Verify the external calls.
    verify(alternateKeyHelper).validateStringParameter("An", "index search result type", SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
    verify(searchIndexTypeDaoHelper).getSearchIndexTypeEntity(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
    verify(searchIndexDaoHelper).getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
    verify(searchIndexDaoHelper).getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.TAG.name());
    verify(indexSearchDao).indexSearch(indexSearchRequest, fields, NO_MATCH, SEARCH_INDEX_NAME, SEARCH_INDEX_NAME_2);
    verifyNoMoreInteractionsHelper();
    // Validate the result.
    assertEquals(indexSearchResponse, result);
}
Also used : IndexSearchKey(org.finra.herd.model.api.xml.IndexSearchKey) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) ArrayList(java.util.ArrayList) IndexSearchResultTypeKey(org.finra.herd.model.api.xml.IndexSearchResultTypeKey) IndexSearchRequest(org.finra.herd.model.api.xml.IndexSearchRequest) IndexSearchResultKey(org.finra.herd.model.api.xml.IndexSearchResultKey) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) IndexSearchResponse(org.finra.herd.model.api.xml.IndexSearchResponse) TagKey(org.finra.herd.model.api.xml.TagKey) IndexSearchResult(org.finra.herd.model.api.xml.IndexSearchResult) IndexSearchFilter(org.finra.herd.model.api.xml.IndexSearchFilter) Test(org.junit.Test)

Example 79 with BusinessObjectDefinitionKey

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

the class BusinessObjectDefinitionColumnDaoTestHelper method createBusinessObjectDefinitionColumnEntity.

/**
 * Creates and persists a new business object definition column entity.
 *
 * @param businessObjectDefinitionColumnKey the business object definition column key
 * @param businessObjectDefinitionColumnDescription the description of the business object definition column
 *
 * @return the newly created business object definition column entity
 */
public BusinessObjectDefinitionColumnEntity createBusinessObjectDefinitionColumnEntity(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey, String businessObjectDefinitionColumnDescription) {
    // Create a business object definition column.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(businessObjectDefinitionColumnKey.getNamespace(), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionName());
    // Create a business object definition entity if needed.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey);
    if (businessObjectDefinitionEntity == null) {
        businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionKey, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.DESCRIPTION);
    }
    return createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, businessObjectDefinitionColumnKey.getBusinessObjectDefinitionColumnName(), businessObjectDefinitionColumnDescription);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)

Example 80 with BusinessObjectDefinitionKey

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

the class BusinessObjectDefinitionDaoTest method testGetBusinessObjectDefinitionKeysByNamespace.

@Test
public void testGetBusinessObjectDefinitionKeysByNamespace() {
    // Create and persist business object definition entities.
    for (BusinessObjectDefinitionKey key : businessObjectDefinitionDaoTestHelper.getTestBusinessObjectDefinitionKeys()) {
        businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(key, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    }
    // Retrieve a list of business object definition keys for the specified namespace.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace(NAMESPACE));
    // Retrieve a list of business object definition keys without specifying a namespace.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeys(), businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace(BLANK_TEXT));
    // Retrieve a list of business object definition keys for the specified namespace.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace(NAMESPACE));
    // Retrieve a list of business object definition keys for the specified namespace in uppercase.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace(NAMESPACE.toUpperCase()));
    // Retrieve a list of business object definition keys for the specified namespace in lowercase.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace(NAMESPACE.toLowerCase()));
    // Try to retrieve a list of business object definition keys for a non-existing namespace.
    assertTrue(businessObjectDefinitionDao.getBusinessObjectDefinitionKeysByNamespace("I_DO_NOT_EXIST").isEmpty());
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)187 Test (org.junit.Test)152 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)73 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)44 TagKey (org.finra.herd.model.api.xml.TagKey)39 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)34 Attribute (org.finra.herd.model.api.xml.Attribute)32 ArrayList (java.util.ArrayList)21 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)16 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)16 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)15 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)14 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)13 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)13 StorageEntity (org.finra.herd.model.jpa.StorageEntity)13 BusinessObjectDefinitionTagKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys)12 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)11 BusinessObjectDefinitionUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest)11 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)11 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)11