use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.
the class JmsValidationSteps method publishMessageFromResourceToDestinationWithName.
/**
* Load JMS message from resource and send it to the topic/queue with name
*
* @param resourceName - name of resource file with the message
* @param type - queue or topic
* @param name - name of topic/queue
*/
@When("publish JMS message from resource {string} to {string} with name {string}")
public void publishMessageFromResourceToDestinationWithName(String resourceName, String type, String name) throws IOException {
ClassLoader classLoader = this.getClass().getClassLoader();
URL fileUrl = classLoader.getResource("jms_messages/" + resourceName);
if (fileUrl == null) {
fail("File with name " + resourceName + " doesn't exist in the resources");
}
File file = new File(fileUrl.getFile());
String jmsMessage = new String(Files.readAllBytes(file.toPath()));
JMSUtils.sendMessage("tcp", JMSUtils.Destination.valueOf(type.toUpperCase()), name, jmsMessage);
}
use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.
the class JmsValidationSteps method sendMessageToQueueOnBroker.
@When("send {string} message to {string} queue on {string} broker")
public void sendMessageToQueueOnBroker(String message, String queue, String brokerAccount) {
Account brokerCredentials = AccountsDirectory.getInstance().get(brokerAccount);
final String userName = brokerCredentials.getProperty("username");
final String password = brokerCredentials.getProperty("password");
final String brokerpod = brokerCredentials.getProperty("appname");
JMSUtils.sendMessage(brokerpod, "tcp", userName, password, JMSUtils.Destination.QUEUE, queue, message);
}
use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.
the class MongoDBValidationSteps method createCollection.
@When("create mongodb collection {string}")
public void createCollection(String collectionName) {
database.getCollection(collectionName).drop();
// json schema is needed when we want to use output from the mongo middle-steps in the data mapper
Document jsonSchema = Document.parse("{ \n" + " bsonType: \"object\", \n" + " required: [ \"value\"], \n" + " properties: { \n" + " value: { \n" + " bsonType: \"string\", \n" + " description: \"required and must be a string\" } \n" + " }}");
ValidationOptions collOptions = new ValidationOptions().validator(Filters.eq("$jsonSchema", jsonSchema));
database.createCollection(collectionName, new CreateCollectionOptions().validationOptions(collOptions));
}
use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.
the class ServiceNowValidationSteps method sendIncidentToQueueAndVerifyItWasCreatedInSN.
@When("send {string} incident to {string} queue and verify it was created in SN")
public void sendIncidentToQueueAndVerifyItWasCreatedInSN(String incidentNumber, String queue) {
incidentNumber = snUtils.modifySNNumber(incidentNumber);
final String description = "CRTDINC01" + UUID.randomUUID().toString().substring(0, 8);
Incident i = Incident.getSampleIncident();
i.setNumber(incidentNumber);
i.setDescription(description);
JMSUtils.sendMessage(JMSUtils.Destination.valueOf("QUEUE"), queue, ServiceNow.getIncidentJson(i));
// wait till message gets through integration
TestUtils.sleepForJenkinsDelayIfHigher(5);
List<Incident> list = ServiceNow.getFilteredIncidents("number=" + incidentNumber, 1);
Assertions.assertThat(list).isNotEmpty();
Incident created = list.get(0);
ServiceNow.deleteIncident(created.getSysId());
Assertions.assertThat(created.getNumber()).isEqualToIgnoringCase(i.getNumber());
Assertions.assertThat(created.getDescription()).contains(description);
}
use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.
the class ServiceNowValidationSteps method createIncidentWithNumber.
@When("create incident with {string} number")
public void createIncidentWithNumber(String number) {
Incident i = Incident.getSampleIncident();
i.setNumber(snUtils.modifySNNumber(number));
i.setDescription("Automated create incident test-updated");
i.setSeverity(BigInteger.valueOf(2));
incidentId = ServiceNow.createIncident(i).getSysId();
}
Aggregations