Ejemplo n.º 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));
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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));
  }