use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceIndexTest method testUpdateSearchIndexDocumentBusinessObjectDefinitionUpdateIdListSizeGreaterThanChunkSize.
@Test
public void testUpdateSearchIndexDocumentBusinessObjectDefinitionUpdateIdListSizeGreaterThanChunkSize() throws Exception {
// Create two lists of business object definition entities.
List<List<BusinessObjectDefinitionEntity>> businessObjectDefinitionEntities = Arrays.asList(Collections.singletonList(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes())), Collections.singletonList(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2())));
// Create a list of business object definition ids that would require to be processed in chunks.
List<Integer> businessObjectDefinitionIds = new ArrayList<>();
businessObjectDefinitionIds.addAll(Collections.nCopies(BusinessObjectDefinitionServiceImpl.UPDATE_SEARCH_INDEX_DOCUMENT_CHUNK_SIZE + 1, ID));
// Mock the external calls.
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_INDEX_NAME, String.class)).thenReturn(SEARCH_INDEX_NAME);
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn(SEARCH_INDEX_DOCUMENT_TYPE);
when(businessObjectDefinitionDao.getAllBusinessObjectDefinitionsByIds(businessObjectDefinitionIds.subList(0, BusinessObjectDefinitionServiceImpl.UPDATE_SEARCH_INDEX_DOCUMENT_CHUNK_SIZE))).thenReturn(businessObjectDefinitionEntities.get(0));
when(businessObjectDefinitionDao.getAllBusinessObjectDefinitionsByIds(businessObjectDefinitionIds.subList(BusinessObjectDefinitionServiceImpl.UPDATE_SEARCH_INDEX_DOCUMENT_CHUNK_SIZE, businessObjectDefinitionIds.size()))).thenReturn(businessObjectDefinitionEntities.get(1));
when(businessObjectDefinitionHelper.safeObjectMapperWriteValueAsString(businessObjectDefinitionEntities.get(0).get(0))).thenReturn(JSON_STRING);
when(businessObjectDefinitionHelper.safeObjectMapperWriteValueAsString(businessObjectDefinitionEntities.get(1).get(0))).thenReturn(JSON_STRING);
// Call the method under test.
businessObjectDefinitionService.updateSearchIndexDocumentBusinessObjectDefinition(new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE));
// Verify the external calls.
verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_INDEX_NAME, String.class);
verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
verify(businessObjectDefinitionDao).getAllBusinessObjectDefinitionsByIds(businessObjectDefinitionIds.subList(0, BusinessObjectDefinitionServiceImpl.UPDATE_SEARCH_INDEX_DOCUMENT_CHUNK_SIZE));
verify(businessObjectDefinitionDao).getAllBusinessObjectDefinitionsByIds(businessObjectDefinitionIds.subList(BusinessObjectDefinitionServiceImpl.UPDATE_SEARCH_INDEX_DOCUMENT_CHUNK_SIZE, businessObjectDefinitionIds.size()));
verify(businessObjectDefinitionHelper).safeObjectMapperWriteValueAsString(businessObjectDefinitionEntities.get(0).get(0));
verify(businessObjectDefinitionHelper).safeObjectMapperWriteValueAsString(businessObjectDefinitionEntities.get(1).get(0));
verify(indexFunctionsDao, times(2)).updateIndexDocuments(eq(SEARCH_INDEX_NAME), eq(SEARCH_INDEX_DOCUMENT_TYPE), Matchers.<Map<String, String>>any());
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.
the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagCreate.
@Test
public void testUpdateSearchIndexDocumentTagCreate() 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("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));
}
use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.
the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagUpdateEmpty.
@Test
public void testUpdateSearchIndexDocumentTagUpdateEmpty() 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("");
// 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());
}
use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.
the class TagServiceIndexTest method testUpdateSearchIndexDocumentTagUnknown.
@Test
public void testUpdateSearchIndexDocumentTagUnknown() 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()));
// Unknown modification type
SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, "UNKNOWN");
// Mock the call to external methods
when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn("DOCUMENT_TYPE");
// 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);
}
use of org.finra.herd.model.dto.SearchIndexUpdateDto in project herd by FINRAOS.
the class SearchIndexUpdateJmsMessageListenerTest method testProcessMessageBusinessObjectDefinition.
@Test
public void testProcessMessageBusinessObjectDefinition() throws Exception {
List<Integer> ids = new ArrayList<>();
SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_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(businessObjectDefinitionService, times(1)).updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class));
}
Aggregations