MasterPmTableHandlerImpl extends MasterPmHandlerImpl<T_MASTER_BEAN> { @Override protected ModificationHandler<T_MASTER_BEAN> getModificationHandler() { return getMasterTablePm().getPmPageableBeanCollection().getModificationHandler(); } MasterPmTableHandlerImpl(PmTableImpl<?, T_MASTER_BEAN> masterPm, DetailsPmHandler... detailsHandlers); @Override void startObservers();  }
@Test public void testAddMasterRowAddDetailsDeleteMasterRow() { Bean newMasterBean = new Bean("M"); dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().addItem(newMasterBean); assertColStrings("a, b, M", dlg.masterTable.name); assertColStrings("a.1", dlg.detailsTable.name); assertColStrings("a.1.1", dlg.detailsDetailsTable.name); assertEquals("{added: 1, updated: 0, removed: 0}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("", dlg.detailsTable.eventCalls.toString()); dlg.cleanCallCounter(); dlg.masterTable.getPmPageableBeanCollection().getSelectionHandler().select(true, newMasterBean); dlg.detailsTable.getPmPageableBeanCollection().getModificationHandler().addItem(new Bean("M.1")); selectDetailsRow(0); dlg.detailsDetailsTable.getPmPageableBeanCollection().getModificationHandler().addItem(new Bean("M.1.1")); assertColStrings("a, b, M", dlg.masterTable.name); assertColStrings("M.1", dlg.detailsTable.name); assertColStrings("M.1.1", dlg.detailsDetailsTable.name); assertEquals("[[a, M]]", dlg.detailsTableHandler.detailsCalls.before.toString()); assertEquals("onPmValueChange=1", dlg.detailsTable.eventCalls.toString()); assertEquals("beforeMsChange=1 afterMsChange=1", dlg.detailsAreaHandler.detailsCalls.toString()); assertEquals("beforeMsChange=1 afterMsChange=1", dlg.detailsTableHandler.detailsCalls.toString()); dlg.cleanCallCounter(); dlg.detailsTable.getPmPageableBeanCollection().getModificationHandler().addItem(new Bean("D")); assertColStrings("a, b, M", dlg.masterTable.name); assertColStrings("M.1, D", dlg.detailsTable.name); assertColStrings("M.1.1", dlg.detailsDetailsTable.name); assertEquals("{added: 1, updated: 0, removed: 0}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{M={added: 2, updated: 0, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("onPmValueChange=1", dlg.detailsTable.eventCalls.toString()); assertEquals("", dlg.detailsAreaHandler.detailsCalls.toString()); assertEquals("", dlg.detailsTableHandler.detailsCalls.toString()); assertEquals("[M]", dlg.masterTable.getPmPageableBeanCollection().getSelection().toString()); dlg.cleanCallCounter(); dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems(); assertColStrings("a, b", dlg.masterTable.name); assertColStrings("a.1", dlg.detailsTable.name); assertColStrings("a.1.1", dlg.detailsDetailsTable.name); assertEquals("{}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("[[null, null], [null, a]]", dlg.detailsAreaHandler.detailsCalls.after.toString()); assertEquals("[[null, a]]", dlg.detailsTableHandler.detailsCalls.after.toString()); assertEquals("onPmValueChange=1", dlg.detailsTable.eventCalls.toString()); assertEquals(1, dlg.detailsTable.eventCalls.valueChangeListener.getEventCount()); assertEquals(1L, dlg.detailsTable.getTotalNumOfPmRows()); dlg.cleanCallCounter(); selectMasterRow(0); dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems(); assertColStrings("b", dlg.masterTable.name); assertColStrings("b.1", dlg.detailsTable.name); assertColStrings("b.1.1", dlg.detailsDetailsTable.name); dlg.cleanCallCounter(); selectMasterRow(0); dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems(); assertColStrings("", dlg.masterTable.name); assertColStrings("", dlg.detailsTable.name); assertColStrings("", dlg.detailsDetailsTable.name); assertEquals(0, dlg.masterTable.getTotalNumOfPmRows()); assertEquals("{}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); }
@Test public void testDeleteAndDependendChanges() { assertColStrings("a, b", dlg.masterTable.name); assertColStrings("a.1", dlg.detailsTable.name); assertColStrings("a.1.1", dlg.detailsDetailsTable.name); setValue(dlg.detailsDetailsTable.getRowPms().get(0).name, "a.1.1'"); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsDetailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{a={added: 0, updated: 1, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{a.1={added: 0, updated: 1, removed: 0}}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertChanged(dlg.detailsDetailsTable, dlg.detailsTable, dlg.masterTable); selectMasterRow(1); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsDetailsTable.getPmPageableBeanCollection().getModifications().toString()); assertColStrings("b.1", dlg.detailsTable.name); assertColStrings("b.1.1", dlg.detailsDetailsTable.name); assertChanged(dlg.masterTable); assertNotChanged(dlg.detailsDetailsTable, dlg.detailsTable); setValue(dlg.detailsDetailsTable.getRowPms().get(0).name, "b.1.1'"); assertEquals("{added: 0, updated: 2, removed: 0}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsDetailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{a={added: 0, updated: 1, removed: 0}, b={added: 0, updated: 1, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{a.1={added: 0, updated: 1, removed: 0}, b.1={added: 0, updated: 1, removed: 0}}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertChanged(dlg.detailsDetailsTable, dlg.detailsTable, dlg.masterTable); assertTrue(dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems()); assertColStrings("a", dlg.masterTable.name); assertColStrings("a.1", dlg.detailsTable.name); assertColStrings("a.1.1'", dlg.detailsDetailsTable.name); assertEquals("{added: 0, updated: 1, removed: 1}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{added: 0, updated: 1, removed: 0}", dlg.detailsDetailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{a={added: 0, updated: 1, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{a.1={added: 0, updated: 1, removed: 0}}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertChanged(dlg.detailsDetailsTable, dlg.detailsTable, dlg.masterTable); assertTrue(dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems()); assertColStrings("", dlg.masterTable.name); assertColStrings("", dlg.detailsTable.name); assertColStrings("", dlg.detailsDetailsTable.name); assertEquals("{added: 0, updated: 0, removed: 2}", dlg.masterTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsDetailsTable.getPmPageableBeanCollection().getModifications().toString()); assertEquals("{}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertChanged(dlg.masterTable); assertNotChanged(dlg.detailsDetailsTable, dlg.detailsTable); }
@Test public void testDeleteAllMasterRows() { dlg.cleanCallCounter(); selectMasterRow(1); assertColStrings("a, b", dlg.masterTable.name); assertColStrings("b.1", dlg.detailsTable.name); assertColStrings("b.1.1", dlg.detailsDetailsTable.name); setValue(dlg.detailsDetailsTable.getRowPms().get(0).name, "b.1.1'"); assertColStrings("b.1.1'", dlg.detailsDetailsTable.name); assertEquals("{b={added: 0, updated: 1, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{b.1={added: 0, updated: 1, removed: 0}}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals(1L, dlg.detailsTable.getPmPageableBeanCollection().getSelection().getSize()); assertEquals(1, dlg.masterTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); assertEquals(2, dlg.detailsTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); assertEquals("beforeMsChange=1 afterMsChange=1", dlg.detailsTableHandler.detailsCalls.toString()); assertEquals(0, dlg.detailsDetailsTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); dlg.cleanCallCounter(); assertTrue(dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems()); assertColStrings("a", dlg.masterTable.name); assertColStrings("a.1", dlg.detailsTable.name); assertColStrings("a.1.1", dlg.detailsDetailsTable.name); setValue(dlg.detailsDetailsTable.getRowPms().get(0).name, "a.1.1'"); assertColStrings("a.1.1'", dlg.detailsDetailsTable.name); assertEquals("{a={added: 0, updated: 1, removed: 0}}", dlg.detailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals("{a.1={added: 0, updated: 1, removed: 0}}", dlg.detailsDetailsTableHandler.getMasterBeanToDetailsModificationsMap().toString()); assertEquals(2, dlg.masterTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); assertEquals(2, dlg.detailsTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); dlg.cleanCallCounter(); assertTrue(dlg.masterTable.getPmPageableBeanCollection().getModificationHandler().removeSelectedItems()); assertColStrings("", dlg.masterTable.name); assertColStrings("", dlg.detailsTable.name); assertColStrings("", dlg.detailsDetailsTable.name); assertEquals("[[a, null]]", dlg.detailsTableHandler.detailsCalls.after.toString()); assertEquals(1, dlg.detailsTable.eventCalls.selectionPropertyListener.getNumOfPropertyChangesCalls()); assertEquals("[[null, null]]", dlg.detailsDetailsTableHandler.detailsCalls.after.toString()); }