use of org.finos.waltz.model.physical_specification.PhysicalSpecification 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");
}
use of org.finos.waltz.model.physical_specification.PhysicalSpecification 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");
}
use of org.finos.waltz.model.physical_specification.PhysicalSpecification 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");
}
use of org.finos.waltz.model.physical_specification.PhysicalSpecification in project waltz by khartec.
the class FlowDiagramService method makeForPhysicalSpecification.
private Long makeForPhysicalSpecification(EntityReference ref, String userId, String providedTitle) {
PhysicalSpecification spec = physicalSpecificationDao.getById(ref.id());
Select<Record1<Long>> logicalFlowSelector = logicalFlowIdSelectorFactory.apply(mkOpts(ref, HierarchyQueryScope.EXACT));
List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
List<PhysicalFlow> physicalFlows = physicalFlowDao.findBySpecificationId(ref.id());
List<EntityReference> nodes = logicalFlows.stream().flatMap(f -> Stream.of(f.source(), f.target())).distinct().collect(toList());
List<FlowDiagramEntity> entities = ListUtilities.concat(map(logicalFlows, d -> mkDiagramEntity(d)), map(physicalFlows, d -> mkDiagramEntity(d)), newArrayList(mkDiagramEntity(spec)), map(nodes, d -> mkDiagramEntity(d)));
String title = isEmpty(providedTitle) ? spec.name() + " flows" : providedTitle;
return mkNewFlowDiagram(title, userId, entities, emptyList());
}
use of org.finos.waltz.model.physical_specification.PhysicalSpecification in project waltz by khartec.
the class FlowDiagramService method makeForPhysicalFlow.
private Long makeForPhysicalFlow(EntityReference ref, String userId, String providedTitle) {
PhysicalFlow physFlow = physicalFlowDao.getById(ref.id());
LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(physFlow.logicalFlowId());
PhysicalSpecification spec = physicalSpecificationDao.getById(physFlow.specificationId());
String title = isEmpty(providedTitle) ? spec.name() + " flows" : providedTitle;
ArrayList<FlowDiagramEntity> entities = newArrayList(mkDiagramEntity(logicalFlow), mkDiagramEntity(physFlow), mkDiagramEntity(spec), mkDiagramEntity(logicalFlow.source()), mkDiagramEntity(logicalFlow.target()));
return mkNewFlowDiagram(title, userId, entities, emptyList());
}
Aggregations