WorkspaceSettings.getInstance().setExperimentalFeaturesVisible(true);
final MasterReport report = new MasterReport();
final CrosstabElement element = new CrosstabElement();
CrosstabGroup rootGroup = new CrosstabGroup();
RelationalGroup relGroup = new RelationalGroup();
relGroup.setBody(new SubGroupBody(rootGroup));
element.setRootGroup(relGroup);
report.getReportHeader().addElement(element);
final TestReportDesignerContext rdc = new TestReportDesignerContext();
rdc.addMasterReport(report);
rdc.addSubReport((ReportDocumentContext) rdc.getDocumentContext(0), element);
rdc.setActiveDocument(rdc.getDocumentContext(1));
final ReportDocumentContext activeContext = rdc.getActiveContext();
Assert.assertNotNull(activeContext);
Assert.assertEquals(activeContext.getReportDefinition(), element);
CrosstabGroup crosstabGroup = new CrosstabGroup();
EditCrosstabAction action = new NonEditingCrosstabAction(crosstabGroup);
action.setReportDesignerContext(rdc);
action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Edit"));
Assert.assertFalse(rdc.getActiveContext().getUndo().isRedoPossible());
Assert.assertTrue(rdc.getActiveContext().getUndo().isUndoPossible());
Assert.assertEquals(crosstabGroup.getObjectID(), element.getRootGroup().getBody().getGroup().getObjectID());
rdc.getActiveContext().getUndo().undo(rdc.getActiveContext());
Assert.assertEquals(rootGroup.getObjectID(), element.getRootGroup().getBody().getGroup().getObjectID());
rdc.getActiveContext().getUndo().redo(rdc.getActiveContext());
Assert.assertEquals(crosstabGroup.getObjectID(), element.getRootGroup().getBody().getGroup().getObjectID());
}