use of org.finra.herd.model.api.xml.SearchIndexActivation in project herd by FINRAOS.
the class SearchIndexActivationServiceTest method testSearchIndexActivation.
@Test
@Ignore
public void testSearchIndexActivation() {
// Get the search index type value.
String searchIndexType = SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name();
SearchIndexTypeEntity searchIndexTypeEntity = new SearchIndexTypeEntity();
searchIndexTypeEntity.setCode(searchIndexType);
// Get the search index status value.
String searchIndexStatus = SearchIndexStatusEntity.SearchIndexStatuses.READY.name();
// Creates a test search index status entity.
SearchIndexStatusEntity searchIndexStatusEntity = new SearchIndexStatusEntity();
searchIndexStatusEntity.setCode(searchIndexStatus);
// Create a search index entity
SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, searchIndexType, searchIndexStatus);
// Search index key
SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
// Create a search index entity response
SearchIndexEntity responseSearchIndexEntity = new SearchIndexEntity();
responseSearchIndexEntity.setName(SEARCH_INDEX_NAME);
responseSearchIndexEntity.setType(searchIndexTypeEntity);
responseSearchIndexEntity.setActive(Boolean.TRUE);
responseSearchIndexEntity.setCreatedBy(USER_ID);
responseSearchIndexEntity.setCreatedOn(new Timestamp(CREATED_ON.toGregorianCalendar().getTimeInMillis()));
responseSearchIndexEntity.setUpdatedOn(new Timestamp(UPDATED_ON.toGregorianCalendar().getTimeInMillis()));
// Create a search index activation request.
SearchIndexActivationCreateRequest searchIndexActivationCreateRequest = new SearchIndexActivationCreateRequest();
searchIndexActivationCreateRequest.setSearchIndexKey(searchIndexKey);
// Mock the external calls.
when(alternateKeyHelper.validateStringParameter("Search index name", SEARCH_INDEX_NAME)).thenReturn(SEARCH_INDEX_NAME);
when(searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey)).thenReturn(searchIndexEntity);
when(searchIndexDao.getSearchIndexEntities(searchIndexTypeEntity)).thenReturn(Arrays.asList(searchIndexEntity));
when(searchIndexDao.saveAndRefresh(any(SearchIndexEntity.class))).thenReturn(responseSearchIndexEntity);
// Call the method under test.
SearchIndexActivation response = searchIndexActivationService.createSearchIndexActivation(searchIndexActivationCreateRequest);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("Search index name", SEARCH_INDEX_NAME);
verify(searchIndexDaoHelper).getSearchIndexEntity(searchIndexKey);
verify(searchIndexDao).getSearchIndexEntities(searchIndexTypeEntity);
verify(searchIndexDao).saveAndRefresh(any(SearchIndexEntity.class));
verifyNoMoreInteractions(alternateKeyHelper, searchIndexDao, searchIndexDaoHelper);
// Validate the returned object.
assertEquals(new SearchIndex(searchIndexKey, searchIndexType, searchIndexStatus, SEARCH_INDEX_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), response);
}
use of org.finra.herd.model.api.xml.SearchIndexActivation in project herd by FINRAOS.
the class SearchIndexActivationRestControllerTest method testCreateSearchIndexActivation.
@Test
public void testCreateSearchIndexActivation() {
// Create a search index activation create request.
SearchIndexActivationCreateRequest searchIndexActivationCreateRequest = new SearchIndexActivationCreateRequest(new SearchIndexKey(SEARCH_INDEX_NAME));
// Create a search index activation response.
SearchIndexActivation searchIndexActivation = new SearchIndexActivation(new SearchIndexKey(SEARCH_INDEX_NAME), SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS, SEARCH_INDEX_ACTIVE_FLAG, CREATED_BY, CREATED_ON, UPDATED_ON);
// Mock the call to the search index activation service.
when(searchIndexActivationService.createSearchIndexActivation(searchIndexActivationCreateRequest)).thenReturn(searchIndexActivation);
// Create a search index activation.
SearchIndexActivation response = searchIndexActivationRestController.createSearchIndexActivation(searchIndexActivationCreateRequest);
// Verify the calls.
verify(searchIndexActivationService, times(1)).createSearchIndexActivation(searchIndexActivationCreateRequest);
// Validate the returned object.
assertEquals(searchIndexActivation, response);
}
use of org.finra.herd.model.api.xml.SearchIndexActivation in project herd by FINRAOS.
the class SearchIndexActivationServiceImpl method createSearchIndexActivation.
@Override
public SearchIndexActivation createSearchIndexActivation(SearchIndexActivationCreateRequest request) {
// Validate the request
validateSearchIndexActivationRequest(request);
// Ensure that search index for the specified search index key exists.
SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(request.getSearchIndexKey());
// Activate the specified search index entity.
searchIndexDaoHelper.activateSearchIndex(searchIndexEntity);
SearchIndex searchIndex = createSearchIndexFromEntity(searchIndexEntity);
return new SearchIndexActivation(searchIndex.getSearchIndexKey(), searchIndex.getSearchIndexType(), searchIndex.getSearchIndexStatus(), searchIndex.isActive(), searchIndex.getCreatedByUserId(), searchIndex.getCreatedOn(), searchIndex.getLastUpdatedOn());
}
Aggregations