/** Tests the assignment of one selected item from the left to the right table. */ @Test public void testMoveOneRight() { AssignmentCompositeModel<MyTo> model = new AssignmentCompositeModel<MyTo>(Collections.<String>emptyList(), TABLE_ROW_VALUES_LEFT); AssignmentCompositeController<MyTo> controller = new AssignmentCompositeController<MyTo>(); AssignmentComposite<MyTo> composite = new AssignmentComposite<MyTo>() { @Override public List<IAssignable<MyTo>> getSelectedValuesLeft() { return Collections.<IAssignable<MyTo>>singletonList(LEFT_ASSIGNABLE_1); } }; controller.setAssignmentComposite(composite); controller.setAssignmentCompositeModel(model); List<IAssignable<MyTo>> tableRowValuesLeft = model.getTableRowValuesLeft(); Assert.assertEquals(2, tableRowValuesLeft.size()); List<IAssignable<MyTo>> tableRowValuesRight = model.getTableRowValuesRight(); Assert.assertEquals(0, tableRowValuesRight.size()); controller.moveRight(); tableRowValuesLeft = model.getTableRowValuesLeft(); Assert.assertEquals(1, tableRowValuesLeft.size()); tableRowValuesRight = model.getTableRowValuesRight(); Assert.assertEquals(1, tableRowValuesRight.size()); }
/** Tests assignment of all items from the right table to the left. */ @Test public void testMoveAllLeft() { AssignmentCompositeModel<MyTo> model = new AssignmentCompositeModel<MyTo>( Collections.<String>emptyList(), Collections.<IAssignable<MyTo>>emptyList(), TABLE_ROW_VALUES_RIGHT); AssignmentCompositeController<MyTo> controller = new AssignmentCompositeController<MyTo>(); controller.setAssignmentComposite(new AssignmentComposite<MyTo>()); controller.setAssignmentCompositeModel(model); List<IAssignable<MyTo>> tableRowValuesRight = model.getTableRowValuesRight(); Assert.assertEquals(2, tableRowValuesRight.size()); List<IAssignable<MyTo>> tableRowValuesLeft = model.getTableRowValuesLeft(); Assert.assertEquals(0, tableRowValuesLeft.size()); controller.moveAllLeft(); tableRowValuesRight = model.getTableRowValuesRight(); Assert.assertEquals(0, tableRowValuesRight.size()); tableRowValuesLeft = model.getTableRowValuesLeft(); Assert.assertEquals(2, tableRowValuesLeft.size()); }