/** * Tests whether the method <code>INavigationProcessor#navigate</code> is called with the proper * parameters: <br> * - a NavigationNode<br> * - a NavigationNodeId and<br> * - a <code>NavigationArgument</code> that has the ridgetId "textFirst" and a parameter that is * compared by a custom compare-method. This compare-method returns 0, if the first- and lastName * of the <code>PersonModificationBean</code> match. */ public void testNavigateToRidgetWithCompare() { final PersonModificationBean bean = new PersonModificationBean(); bean.setPerson(new Person("Doe", "Jane")); // $NON-NLS-1$ //$NON-NLS-2$ expect( getMockNavigationProcessor() .navigate( eq(getController().getNavigationNode()), eq(new NavigationNodeId("org.eclipse.riena.example.combo")), // $NON-NLS-1$ cmp( new NavigationArgument(bean, "textFirst"), new Comparator<NavigationArgument>() { // $NON-NLS-1$ public int compare( final NavigationArgument o1, final NavigationArgument o2) { if (o1.getParameter() instanceof PersonModificationBean && o2.getParameter() instanceof PersonModificationBean) { return comparePersonModificationBeans( (PersonModificationBean) o1.getParameter(), (PersonModificationBean) o2.getParameter()); } else { return -1; } } }, LogicalOperator.EQUAL))) .andReturn(createNavigationNode("org.eclipse.riena.example.combo")); // $NON-NLS-1$ replay(getMockNavigationProcessor()); final IActionRidget navigateToNavigateRidget = getController().getRidget(IActionRidget.class, "btnNavigateToRidget"); // $NON-NLS-1$ navigateToNavigateRidget.fireAction(); verify(getMockNavigationProcessor()); }
private int comparePersonModificationBeans( final PersonModificationBean p1, final PersonModificationBean p2) { if (p1.getFirstName().equals(p2.getFirstName()) && p1.getLastName().equals(p2.getLastName())) { return 0; } else { return -1; } }
/** * Tests whether the method <code>INavigationProcessor#navigate</code> is called with the proper * parameters: <br> * - a NavigationNode<br> * - a NavigationNodeId and<br> * - a <code>NavigationArgument</code> that has the ridgetId "textFirst" and a parameter that * compared by the equals methods in the specific classes. */ public void testNavigateToRidgetWithEquals() { final PersonModificationBean bean = new PersonModificationBean(); bean.setPerson(new Person("Doe", "Jane")); // $NON-NLS-1$ //$NON-NLS-2$ expect( getMockNavigationProcessor() .navigate( eq(getController().getNavigationNode()), eq(new NavigationNodeId("org.eclipse.riena.example.combo")), // $NON-NLS-1$ eq(new NavigationArgument(bean, "textFirst")))) .andReturn( //$NON-NLS-1$ createNavigationNode("org.eclipse.riena.example.combo")); // $NON-NLS-1$ replay(getMockNavigationProcessor()); final IActionRidget navigateToNavigateRidget = getController().getRidget(IActionRidget.class, "btnNavigateToRidget"); // $NON-NLS-1$ navigateToNavigateRidget.fireAction(); verify(getMockNavigationProcessor()); }