request = (T) jsonHelper.unmarshallJsonToObject(xsdClass, requestString);
request = (T) jsonHelper.unmarshallJsonToObject(xsdClass, requestString);
final Map<String, String> fieldsBoostsMap = jsonHelper.unmarshallJsonToObject(Map.class, fieldsBoostsJsonString);
final Map<String, String> fieldsBoostsMap = jsonHelper.unmarshallJsonToObject(Map.class, fieldsBoostsJsonString);
SearchIndexUpdateDto searchIndexUpdateDto = jsonHelper.unmarshallJsonToObject(SearchIndexUpdateDto.class, payload);
@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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); // Call the method under test searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); // Verify the calls to external methods verify(businessObjectDefinitionService, times(1)) .updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class)); }
@Test public void testUnmarshallJsonToObject() throws IOException { assertEquals(STRING_VALUE, jsonHelper.unmarshallJsonToObject(String.class, String.format("\"%s\"", STRING_VALUE))); } }
StoragePolicySelection storagePolicySelection = jsonHelper.unmarshallJsonToObject(StoragePolicySelection.class, payload);
@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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); // Call the method under test searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); // Verify the calls to external methods verify(tagService, times(1)) .updateSearchIndexDocumentTag(any(SearchIndexUpdateDto.class)); }
StoragePolicySelection storagePolicySelection = jsonHelper.unmarshallJsonToObject(StoragePolicySelection.class, payload);
private void verifyHitHighlightingInteractions(SearchRequestBuilder searchRequestBuilder, boolean isHitHighlightingEnabled, Set<String> match) throws IOException { if (isHitHighlightingEnabled) { // verify interactions with the helpers which is required to fetch highlighting config verify(jsonHelper, times(5)).unmarshallJsonToObject(eq(Map.class), any(String.class)); verify(jsonHelper).unmarshallJsonToObject(eq(IndexSearchHighlightFields.class), any(String.class)); verify(configurationHelper, times(3)).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_POSTTAGS); verify(configurationHelper, times(3)).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_PRETAGS); if (match != null && match.contains(MATCH_COLUMN)) { verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_COLUMN_MATCH_HIGHLIGHT_FIELDS); } else { verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_FIELDS); } } else { // verify highlighting is not added to the query if not highlighting is disabled verify(searchRequestBuilder, times(0)).highlighter(any(HighlightBuilder.class)); // verify highlighting-specific configuration values are not fetched if highlighting is disabled verify(configurationHelper, times(0)).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_POSTTAGS); verify(configurationHelper, times(0)).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_PRETAGS); verify(configurationHelper, times(0)).getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_FIELDS); } }
@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); Map<Object, Object> allHeaders = new HashMap<>(); allHeaders.put("jms_messageId", MESSAGE_ID); // Call the method under test searchIndexUpdateJmsMessageListener.processMessage("PAYLOAD", allHeaders); // Verify the calls to external methods verify(businessObjectDefinitionService, times(1)) .updateSearchIndexDocumentBusinessObjectDefinition(any(SearchIndexUpdateDto.class)); }
when(awsHelper.getClientConfiguration(awsParamsDto)).thenReturn(clientConfiguration); when(credStashFactory.getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration)).thenReturn(credStash); when(jsonHelper.unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT)).thenReturn(credStashEncryptionContextMap); verify(awsHelper).getClientConfiguration(awsParamsDto); verify(credStashFactory).getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration); verify(jsonHelper).unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT); verify(credStash).getCredential(USER_CREDENTIAL_NAME, credStashEncryptionContextMap); verifyNoMoreInteractions(credStash);
when(awsHelper.getClientConfiguration(awsParamsDto)).thenReturn(clientConfiguration); when(credStashFactory.getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration)).thenReturn(credStash); when(jsonHelper.unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT)).thenReturn(credStashEncryptionContextMap); verify(awsHelper).getClientConfiguration(awsParamsDto); verify(credStashFactory).getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration); verify(jsonHelper).unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT); verify(credStash).getCredential(USER_CREDENTIAL_NAME, credStashEncryptionContextMap); verifyNoMoreInteractions(credStash);
when(awsHelper.getClientConfiguration(awsParamsDto)).thenReturn(clientConfiguration); when(credStashFactory.getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration)).thenReturn(credStash); when(jsonHelper.unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT)).thenReturn(credStashEncryptionContextMap); verify(awsHelper).getClientConfiguration(awsParamsDto); verify(credStashFactory).getCredStash(AWS_REGION_NAME, TABLE_NAME, clientConfiguration); verify(jsonHelper).unmarshallJsonToObject(Map.class, CREDSTASH_ENCRYPTION_CONTEXT); verify(credStash).getCredential(USER_CREDENTIAL_NAME, credStashEncryptionContextMap); verifyNoMoreInteractions(credStash);
jsonHelper.unmarshallJsonToObject(BusinessObjectDataStatusChangeJsonMessagePayload.class, notificationMessage.getMessageText());
/** * Validates a user namespace authorization change notification message with JSON payload. * * @param expectedMessageType the expected message type * @param expectedMessageDestination the expected message destination * @param expectedUserNamespaceAuthorizationKey the expected user namespace authorization key * @param expectedMessageHeaders the list of expected message headers * @param notificationMessage the notification message to be validated */ private void validateUserNamespaceAuthorizationChangeMessageWithJsonPayload(String expectedMessageType, String expectedMessageDestination, UserNamespaceAuthorizationKey expectedUserNamespaceAuthorizationKey, List<MessageHeader> expectedMessageHeaders, NotificationMessage notificationMessage) throws IOException { assertNotNull(notificationMessage); assertEquals(expectedMessageType, notificationMessage.getMessageType()); assertEquals(expectedMessageDestination, notificationMessage.getMessageDestination()); UserNamespaceAuthorizationChangeJsonMessagePayload businessObjectFormatVersionChangeJsonMessagePayload = jsonHelper.unmarshallJsonToObject(UserNamespaceAuthorizationChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(expectedUserNamespaceAuthorizationKey.getUserId(), businessObjectFormatVersionChangeJsonMessagePayload.userId); assertEquals(expectedUserNamespaceAuthorizationKey.getNamespace(), businessObjectFormatVersionChangeJsonMessagePayload.namespace); assertEquals(expectedMessageHeaders, notificationMessage.getMessageHeaders()); }
/** * Validates a business object data status change notification message with JSON payload. * * @param expectedMessageType the expected message type * @param expectedMessageDestination the expected message destination * @param expectedBusinessObjectFormatKey the expected business object format key * @param expectedNewBusinessObjectFormatVersion the expected new business object format version * @param expectedOldBusinessObjectFormatVersion the expected old business object format version * @param expectedMessageHeaders the list of expected message headers * @param notificationMessage the notification message to be validated */ private void validateBusinessObjectFormatVersionChangeMessageWithJsonPayload(String expectedMessageType, String expectedMessageDestination, BusinessObjectFormatKey expectedBusinessObjectFormatKey, String expectedNewBusinessObjectFormatVersion, String expectedOldBusinessObjectFormatVersion, List<MessageHeader> expectedMessageHeaders, NotificationMessage notificationMessage) throws IOException { assertNotNull(notificationMessage); assertEquals(expectedMessageType, notificationMessage.getMessageType()); assertEquals(expectedMessageDestination, notificationMessage.getMessageDestination()); BusinessObjectFormatVersionChangeJsonMessagePayload businessObjectFormatVersionChangeJsonMessagePayload = jsonHelper.unmarshallJsonToObject(BusinessObjectFormatVersionChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(StringUtils.length(businessObjectFormatVersionChangeJsonMessagePayload.eventDate), StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectFormatKey, businessObjectFormatVersionChangeJsonMessagePayload.businessObjectFormatKey); assertEquals(expectedNewBusinessObjectFormatVersion, businessObjectFormatVersionChangeJsonMessagePayload.newBusinessObjectFormatVersion); assertEquals(expectedOldBusinessObjectFormatVersion, businessObjectFormatVersionChangeJsonMessagePayload.oldBusinessObjectFormatVersion); assertEquals(expectedMessageHeaders, notificationMessage.getMessageHeaders()); }
/** * Validates a storage unit status change notification message with JSON payload. * * @param expectedMessageType the expected message type * @param expectedMessageDestination the expected message destination * @param expectedBusinessObjectDataKey the expected business object data key * @param expectedStorageName the expected storage name * @param expectedNewStorageUnitStatus the expected new business object data status * @param expectedOldStorageUnitStatus the expected old business object data status * @param expectedMessageHeaders the list of expected message headers * @param notificationMessage the notification message to be validated */ private void validateStorageUnitStatusChangeMessageWithJsonPayload(String expectedMessageType, String expectedMessageDestination, BusinessObjectDataKey expectedBusinessObjectDataKey, String expectedStorageName, String expectedNewStorageUnitStatus, String expectedOldStorageUnitStatus, List<MessageHeader> expectedMessageHeaders, NotificationMessage notificationMessage) throws IOException { assertNotNull(notificationMessage); assertEquals(expectedMessageType, notificationMessage.getMessageType()); assertEquals(expectedMessageDestination, notificationMessage.getMessageDestination()); StorageUnitStatusChangeJsonMessagePayload storageUnitStatusChangeJsonMessagePayload = jsonHelper.unmarshallJsonToObject(StorageUnitStatusChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(StringUtils.length(storageUnitStatusChangeJsonMessagePayload.eventDate), StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectDataKey, storageUnitStatusChangeJsonMessagePayload.businessObjectDataKey); assertEquals(expectedStorageName, storageUnitStatusChangeJsonMessagePayload.storageName); assertEquals(expectedNewStorageUnitStatus, storageUnitStatusChangeJsonMessagePayload.newStorageUnitStatus); assertEquals(expectedOldStorageUnitStatus, storageUnitStatusChangeJsonMessagePayload.oldStorageUnitStatus); assertEquals(expectedMessageHeaders, notificationMessage.getMessageHeaders()); }
.unmarshallJsonToObject(BusinessObjectDefinitionDescriptionSuggestionChangeJsonMessagePayload.class, notificationMessage.getMessageText());