SearchIndexUpdateHelper { public void modifyBusinessObjectDefinitionInSearchIndex(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String modificationType) { List<Long> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); processMessage( jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, modificationType))); }  void modifyBusinessObjectDefinitionInSearchIndex(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String modificationType); void modifyBusinessObjectDefinitionsInSearchIndex(List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList, String modificationType); void modifyTagInSearchIndex(TagEntity tagEntity, String modificationType); void modifyTagsInSearchIndex(List<TagEntity> tagEntityList, String modificationType);  }
@Test public void testModifyBusinessObjectDefinitionInSearchIndex() { BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity(); businessObjectDefinitionEntity.setId(1L); List<Long> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE); when(jsonHelper.objectToJson(searchIndexUpdateDto)).thenReturn(MESSAGE_TEXT); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED)).thenReturn("true"); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_SQS_QUEUE_NAME)).thenReturn(AWS_SQS_QUEUE_NAME); searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE); verify(jsonHelper).objectToJson(searchIndexUpdateDto); verify(configurationHelper).getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED); verify(configurationHelper).getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_SQS_QUEUE_NAME); verify(notificationMessagePublishingService) .addNotificationMessageToDatabaseQueue(new NotificationMessage(MessageTypeEntity.MessageEventTypes.SQS.name(), AWS_SQS_QUEUE_NAME, MESSAGE_TEXT, NO_MESSAGE_HEADERS)); verifyNoMoreInteractionsHelper(); }
@Test public void testModifyBusinessObjectDefinitionInSearchIndexBlankMessage() { BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity(); businessObjectDefinitionEntity.setId(1L); List<Long> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE); when(jsonHelper.objectToJson(searchIndexUpdateDto)).thenReturn(""); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED)).thenReturn("true"); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_SQS_QUEUE_NAME)).thenReturn(AWS_SQS_QUEUE_NAME); searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE); verify(jsonHelper).objectToJson(searchIndexUpdateDto); verify(configurationHelper).getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED); verifyNoMoreInteractionsHelper(); }
@Test public void testModifyBusinessObjectDefinitionInSearchIndexNoSqsQueueName() { BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity(); businessObjectDefinitionEntity.setId(1L); List<Long> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); SearchIndexUpdateDto searchIndexUpdateDto = new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, SEARCH_INDEX_UPDATE_TYPE_UPDATE); when(jsonHelper.objectToJson(searchIndexUpdateDto)).thenReturn(MESSAGE_TEXT); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED)).thenReturn("true"); when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_SQS_QUEUE_NAME)).thenReturn(BLANK_TEXT); try { searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE); fail(); } catch (IllegalStateException illegalStateException) { assertThat("Function is null.", illegalStateException.getMessage(), is("SQS queue name not found. Ensure the \"search.index.update.sqs.queue.name\" configuration entry is configured.")); } verify(jsonHelper).objectToJson(searchIndexUpdateDto); verify(configurationHelper).getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED); verify(configurationHelper).getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_SQS_QUEUE_NAME); verifyNoMoreInteractionsHelper(); }