Search in sources :

Example 51 with LogicalFlow

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

the class PhysicalFlowServiceTest method merge_ifSpecShareByMultipleFlowsShouldNotBeRemoved.

@Test
public void merge_ifSpecShareByMultipleFlowsShouldNotBeRemoved() {
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    EntityReference c = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    LogicalFlow bc = lfHelper.createLogicalFlow(b, c);
    Long specId = psHelper.createPhysicalSpec(a, mkName("merge"));
    Long specId2 = psHelper.createPhysicalSpec(a, mkName("merge2"));
    PhysicalFlowCreateCommandResponse firstFlowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("merge"));
    PhysicalFlowCreateCommandResponse secondFlowCreateResp = pfHelper.createPhysicalFlow(bc.entityReference().id(), specId, mkName("merge"));
    PhysicalFlowCreateCommandResponse thirdFlowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId2, mkName("merge"));
    boolean merge = pfSvc.merge(firstFlowCreateResp.entityReference().id(), thirdFlowCreateResp.entityReference().id(), mkName("merge"));
    PhysicalSpecification specAfterUpdate = psSvc.getById(specId);
    assertFalse(specAfterUpdate.isRemoved(), "If other flows share the spec it should not be removed after the merge");
}
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 52 with LogicalFlow

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

the class PhysicalFlowServiceTest method delete_cannotBeDeletedIfReadOnly.

@Test
public void delete_cannotBeDeletedIfReadOnly() {
    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("deleteReadOnly"));
    pfHelper.markFlowAsReadOnly(physFlow.entityReference().id());
    PhysicalFlowDeleteCommandResponse deletedFlowResp = pfSvc.delete(ImmutablePhysicalFlowDeleteCommand.builder().flowId(physFlow.entityReference().id()).build(), mkName("deleteReadOnly"));
    assertEquals(CommandOutcome.FAILURE, deletedFlowResp.outcome(), "Physical flow should not be deleted if marked read only");
}
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 53 with LogicalFlow

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

the class PhysicalFlowServiceTest method getById.

@Test
public void getById() {
    PhysicalFlow unknownId = pfSvc.getById(-1);
    assertNull(unknownId, "If unknown id returns null");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow flow = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, "getById");
    PhysicalFlowCreateCommandResponse physicalFlowResponse = pfHelper.createPhysicalFlow(flow.entityReference().id(), specId, mkName("getById"));
    PhysicalFlow physicalFlow = pfSvc.getById(physicalFlowResponse.entityReference().id());
    assertEquals(physicalFlowResponse.entityReference().id(), physicalFlow.entityReference().id(), "getById returns correct physical flow");
}
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 54 with LogicalFlow

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

the class PhysicalFlowServiceTest method findBySelector.

@Test
public void findBySelector() {
    assertThrows(IllegalArgumentException.class, () -> pfSvc.findBySelector(null), "Null selection options should throw IllegalArgumentException");
    assertThrows(NullPointerException.class, () -> pfSvc.findBySelector(mkOpts(null)), "Null entity reference should throw NullPointerException when constructing options");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    Collection<PhysicalFlow> bySelectorWithNoFlows = pfSvc.findBySelector(mkOpts(a));
    assertEquals(emptyList(), bySelectorWithNoFlows, "Returns empty list when no flows for selector");
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, "findBySpecificationId");
    PhysicalFlowCreateCommandResponse physicalFlowResponse = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findBySpecificationId"));
    Collection<PhysicalFlow> bySelectorWithFlows = pfSvc.findBySelector(mkOpts(a));
    assertEquals(asSet(physicalFlowResponse.entityReference().id()), map(bySelectorWithFlows, d -> d.entityReference().id()), "Returns correct flows for selector");
    EntityReference c = appHelper.createNewApp("c", ouIds.b);
    LogicalFlow bc = lfHelper.createLogicalFlow(b, c);
    PhysicalFlowCreateCommandResponse otherFlowLinkedToSpec = pfHelper.createPhysicalFlow(bc.entityReference().id(), specId, mkName("findBySpecificationId"));
    Collection<PhysicalFlow> bySpecSelectorWithRelatedFlows = pfSvc.findBySelector(mkOpts(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specId)));
    assertEquals(asSet(physicalFlowResponse.entityReference().id(), otherFlowLinkedToSpec.entityReference().id()), map(bySpecSelectorWithRelatedFlows, d -> d.entityReference().id()), "Returns correct flows for spec selector");
    Collection<PhysicalFlow> byLogFlowSelectorWithRelatedFlows = pfSvc.findBySelector(mkOpts(ab.entityReference()));
    assertEquals(asSet(physicalFlowResponse.entityReference().id()), map(byLogFlowSelectorWithRelatedFlows, d -> d.entityReference().id()), "Returns correct flows for log flow selector");
}
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 55 with LogicalFlow

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

the class PhysicalFlowServiceTest method create_canReactivateSpecIfRequired.

@Test
public void create_canReactivateSpecIfRequired() {
    String username = mkName("createCanReactivateSpecIfRequired");
    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("createIfDuplicateFlowWillReturnFailureWithMessage"));
    psSvc.markRemovedIfUnused(ImmutablePhysicalSpecificationDeleteCommand.builder().specificationId(specId).build(), username);
    PhysicalSpecification specOnceRemoved = psSvc.getById(specId);
    assertTrue(specOnceRemoved.isRemoved(), "Specification is only soft deleted prior to reactivation");
    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(specOnceRemoved).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse createResp = pfSvc.create(createCommand, username);
    assertEquals(CommandOutcome.SUCCESS, createResp.outcome(), "Successfully creates flow when spec needs to be reactivated");
    PhysicalFlow newPhysFlow = pfSvc.getById(createResp.entityReference().id());
    PhysicalSpecification reactivatedSpec = psSvc.getById(newPhysFlow.specificationId());
    assertFalse(reactivatedSpec.isRemoved(), "Specification is active after new flow is created");
    assertEquals(specId, Long.valueOf(reactivatedSpec.entityReference().id()), "Specification associated to flow has the correct 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