use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class DataTypeServiceTest method findSuggestedBySourceEntityRef.
@Test
public void findSuggestedBySourceEntityRef() {
dataTypeHelper.clearAllDataTypes();
EntityReference a = appHelper.createNewApp("a", ouIds.a);
EntityReference b = appHelper.createNewApp("b", ouIds.a1);
EntityReference c = appHelper.createNewApp("b", ouIds.b);
Collection<DataType> noDecoratorsOnFlow = dtSvc.findSuggestedBySourceEntityRef(a);
assertEquals(emptyList(), noDecoratorsOnFlow, "if source app has no logical flows returns empty list");
LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
assertEquals(emptyList(), noDecoratorsOnFlow, "if source app has no flow decorators returns empty list");
dataTypeHelper.createDataType(1L, "dt1", "DT1");
lfHelper.createLogicalFlowDecorators(ab.entityReference(), asSet(1L));
Set<Long> suggestedDtIds = map(dtSvc.findSuggestedBySourceEntityRef(a), dtd -> dtd.entityReference().id());
assertEquals(asSet(1L), suggestedDtIds, "returns data type associated to the source application");
LogicalFlow bc = lfHelper.createLogicalFlow(b, c);
dataTypeHelper.createDataType(2L, "dt2", "DT2");
lfHelper.createLogicalFlowDecorators(bc.entityReference(), asSet(2L));
Set<Long> onlySourceDts = map(dtSvc.findSuggestedBySourceEntityRef(a), dtd -> dtd.entityReference().id());
assertEquals(asSet(1L), onlySourceDts, "does not return dts associated to only the target app");
lfHelper.createLogicalFlowDecorators(ab.entityReference(), asSet(2L));
Set<Long> allSourceDts = map(dtSvc.findSuggestedBySourceEntityRef(a), dtd -> dtd.entityReference().id());
assertEquals(asSet(1L, 2L), allSourceDts, "returns all dts associated to source app");
LogicalFlow ac = lfHelper.createLogicalFlow(a, c);
lfHelper.createLogicalFlowDecorators(ac.entityReference(), asSet(2L));
Set<Long> setOfDts = map(dtSvc.findSuggestedBySourceEntityRef(a), dtd -> dtd.entityReference().id());
assertEquals(asSet(1L, 2L), setOfDts, "returns all dts associated to source app");
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class LogicalFlowServiceTest method findBySourceAndTargetEntityReferences.
@Test
public void findBySourceAndTargetEntityReferences() {
EntityReference a = appHelper.createNewApp("a", ouIds.a);
EntityReference b = appHelper.createNewApp("b", ouIds.a1);
EntityReference c = appHelper.createNewApp("c", ouIds.b);
// a -> b
// a -> c
LogicalFlow ab = helper.createLogicalFlow(a, b);
LogicalFlow ac = helper.createLogicalFlow(a, c);
Tuple2<EntityReference, EntityReference> abSrcTarget = tuple(a, b);
Tuple2<EntityReference, EntityReference> acSrcTarget = tuple(a, c);
Tuple2<EntityReference, EntityReference> bcSrcTarget = tuple(b, c);
List<LogicalFlow> flowsFromEmptySearch = lfSvc.findBySourceAndTargetEntityReferences(emptyList());
assertEquals(emptyList(), flowsFromEmptySearch);
List<LogicalFlow> abFlowSearch = lfSvc.findBySourceAndTargetEntityReferences(asList(abSrcTarget));
assertEquals(1, abFlowSearch.size());
List<LogicalFlow> abacFlowSearch = lfSvc.findBySourceAndTargetEntityReferences(asList(abSrcTarget, acSrcTarget));
assertEquals(2, abacFlowSearch.size());
List<LogicalFlow> flowSearchWhereSrcTrgNotFound = lfSvc.findBySourceAndTargetEntityReferences(asList(abSrcTarget, acSrcTarget, bcSrcTarget));
assertEquals(2, flowSearchWhereSrcTrgNotFound.size());
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class LogicalFlowServiceTest method restoreFlow.
@Test
public void restoreFlow() {
EntityReference a = appHelper.createNewApp("a", ouIds.a);
EntityReference b = appHelper.createNewApp("b", ouIds.a1);
EntityReference c = appHelper.createNewApp("c", ouIds.b);
LogicalFlow ab = helper.createLogicalFlow(a, b);
lfSvc.removeFlow(ab.id().get(), "restoreFlowTest");
boolean restoreInvalid = lfSvc.restoreFlow(-1, "restoreFlowTest");
assertFalse(restoreInvalid, "Cannot restore a flow that doesn't exist");
boolean restoredFlow = lfSvc.restoreFlow(ab.id().get(), "restoreFlowTest");
assertTrue(restoredFlow, "Restores flow if exists");
LogicalFlow flow = lfSvc.getById(ab.id().get());
assertNotEquals("Restored flow should not have a lifecycle status of 'REMOVED'", EntityLifecycleStatus.REMOVED.name(), flow.entityLifecycleStatus().name());
assertFalse(flow.isRemoved(), "Restored flow should not be removed");
assertEquals("restoreFlowTest", flow.lastUpdatedBy(), "Restored flow should have last updated by user");
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class LogicalFlowServiceTest method getByIdTest.
@Test
public void getByIdTest() {
EntityReference a = appHelper.createNewApp("a", ouIds.a);
EntityReference b = appHelper.createNewApp("b", ouIds.a1);
// a -> b
// a -> c
LogicalFlow ab = helper.createLogicalFlow(a, b);
LogicalFlow logFlow = lfSvc.getById(ab.id().get());
assertEquals(ab.source(), logFlow.source(), "Retrieved flow has correct source");
assertEquals(ab.target(), logFlow.target(), "Retrieved flow has correct target");
LogicalFlow impossibleIdFlow = lfSvc.getById(-1L);
assertNull(impossibleIdFlow, "Returns null if id not found");
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class LogicalFlowServiceTest method addFlow.
@Test
public void addFlow() {
EntityReference a = appHelper.createNewApp("a", ouIds.a);
EntityReference b = appHelper.createNewApp("b", ouIds.a1);
dataTypeHelper.createUnknownDatatype();
ImmutableAddLogicalFlowCommand createLoopCommand = ImmutableAddLogicalFlowCommand.builder().source(a).target(a).build();
ImmutableAddLogicalFlowCommand createCommand = ImmutableAddLogicalFlowCommand.builder().source(a).target(b).build();
assertThrows(IllegalArgumentException.class, () -> lfSvc.addFlow(createLoopCommand, "addFlowTest"), "If source and target are the same, flow rejected and exception thrown");
LogicalFlow newFlow = lfSvc.addFlow(createCommand, "addFlowTest");
assertEquals(a, newFlow.source(), "Flow created should have the same source as in the create command");
assertEquals(b, newFlow.target(), "Flow created should have the same target as in the create command");
assertEquals("addFlowTest", newFlow.lastUpdatedBy(), "Flow created should have the user as the last updated by value");
}
Aggregations