SearchIndexUpdateJmsMessageListener { @JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE, containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE) public void processMessage(String payload, @Headers Map<Object, Object> allHeaders) { processMessageWithRetry(payload, allHeaders); }  @Scheduled(fixedDelay = 60000) void controlSearchIndexUpdateJmsMessageListener(); @JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE, containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE) void processMessage(String payload, @Headers Map<Object, Object> allHeaders);  }
@Test public void testProcessMessageBusinessObjectDefinition() throws Exception { List<Long> 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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); verify(businessObjectDefinitionService, times(1)) .updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class)); }
@Test public void testProcessMessageTag() throws Exception { List<Long> 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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); verify(tagService, times(1)) .updateSearchIndexDocumentTag(any(SearchIndexUpdateDto.class)); }
@Test public void testProcessMessageOriginalMessageFormat() throws Exception { List<Long> 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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); verify(businessObjectDefinitionService, times(1)) .updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class)); }