@Test public void testDeleteNotExistingImport_shouldWork() throws Exception { FormTester formTester = tester.newFormTester("editForm"); formTester.setValue("importName", "test"); formTester.submit("deleteButton"); LinkTree tree = (LinkTree) tester.getComponentFromLastRenderedPage("tree"); assertEquals( imports.size(), tree.getModelObject().getChildCount(tree.getModelObject().getRoot())); }
@Test public void testAddNewImport_shouldAddImport() throws Exception { FormTester formTester = tester.newFormTester("editForm"); formTester.setValue("importName", "aaaa.bbbb.fff"); formTester.submit("submitButton"); LinkTree tree = (LinkTree) tester.getComponentFromLastRenderedPage("tree"); assertEquals( imports.size(), tree.getModelObject().getChildCount(tree.getModelObject().getRoot())); }
@Test public void testRenderOrganizeImportsPage_shouldShowPage() throws Exception { tester.assertRenderedPage(OrganizeImportsPage.class); tester.assertComponent("tree", LinkTree.class); tester.assertComponent("editForm", Form.class); tester.assertComponent("editForm:importName", TextField.class); tester.assertComponent("editForm:submitButton", AjaxButton.class); tester.assertComponent("editForm:deleteButton", AjaxButton.class); LinkTree tree = (LinkTree) tester.getComponentFromLastRenderedPage("tree"); assertEquals( imports.size(), tree.getModelObject().getChildCount(tree.getModelObject().getRoot())); }