Search in sources :

Example 1 with SearchIndexActivationCreateRequest

use of org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest 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 SearchIndexActivationCreateRequest

use of org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest 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)

Aggregations

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