Source:
<code>protected void setUp() throws Exception { super.setUp(); accessor = new ModelAccessor(); accessor.addExtender(new EcoreIntrinsicExtender(), ExtenderConstants.HIGH_PRIORITY); accessor.activateMetamodels(Lists.newArrayList(new EcoreMetamodelDescriptor(EcorePackage.eINSTANCE))); oDesign = new CreateViewOperationData(); oDesign.load(); URI transientSessionResourceURI = URI.createURI(URIQuery.INMEMORY_URI_SCHEME + ":/Project/test.aird"); URI transientSemanticResourceURI = URI.createURI(URIQuery.INMEMORY_URI_SCHEME + ":/Project/test.ecore"); Resource semanticResource = new ResourceSetImpl().createResource(transientSemanticResourceURI); EPackage semantic = EcoreFactory.eINSTANCE.createEPackage(); semantic.getEClassifiers().add(EcoreFactory.eINSTANCE.createEClass()); semanticResource.getContents().add(semantic); semanticResource.save(Collections.emptyMap()); session = SessionManager.INSTANCE.getSession(transientSessionResourceURI, new NullProgressMonitor()); session.open(new NullProgressMonitor()); TransactionalEditingDomain domain = session.getTransactionalEditingDomain(); Command addSemanticResourceCmd = new AddSemanticResourceCommand(session, transientSemanticResourceURI, new NullProgressMonitor()); domain.getCommandStack().execute(addSemanticResourceCmd); semantic = (EPackage) session.getSemanticResources().iterator().next().getContents().get(0); rootContext = new CommandContext(semantic.getEClassifiers().get(0), null); UserSession.from(session).selectOnlyViewpoint(EcoreModeler.DESIGN_VIEWPOINT_NAME); diagram = DiagramFactory.eINSTANCE.createDSemanticDiagram(); diagram.setDescription(oDesign.group().viewpoint1().diagram1().object()); Command addDiagramCmd = new <START> AbstractCommand() <END> { @Override public void redo() { } @Override public boolean canExecute() { return true; } @Override public void execute() { session.getSessionResource().getContents().add(diagram); } }; domain.getCommandStack().execute(addDiagramCmd); }</code><technical_language>remark a Recording command</technical_language>

Target:
protected void setUp() throws Exception { super.setUp(); accessor = new ModelAccessor(); accessor.addExtender(new EcoreIntrinsicExtender(), ExtenderConstants.HIGH_PRIORITY); accessor.activateMetamodels(Lists.newArrayList(new EcoreMetamodelDescriptor(EcorePackage.eINSTANCE))); oDesign = new CreateViewOperationData(); oDesign.load(); URI transientSessionResourceURI = URI.createURI(URIQuery.INMEMORY_URI_SCHEME + ":/Project/test.aird"); URI transientSemanticResourceURI = URI.createURI(URIQuery.INMEMORY_URI_SCHEME + ":/Project/test.ecore"); Resource semanticResource = new ResourceSetImpl().createResource(transientSemanticResourceURI); EPackage semantic = EcoreFactory.eINSTANCE.createEPackage(); semantic.getEClassifiers().add(EcoreFactory.eINSTANCE.createEClass()); semanticResource.getContents().add(semantic); semanticResource.save(Collections.emptyMap()); session = SessionManager.INSTANCE.getSession(transientSessionResourceURI, new NullProgressMonitor()); session.open(new NullProgressMonitor()); TransactionalEditingDomain domain = session.getTransactionalEditingDomain(); Command addSemanticResourceCmd = new AddSemanticResourceCommand(session, transientSemanticResourceURI, new NullProgressMonitor()); domain.getCommandStack().execute(addSemanticResourceCmd); semantic = (EPackage) session.getSemanticResources().iterator().next().getContents().get(0); rootContext = new CommandContext(semantic.getEClassifiers().get(0), null); UserSession.from(session).selectOnlyViewpoint(EcoreModeler.DESIGN_VIEWPOINT_NAME); diagram = DiagramFactory.eINSTANCE.createDSemanticDiagram(); diagram.setDescription(oDesign.group().viewpoint1().diagram1().object()); Command addDiagramCmd = new RecordingCommand(session.getTransactionalEditingDomain()) { @Override protected void doExecute() { session.getSessionResource().getContents().add(diagram); } }; domain.getCommandStack().execute(addDiagramCmd); }