package com.qa.stepdefinition; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.notNullValue; import java.io.File; import org.junit.Assert; import com.qa.utilities.Util; import com.qa.utilities.ParseXML; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import io.restassured.RestAssured; import io.restassured.response.Response; import io.restassured.response.ValidatableResponse; public class ParseXMLSteps{ private Response response; private ValidatableResponse xml; private Util util =new Util(); private ParseXML parsexml = new ParseXML(); String NodeNames[]=null; @When("^employee XML Updated data is uploaded through webservice$") public void employee_XML_Updated_data_is_uploaded_through_webservice() throws Throwable { StringBuffer NodeNames = new StringBuffer(); //Reads the XML file File reqPayload = new File(util.getValue("employee_XML_correct_req_payload_loc")); //Parses the XML file and gets all the Nodes names NodeNames = parsexml.ReadXMLFileFromLocal(reqPayload); //Updates the node "name" in the XML file, along with random generated value so that name is unique //Updates the XL document with the new value and saves in the XML file parsexml.UpdateNodeNameValue("name","DEF " + (int) Math.ceil(Math.random() * 1000)); parsexml.UpdateNodeNameValue("lat","657"); //Passes the updated XML file as payload to the API response = util.post_XMLData_employee(reqPayload); } @Then("^verify the success status code (\\d+) is generated$") public void verify_the_success_status_code_is_generated(int arg1) { xml = response.then().statusCode(arg1); int statusCode = response.getStatusCode(); Assert.assertEquals(statusCode, 200); } @Then("^verify success message is generated$") public void verify_success_message_is_generated() { String successCode = response.getBody().asString(); System.out.println(" The Sucess Code is :--" + successCode ); Assert.assertEquals( true, successCode.contains("OK")); } }