@Test (dataProvider="dialogTestCases") public void testDialog( boolean isDirty, boolean isDirtyChild, final int choice, final int saveCount ) throws Exception { Mockito.when(mockComponent.isDirty()).thenReturn(isDirty || isDirtyChild); if (isDirtyChild) { AbstractComponent child = Mockito.mock(AbstractComponent.class); ObjectManager om = Mockito.mock(ObjectManager.class); Mockito.when(om.getAllModifiedObjects()).thenReturn(Collections.singleton(child)); Mockito.when(mockComponent.handleGetCapability(ObjectManager.class)).thenReturn(om); } Mockito.when(mockPersistence.getComponent(Mockito.anyString())).thenReturn(mockComponent); Mockito.when(mockWindowing.showInputDialog( Mockito.<String>any(), Mockito.<String>any(), Mockito.<String[]>any(), Mockito.<String>any(), Mockito.<Map<String,Object>>any())).thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { String[] options = (String[]) invocation.getArguments()[2]; if (options != null && choice < options.length) { return options[choice]; } return null; } }); housing = new MCTStandardHousing("", 100, 100, JFrame.DO_NOTHING_ON_CLOSE, pseudoView); UserEnvironmentRegistry.registerHousing(housing); housing.closeHousing(); Mockito.verify(mockPersistence, Mockito.times(saveCount > 0 ? 1 : 0)).persist( Mockito.argThat(new ArgumentMatcher<Collection<AbstractComponent>>() { @SuppressWarnings("rawtypes") @Override public boolean matches(Object argument) { return argument instanceof Collection && ((Collection) argument).size() == saveCount; } })); }
@Override public void closeHousing() { boolean toCloseWindow = true; MCTContentArea centerPane = housingViewManifestation.getContentArea(); if (centerPane != null) { View centerPaneView = centerPane.getHousedViewManifestation(); AbstractComponent centerComponent = centerPaneView.getManifestedComponent(); if (!centerComponent.isStale() && centerComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(centerPaneView, MessageFormat.format(BUNDLE.getString("centerpane.modified.alert.text"), centerPaneView.getInfo().getViewName(), centerComponent.getDisplayName())); } } View inspectionArea = housingViewManifestation.getInspectionArea(); if (inspectionArea != null) { View inspectorPaneView = inspectionArea.getHousedViewManifestation(); AbstractComponent inspectorComponent = inspectorPaneView.getManifestedComponent(); if (!inspectorComponent.isStale() && inspectorComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(inspectionArea, MessageFormat.format(BUNDLE.getString("inspectorpane.modified.alert.text"), inspectorPaneView.getInfo().getViewName(), inspectorComponent.getDisplayName())); } } if (toCloseWindow) { disposeHousing(); } }
MCTStandardHousing extends MCTAbstractHousing implements TwiddleView { @Override public void closeHousing() { boolean toCloseWindow = true; MCTContentArea centerPane = housingViewManifestation.getContentArea(); if (centerPane != null) { View centerPaneView = centerPane.getHousedViewManifestation(); AbstractComponent centerComponent = centerPaneView.getManifestedComponent(); if (!centerComponent.isStale() && centerComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(centerPaneView, MessageFormat.format(BUNDLE.getString("centerpane.modified.alert.text"), centerPaneView.getInfo().getViewName(), centerComponent.getDisplayName())); } } View inspectionArea = housingViewManifestation.getInspectionArea(); if (inspectionArea != null) { View inspectorPaneView = inspectionArea.getHousedViewManifestation(); AbstractComponent inspectorComponent = inspectorPaneView.getManifestedComponent(); if (!inspectorComponent.isStale() && inspectorComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(inspectionArea, MessageFormat.format(BUNDLE.getString("inspectorpane.modified.alert.text"), inspectorPaneView.getInfo().getViewName(), inspectorComponent.getDisplayName())); } } if (toCloseWindow) { disposeHousing(); } } }
MCTStandardHousing extends MCTAbstractHousing implements TwiddleView { @Override public void closeHousing() { boolean toCloseWindow = true; MCTContentArea centerPane = housingViewManifestation.getContentArea(); if (centerPane != null) { View centerPaneView = centerPane.getHousedViewManifestation(); AbstractComponent centerComponent = centerPaneView.getManifestedComponent(); if (!centerComponent.isStale() && centerComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(centerPaneView, MessageFormat.format(BUNDLE.getString("centerpane.modified.alert.text"), centerPaneView.getInfo().getViewName(), centerComponent.getDisplayName())); } } View inspectionArea = housingViewManifestation.getInspectionArea(); if (inspectionArea != null) { View inspectorPaneView = inspectionArea.getHousedViewManifestation(); AbstractComponent inspectorComponent = inspectorPaneView.getManifestedComponent(); if (!inspectorComponent.isStale() && inspectorComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(inspectionArea, MessageFormat.format(BUNDLE.getString("inspectorpane.modified.alert.text"), inspectorPaneView.getInfo().getViewName(), inspectorComponent.getDisplayName())); } } if (toCloseWindow) { disposeHousing(); } } MCTStandardHousing(int width, int height, int closeAction, View housingView);  MCTStandardHousing(GraphicsConfiguration gc, String title, int width, int height, int closeAction, 
            View housingView);  MCTStandardHousing(String title, int width, int height, int closeAction, 
            View housingView); }
MCTStandardHousing extends MCTAbstractHousing implements TwiddleView { @Override public void closeHousing() { boolean toCloseWindow = true; MCTContentArea centerPane = housingViewManifestation.getContentArea(); if (centerPane != null) { View centerPaneView = centerPane.getHousedViewManifestation(); AbstractComponent centerComponent = centerPaneView.getManifestedComponent(); if (!centerComponent.isStale() && centerComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(centerPaneView, MessageFormat.format(BUNDLE.getString("centerpane.modified.alert.text"), centerPaneView.getInfo().getViewName(), centerComponent.getDisplayName())); } } View inspectionArea = housingViewManifestation.getInspectionArea(); if (inspectionArea != null) { View inspectorPaneView = inspectionArea.getHousedViewManifestation(); AbstractComponent inspectorComponent = inspectorPaneView.getManifestedComponent(); if (!inspectorComponent.isStale() && inspectorComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(inspectionArea, MessageFormat.format(BUNDLE.getString("inspectorpane.modified.alert.text"), inspectorPaneView.getInfo().getViewName(), inspectorComponent.getDisplayName())); } } if (toCloseWindow) { disposeHousing(); } } MCTStandardHousing(int width, int height, int closeAction, View housingView);  MCTStandardHousing(GraphicsConfiguration gc, String title, int width, int height, int closeAction, 
            View housingView);  MCTStandardHousing(String title, int width, int height, int closeAction, 
            View housingView); @Override SelectionProvider getSelectionProvider(); MCTHousingViewManifestation showHousedManifestationIfPresent(String manifestedType); void setHousingViewManifesation(MCTHousingViewManifestation housingViewManifestation); void buildGUI(); void setControlArea(MCTControlArea controlArea); void setControlAreaVisible(boolean flag); boolean isControlAreaVisible(); void setDirectoryArea(View directoryArea); void setContentArea(MCTContentArea contentArea); void setInspectionArea(View inspectionArea); @Override View getInspectionArea(); @Override View getDirectoryArea(); @Override MCTContentArea getContentArea(); @Override MCTControlArea getControlArea(); @Override View getCurrentManifestation(); AbstractComponent getWindowComponent(); @Override View getHousedViewManifestation(); @Override Collection<ViewProvider> getHousedManifestationProviders(); @Override void setStatusArea(MCTStatusArea statusArea); @Override MCTStatusArea getStatusArea(); @Override void toggleControlAreas(boolean showing); @Override void addControlArea(ControlProvider provider); @Override void enterTwiddleMode(AbstractComponent twiddledComponent); @Override void exitTwiddleMode(AbstractComponent originalComponent); @Override void closeHousing(); }
MCTStandardHousing extends MCTAbstractHousing implements TwiddleView { @Override public void closeHousing() { boolean toCloseWindow = true; MCTContentArea centerPane = housingViewManifestation.getContentArea(); if (centerPane != null) { View centerPaneView = centerPane.getHousedViewManifestation(); AbstractComponent centerComponent = centerPaneView.getManifestedComponent(); if (!centerComponent.isStale() && centerComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(centerPaneView, MessageFormat.format(BUNDLE.getString("centerpane.modified.alert.text"), centerPaneView.getInfo().getViewName(), centerComponent.getDisplayName())); } } View inspectionArea = housingViewManifestation.getInspectionArea(); if (inspectionArea != null) { View inspectorPaneView = inspectionArea.getHousedViewManifestation(); AbstractComponent inspectorComponent = inspectorPaneView.getManifestedComponent(); if (!inspectorComponent.isStale() && inspectorComponent.isDirty()) { toCloseWindow = commitOrAbortPendingChanges(inspectionArea, MessageFormat.format(BUNDLE.getString("inspectorpane.modified.alert.text"), inspectorPaneView.getInfo().getViewName(), inspectorComponent.getDisplayName())); } } if (toCloseWindow) { disposeHousing(); } } MCTStandardHousing(int width, int height, int closeAction, View housingView);  MCTStandardHousing(GraphicsConfiguration gc, String title, int width, int height, int closeAction, 
            View housingView);  MCTStandardHousing(String title, int width, int height, int closeAction, 
            View housingView); @Override SelectionProvider getSelectionProvider(); MCTHousingViewManifestation showHousedManifestationIfPresent(String manifestedType); void setHousingViewManifesation(MCTHousingViewManifestation housingViewManifestation); void buildGUI(); void setControlArea(MCTControlArea controlArea); void setControlAreaVisible(boolean flag); boolean isControlAreaVisible(); void setDirectoryArea(View directoryArea); void setContentArea(MCTContentArea contentArea); void setInspectionArea(View inspectionArea); @Override View getInspectionArea(); @Override View getDirectoryArea(); @Override MCTContentArea getContentArea(); @Override MCTControlArea getControlArea(); @Override View getCurrentManifestation(); AbstractComponent getWindowComponent(); @Override View getHousedViewManifestation(); @Override Collection<ViewProvider> getHousedManifestationProviders(); @Override void setStatusArea(MCTStatusArea statusArea); @Override MCTStatusArea getStatusArea(); @Override void toggleControlAreas(boolean showing); @Override void addControlArea(ControlProvider provider); @Override void enterTwiddleMode(AbstractComponent twiddledComponent); @Override void exitTwiddleMode(AbstractComponent originalComponent); @Override void closeHousing();  }