@Override
  protected void setUp() throws Exception {
    super.setUp();

    domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
    refreshEditorsPrecommitListener = new RefreshEditorsPrecommitListener(domain);

    resourceSet = domain.getResourceSet();
    sessionResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.aird", true);
    semanticResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.ecore", true);

    sessionResource = resourceSet.getResource(sessionResourceURI, true);

    final DRepresentation firstDRepresentation =
        getFirstElement(sessionResource, DRepresentation.class);
    refreshFilterStub = new RefreshFilterStub(firstDRepresentation);
    RefreshFilterManager.INSTANCE.addRefreshFilter(refreshFilterStub);

    oldRefreshAutoMode =
        Platform.getPreferencesService()
            .getBoolean(
                SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
    InstanceScope.INSTANCE
        .getNode(SiriusPlugin.ID)
        .putBoolean(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
  }
  /**
   * test the edge creation on auto refresh and unsynchro
   *
   * @throws Exception
   */
  public void testEdgeCreationAutoRefreshWithUnsynchronizedDiagram() throws Exception {
    changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);

    unsynchronizeDiagram(diagram);

    Model model = (Model) semanticModel;
    Activity activity = (Activity) model.getPackagedElements().get(0);
    List<ActivityNode> ownedNodes = getActivityOwnedNodes(activity);
    OpaqueAction source = (OpaqueAction) ownedNodes.get(0);
    OpaqueAction target = (OpaqueAction) ownedNodes.get(1);

    applyEdgeCreationTool(
        "Control Flow",
        diagram,
        (EdgeTarget) getFirstDiagramElement(diagram, source),
        (EdgeTarget) getFirstDiagramElement(diagram, target));

    ActivityEdge edge = activity.getEdges().get(0);
    assertNotNull(edge);
    DEdge edgeElement = getFirstEdgeElement(diagram, edge);
    assertNotNull(edgeElement);

    doTestUndoRedoAutoRefreshUnsynchronized(activity, edge);

    doTestCloseOpenUnsynchronized();
  }
  /**
   * test the edge creation on auto refresh
   *
   * @throws Exception
   */
  public void testEdgeCreationAutoRefresh() throws Exception {
    changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);

    Model model = (Model) semanticModel;
    final Activity activity = (Activity) model.getPackagedElements().get(0);
    List<ActivityNode> ownedNodes = getActivityOwnedNodes(activity);
    OpaqueAction source = (OpaqueAction) ownedNodes.get(0);
    OpaqueAction target = (OpaqueAction) ownedNodes.get(1);

    applyEdgeCreationTool(
        "Control Flow",
        diagram,
        (EdgeTarget) getFirstDiagramElement(diagram, source),
        (EdgeTarget) getFirstDiagramElement(diagram, target));

    ActivityEdge edge = activity.getEdges().get(0);
    assertNotNull(edge);
    DEdge edgeElement = getFirstEdgeElement(diagram, edge);
    assertNotNull(edgeElement);

    assertEquals(
        "Wrong EdgeSourceArrow for Edge.",
        EdgeArrows.INPUT_ARROW_LITERAL,
        ((EdgeStyle) edgeElement.getStyle()).getSourceArrow());
    assertEquals(
        "Wrong EdgeTargetArrow for Edge.",
        EdgeArrows.NO_DECORATION_LITERAL,
        ((EdgeStyle) edgeElement.getStyle()).getTargetArrow());

    IDiagramEdgeEditPart gmfEP = (IDiagramEdgeEditPart) getEditPart(edgeElement, editorPart);
    assertNotNull(gmfEP);
    assertNotNull(gmfEP.getPolylineConnectionFigure());

    assertEquals(
        "Wrong Edge target",
        getFirstDiagramElement(diagram, target),
        ((Edge) gmfEP.getModel()).getSource().getElement());
    assertEquals(
        "Wrong Edge source",
        getFirstDiagramElement(diagram, source),
        ((Edge) gmfEP.getModel()).getTarget().getElement());

    doTestUndoRedoAutoRefresh(activity, edge);

    doTestCloseOpen();
  }
  @Override
  protected void tearDown() throws Exception {

    InstanceScope.INSTANCE
        .getNode(SiriusPlugin.ID)
        .putBoolean(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), oldRefreshAutoMode);
    sessionResourceURI = null;
    semanticResourceURI = null;
    domain.dispose();
    domain = null;
    resourceSet = null;
    sessionResource = null;
    refreshEditorsPrecommitListener = null;
    RefreshFilterManager.INSTANCE.removeRefreshFilter(refreshFilterStub);
    refreshFilterStub = null;

    super.tearDown();
  }
 /**
  * Tests.
  *
  * @throws Exception
  */
 public void testDiagramOpenningWithAutoRefresh() throws Exception {
   changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
   doTest();
 }