Search in sources :

Example 1 with SearchIndexUpdateDto

use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.

the class SearchIndexUpdateJmsMessageListenerTest method testProcessMessageTag.

@Test
public void testProcessMessageTag() throws Exception {
    List<Integer> ids = new ArrayList<>();
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, ids, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    when(jsonHelper.unmarshallJsonToObject(SearchIndexUpdateDto.class, "PAYLOAD")).thenReturn(searchIndexUpdateDto);
    // Call the method under test
    searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", null);
    // Verify the calls to external methods
    verify(tagService, times(1)).updateSearchIndexDocumentTag(any(SearchIndexUpdateDto.class));
}
Also used : ArrayList(java.util.ArrayList) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 2 with SearchIndexUpdateDto

use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.

the class SearchIndexUpdateJmsMessageListenerTest method testProcessMessageOriginalMessageFormat.

@Test
public void testProcessMessageOriginalMessageFormat() throws Exception {
    List<Integer> ids = new ArrayList<>();
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto();
    searchIndexUpdateDto.setBusinessObjectDefinitionIds(ids);
    searchIndexUpdateDto.setModificationType(SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    when(jsonHelper.unmarshallJsonToObject(SearchIndexUpdateDto.class, "PAYLOAD")).thenReturn(searchIndexUpdateDto);
    // Call the method under test
    searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", null);
    // Verify the calls to external methods
    verify(businessObjectDefinitionService, times(1)).updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class));
}
Also used : ArrayList(java.util.ArrayList) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 3 with SearchIndexUpdateDto

use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagUpdate.

@Test
public void testUpdateSearchIndexDocumentTagUpdate() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Create a document on the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    when(tagDao.getTagsByIds(tagIds)).thenReturn(tagEntityList);
    when(tagHelper.safeObjectMapperWriteValueAsString(any(TagEntity.class))).thenReturn("JSON_STRING");
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagDao, times(1)).getTagsByIds(tagIds);
    verify(tagHelper, times(2)).safeObjectMapperWriteValueAsString(any(TagEntity.class));
    verify(indexFunctionsDao, times(1)).updateIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 4 with SearchIndexUpdateDto

use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagDelete.

@Test
public void testUpdateSearchIndexDocumentTagDelete() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Delete from the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_DELETE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    doNothing().when(indexFunctionsDao).deleteIndexDocuments(any(), any(), any());
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(indexFunctionsDao, times(1)).deleteIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 5 with SearchIndexUpdateDto

use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.

the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagCreateEmpty.

@Test
public void testUpdateSearchIndexDocumentTagCreateEmpty() throws Exception {
    List<TagEntity> tagEntityList = new ArrayList<>();
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_DESCRIPTION);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(new TagKey(TAG_TYPE_2, TAG_CODE_2), TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    tagEntityList.add(tagEntity1);
    tagEntityList.add(tagEntity2);
    List<Integer> tagIds = new ArrayList<>();
    tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId()));
    // Create a document on the search index
    SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, SEARCH_INDEX_UPDATE_TYPE_CREATE);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
    when(tagDao.getTagsByIds(tagIds)).thenReturn(tagEntityList);
    when(tagHelper.safeObjectMapperWriteValueAsString(any(TagEntity.class))).thenReturn("");
    doNothing().when(indexFunctionsDao).createIndexDocuments(any(), any(), any());
    // Call the method under test
    tagService.updateSearchIndexDocumentTag(searchIndexUpdateDto);
    // Verify the calls to external methods
    verify(configurationHelper, times(1)).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagDao, times(1)).getTagsByIds(tagIds);
    verify(tagHelper, times(2)).safeObjectMapperWriteValueAsString(any(TagEntity.class));
    verify(indexFunctionsDao, times(1)).createIndexDocuments(any(), any(), any());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagKey(org.finra.herd.model.api.xml.TagKey) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)30 SearchIndexUpdateDto (org.finra.herd.model.dto.SearchIndexUpdateDto)30 Test (org.junit.Test)30 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 TagEntity (org.finra.herd.model.jpa.TagEntity)13 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)12 TagKey (org.finra.herd.model.api.xml.TagKey)6 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)4 List (java.util.List)1 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)1 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 BusinessObjectDefinitionUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest)1