Search in sources :

Example 1 with LogicalFlow

use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.

the class LogicalFlowServiceTest method findUpstreamFlowsForEntityReferences.

@Test
public void findUpstreamFlowsForEntityReferences() {
    helper.clearAllFlows();
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    EntityReference c = appHelper.createNewApp("c", ouIds.b);
    EntityReference d = appHelper.createNewApp("d", ouIds.b);
    helper.createLogicalFlow(a, b);
    helper.createLogicalFlow(c, b);
    helper.createLogicalFlow(b, c);
    helper.createLogicalFlow(b, d);
    Collection<LogicalFlow> upstreamFlowsForEmptyList = lfSvc.findUpstreamFlowsForEntityReferences(emptyList());
    assertTrue(isEmpty(upstreamFlowsForEmptyList), "No upstreams when no ref provided");
    Collection<LogicalFlow> upstreamsWhereOnlySource = lfSvc.findUpstreamFlowsForEntityReferences(asList(a));
    assertEquals(0, upstreamsWhereOnlySource.size(), "No upstreams when all refs are only targets");
    Collection<LogicalFlow> allUpstreams = lfSvc.findUpstreamFlowsForEntityReferences(asList(b, c));
    assertEquals(3, allUpstreams.size(), "Returns all upstreams but not downstreams");
}
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 2 with LogicalFlow

use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.

the class PhysicalFlowServiceTest method findByProducerEntityReference.

@Test
public void findByProducerEntityReference() {
    assertThrows(IllegalArgumentException.class, () -> pfSvc.findByProducerEntityReference(null), "Null entity reference throws an IllegalArgumentException");
    List<PhysicalFlow> entityNotExists = pfSvc.findByProducerEntityReference(mkRef(EntityKind.APPLICATION, -1));
    assertEquals(emptyList(), entityNotExists, "Returns empty list when entity doesn't exist");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    EntityReference c = appHelper.createNewApp("c", ouIds.b);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    LogicalFlow ac = lfHelper.createLogicalFlow(a, c);
    LogicalFlow ca = lfHelper.createLogicalFlow(c, a);
    Long specId = psHelper.createPhysicalSpec(a, "findByExternalId");
    PhysicalFlowCreateCommandResponse physicalFlowResponse1 = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findByProducerEntityReference"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse2 = pfHelper.createPhysicalFlow(ac.entityReference().id(), specId, mkName("findByProducerEntityReference"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse3 = pfHelper.createPhysicalFlow(ca.entityReference().id(), specId, mkName("findByProducerEntityReference"));
    List<PhysicalFlow> physicalsDownstreamOfA = pfSvc.findByProducerEntityReference(a);
    assertEquals(2, physicalsDownstreamOfA.size(), "Returns all flows downstream of a but not upstream flows");
    assertEquals(asSet(physicalFlowResponse1.entityReference().id(), physicalFlowResponse2.entityReference().id()), map(physicalsDownstreamOfA, d -> d.entityReference().id()), "Returns expected flows downstream of a");
    List<PhysicalFlow> physicalsDownstreamOfC = pfSvc.findByProducerEntityReference(c);
    assertEquals(asSet(physicalFlowResponse3.entityReference().id()), map(physicalsDownstreamOfC, d -> d.entityReference().id()), "Returns expected flows downstream of c");
    List<PhysicalFlow> physicalsDownstreamOfB = pfSvc.findByProducerEntityReference(b);
    assertEquals(emptySet(), map(physicalsDownstreamOfB, d -> d.entityReference().id()), "Returns expected flows downstream of b");
}
Also used : org.finos.waltz.model(org.finos.waltz.model) ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) CommandOutcome(org.finos.waltz.model.command.CommandOutcome) PhysicalSpecificationService(org.finos.waltz.service.physical_specification.PhysicalSpecificationService) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) NameHelper.mkName(org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkName) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) DataFormatKind(org.finos.waltz.model.physical_specification.DataFormatKind) ImmutablePhysicalSpecificationDeleteCommand(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecificationDeleteCommand) ImmutablePhysicalSpecDefinitionChangeCommand(org.finos.waltz.model.physical_specification_definition.ImmutablePhysicalSpecDefinitionChangeCommand) org.finos.waltz.integration_test.inmem.helpers(org.finos.waltz.integration_test.inmem.helpers) PhysicalFlowService(org.finos.waltz.service.physical_flow.PhysicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) CollectionUtilities.isEmpty(org.finos.waltz.common.CollectionUtilities.isEmpty) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Collections.emptyList(java.util.Collections.emptyList) PhysicalSpecDefinitionType(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinitionType) Collection(java.util.Collection) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) org.finos.waltz.model.physical_flow(org.finos.waltz.model.physical_flow) Test(org.junit.jupiter.api.Test) List(java.util.List) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) PhysicalSpecDefinitionService(org.finos.waltz.service.physical_specification_definition.PhysicalSpecDefinitionService) Assertions(org.junit.jupiter.api.Assertions) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) Optional(java.util.Optional) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with LogicalFlow

use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.

the class PhysicalFlowServiceTest method delete.

@Test
public void delete() {
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, mkName("delete"));
    PhysicalFlowCreateCommandResponse physFlow = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("delete"));
    assertThrows(IllegalArgumentException.class, () -> pfSvc.delete(null, mkName("deletingFlow")), "Should throw exception if passed in a null phys flow id");
    PhysicalFlowDeleteCommandResponse invalidFlowIdResp = pfSvc.delete(ImmutablePhysicalFlowDeleteCommand.builder().flowId(-1).build(), mkName("deletingFlow"));
    assertEquals(CommandOutcome.FAILURE, invalidFlowIdResp.outcome(), "Should return failure if the flow does not exist");
    PhysicalFlowDeleteCommandResponse deletedFlowResp = pfSvc.delete(ImmutablePhysicalFlowDeleteCommand.builder().flowId(physFlow.entityReference().id()).build(), mkName("deletingFlow"));
    PhysicalFlow physicalFlowAfterDeletion = pfSvc.getById(physFlow.entityReference().id());
    assertEquals(CommandOutcome.SUCCESS, deletedFlowResp.outcome(), "Should be successful if flow was deleted");
    assertTrue(physicalFlowAfterDeletion.isRemoved(), "Physical flow should be soft deleted with isRemoved set true");
    PhysicalFlowDeleteCommandResponse reDeletingFlowResp = pfSvc.delete(ImmutablePhysicalFlowDeleteCommand.builder().flowId(physFlow.entityReference().id()).build(), mkName("deletingFlow"));
    assertEquals(CommandOutcome.FAILURE, reDeletingFlowResp.outcome(), "Should fail when trying to delete a flow that is already removed");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with LogicalFlow

use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.

the class PhysicalFlowServiceTest method updateAttribute.

@Test
public void updateAttribute() {
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, mkName("updateAttribute"));
    PhysicalSpecification spec = psSvc.getById(specId);
    ImmutableFlowAttributes flowAttributes = ImmutableFlowAttributes.builder().transport(TransportKindValue.UNKNOWN).description("before").basisOffset(1).criticality(Criticality.MEDIUM).frequency(FrequencyKind.DAILY).build();
    ImmutablePhysicalFlowCreateCommand createCmd = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(spec).flowAttributes(flowAttributes).build();
    PhysicalFlowCreateCommandResponse flowResp = pfSvc.create(createCmd, mkName("updateAttribute"));
    assertThrows(UnsupportedOperationException.class, () -> pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("invalidAttr").entityReference(flowResp.entityReference()).value("invalid").build()), "If attribute name is not recognised throw exception");
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("description").entityReference(flowResp.entityReference()).value("after").build());
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("frequency").entityReference(flowResp.entityReference()).value("MONTHLY").build());
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("criticality").entityReference(flowResp.entityReference()).value("LOW").build());
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("entity_lifecycle_status").entityReference(flowResp.entityReference()).value("REMOVED").build());
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("basisOffset").entityReference(flowResp.entityReference()).value("0").build());
    pfSvc.updateAttribute(mkName("updateAttribute"), ImmutableSetAttributeCommand.builder().name("transport").entityReference(flowResp.entityReference()).value("OTHER").build());
    PhysicalFlow physFlowAfterUpdates = pfSvc.getById(flowResp.entityReference().id());
    assertEquals("after", physFlowAfterUpdates.description(), "Description should be updated after updateAttribute");
    assertEquals(FrequencyKind.MONTHLY, physFlowAfterUpdates.frequency(), "Frequency should be updated after updateAttribute");
    assertEquals(TransportKindValue.of("OTHER"), physFlowAfterUpdates.transport(), "Transport should be updated after updateAttribute");
    assertEquals(0, physFlowAfterUpdates.basisOffset(), "Basis offset should be updated after updateAttribute");
    assertEquals(EntityLifecycleStatus.REMOVED, physFlowAfterUpdates.entityLifecycleStatus(), "EntityLifecycleStatus should be updated after updateAttribute");
    assertEquals(Criticality.LOW, physFlowAfterUpdates.criticality(), "Criticality should be updated after updateAttribute");
}
Also used : ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with LogicalFlow

use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.

the class PhysicalFlowServiceTest method findByEntityReference.

@Test
public void findByEntityReference() {
    assertThrows(IllegalArgumentException.class, () -> pfSvc.findByEntityReference(null), "Null entity reference throws an IllegalArgumentException");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    EntityReference c = appHelper.createNewApp("c", ouIds.b);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    LogicalFlow ac = lfHelper.createLogicalFlow(a, c);
    Long specId = psHelper.createPhysicalSpec(a, "findByExternalId");
    PhysicalFlowCreateCommandResponse physicalFlowResponse1 = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findByExternalId"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse2 = pfHelper.createPhysicalFlow(ac.entityReference().id(), specId, mkName("findByExternalId"));
    List<PhysicalFlow> entityNotExists = pfSvc.findByEntityReference(mkRef(EntityKind.APPLICATION, -1));
    assertEquals(emptyList(), entityNotExists, "Returns empty list when entity doesn't exist");
    List<PhysicalFlow> entityExists = pfSvc.findByEntityReference(mkRef(EntityKind.APPLICATION, a.id()));
    assertEquals(2, entityExists.size(), "Returns correct number of flows for entity");
    assertEquals(asSet(physicalFlowResponse1.entityReference().id(), physicalFlowResponse2.entityReference().id()), map(entityExists, d -> d.entityReference().id()), "Returns correct flows for entity");
    List<PhysicalFlow> correctFlowsForEntity = pfSvc.findByEntityReference(mkRef(EntityKind.APPLICATION, b.id()));
    assertEquals(1, correctFlowsForEntity.size(), "Returns correct number of flows for entity");
    assertEquals(asSet(physicalFlowResponse1.entityReference().id()), map(correctFlowsForEntity, d -> d.entityReference().id()), "Returns correct flows for entity");
}
Also used : org.finos.waltz.model(org.finos.waltz.model) ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) CommandOutcome(org.finos.waltz.model.command.CommandOutcome) PhysicalSpecificationService(org.finos.waltz.service.physical_specification.PhysicalSpecificationService) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) NameHelper.mkName(org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkName) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) DataFormatKind(org.finos.waltz.model.physical_specification.DataFormatKind) ImmutablePhysicalSpecificationDeleteCommand(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecificationDeleteCommand) ImmutablePhysicalSpecDefinitionChangeCommand(org.finos.waltz.model.physical_specification_definition.ImmutablePhysicalSpecDefinitionChangeCommand) org.finos.waltz.integration_test.inmem.helpers(org.finos.waltz.integration_test.inmem.helpers) PhysicalFlowService(org.finos.waltz.service.physical_flow.PhysicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) CollectionUtilities.isEmpty(org.finos.waltz.common.CollectionUtilities.isEmpty) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Collections.emptyList(java.util.Collections.emptyList) PhysicalSpecDefinitionType(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinitionType) Collection(java.util.Collection) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) org.finos.waltz.model.physical_flow(org.finos.waltz.model.physical_flow) Test(org.junit.jupiter.api.Test) List(java.util.List) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) PhysicalSpecDefinitionService(org.finos.waltz.service.physical_specification_definition.PhysicalSpecDefinitionService) Assertions(org.junit.jupiter.api.Assertions) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) Optional(java.util.Optional) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) 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