/** * Fails with a verbose error message. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void failWithVerboseMessage(final Collection<?> expects, final Collection<?> actuals) { Assert.fail("\nexpect (" + expects.size() + "):\n" + asLined(expects) + "\nbut was (" + actuals.size() + "):\n" + asLined(actuals)); }
/** * Assert info-level feedback messages. * * @param expectedInfoMessages * expected info messages */ public void assertInfoMessages(String[] expectedInfoMessages) { List<Serializable> actualMessages = getMessages(FeedbackMessage.INFO); WicketTesterHelper.assertEquals(Arrays.asList(expectedInfoMessages), actualMessages); }
/** * Asserts that both <code>Collection</code>s contain the same elements. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void assertEquals(final Collection expects, final Collection actuals) { if (!expects.containsAll(actuals) || !actuals.containsAll(expects)) { failWithVerboseMessage(expects, actuals); } }
/** * Dumps the <code>Component</code> trees to log. Show only the <code>Component</code>s whose * paths contain the filter <code>String</code>. * * @param filter * a filter <code>String</code> */ public void debugComponentTrees(String filter) { log.info("debugging ----------------------------------------------"); for (WicketTesterHelper.ComponentData obj : WicketTesterHelper.getComponentData(getLastRenderedPage())) { if (obj.path.matches(".*" + filter + ".*")) { log.info("[{}{}] path\t" + obj.path + " \t" + obj.type + " \t[" + obj.value + "]", obj.isEnabled?"E":"-", obj.isVisible?"V":"-"); } } }
List<AjaxEventBehavior> behaviors = WicketTesterHelper.findAjaxEventBehaviors( linkComponent, "click"); for (AjaxEventBehavior behavior : behaviors) (AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, "click")); List<AjaxEventBehavior> behaviors = WicketTesterHelper.findAjaxEventBehaviors( linkComponent, "click"); for (AjaxEventBehavior behavior : behaviors)
/** * Finds the first AjaxEventBehavior attached to the specified component with the * specified event. * * @param component * @param event * @return the first behavior for this event, or {@code null} */ public static AjaxEventBehavior findAjaxEventBehavior(Component component, String event) { List<AjaxEventBehavior> behaviors = findAjaxEventBehaviors(component, event); AjaxEventBehavior behavior = null; if (behaviors != null && behaviors.isEmpty() == false) { behavior = behaviors.get(0); } return behavior; }
/** * * @param link * @return Url */ public Url urlFor(final AjaxLink<?> link) { AbstractAjaxBehavior behavior = WicketTesterHelper.findAjaxEventBehavior(link, "click"); Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding())); return transform(url); }
/** * Dumps the <code>Component</code> trees to log. Show only the <code>Component</code>s * whose paths contain the filter <code>String</code>. * * @param filter * a filter <code>String</code> */ public void debugComponentTrees(String filter) { log.info("debugging ----------------------------------------------"); for (Iterator iter = WicketTesterHelper.getComponentData(getLastRenderedPage()).iterator(); iter.hasNext();) { WicketTesterHelper.ComponentData obj = (WicketTesterHelper.ComponentData)iter.next(); if (obj.path.matches(".*" + filter + ".*")) { log.info("path\t" + obj.path + " \t" + obj.type + " \t[" + obj.value + "]"); } } }
.findAjaxEventBehaviors(linkComponent, "click"); for (AjaxEventBehavior behavior : behaviors) (AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, "click")); .findAjaxEventBehaviors(linkComponent, "click"); for (AjaxEventBehavior behavior : behaviors)
/** * Finds the first AjaxEventBehavior attached to the specified component with the * specified event. * * @param component * @param event * @return the first behavior for this event, or {@code null} */ public static AjaxEventBehavior findAjaxEventBehavior(Component component, String event) { List<AjaxEventBehavior> behaviors = findAjaxEventBehaviors(component, event); AjaxEventBehavior behavior = null; if (behaviors != null && behaviors.isEmpty() == false) { behavior = behaviors.get(0); } return behavior; }
/** * * @param link * @return Url */ public Url urlFor(final AjaxLink<?> link) { AbstractAjaxBehavior behavior = WicketTesterHelper.findAjaxEventBehavior(link, "click"); Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding())); return transform(url); }
/** * Fails with a verbose error message. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void failWithVerboseMessage(final Collection expects, final Collection actuals) { Assert.fail("\nexpect (" + expects.size() + "):\n" + asLined(expects) + "\nbut was (" + actuals.size() + "):\n" + asLined(actuals)); }
/** * Assert info-level feedback messages. * * @param expectedInfoMessages * expected info messages */ public void assertInfoMessages(String[] expectedInfoMessages) { List actualMessages = getMessages(FeedbackMessage.INFO); WicketTesterHelper.assertEquals(Arrays.asList(expectedInfoMessages), actualMessages); }
/** * Asserts that both <code>Collection</code>s contain the same elements. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void assertEquals(final Collection<?> expects, final Collection<?> actuals) { if ((actuals.size() != expects.size()) || !expects.containsAll(actuals) || !actuals.containsAll(expects)) { failWithVerboseMessage(expects, actuals); } }
/** * Dumps the <code>Component</code> trees to log. Show only the <code>Component</code>s whose * paths contain the filter <code>String</code>. * * @param filter * a filter <code>String</code> */ public void debugComponentTrees(String filter) { log.info("debugging ----------------------------------------------"); for (WicketTesterHelper.ComponentData obj : WicketTesterHelper .getComponentData(getLastRenderedPage())) { if (obj.path.matches(".*" + filter + ".*")) { log.info("[{}{}] path\t" + obj.path + " \t" + obj.type + " \t[" + obj.value + "]", obj.isEnabled ? "E" : "-", obj.isVisible ? "V" : "-"); } } }
List<AjaxEventBehavior> ajaxEventBehaviors = WicketTesterHelper.findAjaxEventBehaviors( component, event); for (AjaxEventBehavior ajaxEventBehavior : ajaxEventBehaviors)
/** * Fails with a verbose error message. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void failWithVerboseMessage(final Collection<?> expects, final Collection<?> actuals) { fail("\nexpect (" + expects.size() + "):\n" + asLined(expects) + "\nbut was (" + actuals.size() + "):\n" + asLined(actuals)); }
/** * Asserts error-level feedback messages. * * @param expectedErrorMessages * expected error messages */ public void assertErrorMessages(String[] expectedErrorMessages) { List<Serializable> actualMessages = getMessages(FeedbackMessage.ERROR); List<Serializable> msgs = new ArrayList<Serializable>(); for (Iterator<Serializable> iterator = actualMessages.iterator(); iterator.hasNext();) { msgs.add(iterator.next().toString()); } WicketTesterHelper.assertEquals(Arrays.asList(expectedErrorMessages), msgs); }
/** * Asserts that both <code>Collection</code>s contain the same elements. * * @param expects * a <code>Collection</code> object * @param actuals * a <code>Collection</code> object */ public static void assertEquals(final Collection<?> expects, final Collection<?> actuals) { if ((actuals.size() != expects.size()) || !expects.containsAll(actuals) || !actuals.containsAll(expects)) { failWithVerboseMessage(expects, actuals); } }
/** * Dumps the <code>Component</code> trees to log. Show only the <code>Component</code>s whose * paths contain the filter <code>String</code>. * * @param filter * a filter <code>String</code> */ public void debugComponentTrees(String filter) { log.info("debugging ----------------------------------------------"); for (WicketTesterHelper.ComponentData obj : WicketTesterHelper.getComponentData(getLastRenderedPage())) { if (obj.path.matches(".*" + filter + ".*")) { log.info("path\t" + obj.path + " \t" + obj.type + " \t[" + obj.value + "]"); } } }