use of org.finra.herd.model.api.xml.SearchIndexCreateRequest in project herd by FINRAOS.
the class SearchIndexServiceImplTest method testCreateSearchIndexEntity.
@Test
public void testCreateSearchIndexEntity() {
// Create a search index key.
SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
// Create a search index create request.
SearchIndexCreateRequest searchIndexCreateRequest = new SearchIndexCreateRequest(SEARCH_INDEX_TYPE);
// 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 search index entity from the search index create request.
SearchIndexEntity searchIndexEntity = searchIndexServiceImpl.createSearchIndexEntity(searchIndexCreateRequest, searchIndexTypeEntity, searchIndexStatusEntity);
// Verify the external calls.
verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
// Validate the returned object.
assertNotNull(searchIndexEntity);
assertNotNull(searchIndexEntity.getType());
assertEquals(SEARCH_INDEX_TYPE, searchIndexEntity.getType().getCode());
assertNotNull(searchIndexEntity.getStatus());
assertEquals(SEARCH_INDEX_STATUS, searchIndexEntity.getStatus().getCode());
assertNull(searchIndexEntity.getCreatedBy());
assertNull(searchIndexEntity.getCreatedOn());
assertNull(searchIndexEntity.getUpdatedBy());
assertNull(searchIndexEntity.getUpdatedOn());
}
use of org.finra.herd.model.api.xml.SearchIndexCreateRequest in project herd by FINRAOS.
the class SearchIndexRestControllerTest method testCreateSearchIndex.
@Test
public void testCreateSearchIndex() {
// Create a search index create request.
SearchIndexCreateRequest searchIndexCreateRequest = new SearchIndexCreateRequest(SEARCH_INDEX_TYPE);
// Create a search index create response.
SearchIndex searchIndex = new SearchIndex(new SearchIndexKey(SEARCH_INDEX_NAME), SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON);
// Mock the call to the search index service.
when(searchIndexService.createSearchIndex(searchIndexCreateRequest)).thenReturn(searchIndex);
// Create a search index.
SearchIndex response = searchIndexRestController.createSearchIndex(searchIndexCreateRequest);
// Verify the calls.
verify(searchIndexService, times(1)).createSearchIndex(searchIndexCreateRequest);
// Validate the returned object.
assertEquals(searchIndex, response);
}
use of org.finra.herd.model.api.xml.SearchIndexCreateRequest in project herd by FINRAOS.
the class SearchIndexServiceTest method testCreateSearchIndex.
@Test
public void testCreateSearchIndex() {
// Create a search index key.
SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
// Get the search index type value.
String searchIndexType = SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name();
// Get the search index status value.
String searchIndexStatus = SearchIndexStatusEntity.SearchIndexStatuses.BUILDING.name();
// Create a search index create request.
SearchIndexCreateRequest searchIndexCreateRequest = new SearchIndexCreateRequest(searchIndexType);
// Creates a test search index type entity.
SearchIndexTypeEntity searchIndexTypeEntity = new SearchIndexTypeEntity();
searchIndexTypeEntity.setCode(searchIndexType);
// Creates a test search index status entity.
SearchIndexStatusEntity searchIndexStatusEntity = new SearchIndexStatusEntity();
searchIndexStatusEntity.setCode(searchIndexStatus);
// Creates 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);
// Mock some of the external call responses.
@SuppressWarnings("unchecked") Future<Void> mockedFuture = mock(Future.class);
// Mock the external calls.
when(alternateKeyHelper.validateStringParameter("Search index type", searchIndexType)).thenReturn(searchIndexType);
when(searchIndexTypeDaoHelper.getSearchIndexTypeEntity(searchIndexType)).thenReturn(searchIndexTypeEntity);
when(searchIndexStatusDaoHelper.getSearchIndexStatusEntity(searchIndexStatus)).thenReturn(searchIndexStatusEntity);
when(searchIndexDao.saveAndRefresh(any(SearchIndexEntity.class))).thenReturn(searchIndexEntity);
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn(SEARCH_INDEX_DOCUMENT_TYPE);
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_INDEX_NAME, String.class)).thenReturn(SEARCH_INDEX_ALIAS_BDEF);
when(configurationDaoHelper.getClobProperty(ConfigurationValue.ELASTICSEARCH_BDEF_MAPPINGS_JSON.getKey())).thenReturn(SEARCH_INDEX_MAPPING);
when(configurationDaoHelper.getClobProperty(ConfigurationValue.ELASTICSEARCH_BDEF_SETTINGS_JSON.getKey())).thenReturn(SEARCH_INDEX_SETTINGS);
when(searchIndexHelperService.indexAllBusinessObjectDefinitions(searchIndexKey, SEARCH_INDEX_DOCUMENT_TYPE)).thenReturn(mockedFuture);
// Create a search index.
SearchIndex response = searchIndexService.createSearchIndex(searchIndexCreateRequest);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("Search index type", searchIndexType);
verify(searchIndexTypeDaoHelper).getSearchIndexTypeEntity(searchIndexType);
verify(searchIndexStatusDaoHelper).getSearchIndexStatusEntity(searchIndexStatus);
verify(searchIndexDao).saveAndRefresh(any(SearchIndexEntity.class));
verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
verify(configurationHelper, times(2)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_INDEX_NAME, String.class);
verify(configurationDaoHelper).getClobProperty(ConfigurationValue.ELASTICSEARCH_BDEF_MAPPINGS_JSON.getKey());
verify(configurationDaoHelper).getClobProperty(ConfigurationValue.ELASTICSEARCH_BDEF_SETTINGS_JSON.getKey());
verify(indexFunctionsDao).createIndex(any(), any(), any(), any(), any());
verify(searchIndexHelperService).indexAllBusinessObjectDefinitions(searchIndexKey, SEARCH_INDEX_DOCUMENT_TYPE);
verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, indexFunctionsDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
// Validate the returned object.
assertEquals(new SearchIndex(searchIndexKey, searchIndexType, searchIndexStatus, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), response);
}
Aggregations