Package core.apiCore.helpers
Class MessageQueueHelper
- java.lang.Object
-
- core.apiCore.helpers.MessageQueueHelper
-
public class MessageQueueHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringRESPONSE_IDENTIFIER
-
Constructor Summary
Constructors Constructor Description MessageQueueHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidevaluateOption(ServiceObject serviceObject)static CopyOnWriteArrayList<MessageObject>filterOutboundMessage(String messageId)filter outbound message based on messageIdstatic CopyOnWriteArrayList<MessageObject>findMessagesBasedOnMessageId(String messageId)find message based on record idstatic CopyOnWriteArrayList<MessageObject>findMessagesBasedOnResponseIdentifier()find message based on unique identifier passed in through options identifiers are separated by comma separators have And relationshipstatic StringgenerateMessageId(ServiceObject serviceObject, String messageIdPrefix)generate message id if the request body is setstatic List<String>getHeaderList(CopyOnWriteArrayList<MessageObject> filteredMessages)inserts filtered headers to array list of stringsstatic Map<String,String>getKeyValueFromString(String value, String entriesSeparator, String separator)separated based on key value if key value exists eg.static List<String>getMessageList(CopyOnWriteArrayList<MessageObject> filteredMessages)inserts filtered messages to array list of stringsstatic voidgetOutboundMessages(MessageObject.messageType messageType)static List<String>getTopicList(CopyOnWriteArrayList<MessageObject> filteredMessages)inserts filtered topics to array list of stringsstatic booleanisExpectingMessageCount(String expectedResponse)is fixed messaged count expected eg.static longlogPerInterval(int interval, StopWatchHelper watch, long lastLogged, int receivedMessageCount)log per interval stating the wait time for a message from message queuestatic voidprintAllFilteredMessages(CopyOnWriteArrayList<MessageObject> filteredMessages)static voidprintAllMessages()print all messages idsstatic voidreceiveAndValidateMessages(ServiceObject serviceObject, String messageId, MessageObject.messageType messageType)1) gets messages, adds them to the outboundMessages 2) filters based on the message key 3) validates based on expected response requirementsstatic voidsaveOutBoundValues(ServiceObject serviceObject, CopyOnWriteArrayList<MessageObject> filteredMessages, List<String> errorMessages)static List<String>validateExpectedMessageCount(String request, List<String> filteredMessages)validate expected message count from received message format: EXPECTED_MESSAGE_COUNT:1;static List<String>validateMessages(ServiceObject serviceObject, CopyOnWriteArrayList<MessageObject> filteredMessages)validate message based on message, header, or topic valites json, xml, or text response
-
-
-
Field Detail
-
RESPONSE_IDENTIFIER
public static final String RESPONSE_IDENTIFIER
- See Also:
- Constant Field Values
-
-
Method Detail
-
receiveAndValidateMessages
public static void receiveAndValidateMessages(ServiceObject serviceObject, String messageId, MessageObject.messageType messageType) throws Exception
1) gets messages, adds them to the outboundMessages 2) filters based on the message key 3) validates based on expected response requirements- Parameters:
messageId-- Throws:
Exception
-
saveOutBoundValues
public static void saveOutBoundValues(ServiceObject serviceObject, CopyOnWriteArrayList<MessageObject> filteredMessages, List<String> errorMessages)
-
generateMessageId
public static String generateMessageId(ServiceObject serviceObject, String messageIdPrefix)
generate message id if the request body is set- Parameters:
requestBody-- Returns:
-
logPerInterval
public static long logPerInterval(int interval, StopWatchHelper watch, long lastLogged, int receivedMessageCount)log per interval stating the wait time for a message from message queue- Parameters:
interval-watch-lastLogged-- Returns:
-
validateExpectedMessageCount
public static List<String> validateExpectedMessageCount(String request, List<String> filteredMessages)
validate expected message count from received message format: EXPECTED_MESSAGE_COUNT:1;- Parameters:
request-filteredMessages-- Returns:
-
isExpectingMessageCount
public static boolean isExpectingMessageCount(String expectedResponse)
is fixed messaged count expected eg. EXPECTED_MESSAGE_COUNT:2- Parameters:
expectedResponse-- Returns:
-
getKeyValueFromString
public static Map<String,String> getKeyValueFromString(String value, String entriesSeparator, String separator)
separated based on key value if key value exists eg. key:value; key1:value1- Parameters:
value-entriesSeparator- eg. ";"separator- eg ":"- Returns:
-
findMessagesBasedOnResponseIdentifier
public static CopyOnWriteArrayList<MessageObject> findMessagesBasedOnResponseIdentifier()
find message based on unique identifier passed in through options identifiers are separated by comma separators have And relationship- Parameters:
messageId-- Returns:
-
findMessagesBasedOnMessageId
public static CopyOnWriteArrayList<MessageObject> findMessagesBasedOnMessageId(String messageId)
find message based on record id- Parameters:
messageId-- Returns:
-
filterOutboundMessage
public static CopyOnWriteArrayList<MessageObject> filterOutboundMessage(String messageId)
filter outbound message based on messageId- Parameters:
msgId-- Returns:
-
getOutboundMessages
public static void getOutboundMessages(MessageObject.messageType messageType) throws Exception
- Throws:
Exception
-
printAllMessages
public static void printAllMessages()
print all messages ids
-
printAllFilteredMessages
public static void printAllFilteredMessages(CopyOnWriteArrayList<MessageObject> filteredMessages)
-
getMessageList
public static List<String> getMessageList(CopyOnWriteArrayList<MessageObject> filteredMessages)
inserts filtered messages to array list of strings- Parameters:
filteredMessages-- Returns:
-
getHeaderList
public static List<String> getHeaderList(CopyOnWriteArrayList<MessageObject> filteredMessages)
inserts filtered headers to array list of strings- Parameters:
filteredMessages-- Returns:
-
getTopicList
public static List<String> getTopicList(CopyOnWriteArrayList<MessageObject> filteredMessages)
inserts filtered topics to array list of strings- Parameters:
filteredMessages-- Returns:
-
validateMessages
public static List<String> validateMessages(ServiceObject serviceObject, CopyOnWriteArrayList<MessageObject> filteredMessages)
validate message based on message, header, or topic valites json, xml, or text response- Returns:
-
evaluateOption
public static void evaluateOption(ServiceObject serviceObject)
-
-