Search in sources :

Example 11 with SearchIndex

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

the class SearchIndexServiceTest method testDeleteSearchIndex.

@Test
public void testDeleteSearchIndex() {
    // Create a search index key.
    SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
    // Create the search index entity.
    SearchIndexEntity searchIndexEntity = createTestSearchIndexEntity();
    // Mock the external calls.
    when(indexFunctionsDao.isIndexExists(any())).thenReturn(true);
    when(alternateKeyHelper.validateStringParameter("Search index name", SEARCH_INDEX_NAME)).thenReturn(SEARCH_INDEX_NAME);
    when(searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey)).thenReturn(searchIndexEntity);
    // Delete a search index.
    SearchIndex response = searchIndexService.deleteSearchIndex(searchIndexKey);
    // Verify the external calls.
    verify(alternateKeyHelper).validateStringParameter("Search index name", SEARCH_INDEX_NAME);
    verify(searchIndexDaoHelper).getSearchIndexEntity(searchIndexKey);
    verify(indexFunctionsDao).isIndexExists(any());
    verify(indexFunctionsDao).deleteIndex(any());
    verify(searchIndexDao).delete(searchIndexEntity);
    verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, indexFunctionsDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
    // Validate the returned object.
    assertEquals(new SearchIndex(searchIndexKey, SEARCH_INDEX_TYPE_BDEF, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), response);
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Test(org.junit.Test)

Example 12 with SearchIndex

use of org.finra.herd.model.api.xml.SearchIndex 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)

Aggregations

SearchIndex (org.finra.herd.model.api.xml.SearchIndex)12 SearchIndexKey (org.finra.herd.model.api.xml.SearchIndexKey)10 Test (org.junit.Test)8 SearchIndexEntity (org.finra.herd.model.jpa.SearchIndexEntity)7 Timestamp (java.sql.Timestamp)3 SearchIndexStatusEntity (org.finra.herd.model.jpa.SearchIndexStatusEntity)3 SearchIndexTypeEntity (org.finra.herd.model.jpa.SearchIndexTypeEntity)3 Settings (org.elasticsearch.common.settings.Settings)2 DocsStats (org.elasticsearch.index.shard.DocsStats)2 SearchIndexActivation (org.finra.herd.model.api.xml.SearchIndexActivation)2 SearchIndexCreateRequest (org.finra.herd.model.api.xml.SearchIndexCreateRequest)2 HashMap (java.util.HashMap)1 SearchIndexActivationCreateRequest (org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest)1 SearchIndexStatistics (org.finra.herd.model.api.xml.SearchIndexStatistics)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1 Ignore (org.junit.Ignore)1