Search in sources :

Example 46 with LogicalFlow

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

the class PhysicalFlowServiceTest method create_canCreateNewSpecIfRequired.

@Test
public void create_canCreateNewSpecIfRequired() {
    String username = mkName("createWillCreateSpecIfRequired");
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    String specExtId = mkName("createWillCreateSpecIfRequired");
    ImmutablePhysicalSpecification newSpec = ImmutablePhysicalSpecification.builder().externalId(specExtId).owningEntity(a).name(specExtId).description(specExtId).format(DataFormatKind.UNKNOWN).lastUpdatedBy(username).isRemoved(false).created(UserTimestamp.mkForUser(username, DateTimeUtilities.nowUtcTimestamp())).build();
    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(newSpec).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse firstCreateResp = pfSvc.create(createCommand, username);
    assertEquals(CommandOutcome.SUCCESS, firstCreateResp.outcome(), "Successfully creates flow when new spec needs to be created");
    PhysicalFlow newPhysFlow = pfSvc.getById(firstCreateResp.entityReference().id());
    PhysicalSpecification createdSpec = psSvc.getById(newPhysFlow.specificationId());
    assertEquals(specExtId, createdSpec.externalId().get(), "Specification associated to new flow has the correct external id");
    assertEquals(username, createdSpec.created().get().by(), "Specification associated to flow has the correct user against it");
}
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) ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 47 with LogicalFlow

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

the class PhysicalFlowServiceTest method merge.

@Test
public void merge() {
    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("merge"));
    Long specId2 = psHelper.createPhysicalSpec(a, mkName("merge2"));
    PhysicalFlowCreateCommandResponse firstFlowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("merge"));
    PhysicalFlowCreateCommandResponse secondFlowCreateResp = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId2, mkName("merge"));
    pfHelper.updateExternalIdOnFlowDirectly(firstFlowCreateResp.entityReference().id(), "merge");
    boolean merge = pfSvc.merge(firstFlowCreateResp.entityReference().id(), secondFlowCreateResp.entityReference().id(), mkName("merge"));
    List<PhysicalFlow> flowsWithMergeExtId = pfSvc.findByExternalId("merge");
    PhysicalFlow firstFlowAfterUpdate = pfSvc.getById(firstFlowCreateResp.entityReference().id());
    assertTrue(firstFlowAfterUpdate.isRemoved(), "Once merged the original flow should no longer be active");
    assertTrue(map(flowsWithMergeExtId, d -> d.entityReference().id()).contains(secondFlowCreateResp.entityReference().id()), "Once merged the second flow should have the external id of the original");
    PhysicalSpecification specAfterUpdate = psSvc.getById(specId);
    assertTrue(specAfterUpdate.isRemoved(), "If last remaining flow spec should be 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 48 with LogicalFlow

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

the class PhysicalFlowServiceTest method findBySpecificationId.

@Test
public void findBySpecificationId() {
    List<PhysicalFlow> unknownSpecId = pfSvc.findBySpecificationId(-1);
    assertEquals(emptyList(), unknownSpecId, "If unknown spec id returns empty list");
    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 bc = lfHelper.createLogicalFlow(b, c);
    LogicalFlow ac = lfHelper.createLogicalFlow(a, c);
    Long specId = psHelper.createPhysicalSpec(a, "findBySpecificationId");
    Long specId2 = psHelper.createPhysicalSpec(a, mkName("findBySpecificationId"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse = pfHelper.createPhysicalFlow(ab.entityReference().id(), specId, mkName("findBySpecificationId"));
    List<PhysicalFlow> physicalFlows = pfSvc.findBySpecificationId(specId);
    assertEquals(asSet(physicalFlowResponse.entityReference().id()), map(physicalFlows, d -> d.entityReference().id()), "findBySpecificationId returns correct physical flows");
    PhysicalFlowCreateCommandResponse physicalFlowResponse2 = pfHelper.createPhysicalFlow(bc.entityReference().id(), specId, mkName("findBySpecificationId"));
    PhysicalFlowCreateCommandResponse physicalFlowResponse3 = pfHelper.createPhysicalFlow(ac.entityReference().id(), specId2, mkName("findBySpecificationId"));
    List<PhysicalFlow> physicalFlows2 = pfSvc.findBySpecificationId(specId);
    assertEquals(asSet(physicalFlowResponse.entityReference().id(), physicalFlowResponse2.entityReference().id()), map(physicalFlows2, d -> d.entityReference().id()), "findBySpecificationId returns only physical flows with that spec");
}
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 49 with LogicalFlow

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

the class PhysicalFlowServiceTest method findByExternalId.

@Test
public void findByExternalId() {
    List<PhysicalFlow> listFromNullExtId = pfSvc.findByExternalId(null);
    assertEquals(emptyList(), listFromNullExtId, "If null ext id returns empty list");
    List<PhysicalFlow> listFromUnknownExtId = pfSvc.findByExternalId(mkName("findByExternalId"));
    assertEquals(emptyList(), listFromUnknownExtId, "If ext id doesn't exist returns empty list");
    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, "findByExternalId");
    PhysicalFlowCreateCommandResponse physicalFlowResponse = pfHelper.createPhysicalFlow(flow.entityReference().id(), specId, mkName("findByExternalId"));
    extIdHelper.createExtId(physicalFlowResponse.entityReference(), "findByExternalId", mkName("findByExternalId"));
    List<PhysicalFlow> physicalFlows = pfSvc.findByExternalId("findByExternalId");
    assertEquals(1, physicalFlows.size(), "findByExternalIds returns correct number of physical flows");
    assertEquals(asSet(physicalFlowResponse.entityReference().id()), map(physicalFlows, d -> d.entityReference().id()), "findByExternalIds returns correct physical flows");
    Long specId2 = psHelper.createPhysicalSpec(a, "findByExternalId2");
    PhysicalFlowCreateCommandResponse physicalFlowResponse2 = pfHelper.createPhysicalFlow(flow.entityReference().id(), specId2, mkName("findByExternalId2"));
    extIdHelper.createExtId(physicalFlowResponse2.entityReference(), "findByExternalId", mkName("findByExternalId2"));
    List<PhysicalFlow> twoPhysicalFlows = pfSvc.findByExternalId("findByExternalId");
    assertEquals(2, twoPhysicalFlows.size(), "findByExternalIds returns correct number of physical flows");
    assertEquals(asSet(physicalFlowResponse.entityReference().id(), physicalFlowResponse2.entityReference().id()), map(twoPhysicalFlows, d -> d.entityReference().id()), "findByExternalIds returns correct physical flows");
}
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 50 with LogicalFlow

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

the class PhysicalFlowServiceTest method create_ifDuplicateFlowWillReturnFailureWithMessage.

@Test
public void create_ifDuplicateFlowWillReturnFailureWithMessage() {
    String username = mkName("createIfDuplicateFlowWillReturnFailureWithMessage");
    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"));
    PhysicalSpecification spec = psSvc.getById(specId);
    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 createCommand2 = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(spec).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse firstCreateResp = pfSvc.create(createCommand, username);
    assertEquals(CommandOutcome.SUCCESS, firstCreateResp.outcome(), "Successfully creates flow when new");
    PhysicalFlowCreateCommandResponse secondCreateResp = pfSvc.create(createCommand2, username);
    assertEquals(CommandOutcome.FAILURE, secondCreateResp.outcome(), "Fails to create flow when a similar one is already active");
    assertTrue(secondCreateResp.message().map(msg -> msg.equalsIgnoreCase("Duplicate with existing flow")).orElse(false), "Failure message advises user that there is an existing flow");
}
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