use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testModelCommands.
@Test
public void testModelCommands() {
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(model);
for (IEntity e : i) {
ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
cmd = ((InternalIEntity) e).wGetLastCommand();
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
}
performChanges(model);
List<ICommand> changes = history.getUndoCommands();
i = IteratorFactory.descendantOrSelfIterator();
i.reset(model);
for (IEntity e : i) {
ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
if (cmd.getKind() != CommandKind.NULL)
Assert.assertTrue(changes.contains(cmd));
cmd = ((InternalIEntity) e).wGetLastCommand();
if (cmd.getKind() != CommandKind.NULL)
Assert.assertTrue(changes.contains(cmd));
}
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testClearHistory.
@Test
public void testClearHistory() {
performChanges(model);
IEntity model2 = EntityUtils.clone(model);
history.clearHistory();
Assert.assertTrue(history.getUndoCommands().isEmpty());
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(model);
for (IEntity e : i) {
ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
cmd = ((InternalIEntity) e).wGetLastCommand();
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
}
Assert.assertTrue(Matcher.match(model2, model));
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testModelNullCommands.
@Test
public void testModelNullCommands() {
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(model);
for (IEntity e : i) {
Assert.assertEquals(NullCommand.instance, ((InternalIEntity) e).wGetBindingCommand());
Assert.assertEquals(NullCommand.instance, ((InternalIEntity) e).wGetLastCommand());
}
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testChangeOrder.
@Test
public void testChangeOrder() {
IEntity e1 = model.getName();
IEntity e2 = model.getNamespace();
e1.wSetValue("newLangName");
e2.wSetValue("newNamespace");
Assert.assertTrue(((InternalIEntity) e1).wGetLastCommand().getExecutionTime() <= ((InternalIEntity) e2).wGetLastCommand().getExecutionTime());
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class LifecycleAPITest method testCommit.
@Test
public void testCommit() {
ITransaction transaction = ReflectionFactory.getTransaction(model);
IEntity e1 = model.wGet(0);
IEntity e2 = model.wGet(3);
transaction.begin();
e1.wSetValue("newLangName");
ICommand c1 = ((InternalIEntity) e1).wGetLastCommand();
e2.wSetValue("newNamespace");
ICommand c2 = ((InternalIEntity) e2).wGetLastCommand();
String langName = e1.wStringValue();
int size = history.getUndoSize();
assertTrue(c1.getExecutionTime() <= c2.getExecutionTime());
transaction.commit();
assertEquals(e1.wStringValue(), langName);
assertTrue(history.getUndoSize() < size);
assertEquals(c1.getExecutionTime(), c2.getExecutionTime());
}
Aggregations