Search in sources :

Example 11 with When

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);
}
Also used : File(java.io.File) URL(java.net.URL) When(io.cucumber.java.en.When)

Example 12 with When

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);
}
Also used : Account(io.syndesis.qe.account.Account) When(io.cucumber.java.en.When)

Example 13 with When

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));
}
Also used : CreateCollectionOptions(com.mongodb.client.model.CreateCollectionOptions) Document(org.bson.Document) ValidationOptions(com.mongodb.client.model.ValidationOptions) When(io.cucumber.java.en.When)

Example 14 with When

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);
}
Also used : Incident(io.syndesis.qe.util.servicenow.model.Incident) When(io.cucumber.java.en.When)

Example 15 with When

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();
}
Also used : Incident(io.syndesis.qe.util.servicenow.model.Incident) When(io.cucumber.java.en.When)

Aggregations

When (io.cucumber.java.en.When)111 SelenideElement (com.codeborne.selenide.SelenideElement)23 Map (java.util.Map)10 File (java.io.File)8 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)7 ModalDialogPage (io.syndesis.qe.pages.ModalDialogPage)7 Attribute (com.vaticle.typedb.core.concept.thing.Attribute)6 Account (io.syndesis.qe.account.Account)6 Form (io.syndesis.qe.fragments.common.form.Form)6 Syndesis (io.syndesis.qe.resource.impl.Syndesis)6 TimeoutException (java.util.concurrent.TimeoutException)6 RoleType (com.vaticle.typedb.core.concept.type.RoleType)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Slf4j (lombok.extern.slf4j.Slf4j)5 ElementsCollection (com.codeborne.selenide.ElementsCollection)4 DataTable (io.cucumber.datatable.DataTable)4 IntegrationsEndpoint (io.syndesis.qe.endpoint.IntegrationsEndpoint)4 SyndesisRootPage (io.syndesis.qe.pages.SyndesisRootPage)4 List (java.util.List)4