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");
}
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");
}
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");
}
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");
}
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");
}
Aggregations