예제 #1
0
 /*
  * ToDo This test should pass but currently the undo manager is broken.
  *
  */
 public void testUndoDeleteSimpleInstance() {
   String value = "hello";
   Cls clsA = createCls();
   Slot slotA = createSlot();
   clsA.addDirectTemplateSlot(slotA);
   Instance i1 = clsA.createDirectInstance("i1");
   i1.setDirectOwnSlotValue(slotA, value);
   assertEquals(value, i1.getDirectOwnSlotValue(slotA));
   _frameStore.deleteSimpleInstance((SimpleInstance) i1);
   _frameStore.undo();
   assertEquals(value, i1.getDirectOwnSlotValue(slotA));
 }
예제 #2
0
 public void testUndoCreateSlot() {
   Slot slot = createSlot();
   String name = slot.getName();
   assertNotNull("name", name);
   Frame frame = getFrame(name);
   assertEquals("created", slot, frame);
   assertTrue("can undo", _frameStore.canUndo());
   _frameStore.undo();
   frame = getFrame(name);
   assertNull("undone", frame);
   _frameStore.redo();
   frame = getFrame(name);
   assertEquals("recreated", frame.getName(), name);
 }
예제 #3
0
 public void testUndocreateCls() {
   Cls cls = createCls();
   String name = cls.getName();
   assertNotNull("name", name);
   Frame frame = getFrame(name);
   assertEquals("created", cls, frame);
   assertTrue("can undo", _frameStore.canUndo());
   _frameStore.undo();
   frame = getFrame(name);
   assertNull("undone", frame);
   _frameStore.redo();
   frame = getFrame(name);
   assertEquals("recreated", frame.getName(), name);
 }
예제 #4
0
 public void testUndoCreateSimpleInstance() {
   Cls cls = createCls();
   Instance instance = createSimpleInstance(cls);
   String name = instance.getName();
   assertNotNull("name", name);
   Frame frame = getFrame(name);
   assertEquals("created", instance, frame);
   assertTrue("can undo", _frameStore.canUndo());
   _frameStore.undo();
   frame = getFrame(name);
   assertNull("undone", frame);
   _frameStore.redo();
   instance = (Instance) getFrame(name);
   assertEquals("recreated", instance.getName(), name);
 }
예제 #5
0
  public void testUndoDeleteSlot() {
    String templateSlotValue = "restricted";
    String slotValue = "something";
    Cls cls = createCls();
    Slot slot = createSlot();
    cls.addDirectTemplateSlot(slot);
    _frameStore.setDirectTemplateSlotValues(cls, slot, Collections.singleton(templateSlotValue));
    SimpleInstance i = createSimpleInstance(cls);
    i.setDirectOwnSlotValue(slot, slotValue);

    assertTrue(_frameStore.getTemplateSlotValues(cls, slot).size() == 1);
    assertTrue(_frameStore.getTemplateSlotValues(cls, slot).contains(templateSlotValue));
    assertTrue(i.getDirectOwnSlotValues(slot).size() == 1);
    assertTrue(i.getDirectOwnSlotValue(slot).equals(slotValue));

    _frameStore.deleteSlot(slot);
    _frameStore.undo();

    assertTrue(_frameStore.getTemplateSlotValues(cls, slot).size() == 1);
    assertTrue(_frameStore.getTemplateSlotValues(cls, slot).contains(templateSlotValue));
    assertTrue(i.getDirectOwnSlotValues(slot).size() == 1);
    assertTrue(i.getDirectOwnSlotValue(slot).equals(slotValue));
  }
예제 #6
0
 public void testUndoSimpleTransaction() {
   Cls cls = createCls();
   Slot slot1 = createSlot();
   Slot slot2 = createSlot();
   cls.addDirectTemplateSlot(slot1);
   cls.addDirectTemplateSlot(slot2);
   Instance instance = cls.createDirectInstance(null);
   _frameStore.beginTransaction("simple nonsense");
   _frameStore.setDirectOwnSlotValues(instance, slot1, makeList("foo1"));
   _frameStore.setDirectOwnSlotValues(instance, slot2, makeList("foo2"));
   _frameStore.commitTransaction();
   assertEqualsList(makeList("foo1"), _frameStore.getDirectOwnSlotValues(instance, slot1));
   assertEqualsList(makeList("foo2"), _frameStore.getDirectOwnSlotValues(instance, slot2));
   _frameStore.undo();
   assertEqualsList(makeList(), _frameStore.getDirectOwnSlotValues(instance, slot1));
   assertEqualsList(makeList(), _frameStore.getDirectOwnSlotValues(instance, slot2));
   _frameStore.redo();
   assertEqualsList(makeList("foo1"), _frameStore.getDirectOwnSlotValues(instance, slot1));
   assertEqualsList(makeList("foo2"), _frameStore.getDirectOwnSlotValues(instance, slot2));
 }
예제 #7
0
  public void testUndoDeleteCls() {
    Cls clsA = createCls();
    Cls clsB = createCls();
    Cls clsA1 = createCls(clsA);
    Cls clsB1 = createCls(clsB);
    Cls clsAB2 = createCls(clsA1);
    _frameStore.addDirectSuperclass(clsAB2, clsB1);
    Cls clsAB3 = createCls(clsAB2);
    int count = _frameStore.getFrames().size();
    _frameStore.deleteCls(clsAB3);
    int newCount = _frameStore.getFrames().size();
    assertEquals("first count", count - 1, newCount);
    _frameStore.undo();
    newCount = _frameStore.getFrames().size();
    assertEquals("second count", count, newCount);
    _frameStore.redo();
    newCount = _frameStore.getFrames().size();
    assertEquals("third count", count - 1, newCount);
    _frameStore.undo();
    newCount = _frameStore.getFrames().size();
    assertEquals("forth count", count, newCount);

    String clsAName = _frameStore.getFrameName(clsA);
    _frameStore.deleteCls(clsA1);
    _frameStore.deleteCls(clsA);
    newCount = _frameStore.getFrames().size();
    assertEquals("fifth count", count - 2, newCount);
    _frameStore.undo();
    _frameStore.undo();
    newCount = _frameStore.getFrames().size();
    assertEquals("sixth count", count, newCount);
    Frame frame = _frameStore.getFrame(clsAName);
    assertNotNull("clsA", frame);
  }
예제 #8
0
 public FrameStore createFrameStore(DefaultKnowledgeBase kb) {
   // _frameStore = new UndoFrameStore(true);
   _frameStore = new UndoFrameStore();
   _frameStore.setDelegate(new InMemoryFrameStore(kb));
   return _frameStore;
 }