Search in sources :

Example 1 with AbstractListPage

use of uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.AbstractListPage in project miso-lims by miso-lims.

the class DeleteIT method doTestDelete.

private void doTestDelete(String listTarget, String tab, String search, String selectByColumn, String columnValue, Class<?> clazz, Long id) {
    assertNotNull("Couldn't find item in the database", getSession().get(clazz, id));
    AbstractListPage page = null;
    if (tab == null) {
        page = ListPage.getListPage(getDriver(), getBaseUrl(), listTarget);
    } else {
        ListTabbedPage tabbedPage = ListTabbedPage.getTabbedListPage(getDriver(), getBaseUrl(), listTarget);
        tabbedPage.clickTab(tab);
        page = tabbedPage;
    }
    DataTable table = page.getTable();
    if (search != null) {
        if (table.hasAdvancedSearch() && search.equals(columnValue)) {
            table.searchFor("\"" + search + "\"");
        } else {
            table.searchFor(search);
        }
    }
    List<String> values = table.getColumnValues(selectByColumn);
    assertFalse("No values found in column", values.isEmpty());
    boolean found = false;
    for (int i = 0; i < values.size(); i++) {
        if (values.get(i).equals(columnValue)) {
            table.checkBoxForRow(i);
            found = true;
            break;
        }
    }
    assertTrue("Couldn't find item in the list table", found);
    AbstractListPage page2 = page.deleteSelected();
    assertNotNull("Error deleting item", page2);
    DataTable table2 = page2.getTable();
    if (search != null) {
        table2.searchFor(search);
    }
    assertFalse("Found item in list table after delete attempt", table2.getColumnValues(selectByColumn).contains(search));
    assertNull("Found item in database after delete attempt", getSession().get(clazz, id));
}
Also used : DataTable(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.element.DataTable) ListTabbedPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.ListTabbedPage) AbstractListPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.AbstractListPage)

Aggregations

AbstractListPage (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.AbstractListPage)1 ListTabbedPage (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.ListTabbedPage)1 DataTable (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.element.DataTable)1