Search in sources :

Example 96 with EntityReference

use of org.finos.waltz.model.EntityReference 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 97 with EntityReference

use of org.finos.waltz.model.EntityReference 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 98 with EntityReference

use of org.finos.waltz.model.EntityReference 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 99 with EntityReference

use of org.finos.waltz.model.EntityReference 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 100 with EntityReference

use of org.finos.waltz.model.EntityReference 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

EntityReference (org.finos.waltz.model.EntityReference)114 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)55 Test (org.junit.jupiter.api.Test)55 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)40 EntityKind (org.finos.waltz.model.EntityKind)23 List (java.util.List)21 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)19 Autowired (org.springframework.beans.factory.annotation.Autowired)17 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)16 Set (java.util.Set)14 Collection (java.util.Collection)13 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)9 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 Collections.emptyList (java.util.Collections.emptyList)7 Collectors (java.util.stream.Collectors)7 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)7