public void testDeleteUserWithLoan() throws Exception { logger.info("Entered TC18 testDeleteUserWithLoan"); User user; String parameterUserName = "******" + System.currentTimeMillis(); String IsbnName = "testISBN" + System.currentTimeMillis(); user = new User("TestFirstName", "TestLastName", parameterUserName, "password", Role.STUDENT); String parameterBookName = "MyBook" + System.currentTimeMillis(); userService.saveOrUpdate(user); Book book = new Book(parameterBookName, IsbnName, 2); bookService.saveOrUpdate(book); session.refresh(book); logger.info("User added" + user.getUsername()); // now create loan for this user Calendar now = Calendar.getInstance(); now.add(Calendar.MINUTE, 5); logger.info("Book " + book.getBookid() + " user " + user.getUserId()); Loan loan = new Loan(user.getUserId(), book.getBookid(), now.getTime(), 0, 10, false); loandao.saveOrUpdate(loan); loanId = loan.getLoanId(); bookId = book.getBookid(); userId = user.getUserId(); logger.debug("Loan " + loan.getLoanId() + " created for user " + user.getUserId()); logger.info("Loan created: " + loan.getLoanId()); logger.info("trying to delete userID: " + user.getUserId()); WebConversation conversation = new WebConversation(); WebRequest requestDeleteUser = new GetMethodWebRequest(Constant.DELETE_USER_URL + user.getUserId()); WebResponse responseGetUser = conversation.getResponse(requestDeleteUser); WebTable bookListUpdatedTable = responseGetUser.getTableWithID("userListTable"); TableCell tableUpdatedCell = bookListUpdatedTable.getTableCellWithID(user.getUserId()); assertEquals(tableUpdatedCell.getText(), user.getUserId()); logger.info("Exited TC18 testDeleteUserWithLoan"); }
/** * testReassignLabProcedure * * @throws Exception */ public void testReassignLabProcedure() throws Exception { gen.clearAllTables(); gen.standardData(); WebConversation wc = login("9000000000", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - HCP Home", wr.getTitle()); // click Document Office Visit wr = wr.getLinkWith("Document Office Visit").click(); // select the patient WebForm form = wr.getForms()[0]; form.getScriptableObject().setParameterValue("UID_PATIENTID", "2"); form.getButtons()[1].click(); wr = wc.getCurrentPage(); assertEquals(ADDRESS + "auth/hcp-uap/documentOfficeVisit.jsp", wr.getURL().toString()); // Select the office visit from specific date wr.getLinkWith("6/10/2007").click(); wr = wc.getCurrentPage(); assertEquals("iTrust - Document Office Visit", wr.getTitle()); // Click the Reassign link. WebTable tbl = wr.getTableWithID("labProceduresTable"); assertEquals("Nice Guy", tbl.getCellAsText(2, 1)); assertTrue(tbl.getCellAsText(2, 10).contains("Reassign")); wr = tbl.getTableCell(2, 10).getLinkWith("Reassign").click(); wr = wc.getCurrentPage(); assertEquals("iTrust - Reassign Lab Procedure", wr.getTitle()); // Change the currently-assigned lab tech form = wr.getFormWithID("reassignLabProcedureForm"); form.setParameter("newLabTech", "5000000001"); form.setParameter("labProcPriority", "1"); form.getButtonWithID("setLabTech").click(); assertLogged(TransactionType.LAB_RESULTS_REASSIGN, 9000000000L, 2L, ""); wr = wc.getCurrentPage(); assertEquals("iTrust - Document Office Visit", wr.getTitle()); // Ensure the lab tech has been changed tbl = wr.getTableWithID("labProceduresTable"); assertEquals("Lab Dude", tbl.getCellAsText(2, 1)); }
/** * testLabProcedureInTransitToReceived * * @throws Exception */ public void testLabProcedureInTransitToReceived() throws Exception { gen.clearAllTables(); gen.standardData(); WebConversation wc = login("5000000001", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - Lab Tech Home", wr.getTitle()); wr = wr.getLinkWith("All Lab Procedures").click(); assertEquals("iTrust - View Laboratory Procedures", wr.getTitle()); // Ensure the table of received lab procedures has only one entry WebTable tbl = wr.getTableWithID("receivedTable"); assertEquals(3, tbl.getRowCount()); assertEquals("Beaker Beaker", tbl.getCellAsText(2, 4)); // Check table of in-transit lab procedures tbl = wr.getTableWithID("inTransitTable"); assertEquals(20, tbl.getRowCount()); String labProcID = tbl.getCellAsText(2, 0); // lab proc id is auto-assigned // Click "Set to Received" on Lab Procedure WebForm form = wr.getFormWithID("inTransitForm"); Button receivedButton = form.getButtons()[0]; assertEquals("Set to Received", receivedButton.getText()); receivedButton.click(); wr = wc.getCurrentPage(); assertEquals("iTrust - View Laboratory Procedures", wr.getTitle()); // Ensure the table of received lab procedures contains the modified lab procedure. tbl = wr.getTableWithID("receivedTable"); assertEquals(4, tbl.getRowCount()); // assertFalse(tbl.getCellAsText(2, 0).contains("There are no received lab procedures")); assertEquals(labProcID, tbl.getCellAsText(2, 0)); // check that the lab proc is now here // Check that table of in-transit lab procedures has no lab procedures tbl = wr.getTableWithID("inTransitTable"); assertEquals(19, tbl.getRowCount()); // assertTrue(tbl.getCellAsText(2, 0).contains("There are no lab procedures in transit")); // // lab procedure ID }
public void testAddLabProcedureWithLabTech() throws Exception { gen.clearAllTables(); gen.standardData(); WebConversation wc = login("9000000000", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - HCP Home", wr.getTitle()); // click Document Office Visit wr = wr.getLinkWith("Document Office Visit").click(); // select the patient WebForm form = wr.getForms()[0]; form.getScriptableObject().setParameterValue("UID_PATIENTID", "2"); form.getButtons()[1].click(); wr = wc.getCurrentPage(); assertEquals(ADDRESS + "auth/hcp-uap/documentOfficeVisit.jsp", wr.getURL().toString()); // Select the office visit from specific date wr.getLinkWith("6/10/2007").click(); wr = wc.getCurrentPage(); assertEquals("iTrust - Document Office Visit", wr.getTitle()); form = wr.getFormWithID("labProcedureForm"); form.setParameter("loinc", "10666-6"); form.setParameter("labTech", "5000000001"); form.setParameter("labProcPriority", "1"); form.getButtonWithID("add_labProcedure").click(); // check updated page wr = wc.getCurrentPage(); assertTrue(wr.getText().contains("Lab Procedure information successfully updated.")); assertLogged(TransactionType.LAB_PROCEDURE_ADD, 9000000000L, 2L, ""); // Get row containing procedure. WebTable tbl = wr.getTableWithID("labProceduresTable"); TableRow[] rows = tbl.getRows(); int rowi = 0; for (; rowi < rows.length; rowi++) { if (rows[rowi].getText().startsWith("| 10666-6")) { break; } } assertTrue(rowi < rows.length); // Verify data in table assertEquals("Lab Dude", tbl.getCellAsText(rowi, 1)); assertEquals("In Transit", tbl.getCellAsText(rowi, 2)); // status assertEquals("", tbl.getCellAsText(rowi, 5)); // commentary assertEquals("", tbl.getCellAsText(rowi, 6)); // numerical results assertEquals("", tbl.getCellAsText(rowi, 7)); // lower bound assertEquals("", tbl.getCellAsText(rowi, 8)); // upper bound assertTrue(tbl.getCellAsText(rowi, 10).contains("Remove")); // action assertTrue(tbl.getCellAsText(rowi, 10).contains("Reassign")); // action }
/** * testPatientViewLabProcedureResults * * @throws Exception */ public void testPatientViewLabProcedureResults() throws Exception { gen.clearAllTables(); gen.standardData(); WebConversation wc = login("22", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - Patient Home", wr.getTitle()); wr = wr.getLinkWith("My Lab Procedures").click(); assertEquals("iTrust - View Lab Procedures", wr.getTitle()); WebTable tbl = wr.getTableWithID("labProceduresTable"); assertEquals(51, tbl.getRowCount()); int numericalColumn = 5; assertEquals("", tbl.getCellAsText(13, numericalColumn)); assertEquals("", tbl.getCellAsText(12, numericalColumn)); assertEquals("", tbl.getCellAsText(11, numericalColumn)); assertEquals("7", tbl.getCellAsText(10, numericalColumn)); assertEquals("", tbl.getCellAsText(9, numericalColumn)); assertEquals("", tbl.getCellAsText(8, numericalColumn)); assertEquals("", tbl.getCellAsText(7, numericalColumn)); assertEquals("5.23", tbl.getCellAsText(6, numericalColumn)); assertEquals("", tbl.getCellAsText(5, numericalColumn)); assertEquals("", tbl.getCellAsText(4, numericalColumn)); assertEquals("", tbl.getCellAsText(3, numericalColumn)); assertEquals("18", tbl.getCellAsText(2, numericalColumn)); int statusColumn = 3; assertEquals("In Transit", tbl.getCellAsText(13, statusColumn)); assertEquals("Received", tbl.getCellAsText(12, statusColumn)); assertEquals("Pending", tbl.getCellAsText(11, statusColumn)); assertEquals("Completed", tbl.getCellAsText(10, statusColumn)); assertEquals("In Transit", tbl.getCellAsText(9, statusColumn)); assertEquals("Received", tbl.getCellAsText(8, statusColumn)); assertEquals("Pending", tbl.getCellAsText(7, statusColumn)); assertEquals("Completed", tbl.getCellAsText(6, statusColumn)); assertEquals("In Transit", tbl.getCellAsText(5, statusColumn)); assertEquals("Received", tbl.getCellAsText(4, statusColumn)); assertEquals("Pending", tbl.getCellAsText(3, statusColumn)); assertEquals("Completed", tbl.getCellAsText(2, statusColumn)); }
/** * testPatient_LabProcedureViewChart * * @throws Exception */ public void testPatient_LabProcedureViewChart() throws Exception { gen.clearAllTables(); gen.standardData(); gen.patientLabProcedures(); WebConversation wc = login("21", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - Patient Home", wr.getTitle()); wr = wr.getLinkWith("My Lab Procedures").click(); assertEquals("iTrust - View Lab Procedures", wr.getTitle()); WebTable tbl = wr.getTableWithID("labProceduresTable"); assertEquals(5, tbl.getRowCount()); wr = wr.getLinkWithID("viewResultsChart").click(); assertEquals("Lab Procedure Results Chart", wr.getTitle()); // assertTrue(wr.getText().contains("src=\"/iTrust/charts/")); }
/** * testPatient_LabProcedureView2 * * @throws Exception */ public void testPatient_LabProcedureView2() throws Exception { gen.clearAllTables(); gen.standardData(); gen.patientLabProcedures(); WebConversation wc = login("1", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - Patient Home", wr.getTitle()); wr = wr.getLinkWith("My Lab Procedures").click(); assertEquals("iTrust - View Lab Procedures", wr.getTitle()); WebTable tbl = wr.getTableWithID("labProceduresTable"); assertEquals(5, tbl.getRowCount()); assertEquals("Kelly Doctor", tbl.getCellAsText(2, 0)); assertEquals("10/20/2011", tbl.getCellAsText(2, 1)); assertEquals("Specimen volume", tbl.getCellAsText(2, 2)); assertEquals("Completed", tbl.getCellAsText(2, 3)); assertEquals("", tbl.getCellAsText(2, 4)); assertEquals("79", tbl.getCellAsText(2, 5)); assertEquals("ml", tbl.getCellAsText(2, 6)); assertEquals("Abnormal", tbl.getCellAsText(2, 7)); }
/** * testPatient_LabProcedureView * * @throws Exception */ public void testPatient_LabProcedureView() throws Exception { gen.clearAllTables(); gen.standardData(); gen.patientLabProcedures(); WebConversation wc = login("2", "pw"); WebResponse wr = wc.getCurrentPage(); assertEquals("iTrust - Patient Home", wr.getTitle()); wr = wr.getLinkWith("My Lab Procedures").click(); assertEquals("iTrust - View Lab Procedures", wr.getTitle()); WebTable tbl = wr.getTableWithID("labProceduresTable"); assertEquals(4, tbl.getRowCount()); assertEquals("Kelly Doctor", tbl.getCellAsText(2, 0)); assertEquals("11/20/2011", tbl.getCellAsText(2, 1)); assertEquals("Microscopic Observation", tbl.getCellAsText(2, 2)); assertEquals("Completed", tbl.getCellAsText(2, 3)); assertEquals("Its all done", tbl.getCellAsText(2, 4)); assertEquals("85", tbl.getCellAsText(2, 5)); assertEquals("grams", tbl.getCellAsText(2, 6)); assertEquals("Normal", tbl.getCellAsText(2, 7)); }
public void testSimpleUser() throws Exception { WebConversation connection = new WebConversation(); WebResponse loginPage = connection.getResponse(buildUrl("silverpeas/")); assertNotNull(loginPage); WebForm loginForm = loginPage.getFormWithName("EDform"); assertNotNull(loginForm); loginForm.setParameter("Login", "SilverAdmin"); loginForm.setParameter("Password", "SilverAdmin"); HttpUnitOptions.setScriptingEnabled(false); WebResponse welcomePage = loginForm.submit(); assertNotNull(welcomePage); String[] frameNames = welcomePage.getFrameNames(); assertEquals(5, frameNames.length); WebResponse navigationFrame = connection.getFrameContents("bottomFrame"); assertNotNull(navigationFrame); navigationFrame = connection.getFrameContents("SpacesBar"); assertNotNull(navigationFrame); WebLink mailingListLink = navigationFrame.getLinkWith("Liste de diffusion"); assertNotNull(mailingListLink); HttpUnitOptions.setScriptingEnabled(false); WebResponse activityPage = connection.getResponse(buildUrl(mailingListLink.getURLString())); assertNotNull(activityPage); WebTable browseBar = activityPage.getTableWithID("browseBar"); assertNotNull(browseBar); assertEquals("MGI Coutier > Liste de diffusion > Activité", browseBar.getCellAsText(0, 0)); assertEquals( "Main", browseBar.getTableCell(0, 0).getLinkWith("Liste de diffusion").getURLString()); WebTable tableDescription = activityPage.getTableWithID("description"); assertNotNull(tableDescription); String description = tableDescription.getCellAsText(1, 0); assertEquals("Liste de diffusion de test", description); WebTable tableAddress = activityPage.getTableWithID("subscribedAddress"); assertNotNull(tableAddress); String subscribedAddress = tableAddress.getCellAsText(1, 0); assertEquals("*****@*****.**", subscribedAddress); WebTable tableHistory = activityPage.getTableWithID("activities"); assertNotNull(tableHistory); assertEquals("Historique des Messages", tableHistory.getCellAsText(0, 0)); assertEquals("2007", tableHistory.getCellAsText(2, 0)); assertEquals("", tableHistory.getCellAsText(2, 1)); assertEquals("", tableHistory.getCellAsText(2, 2)); assertEquals("", tableHistory.getCellAsText(2, 3)); assertEquals("", tableHistory.getCellAsText(2, 4)); assertEquals("", tableHistory.getCellAsText(2, 5)); assertEquals("", tableHistory.getCellAsText(2, 6)); assertEquals("", tableHistory.getCellAsText(2, 7)); assertEquals("", tableHistory.getCellAsText(2, 8)); assertEquals("", tableHistory.getCellAsText(2, 9)); assertEquals("", tableHistory.getCellAsText(2, 10)); assertEquals("2", tableHistory.getCellAsText(2, 11)); assertEquals("2", tableHistory.getCellAsText(2, 12)); assertEquals("1", tableHistory.getCellAsText(3, 1)); assertEquals("3", tableHistory.getCellAsText(3, 2)); assertEquals("3", tableHistory.getCellAsText(3, 3)); assertEquals("", tableHistory.getCellAsText(3, 4)); assertEquals("", tableHistory.getCellAsText(3, 5)); assertEquals("", tableHistory.getCellAsText(3, 6)); assertEquals("", tableHistory.getCellAsText(3, 7)); assertEquals("", tableHistory.getCellAsText(3, 8)); assertEquals("", tableHistory.getCellAsText(3, 9)); assertEquals("", tableHistory.getCellAsText(3, 10)); assertEquals("", tableHistory.getCellAsText(3, 11)); assertEquals("", tableHistory.getCellAsText(3, 12)); assertEquals( "list/mailinglist45/currentYear/2007/currentMonth/11", tableHistory.getTableCell(2, 12).getLinkWith("2").getURLString()); assertEquals( "list/mailinglist45/currentYear/2008/currentMonth/2", tableHistory.getTableCell(3, 3).getLinkWith("3").getURLString()); WebTable tableMessages = activityPage.getTableWithID("messages"); assertNotNull(tableMessages); assertEquals("Message récents", tableMessages.getCellAsText(0, 0)); assertEquals("Simple database message 3", tableMessages.getCellAsText(1, 0)); assertEquals( MESSAGE_BASE + 3, tableMessages.getTableCell(1, 0).getLinkWith("Simple database message 3").getURLString()); assertEquals( "[email protected] - 02/03/2008 10:34:15", tableMessages.getCellAsText(2, 0)); assertEquals( "Bonjour famille Simpson, j\'espère que vous allez bien. Ici " + "tout se passe bien et Krusty est très sympathique. Surtout depuis que " + "Tahiti Bob est retourné en prison. Je dois remplacer l\'homme canon " + "dans ...", tableMessages.getCellAsText(3, 0)); assertEquals(MESSAGE_BASE + 3, tableMessages.getTableCell(3, 0).getLinks()[0].getURLString()); assertEquals("Simple database message 4", tableMessages.getCellAsText(4, 0)); assertEquals( MESSAGE_BASE + 4, tableMessages.getTableCell(4, 0).getLinkWith("Simple database message 4").getURLString()); assertEquals( "[email protected] - 02/03/2008 10:12:15", tableMessages.getCellAsText(5, 0)); assertEquals( "Bonjour famille Simpson, j\'espère que vous allez bien. Ici " + "tout se passe bien et Krusty est très sympathique. Surtout depuis que " + "Tahiti Bob est retourné en prison. Je dois remplacer l\'homme canon " + "dans ...", tableMessages.getCellAsText(6, 0)); assertEquals(MESSAGE_BASE + 4, tableMessages.getTableCell(6, 0).getLinks()[0].getURLString()); assertEquals("Simple database message 1", tableMessages.getCellAsText(7, 0)); assertEquals( MESSAGE_BASE + 1, tableMessages.getTableCell(7, 0).getLinkWith("Simple database message 1").getURLString()); assertEquals( "[email protected] - 01/03/2008 10:34:15", tableMessages.getCellAsText(8, 0)); assertEquals( "Bonjour famille Simpson, j\'espère que vous allez bien. Ici " + "tout se passe bien et Krusty est très sympathique. Surtout depuis que " + "Tahiti Bob est retourné en prison. Je dois remplacer l\'homme canon " + "dans ...", tableMessages.getCellAsText(9, 0)); assertEquals(MESSAGE_BASE + 1, tableMessages.getTableCell(9, 0).getLinks()[0].getURLString()); assertEquals("Simple database message 11", tableMessages.getCellAsText(10, 0)); assertEquals( MESSAGE_BASE + 11, tableMessages.getTableCell(10, 0).getLinkWith("Simple database message 11").getURLString()); assertEquals( "[email protected] - 21/02/2008 10:34:15", tableMessages.getCellAsText(11, 0)); assertEquals( "Bonjour famille Simpson, j\'espère que vous allez bien. Ici " + "tout se passe bien et Krusty est très sympathique. Surtout depuis que " + "Tahiti Bob est retourné en prison. Je dois remplacer l\'homme canon " + "dans ...", tableMessages.getCellAsText(12, 0)); assertEquals(MESSAGE_BASE + 11, tableMessages.getTableCell(12, 0).getLinks()[0].getURLString()); WebTable tableTabbedPane = activityPage.getTableWithID("tabbedPane"); assertNotNull(tableTabbedPane); tableTabbedPane = tableTabbedPane.getTableCell(0, 0).getTables()[0]; assertNotNull(tableTabbedPane); assertEquals("Activité", tableTabbedPane.getCellAsText(0, 2)); assertEquals("Liste des Messages", tableTabbedPane.getCellAsText(0, 5)); assertFalse(activityPage.getText().indexOf("Modération") > 0); assertFalse(activityPage.getText().indexOf("Abonnés Extérieurs") > 0); }