use of org.osate.ge.internal.operations.OperationExecutor in project osate2 by osate.
the class OperationTest method testMapWithoutodify.
@Test
public void testMapWithoutodify() {
DefaultOperationBuilder rootOpBuilder = new DefaultOperationBuilder();
final OperationBuilder<Integer> b = rootOpBuilder.map(arg -> StepResultBuilder.create(1).build());
b.map(pr -> StepResultBuilder.create().showNewBusinessObject(stubBoc, Integer.valueOf(100)).build());
final Step firstStep = rootOpBuilder.build();
final OperationExecutor executor = new OperationExecutor(modificationService, referenceBuilder);
final OperationResults results = executor.execute(firstStep);
// Verify that result was created from the map after the modification
final ImmutableSet<Integer> expectedBosToShow = ImmutableSet.of(100);
final Set<?> bosToShow = results.getContainerToBoToShowDetailsMap().values().stream().map(v -> v.bo).collect(Collectors.toSet());
assertEquals(expectedBosToShow, bosToShow);
}
use of org.osate.ge.internal.operations.OperationExecutor in project osate2 by osate.
the class OperationTest method testAbort.
@Test
public void testAbort() {
final DefaultOperationBuilder rootOpBuilder = new DefaultOperationBuilder();
final OperationBuilder<Integer> b = rootOpBuilder.map(arg -> StepResultBuilder.create(1).build());
final AtomicBoolean executed = new AtomicBoolean(false);
b.map(pr -> StepResultBuilder.create(pr + 2).build()).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
return StepResultBuilder.create(prevResult + 1).abort().build();
}).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
executed.set(true);
return StepResultBuilder.create().showNewBusinessObject(stubBoc, prevResult + 2).build();
});
final Step firstStep = rootOpBuilder.build();
final OperationExecutor executor = new OperationExecutor(modificationService, referenceBuilder);
executor.execute(firstStep);
assertEquals(false, executed.get());
}
use of org.osate.ge.internal.operations.OperationExecutor in project osate2 by osate.
the class OperationTest method testMapAfterModify.
@Test
public void testMapAfterModify() {
DefaultOperationBuilder rootOpBuilder = new DefaultOperationBuilder();
final OperationBuilder<Integer> b = rootOpBuilder.map(arg -> StepResultBuilder.create(1).build());
b.map(pr -> StepResultBuilder.create(pr + 2).build()).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
return StepResultBuilder.create(prevResult + 1).build();
}).map(pr -> StepResultBuilder.create().showNewBusinessObject(stubBoc, Integer.valueOf(100)).build());
final Step firstStep = rootOpBuilder.build();
final OperationExecutor executor = new OperationExecutor(modificationService, referenceBuilder);
final OperationResults results = executor.execute(firstStep);
// Verify that result was created from the map after the modification
final ImmutableSet<Integer> expectedBosToShow = ImmutableSet.of(100);
final Set<?> bosToShow = results.getContainerToBoToShowDetailsMap().values().stream().map(v -> v.bo).collect(Collectors.toSet());
assertEquals(expectedBosToShow, bosToShow);
}
use of org.osate.ge.internal.operations.OperationExecutor in project osate2 by osate.
the class OperationTest method testSplitAbort.
@Test
public void testSplitAbort() {
final DefaultOperationBuilder rootOpBuilder = new DefaultOperationBuilder();
final OperationBuilder<Integer> b = rootOpBuilder.map(arg -> StepResultBuilder.create(1).build());
final AtomicBoolean executed = new AtomicBoolean(false);
b.map(pr -> StepResultBuilder.create(pr + 2).build()).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
return StepResultBuilder.create(prevResult + 1).abort().build();
}).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
executed.set(true);
return StepResultBuilder.create().showNewBusinessObject(stubBoc, prevResult + 2).build();
});
b.map(pr -> StepResultBuilder.create(pr + 6).build()).modifyModel(null, (tag, prevResult) -> testBo, (tag, boToModify, prevResult) -> {
executed.set(true);
return StepResultBuilder.create().showNewBusinessObject(stubBoc, prevResult + 3).build();
});
final Step firstStep = rootOpBuilder.build();
final OperationExecutor executor = new OperationExecutor(modificationService, referenceBuilder);
executor.execute(firstStep);
assertEquals(false, executed.get());
}
Aggregations