Queue Operations
setHost
Description: This function is used to set the host for establishing the queue connection.
Input Format : @Expected host name
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setHost |
@value | Hardcoded Input | ||
Queue | setHost |
Sheet:Column | Input from Datasheet | ||
Queue | setHost |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Host", input = InputType.YES, condition = InputType.NO)
public void setHost() {
try {
jmsHost.put(key, Data);
Report.updateTestLog(Action, "Queue Host has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Host: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setPort
Description: This function is used to set the port for establishing the queue connection.
Input Format : @Expected port name
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setPort |
@value | Hardcoded Input | ||
Queue | setPort |
Sheet:Column | Input from Datasheet | ||
Queue | setPort |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Port", input = InputType.YES, condition = InputType.NO)
public void setPort() {
try {
jmsPort.put(key, Integer.valueOf(Data));
Report.updateTestLog(Action, "Queue Port has been set successfully", Status.DONE);
} catch (NumberFormatException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Port: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setChannel
Description: This function is used to set the channel for establishing the queue connection.
Input Format : @Expected channel name
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setChannel |
@value | Hardcoded Input | ||
Queue | setChannel |
Sheet:Column | Input from Datasheet | ||
Queue | setChannel |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Channel", input = InputType.YES, condition = InputType.NO)
public void setChannel() {
try {
jmsChannel.put(key, Data);
Report.updateTestLog(Action, "Queue Channel has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Channel: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setQueueManager
Description: This function is used to set the Queue Manager for the connection.
Input Format : @Expected Queue manager name
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setQueueManager |
@value | Hardcoded Input | ||
Queue | setQueueManager |
Sheet:Column | Input from Datasheet | ||
Queue | setQueueManager |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Queue Manager", input = InputType.YES, condition = InputType.NO)
public void setQueueManager() {
try {
jmsQmgr.put(key, Data);
Report.updateTestLog(Action, "Queue manager has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Queue manager: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setUserName
Description: This function is used to set the username for the queue connection.
Input Format : @Expected Username
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setUserName |
@value | Hardcoded Input | ||
Queue | setUserName |
Sheet:Column | Input from Datasheet | ||
Queue | setUserName |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Username", input = InputType.YES, condition = InputType.NO)
public void setUserName() {
try {
jmsUsername.put(key, Data);
Report.updateTestLog(Action, "Username has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Username: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setPassword
Description: This function is used to set the password for the queue connection.
Input Format : @Expected Password value
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setPassword |
@value | Hardcoded Input | ||
Queue | setPassword |
Sheet:Column | Input from Datasheet | ||
Queue | setPassword |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Password", input = InputType.YES, condition = InputType.NO)
public void setPassword() {
try {
jmsPassword.put(key, Data);
Report.updateTestLog(Action, "Password has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Password: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setSSLCipherSuite
Description: This function is used to set the SSL Cipher Suite for the queue connection.
Input Format : @Expected SSL Cipher Suite
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setSSLCipherSuite |
@value | Hardcoded Input | ||
Queue | setSSLCipherSuite |
Sheet:Column | Input from Datasheet | ||
Queue | setSSLCipherSuite |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set SSL Cipher Suite", input = InputType.YES, condition = InputType.NO)
public void setSSLCipherSuite() {
try {
WMQ_SSL_CIPHER_SUITE.put(key, Data);
Report.updateTestLog(Action, "SSL Cipher Suite has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting SSL Cipher Suite: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setRequestQueue
Description: This function is used to set the Request Queue for the connection.
Input Format : @Expected Request Queue
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setRequestQueue |
@value | Hardcoded Input | ||
Queue | setRequestQueue |
Sheet:Column | Input from Datasheet | ||
Queue | setRequestQueue |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Request Queue", input = InputType.YES, condition = InputType.NO)
public void setRequestQueue() {
try {
if (Data.startsWith("queue:///"))
jmsReqQueueName.put(key, Data);
else {
Data = "queue:///" + Data;
jmsReqQueueName.put(key, Data);
}
Report.updateTestLog(Action, "Request Queue has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Request Queue: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setResponseQueue
Description: This function is used to set Response Queue for the connection.
Input Format : @Expected ResponseQueue
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setResponseQueue |
@value | Hardcoded Input | ||
Queue | setResponseQueue |
Sheet:Column | Input from Datasheet | ||
Queue | setResponseQueue |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Response Queue", input = InputType.YES, condition = InputType.NO)
public void setResponseQueue() {
try {
if (Data.startsWith("queue:///"))
jmsRespQueueName.put(key, Data);
else {
Data = "queue:///" + Data;
jmsRespQueueName.put(key, Data);
}
Report.updateTestLog(Action, "Response Queue has been set successfully", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during queue connection setup", ex);
Report.updateTestLog(Action, "Error in setting Response Queue: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setCorrelationID
Description: This function is used to set Correlation ID for the queue connection.
Input Format : @Expected CorrelationID
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setCorrelationID |
@value | Hardcoded Input | ||
Queue | setCorrelationID |
Sheet:Column | Input from Datasheet | ||
Queue | setCorrelationID |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Correlation ID", input = InputType.YES, condition = InputType.NO)
public void setCorrelationID() {
try {
jmsMessage.get(key).setJMSCorrelationID(Data);
Report.updateTestLog(Action, "Correlation ID set", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during setting of Correlation ID", ex);
Report.updateTestLog(Action, "Error in setting Correlation ID: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setMesssageID
Description: This function is used to set the message ID for the queue connection.
Input Format : @Expected MessageID
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setMesssageID |
@value | Hardcoded Input | ||
Queue | setMesssageID |
Sheet:Column | Input from Datasheet | ||
Queue | setMesssageID |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Set Message ID", input = InputType.YES, condition = InputType.NO)
public void setMesssageID() {
try {
jmsMessage.get(key).setJMSMessageID(Data);
Report.updateTestLog(Action, "Message ID set", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during setting of Message ID", ex);
Report.updateTestLog(Action, "Error in setting Message ID: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
setText
Description: This function is used to set the text.
Input Format : @Expected Payload
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | setText |
@Payload (from Editor) | Hardcoded Input | ||
Queue | setText |
Sheet:Column | Input from Datasheet | ||
Queue | setText |
%dynamicVar% | Input from variable |
Inputs in the Input column can be either hardcoded
, passed inside the Payload editor which is capable of parameterising the Payload (Press ctrl+space to see the list of variables available ), passed from the data sheet (datasheet name : column name
) or passed from a variable value (%variable name%
), as given in the above example.
@Action(object = ObjectType.QUEUE, desc = "Set Text", input = InputType.YES, condition = InputType.NO)
public void setText() {
try {
createConnectionFactory();
jmsDestination.put(key, jmsContext.get(key).createQueue(jmsReqQueueName.get(key)));
jmsMessage.get(key).setText(handlePayloadorEndpoint(Data));
Report.updateTestLog(Action, "Text set", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during setting of Text", ex);
Report.updateTestLog(Action, "Error in setting Text: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
sendMessage
Description: This function is used to send message.
ObjectName | Action | Input | Condition | Reference |
---|---|---|---|---|
Queue | sendMessage |
@Action(object = ObjectType.QUEUE, desc = "Send Message", input = InputType.NO, condition = InputType.NO)
public void sendMessage() {
try {
jmsProducer.put(key, jmsContext.get(key).createProducer());
before.put(key, Instant.now());
jmsProducer.get(key).send(jmsDestination.get(key), jmsMessage.get(key));
Report.updateTestLog(Action, "Message sent", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception while sending message", ex);
Report.updateTestLog(Action, "Error in sending message: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
receiveMessageWithFilter
Description: This function is used to receive message based on filter.
Input Format : @Expected filter
Condition Format: timeout
in ms
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | receiveMessageWithFilter |
@value | timeout in ms |
Hardcoded Input | |
Queue | receiveMessageWithFilter |
Sheet:Column | timeout in ms |
Input from Datasheet | |
Queue | receiveMessageWithFilter |
%dynamicVar% | timeout in ms |
Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Receive Message based on Filter", input = InputType.YES, condition = InputType.YES)
public void receiveMessageWithFilter() {
try {
long timeout = Long.valueOf(Condition);
jmsDestination.put(key, jmsContext.get(key).createQueue(jmsRespQueueName.get(key)));
jmsConsumer.put(key, jmsContext.get(key).createConsumer(jmsDestination.get(key), Data));
receivedMessage.put(key, jmsConsumer.get(key).receiveBody(String.class, timeout));
after.put(key, Instant.now());
duration.put(key, Duration.between(before.get(key), after.get(key)).toMillis());
if (receivedMessage.get(key) != null) {
Report.updateTestLog(Action, "Message received in : [" + duration.get(key) + "ms]. Message body is : \n" + receivedMessage, Status.DONE);
} else {
Report.updateTestLog(Action, "No Message received with filter " + Data, Status.DONE);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during receiving message", ex);
Report.updateTestLog(Action, "Error in receiving message: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
closeContext
Description: This function is used to close the queue connection.
ObjectName | Action | Input | Condition | Reference |
---|---|---|---|---|
Queue | closeContext |
@Action(object = ObjectType.QUEUE, desc = "Close the connection", input = InputType.NO, condition = InputType.NO)
public void closeContext() {
try {
jmsContext.get(key).close();
Report.updateTestLog(Action, "Context closed", Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Exception during context closure", ex);
Report.updateTestLog(Action, "Error while closing context: " + "\n" + ex.getMessage(), Status.DEBUG);
}
}
storeQueueXMLtagInDataSheet
Description: This function is used to store a certain XML tag value into a respective column of a given datasheet.
Input Format : @Expected datasheet name:column name
Condition Format: XPath
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | storeQueueXMLtagInDataSheet |
Sheet:Column | XPath | Datasheet to where value is supposed br stored |
Note: Ensure that your data sheet doesn't contain column names with spaces.
@Action(object = ObjectType.QUEUE, desc = "Store XML tag In DataSheet ", input = InputType.YES, condition = InputType.YES)
public void storeQueueXMLtagInDataSheet() {
try {
String strObj = Input;
if (strObj.matches(".*:.*")) {
try {
System.out.println("Updating value in SubIteration " + userData.getSubIteration());
String sheetName = strObj.split(":", 2)[0];
String columnName = strObj.split(":", 2)[1];
String xmlText = receivedMessage.get(key);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(xmlText));
dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputSource);
doc.getDocumentElement().normalize();
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = Condition;
String value = (String) xPath.compile(expression).evaluate(doc);
userData.putData(sheetName, columnName, value);
Report.updateTestLog(Action, "Element text [" + value + "] is stored in " + strObj, Status.DONE);
} catch (IOException | ParserConfigurationException | XPathExpressionException | DOMException
| SAXException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, ex.getMessage(), ex);
Report.updateTestLog(Action, "Error Storing XML element in datasheet :" + "\n" + ex.getMessage(),
Status.DEBUG);
}
} else {
Report.updateTestLog(Action,
"Given input [" + Input + "] format is invalid. It should be [sheetName:ColumnName]",
Status.DEBUG);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error Storing XML element in datasheet :" + "\n" + ex.getMessage(),
Status.DEBUG);
}
}
assertQueueXMLtagEquals
Description: This function is used to validate whether a certain XML tag equals an expected text or not.
Input Format : @Expected Text
Condition Format : XPath
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | assertQueueXMLtagEquals |
@value | XPath | Hardcoded Input | |
Queue | assertQueueXMLtagEquals |
Sheet:Column | XPath | Input from Datasheet | |
Queue | assertQueueXMLtagEquals |
%dynamicVar% | XPath | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Assert XML Tag Equals ", input = InputType.YES, condition = InputType.YES)
public void assertQueueXMLtagEquals() {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(receivedMessage.get(key)));
dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputSource);
doc.getDocumentElement().normalize();
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = Condition;
String value = (String) xPath.compile(expression).evaluate(doc);
if (value.equals(Data)) {
Report.updateTestLog(Action, "Element text [" + value + "] is as expected", Status.PASSNS);
} else {
Report.updateTestLog(Action, "Element text [" + value + "] is not as expected", Status.FAILNS);
}
} catch (IOException | ParserConfigurationException | XPathExpressionException | DOMException
| SAXException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error validating XML element :" + "\n" + ex.getMessage(), Status.DEBUG);
}
}
assertQueueXMLtagContains
Description: This function is used to validate whether a certain XML tag contains an expected text or not.
Input Format : @Expected Text
Condition Format : XPath
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | assertQueueXMLtagContains |
@value | XPath | Hardcoded Input | |
Queue | assertQueueXMLtagContains |
Sheet:Column | XPath | Input from Datasheet | |
Queue | assertQueueXMLtagContains |
%dynamicVar% | XPath | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Assert XML Tag Contains ", input = InputType.YES, condition = InputType.YES)
public void assertQueueXMLtagContains() {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(receivedMessage.get(key)));
dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputSource);
doc.getDocumentElement().normalize();
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = Condition;
String value = (String) xPath.compile(expression).evaluate(doc);
if (value.contains(Data)) {
Report.updateTestLog(Action, "Element text contains [" + Data + "] is as expected", Status.PASSNS);
} else {
Report.updateTestLog(Action, "Element text [" + value + "] does not contain [" + Data + "]",
Status.FAILNS);
}
} catch (IOException | ParserConfigurationException | XPathExpressionException | DOMException
| SAXException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error validating XML element :" + "\n" + ex.getMessage(), Status.DEBUG);
}
}
assertQueueResponseMessageContains
Description: This function is used to validate whether response message contains an expected text or not.
Input Format : @Expected Text
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | assertQueueResponseMessageContains |
@value | Hardcoded Input | ||
Queue | assertQueueResponseMessageContains |
Sheet:Column | Input from Datasheet | ||
Queue | assertQueueResponseMessageContains |
%dynamicVar% | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Assert Response Message contains ", input = InputType.YES)
public void assertQueueResponseMessageContains() {
try {
if (receivedMessage.get(key).contains(Data)) {
Report.updateTestLog(Action, "Response Message contains : " + Data, Status.PASSNS);
} else {
Report.updateTestLog(Action, "Response Message does not contain : " + Data, Status.FAILNS);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error in validating response body :" + "\n" + ex.getMessage(), Status.DEBUG);
}
}
assertQueueJSONtagEquals
Description: This function is used to validate whether a certain JSON tag equals an expected text or not.
Input Format : @Expected Text
Condition Format : JSON Path of the tag
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | assertQueueJSONtagEquals |
@value | JSONPath | Hardcoded Input | |
Queue | assertQueueJSONtagEquals |
Sheet:Column | JSONPath | Input from Datasheet | |
Queue | assertQueueJSONtagEquals |
%dynamicVar% | JSONPath | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Assert JSON Tag Equals ", input = InputType.YES, condition = InputType.YES)
public void assertQueueJSONtagEquals() {
try {
String response = receivedMessage.get(key);
String jsonpath = Condition;
String value = JsonPath.read(response, jsonpath).toString();
if (value.equals(Data)) {
Report.updateTestLog(Action, "Element text [" + value + "] is as expected", Status.PASSNS);
} else {
Report.updateTestLog(Action, "Element text is [" + value + "] but is expected to be [" + Data + "]",
Status.FAILNS);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error in validating JSON element :" + "\n" + ex.getMessage(), Status.DEBUG);
}
}
assertQueueJSONtagContains
Description: This function is used to validate whether a certain JSON tag contains an expected text or not.
Input Format : @Expected Text
Condition Format : JSON Path of the tag
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | assertQueueJSONtagContains |
@value | JSONPath | Hardcoded Input | |
Queue | assertQueueJSONtagContains |
Sheet:Column | JSONPath | Input from Datasheet | |
Queue | assertQueueJSONtagContains |
%dynamicVar% | JSONPath | Input from variable |
@Action(object = ObjectType.QUEUE, desc = "Assert JSON Tag Contains ", input = InputType.YES, condition = InputType.YES)
public void assertQueueJSONtagContains() {
try {
String response = receivedMessage.get(key);
String jsonpath = Condition;
String value = JsonPath.read(response, jsonpath).toString();
if (value.contains(Data)) {
Report.updateTestLog(Action, "Element text contains [" + Data + "] is as expected", Status.PASSNS);
} else {
Report.updateTestLog(Action, "Element text [" + value + "] does not contain [" + Data + "]",
Status.FAILNS);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error in validating JSON element :" + "\n" + ex.getMessage(), Status.DEBUG);
}
} }
}
storeQueueJSONtagInDataSheet
Description: This function is used to store a certain JSON tag value into a respective column of a given datasheet.
Input Format : @Expected datasheet name:column name
Condition Format: JSONPath of the tag
ObjectName | Action | Input | Condition | Reference | |
---|---|---|---|---|---|
Queue | storeQueueJSONtagInDataSheet |
Sheet:Column | JSONPath | Datasheet to where value is supposed br stored |
Note: Ensure that your data sheet doesn't contain column names with spaces.
@Action(object = ObjectType.QUEUE, desc = "Store JSON Tag In DataSheet ", input = InputType.YES, condition = InputType.YES)
public void storeQueueJSONtagInDataSheet() {
try {
String strObj = Input;
if (strObj.matches(".*:.*")) {
try {
System.out.println("Updating value in SubIteration " + userData.getSubIteration());
String sheetName = strObj.split(":", 2)[0];
String columnName = strObj.split(":", 2)[1];
String response = receivedMessage.get(key);
String jsonpath = Condition;
String value = JsonPath.read(response, jsonpath).toString();
userData.putData(sheetName, columnName, value);
Report.updateTestLog(Action, "Element text [" + value + "] is stored in " + strObj, Status.DONE);
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, ex.getMessage(), ex);
Report.updateTestLog(Action, "Error Storing JSON element in datasheet :" + "\n" + ex.getMessage(),
Status.DEBUG);
}
} else {
Report.updateTestLog(Action,
"Given input [" + Input + "] format is invalid. It should be [sheetName:ColumnName]",
Status.DEBUG);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error Storing JSON element in datasheet :" + "\n" + ex.getMessage(),
Status.DEBUG);
}
}