clickButton("form:cancel");  SiteTestHelper.assertNoException(tester); for (int i = 0; i < gatewayCount; i++) { SiteTestHelper.selectRow(tester, i, true); } clickButton("select:gateway:save"); assertEquals(gatewayCount + 1, SiteTestHelper.getRowCount(tester, "list:gateway"));
assertEquals(2, SiteTestHelper.getRowCount(tester, "list:gateway")); gatewayTable = getTester().getDialog().getWebTableBySummaryOrId("list:gateway"); assertEquals(gateways[0][0], gatewayTable.getCellAsText(1, 1));
    private void checkGateways() throws Exception {        assertLinkPresent("gateway:add");        assertLinkPresent("gateway:select");        assertButtonPresent("gateway:remove");        assertButtonPresent("gateway:moveUp");        assertButtonPresent("gateway:moveDown");        assertTablePresent("list:gateway");        // add gateways        final int gatewayCount = 4;        String[][] gateways = new String[gatewayCount][];        for (int i = 0; i < gatewayCount; i++) {            clickLink("gateway:add");            SiteTestHelper.assertNoException(tester);            SiteTestHelper.assertNoUserError(tester);            // Give the new gateway a name that is extremely unlikely to collide            // with any existing gateway names            String gatewayName = "gateway" + i + Long.toString(System.currentTimeMillis());            gateways[i] = GatewaysTestUi.addGateway(tester, gatewayName);            SiteTestHelper.assertNoException(tester);        }        assertEquals(gatewayCount + 1, SiteTestHelper.getRowCount(tester, "list:gateway"));        assertTableRowsEqual("list:gateway", 1, gateways);        // test moving up/down        SiteTestHelper.selectRow(tester, 0, true);        clickButton("gateway:moveUp");        // no changes expected - cannot move up        SiteTestHelper.assertNoException(getTester());        assertTableRowsEqual("list:gateway", 1, gateways);        // move down one row - no other changes expected        clickButton("gateway:moveDown");        WebTable gatewayTable = getTester().getDialog().getWebTableBySummaryOrId("list:gateway");        assertEquals(gateways[0][0], gatewayTable.getCellAsText(2, 1));        assertEquals(gateways[1][0], gatewayTable.getCellAsText(1, 1));        assertEquals(gateways[2][0], gatewayTable.getCellAsText(3, 1));        // click the gateway link - and then click cancel        clickLinkWithText(gateways[0][0]);        SiteTestHelper.assertNoException(tester);        clickButton("form:cancel");        SiteTestHelper.assertNoException(tester);        // test removal        for (int i = 0; i < gatewayCount; i++) {            SiteTestHelper.selectRow(tester, i, true);        }        clickButton("gateway:remove");        // only header in the table        assertEquals(1, SiteTestHelper.getRowCount(tester, "list:gateway"));        // test adding existing gateways        clickLink("gateway:select");        // one more time check if gateway edit is working        clickLinkWithText(gateways[0][0]);        SiteTestHelper.assertNoException(tester);        clickButton("form:cancel");        SiteTestHelper.assertNoException(tester);        for (int i = 0; i < gatewayCount; i++) {            SiteTestHelper.selectRow(tester, i, true);        }        clickButton("select:gateway:save");        assertEquals(gatewayCount + 1, SiteTestHelper.getRowCount(tester, "list:gateway"));    }