/** * assert last rendered Page class * * @param expectedReneredPageClass expected class of last renered page */ public void assertRenderedPage(Class expectedReneredPageClass) { if (!getLastRenderedPage().getClass().isAssignableFrom(expectedReneredPageClass)) { Assert.assertEquals( Classes.simpleName(expectedReneredPageClass), Classes.simpleName(getLastRenderedPage().getClass())); } }
/** * assert component class * * @param path path to component * @param expectedComponentClass expected component class */ public void assertComponent(String path, Class<?> expectedComponentClass) { Component component = getComponentFromLastRenderedPage(path); Assert.assertTrue( "component '" + Classes.simpleName(component.getClass()) + "' is not type:" + Classes.simpleName(expectedComponentClass), expectedComponentClass.isAssignableFrom(component.getClass())); }
/** * assert component visible. * * @param path path to component */ public void assertVisible(String path) { Component component = getLastRenderedPage().get(path); if (component == null) { Assert.fail( "path: '" + path + "' does no exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); } Assert.assertTrue("component '" + path + "' is not visible", component.isVisible()); }
/** * Gets the component with the given path from last rendered page. This method fails in case the * component couldn't be found, and it will return null if the component was found, but is not * visible. * * @param path Path to component * @return The component at the path * @see wicket.MarkupContainer#get(String) */ public Component getComponentFromLastRenderedPage(String path) { final Component component = getLastRenderedPage().get(path); if (component == null) { Assert.fail( "path: '" + path + "' does no exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); return component; } if (component.isVisibleInHierarchy()) { return component; } return null; }