Search in sources :

Example 31 with SearchIndexKey

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

the class SearchIndexServiceImplTest method testCreateSearchIndexFromEntity.

@Test
public void testCreateSearchIndexFromEntity() {
    // Create a search index key.
    SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
    // Creates a test search index type entity.
    SearchIndexTypeEntity searchIndexTypeEntity = new SearchIndexTypeEntity();
    searchIndexTypeEntity.setCode(SEARCH_INDEX_TYPE);
    // Creates a test search index status entity.
    SearchIndexStatusEntity searchIndexStatusEntity = new SearchIndexStatusEntity();
    searchIndexStatusEntity.setCode(SEARCH_INDEX_STATUS);
    // Create a test search index entity.
    SearchIndexEntity searchIndexEntity = new SearchIndexEntity();
    searchIndexEntity.setName(SEARCH_INDEX_NAME);
    searchIndexEntity.setType(searchIndexTypeEntity);
    searchIndexEntity.setStatus(searchIndexStatusEntity);
    searchIndexEntity.setCreatedBy(USER_ID);
    searchIndexEntity.setCreatedOn(new Timestamp(CREATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setUpdatedOn(new Timestamp(UPDATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setActive(Boolean.FALSE);
    // Create a search index object from the search index entity.
    SearchIndex searchIndex = searchIndexServiceImpl.createSearchIndexFromEntity(searchIndexEntity);
    // Verify the external calls.
    verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
    // Validate the returned object.
    assertEquals(new SearchIndex(searchIndexKey, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), searchIndex);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) Timestamp(java.sql.Timestamp) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 32 with SearchIndexKey

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

the class SearchIndexServiceImplTest method testCreateSearchIndexHelperInvalidSearchIndexType.

@Test
public void testCreateSearchIndexHelperInvalidSearchIndexType() {
    // Try to create a search index using an invalid search index type.
    try {
        searchIndexServiceImpl.createSearchIndexHelper(new SearchIndexKey(SEARCH_INDEX_NAME), SEARCH_INDEX_TYPE);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Search index type with code \"%s\" is not supported.", SEARCH_INDEX_TYPE), e.getMessage());
    }
    // Verify the external calls.
    verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 33 with SearchIndexKey

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

the class SearchIndexDaoHelperTest method testUpdateSearchIndexStatus.

@Test
public void testUpdateSearchIndexStatus() {
    // Create and persist a search index entity.
    SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS);
    // Create and persist a search index status entity.
    searchIndexStatusDaoTestHelper.createSearchIndexStatusEntity(SEARCH_INDEX_STATUS_2);
    // Update the status of the search index entity.
    searchIndexDaoHelper.updateSearchIndexStatus(new SearchIndexKey(SEARCH_INDEX_NAME), SEARCH_INDEX_STATUS_2);
    // Validate the results.
    assertEquals(SEARCH_INDEX_STATUS_2, searchIndexEntity.getStatus().getCode());
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

SearchIndexKey (org.finra.herd.model.api.xml.SearchIndexKey)33 Test (org.junit.Test)28 SearchIndexEntity (org.finra.herd.model.jpa.SearchIndexEntity)11 SearchIndex (org.finra.herd.model.api.xml.SearchIndex)10 SearchIndexTypeEntity (org.finra.herd.model.jpa.SearchIndexTypeEntity)8 ArrayList (java.util.ArrayList)6 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)6 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 IndexSearchResult (org.finra.herd.model.api.xml.IndexSearchResult)5 IndexSearchResultKey (org.finra.herd.model.api.xml.IndexSearchResultKey)5 SearchIndexValidationCreateRequest (org.finra.herd.model.api.xml.SearchIndexValidationCreateRequest)5 TagKey (org.finra.herd.model.api.xml.TagKey)5 SearchIndexStatusEntity (org.finra.herd.model.jpa.SearchIndexStatusEntity)5 IndexSearchRequest (org.finra.herd.model.api.xml.IndexSearchRequest)4 IndexSearchResponse (org.finra.herd.model.api.xml.IndexSearchResponse)4 Timestamp (java.sql.Timestamp)3 IndexSearchFilter (org.finra.herd.model.api.xml.IndexSearchFilter)3 IndexSearchKey (org.finra.herd.model.api.xml.IndexSearchKey)3 IndexSearchResultTypeKey (org.finra.herd.model.api.xml.IndexSearchResultTypeKey)3 SearchIndexCreateRequest (org.finra.herd.model.api.xml.SearchIndexCreateRequest)3