Search in sources :

Example 6 with LogicalFlow

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

the class PhysicalFlowServiceTest method updateSpecDefinitionId.

@Test
public void updateSpecDefinitionId() {
    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("updateSpecDefinitionId"));
    long specDefnId = psdSvc.create(mkName("updateSpecDefinitionId"), specId, ImmutablePhysicalSpecDefinitionChangeCommand.builder().version("updateSpecDefinitionId").type(PhysicalSpecDefinitionType.DELIMITED).status(ReleaseLifecycleStatus.ACTIVE).delimiter(";").build());
    PhysicalFlowCreateCommandResponse flowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("updateSpecDefinitionId"));
    PhysicalFlow physicalFlow = pfSvc.getById(flowCreateResp.entityReference().id());
    assertEquals(Optional.empty(), physicalFlow.specificationDefinitionId(), "Check the physical flow has been created without correct spec id");
    assertThrows(IllegalArgumentException.class, () -> pfSvc.updateSpecDefinitionId(mkName("updateSpecDefinitionId"), physicalFlow.id().get(), null), "Should throw an IllegalArgumentException if the update command is null");
    int updated = pfSvc.updateSpecDefinitionId(mkName("updateSpecDefinitionId"), physicalFlow.id().get(), ImmutablePhysicalFlowSpecDefinitionChangeCommand.builder().newSpecDefinitionId(specDefnId).build());
    assertEquals(1, updated, "Should successfully update the specification id to the new spec");
    PhysicalFlow flowWithNewSpec = pfSvc.getById(flowCreateResp.entityReference().id());
    assertEquals(Long.valueOf(specDefnId), flowWithNewSpec.specificationDefinitionId().get(), "Should successfully update the specification id to the new spec");
}
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 7 with LogicalFlow

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

the class PhysicalFlowServiceTest method create_allowsSimilarFlowToBeCreatedIfOriginalWasRemoved.

@Test
public void create_allowsSimilarFlowToBeCreatedIfOriginalWasRemoved() {
    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"));
    PhysicalSpecification spec = psSvc.getById(specId);
    assertThrows(IllegalArgumentException.class, () -> pfSvc.create(null, mkName("create")), "Should throw exception if null object passed into create");
    ImmutableFlowAttributes flowAttrs = ImmutableFlowAttributes.builder().frequency(FrequencyKind.DAILY).criticality(Criticality.MEDIUM).transport(TransportKindValue.UNKNOWN).basisOffset(0).build();
    ImmutablePhysicalFlowCreateCommand createCommand = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(spec).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse firstCreateResp = pfSvc.create(createCommand, mkName("createAllowsSimilarToBeCreatedInFuture"));
    PhysicalFlowDeleteCommandResponse deleteResp = pfHelper.deletePhysicalFlow(firstCreateResp.entityReference().id());
    PhysicalFlowCreateCommandResponse secondCreateResp = pfSvc.create(createCommand, mkName("createAllowsSimilarToBeCreatedInFuture"));
    PhysicalFlow pf1 = pfSvc.getById(firstCreateResp.entityReference().id());
    PhysicalFlow pf2 = pfSvc.getById(secondCreateResp.entityReference().id());
    assertTrue(pf1.isRemoved(), "First flows should remain removed");
    assertFalse(pf2.isRemoved(), "Second flow should be active");
    assertEquals(CommandOutcome.SUCCESS, secondCreateResp.outcome(), "Can successfully create physical flows sharing attributes if the first physical similar was removed");
}
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 8 with LogicalFlow

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

the class PhysicalFlowServiceTest method findUnderlyingPhysicalFlows.

@Test
public void findUnderlyingPhysicalFlows() {
    Collection<PhysicalFlowInfo> underlyingPhysicalFlowsWhenLogicalNull = pfSvc.findUnderlyingPhysicalFlows(null);
    assertTrue(isEmpty(underlyingPhysicalFlowsWhenLogicalNull), "If null logical flow id then returns empty list");
    Collection<PhysicalFlowInfo> underlyingPhysicalFlowsWhenLogicalDoesntExist = pfSvc.findUnderlyingPhysicalFlows(-1L);
    assertTrue(isEmpty(underlyingPhysicalFlowsWhenLogicalDoesntExist), "If invalid logical flow id then returns empty list");
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Collection<PhysicalFlowInfo> noPhysicalsAssociated = pfSvc.findUnderlyingPhysicalFlows(ab.entityReference().id());
    assertTrue(isEmpty(noPhysicalsAssociated), "If no physicals associated to the logical then returns empty list");
    Long specId = psHelper.createPhysicalSpec(a, mkName("updateAttribute"));
    PhysicalFlowCreateCommandResponse flowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findUnderlyingPhysicalFlows"));
    Collection<PhysicalFlowInfo> physicalAssociated = pfSvc.findUnderlyingPhysicalFlows(ab.entityReference().id());
    assertEquals(1, physicalAssociated.size(), "Returns correct number of underlying physical flows for that logical");
    pfHelper.deletePhysicalFlow(flowCreateResp.entityReference().id());
    Collection<PhysicalFlowInfo> noActivePhysicals = pfSvc.findUnderlyingPhysicalFlows(ab.entityReference().id());
    assertTrue(isEmpty(noActivePhysicals), "If no active physicals associated to the logical then returns empty list");
    PhysicalFlowCreateCommandResponse flowCreateResp2 = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findUnderlyingPhysicalFlows"));
    Collection<PhysicalFlowInfo> physicalAssociated2 = pfSvc.findUnderlyingPhysicalFlows(ab.entityReference().id());
    assertEquals(1, physicalAssociated2.size(), "Returns correct number of underlying physical flows for that logical");
    lfSvc.removeFlow(ab.entityReference().id(), mkName("findUnderlyingPhysicalFlows"));
    Collection<PhysicalFlowInfo> underlyingPhysicalsForRemovedLogical = pfSvc.findUnderlyingPhysicalFlows(ab.entityReference().id());
    assertTrue(isEmpty(underlyingPhysicalsForRemovedLogical), "Returns empty list of the logical flow is 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 9 with LogicalFlow

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

the class PhysicalFlowServiceTest method findByConsumerEntityReference.

@Test
public void findByConsumerEntityReference() {
    assertThrows(IllegalArgumentException.class, () -> pfSvc.findByConsumerEntityReference(null), "Null entity reference throws an IllegalArgumentException");
    List<PhysicalFlow> entityNotExists = pfSvc.findByConsumerEntityReference(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 bc = lfHelper.createLogicalFlow(b, c);
    Long specId = psHelper.createPhysicalSpec(a, "findByExternalId");
    PhysicalFlowCreateCommandResponse physicalFlowResponse1 = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findByConsumerEntityReference"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse2 = pfHelper.createPhysicalFlow(ac.entityReference().id(), specId, mkName("findByConsumerEntityReference"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse3 = pfHelper.createPhysicalFlow(bc.entityReference().id(), specId, mkName("findByConsumerEntityReference"));
    List<PhysicalFlow> physicalsUpstreamOfA = pfSvc.findByConsumerEntityReference(a);
    assertEquals(emptySet(), map(physicalsUpstreamOfA, d -> d.entityReference().id()), "Returns expected flows upstream of a");
    List<PhysicalFlow> physicalsUpstreamOfC = pfSvc.findByConsumerEntityReference(c);
    assertEquals(2, physicalsUpstreamOfC.size(), "Returns all flows upstream of a but not downstream flows");
    assertEquals(asSet(physicalFlowResponse2.entityReference().id(), physicalFlowResponse3.entityReference().id()), map(physicalsUpstreamOfC, d -> d.entityReference().id()), "Returns expected flows upstream of c");
    List<PhysicalFlow> physicalsDownstreamOfB = pfSvc.findByConsumerEntityReference(b);
    assertEquals(asSet(physicalFlowResponse1.entityReference().id()), map(physicalsDownstreamOfB, d -> d.entityReference().id()), "Returns expected flows upstream 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 10 with LogicalFlow

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

the class PhysicalFlowServiceTest method create.

@Test
public void create() {
    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"));
    PhysicalSpecification spec = psSvc.getById(specId);
    assertThrows(IllegalArgumentException.class, () -> pfSvc.create(null, mkName("create")), "Should throw exception if null object passed into create");
    ImmutableFlowAttributes flowAttrs = ImmutableFlowAttributes.builder().frequency(FrequencyKind.DAILY).criticality(Criticality.MEDIUM).transport(TransportKindValue.UNKNOWN).basisOffset(0).build();
    ImmutablePhysicalFlowCreateCommand createCommand = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(spec).flowAttributes(flowAttrs).build();
    ImmutablePhysicalFlowCreateCommand createCommandInvalidFlowId = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(-1).specification(spec).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse createResp = pfSvc.create(createCommand, mkName("create"));
    assertEquals(CommandOutcome.SUCCESS, createResp.outcome(), "Can successfully create physical flows");
    assertThrows(IllegalArgumentException.class, () -> pfSvc.create(createCommandInvalidFlowId, mkName("create")), "Throws an exception when trying to create a physical flow for an invalid logical flow id");
}
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)

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