Search in sources :

Example 1 with Incident

use of io.syndesis.qe.util.servicenow.model.Incident 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 2 with Incident

use of io.syndesis.qe.util.servicenow.model.Incident 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)

Example 3 with Incident

use of io.syndesis.qe.util.servicenow.model.Incident in project syndesis-qe by syndesisio.

the class ServiceNow method parseResponse.

/**
 * Service-Now API returns single object when there is 1 record, but list of records when there are more records.
 *
 * @param response json response
 * @return list of records
 */
private static List<Incident> parseResponse(String response) {
    List<Incident> incidents = new ArrayList<>();
    try {
        IncidentRecordList irl = om.readValue(response, IncidentRecordList.class);
        incidents.addAll(irl.getRecords());
        return incidents;
    } catch (IOException e) {
        // Try to parse it as single record response
        try {
            incidents.add(om.readValue(response, IncidentSingleResponse.class).getRecord());
            return incidents;
        } catch (IOException e1) {
            fail("Unable to unmarshall incident response", e);
        }
    }
    return null;
}
Also used : IncidentSingleResponse(io.syndesis.qe.util.servicenow.model.IncidentSingleResponse) IncidentRecordList(io.syndesis.qe.util.servicenow.model.IncidentRecordList) ArrayList(java.util.ArrayList) Incident(io.syndesis.qe.util.servicenow.model.Incident) IOException(java.io.IOException)

Example 4 with Incident

use of io.syndesis.qe.util.servicenow.model.Incident in project syndesis-qe by syndesisio.

the class ServiceNowValidationSteps method verifyIncidentsWithNumber.

@Then("verify that incident with {string} number has {string} description")
public void verifyIncidentsWithNumber(String numbers, String description) {
    List<Incident> list = ServiceNow.getFilteredIncidents("number=" + snUtils.modifySNNumber(numbers), 1);
    Assertions.assertThat(list).isNotEmpty();
    Incident created = list.get(0);
    Assertions.assertThat(created.getDescription()).contains(description);
}
Also used : Incident(io.syndesis.qe.util.servicenow.model.Incident) Then(io.cucumber.java.en.Then)

Aggregations

Incident (io.syndesis.qe.util.servicenow.model.Incident)4 When (io.cucumber.java.en.When)2 Then (io.cucumber.java.en.Then)1 IncidentRecordList (io.syndesis.qe.util.servicenow.model.IncidentRecordList)1 IncidentSingleResponse (io.syndesis.qe.util.servicenow.model.IncidentSingleResponse)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1