Search in sources :

Example 1 with SetHasValueCommand

use of org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand in project kie-wb-common by kiegroup.

the class ExpressionContainerGridTest method testSpyHasNameUpdateUndoWithSetHasNameCommand.

@Test
public void testSpyHasNameUpdateUndoWithSetHasNameCommand() {
    grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
    final Optional<HasName> spy = grid.spyHasName(Optional.of(hasName));
    final Name newName = new Name("new-name");
    final Name oldName = spy.get().getName();
    final org.uberfire.mvp.Command canvasOperation = mock(org.uberfire.mvp.Command.class);
    final SetHasValueCommand command = new SetHasValueCommand<>(spy.get(), newName, canvasOperation);
    command.execute(canvasHandler);
    spy.ifPresent(name -> assertThat(name.getName().getValue()).isEqualTo(newName.getValue()));
    command.undo(canvasHandler);
    spy.ifPresent(name -> assertThat(name.getName().getValue()).isEqualTo(oldName.getValue()));
}
Also used : SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Command(org.uberfire.mvp.Command) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 SetHasValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand)1 Command (org.uberfire.mvp.Command)1