Untitled
unknown
plain_text
2 days ago
3.4 kB
4
Indexable
package stepdefs.ipvs; import io.cucumber.java.en.*; import sth.ipvs.IPVSBaseTest; import sth.ipvs.rest.IPVSResponse; import sth.json.JSON; public class ChannelsApiChecks extends IPVSBaseTest { private IPVSResponse response; @When("I request IPVS channels v4 data with valid headers") public void requestIPVSChannelsV4Data() { // Get the response from the API call TemplateResponse tempResponse = restIPVS().channelsV4() .header("x-accountId", "LNK.8347:8347100040106596") .header("x-mso", "TWC") .header("x-pi-forwarded-for", "1.2.3.4") .get(); // Create an IPVSResponse from the TemplateResponse response = new IPVSResponse(tempResponse.request(), tempResponse.response()); assertTrue(response.isSuccess(), restIPVS().getRequestUri() + " Call is failing with " + response.status()); } @Then("the response should contain expected channel data structure") public void verifyChannelsResponseStructure() { // Verify response has content assertFalse(response.responseString().isEmpty(), "Response does not contain content"); // Get the JSON object from response JSON json = response.json(); // Verify channels data contains expected fields assertTrue(json.hasField("name"), "Response missing 'name' field"); assertTrue(json.hasField("logoUrl"), "Response missing 'logoUrl' field"); assertTrue(json.hasField("services"), "Response missing 'services' field"); // Verify linear services structure if present JSON services = json.get("services"); if (services.hasField("linear")) { Object linearObj = services.get("linear"); // First verify it's a JSON object and cast properly if (linearObj instanceof JSON) { JSON linearJSON = (JSON) linearObj; if (linearJSON.isArray() && linearJSON.size() > 0) { JSON firstLinear = linearJSON.get(0); assertTrue(firstLinear.hasField("callSign"), "Linear service missing 'callSign' field"); assertTrue(firstLinear.hasField("serviceName"), "Linear service missing 'serviceName' field"); assertTrue(firstLinear.hasField("ncsServiceId"), "Linear service missing 'ncsServiceId' field"); } } } // Verify VOD services structure if present if (services.hasField("vod")) { Object vodObj = services.get("vod"); if (vodObj instanceof JSON) { JSON vodJSON = (JSON) vodObj; if (vodJSON.isArray() && vodJSON.size() > 0) { JSON firstVod = vodJSON.get(0); assertTrue(firstVod.hasField("serviceName"), "VOD service missing 'serviceName' field"); assertTrue(firstVod.hasField("entitled"), "VOD service missing 'entitled' field"); } } } // Print response for debugging (optional) System.out.println("Channels v4 response: " + response.responseString()); } @Override public void verifyTestData() {} } import sth.template.rest.TemplateResponse;
Editor is loading...
Leave a Comment