use of org.finra.herd.model.api.xml.SearchIndexKey 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.SearchIndexKey in project herd by FINRAOS.
the class SearchIndexValidationRestControllerTest method testCreateSearchIndexValidation.
@Test
public void testCreateSearchIndexValidation() {
// Create a search index validation create request.
SearchIndexValidationCreateRequest searchIndexValidationCreateRequest = new SearchIndexValidationCreateRequest(new SearchIndexKey(SEARCH_INDEX_NAME), PERFORM_FULL_SEARCH_INDEX_VALIDATION);
// Create a search index validation response.
SearchIndexValidation searchIndexValidation = new SearchIndexValidation(new SearchIndexKey(SEARCH_INDEX_NAME), SEARCH_INDEX_STATISTICS_CREATION_DATE, false, false, false);
// Mock the call to the search index validation service.
when(searchIndexValidationService.createSearchIndexValidation(searchIndexValidationCreateRequest)).thenReturn(searchIndexValidation);
// Create a search index validation.
SearchIndexValidation response = searchIndexValidationRestController.createSearchIndexValidation(searchIndexValidationCreateRequest);
// Verify the calls.
verify(searchIndexValidationService, times(1)).createSearchIndexValidation(searchIndexValidationCreateRequest);
response.setValidateStartTime(SEARCH_INDEX_STATISTICS_CREATION_DATE);
// Validate the returned object.
assertEquals(searchIndexValidation, response);
}
use of org.finra.herd.model.api.xml.SearchIndexKey in project herd by FINRAOS.
the class SearchIndexServiceImpl method createSearchIndex.
@Override
public SearchIndex createSearchIndex(SearchIndexCreateRequest request) {
// Perform validation and trim.
validateSearchIndexCreateRequest(request);
// Get the search index type and ensure it exists.
SearchIndexTypeEntity searchIndexTypeEntity = searchIndexTypeDaoHelper.getSearchIndexTypeEntity(request.getSearchIndexType());
// Get the BUILDING search index status entity and ensure it exists.
SearchIndexStatusEntity searchIndexStatusEntity = searchIndexStatusDaoHelper.getSearchIndexStatusEntity(SearchIndexStatusEntity.SearchIndexStatuses.BUILDING.name());
// Creates the relative search index entity from the request information.
SearchIndexEntity searchIndexEntity = createSearchIndexEntity(request, searchIndexTypeEntity, searchIndexStatusEntity);
// Persist the new entity.
searchIndexEntity = searchIndexDao.saveAndRefresh(searchIndexEntity);
// Create search index key with the auto-generated search index name
SearchIndexKey searchIndexKey = new SearchIndexKey();
searchIndexKey.setSearchIndexName(searchIndexEntity.getName());
// Create the search index.
createSearchIndexHelper(searchIndexKey, searchIndexTypeEntity.getCode());
// Create and return the search index object from the persisted entity.
return createSearchIndexFromEntity(searchIndexEntity);
}
use of org.finra.herd.model.api.xml.SearchIndexKey in project herd by FINRAOS.
the class SearchIndexServiceImpl method createSearchIndexFromEntity.
/**
* Creates a search index object from the persisted entity.
*
* @param searchIndexEntity the search index entity
*
* @return the search index
*/
protected SearchIndex createSearchIndexFromEntity(SearchIndexEntity searchIndexEntity) {
SearchIndex searchIndex = new SearchIndex();
searchIndex.setSearchIndexKey(new SearchIndexKey(searchIndexEntity.getName()));
searchIndex.setSearchIndexType(searchIndexEntity.getType().getCode());
searchIndex.setSearchIndexStatus(searchIndexEntity.getStatus().getCode());
if (searchIndexEntity.getActive() != null) {
searchIndex.setActive(searchIndexEntity.getActive());
} else {
searchIndex.setActive(Boolean.FALSE);
}
searchIndex.setCreatedByUserId(searchIndexEntity.getCreatedBy());
searchIndex.setCreatedOn(HerdDateUtils.getXMLGregorianCalendarValue(searchIndexEntity.getCreatedOn()));
searchIndex.setLastUpdatedOn(HerdDateUtils.getXMLGregorianCalendarValue(searchIndexEntity.getUpdatedOn()));
return searchIndex;
}
use of org.finra.herd.model.api.xml.SearchIndexKey in project herd by FINRAOS.
the class SearchIndexRestControllerTest method testGetSearchIndex.
@Test
public void testGetSearchIndex() {
// Create a search index key.
SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
// Create a search index get response.
SearchIndex searchIndex = new SearchIndex(searchIndexKey, 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.getSearchIndex(searchIndexKey)).thenReturn(searchIndex);
// Get a search index.
SearchIndex response = searchIndexRestController.getSearchIndex(SEARCH_INDEX_NAME);
// Verify the calls.
verify(searchIndexService, times(1)).getSearchIndex(new SearchIndexKey(SEARCH_INDEX_NAME));
// Validate the returned object.
assertEquals(searchIndex, response);
}
Aggregations