@Test(groups = {"webserviceSmoke"}) public void testRequisitionStatusUsingCommTrackUserForExportOrderFlagFalse() throws IOException, SQLException, ParserConfigurationException, SAXException { HttpClient client = new HttpClient(); client.createContext(); submitRnRThroughApi("V10", "HIV", "P10", 1, 10, 1, 0, 0, 2); Long id = (long) dbWrapper.getMaxRnrID(); ResponseEntity responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); assertEquals(StringUtils.countMatches(responseEntity.getResponse(), ":"), 41); List<String> feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkRequisitionStatusOnFeed("INITIATED", feedJSONList.get(0), id); checkRequisitionStatusOnFeed("SUBMITTED", feedJSONList.get(1), id); checkRequisitionStatusOnFeed("AUTHORIZED", feedJSONList.get(2), id); dbWrapper.setExportOrdersFlagInSupplyLinesTable(false, "F10"); approveRequisition(id, 65); dbWrapper.updateRestrictLogin("commTrack", false); convertToOrder("commTrack", "Admin123"); dbWrapper.updateRestrictLogin("commTrack", true); responseEntity = client.SendJSON("", URL + "1", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkRequisitionStatusOnFeed("APPROVED", feedJSONList.get(3), id); checkRequisitionStatusOnFeed("RELEASED", feedJSONList.get(4), id); responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkOrderStatusOnFeed("READY_TO_PACK", feedJSONList.get(0), id); dbWrapper.assignRight("store in-charge", "MANAGE_POD"); OrderPOD OrderPODFromJson = JsonUtility.readObjectFromFile(FULL_JSON_POD_TXT_FILE_NAME, OrderPOD.class); OrderPODFromJson.getPodLineItems().get(0).setQuantityReceived(65); OrderPODFromJson.getPodLineItems().get(0).setProductCode("P10"); client.SendJSON( getJsonStringFor(OrderPODFromJson), format(POD_URL, id), "POST", "commTrack", "Admin123"); responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkOrderStatusOnFeed("RECEIVED", feedJSONList.get(1), id); }
private ResponseEntity waitForOrderStatusUpdatedOrTimeOut(int index) throws ParserConfigurationException, SAXException, InterruptedException { HttpClient client = new HttpClient(); client.createContext(); ResponseEntity responseEntity; responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); List<String> feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); int time = 0; while (time <= 5000) { if (feedJSONList.size() == index + 1) { break; } responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); time += 500; Thread.sleep(500); } return responseEntity; }
@Test(groups = {"webservice"}) public void testRequisitionStatusUsingCommTrackUserForExportOrderFlagTrueAndFtpDetailsValid() throws IOException, SQLException, ParserConfigurationException, SAXException, InterruptedException { HttpClient client = new HttpClient(); client.createContext(); submitRnRThroughApi("V10", "HIV", "P10", 1, 10, 1, 0, 0, 2); Long id = (long) dbWrapper.getMaxRnrID(); ResponseEntity responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); List<String> feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkRequisitionStatusOnFeed("INITIATED", feedJSONList.get(0), id); checkRequisitionStatusOnFeed("SUBMITTED", feedJSONList.get(1), id); checkRequisitionStatusOnFeed("AUTHORIZED", feedJSONList.get(2), id); dbWrapper.setExportOrdersFlagInSupplyLinesTable(true, "F10"); dbWrapper.enterValidDetailsInFacilityFtpDetailsTable("F10"); approveRequisition(id, 65); dbWrapper.updateRestrictLogin("commTrack", false); convertToOrder("commTrack", "Admin123"); dbWrapper.updateRestrictLogin("commTrack", true); responseEntity = client.SendJSON("", URL + "1", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkRequisitionStatusOnFeed("APPROVED", feedJSONList.get(3), id); checkRequisitionStatusOnFeed("RELEASED", feedJSONList.get(4), id); responseEntity = client.SendJSON("", URL + "recent", "GET", "", ""); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkOrderStatusOnFeed("IN_ROUTE", feedJSONList.get(0), id); responseEntity = waitForOrderStatusUpdatedOrTimeOut(1); assertEquals(200, responseEntity.getStatus()); feedJSONList = XmlUtils.getNodeValues(responseEntity.getResponse(), "content"); checkOrderStatusOnFeed("RELEASED", feedJSONList.get(1), id); }