Search in sources :

Example 1 with InternalIEntity

use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testPrevCommandExecutionTimeOrder.

// The entity local history of binding commands is ordered
// invariant: for each cmd, cmd.prevCommand.executionTime <= cmd.executionTime
@Test
public void testPrevCommandExecutionTimeOrder() {
    performChanges(model);
    IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
    i.reset(model);
    for (IEntity e : i) {
        ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
        while (cmd.getKind() != CommandKind.NULL) {
            ICommand cmd1 = cmd.getPrevCommand();
            Assert.assertTrue(cmd1.getExecutionTime() <= cmd.getExecutionTime());
            cmd = cmd1;
        }
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Example 2 with InternalIEntity

use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testUndo.

@Test
public void testUndo() {
    InternalIEntity e1 = (InternalIEntity) model.getName();
    e1.wSetValue("newLangName1");
    ICommand c1 = e1.wGetLastCommand();
    e1.wSetValue("newLangName2");
    ICommand c2 = e1.wGetLastCommand();
    e1.wSetValue("newLangName3");
    Assert.assertNotSame(c1, e1.wGetLastCommand());
    history.undo();
    Assert.assertEquals(e1.wStringValue(), "newLangName2");
    Assert.assertEquals(e1.wGetLastCommand(), c2);
    history.undo();
    Assert.assertEquals(e1.wStringValue(), "newLangName1");
    Assert.assertEquals(e1.wGetLastCommand(), c1);
}
Also used : InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Example 3 with InternalIEntity

use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testLastCommand.

@Test
public void testLastCommand() {
    IEntity e1 = model.getName();
    e1.wSetValue("newLangName");
    ICommand c1 = ((InternalIEntity) e1).wGetLastCommand();
    List<ICommand> changes = history.getUndoCommands();
    ICommand lastCmd = (ICommand) changes.get(changes.size() - 1);
    Assert.assertSame(lastCmd, c1);
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Example 4 with InternalIEntity

use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testUndoRedo.

@Test
public void testUndoRedo() {
    InternalIEntity e1 = (InternalIEntity) model.getName();
    e1.wSetValue("newLangName1");
    ICommand c1 = e1.wGetLastCommand();
    e1.wSetValue("newLangName2");
    ICommand c2 = e1.wGetLastCommand();
    history.undo();
    Assert.assertEquals(e1.wStringValue(), "newLangName1");
    Assert.assertEquals(e1.wGetLastCommand(), c1);
    history.redo();
    Assert.assertEquals(e1.wStringValue(), "newLangName2");
    Assert.assertEquals(e1.wGetLastCommand(), c2);
}
Also used : InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Example 5 with InternalIEntity

use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testUndoSet.

@Test
public void testUndoSet() {
    InternalIEntity e1 = (InternalIEntity) model.getName();
    e1.wSetValue("newLangName1");
    ICommand c1 = e1.wGetLastCommand();
    e1.wSetValue("newLangName2");
    ICommand c2 = e1.wGetLastCommand();
    Assert.assertNotSame(c2, c1);
    history.undo();
    e1.wSetValue("newLangName3");
    Assert.assertSame(e1.wGetLastCommand().getPrevCommand(), c1);
}
Also used : InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Aggregations

InternalIEntity (org.whole.lang.model.InternalIEntity)25 IEntity (org.whole.lang.model.IEntity)19 Test (org.junit.Test)13 ICommand (org.whole.lang.commands.ICommand)6 IFragmentModel (org.whole.lang.model.IFragmentModel)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 Serializable (java.io.Serializable)1 Category (org.junit.experimental.categories.Category)1 ITransactionScope (org.whole.lang.bindings.ITransactionScope)1 QuantifierEnum (org.whole.lang.commons.model.QuantifierEnum)1 Variable (org.whole.lang.commons.model.Variable)1 SubstituteException (org.whole.lang.matchers.SubstituteException)1