Ejemplo n.º 1
0
  @Test
  public void testReplace() {
    final AnalysesModel model = new AnalysesModel();
    final MCMCPresentation inco1 = new MCMCPresentation(d_wrapper, "inco1");
    final MCMCPresentation inco2 = new MCMCPresentation(d_wrapper, "inco2");

    model.add(ModelType.Inconsistency, inco1);
    JUnitUtil.assertAllAndOnly(
        model.getModels(ModelType.Inconsistency), Collections.singleton(inco1));

    TreeModelListener listener = EasyMock.createStrictMock(TreeModelListener.class);

    TreeModelEvent event1a =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot(), ModelType.Inconsistency},
            new int[] {0},
            new Object[] {inco2});
    listener.treeNodesChanged(TreeModelEventMatcher.eqTreeModelEvent(event1a));

    EasyMock.replay(listener);
    model.addTreeModelListener(listener);
    model.replace(ModelType.Inconsistency, inco1, inco2);
    EasyMock.verify(listener);

    JUnitUtil.assertAllAndOnly(
        model.getModels(ModelType.Inconsistency), Collections.singleton(inco2));
  }
Ejemplo n.º 2
0
  @Test
  public void testListeners() {
    final AnalysesModel model = new AnalysesModel();
    final MCMCPresentation inco1 = new MCMCPresentation(d_wrapper, "inco1");
    final MCMCPresentation cons1 = new MCMCPresentation(d_wrapper, "cons1");
    final MCMCPresentation splt1 = new MCMCPresentation(d_wrapper, "splt1");
    final MCMCPresentation splt2 = new MCMCPresentation(d_wrapper, "splt2");

    TreeModelListener listener = EasyMock.createStrictMock(TreeModelListener.class);
    TreeModelEvent event1a =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot()},
            new int[] {0},
            new Object[] {ModelType.Inconsistency});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event1a));
    TreeModelEvent event1b =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot(), ModelType.Inconsistency},
            new int[] {0},
            new Object[] {inco1});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event1b));
    TreeModelEvent event2a =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot()},
            new int[] {0},
            new Object[] {ModelType.Consistency});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event2a));
    TreeModelEvent event2b =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot(), ModelType.Consistency},
            new int[] {0},
            new Object[] {cons1});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event2b));
    TreeModelEvent event3a =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot()},
            new int[] {2},
            new Object[] {ModelType.NodeSplit});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event3a));
    TreeModelEvent event3b =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot(), ModelType.NodeSplit},
            new int[] {0},
            new Object[] {splt2});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event3b));
    TreeModelEvent event4 =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot(), ModelType.NodeSplit},
            new int[] {0},
            new Object[] {splt1});
    listener.treeNodesInserted(TreeModelEventMatcher.eqTreeModelEvent(event4));
    TreeModelEvent event5 =
        new TreeModelEvent(
            model,
            new Object[] {model.getRoot()},
            new int[] {0, 1, 2},
            new Object[] {ModelType.Consistency, ModelType.Inconsistency, ModelType.NodeSplit});
    listener.treeNodesRemoved(TreeModelEventMatcher.eqTreeModelEvent(event5));
    EasyMock.replay(listener);

    model.addTreeModelListener(listener);
    model.add(ModelType.Inconsistency, inco1);
    model.add(ModelType.Consistency, cons1);
    model.add(ModelType.NodeSplit, splt2);
    model.add(ModelType.NodeSplit, splt1);
    model.clear();
    model.removeTreeModelListener(listener);

    model.add(ModelType.Inconsistency, inco1);

    EasyMock.verify(listener);
  }