Search in sources :

Example 16 with SearchIndexKey

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);
}
Also used : SearchIndexActivationCreateRequest(org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexActivation(org.finra.herd.model.api.xml.SearchIndexActivation) Test(org.junit.Test)

Example 17 with SearchIndexKey

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);
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexValidationCreateRequest(org.finra.herd.model.api.xml.SearchIndexValidationCreateRequest) SearchIndexValidation(org.finra.herd.model.api.xml.SearchIndexValidation) Test(org.junit.Test)

Example 18 with SearchIndexKey

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);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Example 19 with SearchIndexKey

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;
}
Also used : SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey)

Example 20 with SearchIndexKey

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);
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndex(org.finra.herd.model.api.xml.SearchIndex) Test(org.junit.Test)

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