Search in sources :

Example 1 with SearchIndexActivation

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);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexActivationCreateRequest(org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest) SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) SearchIndexActivation(org.finra.herd.model.api.xml.SearchIndexActivation) Timestamp(java.sql.Timestamp) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with SearchIndexActivation

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);
}
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 3 with SearchIndexActivation

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

Aggregations

SearchIndexActivation (org.finra.herd.model.api.xml.SearchIndexActivation)3 SearchIndex (org.finra.herd.model.api.xml.SearchIndex)2 SearchIndexActivationCreateRequest (org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest)2 SearchIndexKey (org.finra.herd.model.api.xml.SearchIndexKey)2 SearchIndexEntity (org.finra.herd.model.jpa.SearchIndexEntity)2 Test (org.junit.Test)2 Timestamp (java.sql.Timestamp)1 SearchIndexStatusEntity (org.finra.herd.model.jpa.SearchIndexStatusEntity)1 SearchIndexTypeEntity (org.finra.herd.model.jpa.SearchIndexTypeEntity)1 Ignore (org.junit.Ignore)1