Search in sources :

Example 61 with LogicalFlow

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");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) DataType(org.finos.waltz.model.datatype.DataType) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 62 with LogicalFlow

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());
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 63 with LogicalFlow

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");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 64 with LogicalFlow

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");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 65 with LogicalFlow

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");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) ImmutableAddLogicalFlowCommand(org.finos.waltz.model.logical_flow.ImmutableAddLogicalFlowCommand) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)72 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)52 Test (org.junit.jupiter.api.Test)52 EntityReference (org.finos.waltz.model.EntityReference)40 PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)21 ImmutablePhysicalSpecification (org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification)15 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)13 LogicalFlowService (org.finos.waltz.service.logical_flow.LogicalFlowService)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Collections.emptyList (java.util.Collections.emptyList)12 List (java.util.List)12 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)12 Collection (java.util.Collection)11 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)11 Collections.emptySet (java.util.Collections.emptySet)10 SetUtilities.asSet (org.finos.waltz.common.SetUtilities.asSet)10 Assertions (org.junit.jupiter.api.Assertions)10 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)9 org.finos.waltz.integration_test.inmem.helpers (org.finos.waltz.integration_test.inmem.helpers)9