use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method testGraphCommandExecuteMultipleEntriesPresent.
@Test
public void testGraphCommandExecuteMultipleEntriesPresent() {
final String EXISTING_ENTRY_NAME = "old one";
final ContextEntry firstEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name(EXISTING_ENTRY_NAME));
}
});
}
};
context.getContextEntry().add(0, firstEntry);
makeCommand();
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(3, context.getContextEntry().size());
assertEquals(firstEntry, context.getContextEntry().get(0));
assertEquals(EXISTING_ENTRY_NAME, firstEntry.getVariable().getName().getValue());
assertEquals(contextEntry, context.getContextEntry().get(1));
assertEquals(ContextEntryDefaultValueUtilities.PREFIX + "1", contextEntry.getVariable().getName().getValue());
assertEquals(defaultResultContextEntry, context.getContextEntry().get(2));
assertEquals(context, contextEntry.getParent());
assertEquals(contextEntry, contextEntry.getVariable().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method testGraphCommandUndoMultipleEntriesPresent.
@Test
public void testGraphCommandUndoMultipleEntriesPresent() {
final ContextEntry firstEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("old one"));
}
});
}
};
context.getContextEntry().add(0, firstEntry);
makeCommand();
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Add column and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertEquals(2, context.getContextEntry().size());
assertEquals(firstEntry, context.getContextEntry().get(0));
assertEquals(defaultResultContextEntry, context.getContextEntry().get(1));
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method testGraphCommandExecuteMultipleRows.
@Test
public void testGraphCommandExecuteMultipleRows() {
addContextEntries(3);
final ContextEntry firstEntry = context.getContextEntry().get(0);
final ContextEntry lastEntry = context.getContextEntry().get(2);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, lastEntry);
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method testGraphCommandUndoMultipleRows.
@Test
public void testGraphCommandUndoMultipleRows() {
addContextEntries(3);
final ContextEntry firstEntry = context.getContextEntry().get(0);
final ContextEntry originalEntry = context.getContextEntry().get(1);
final ContextEntry lastEntry = context.getContextEntry().get(2);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Delete row and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, originalEntry, lastEntry);
}
use of org.kie.workbench.common.dmn.api.definition.model.ContextEntry in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method addContextEntries.
private void addContextEntries(final int entriesCount) {
final int originalRowCount = uiModel.getRowCount();
for (int i = 0; i < originalRowCount; i++) {
uiModel.deleteRow(0);
}
context.getContextEntry().clear();
for (int i = 0; i < entriesCount; i++) {
context.getContextEntry().add(new ContextEntry());
uiModel.appendRow(new BaseGridRow());
}
}
Aggregations