Search in sources :

Example 1 with PhysicalSpecification

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");
}
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 2 with PhysicalSpecification

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");
}
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 3 with PhysicalSpecification

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");
}
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 4 with PhysicalSpecification

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());
}
Also used : ChangeInitiative(org.finos.waltz.model.change_initiative.ChangeInitiative) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) org.finos.waltz.model(org.finos.waltz.model) Autowired(org.springframework.beans.factory.annotation.Autowired) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ImmutableChangeLog(org.finos.waltz.model.changelog.ImmutableChangeLog) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) StringUtilities.isEmpty(org.finos.waltz.common.StringUtilities.isEmpty) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) FlowDiagramDao(org.finos.waltz.data.flow_diagram.FlowDiagramDao) Select(org.jooq.Select) org.finos.waltz.model.flow_diagram(org.finos.waltz.model.flow_diagram) ChangeInitiativeDao(org.finos.waltz.data.change_initiative.ChangeInitiativeDao) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao) Collections.emptyList(java.util.Collections.emptyList) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) ListUtilities.map(org.finos.waltz.common.ListUtilities.map) Stream(java.util.stream.Stream) DateTimeUtilities.nowUtc(org.finos.waltz.common.DateTimeUtilities.nowUtc) SetUtilities(org.finos.waltz.common.SetUtilities) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) Actor(org.finos.waltz.model.actor.Actor) java.util(java.util) FlowDiagramAnnotationDao(org.finos.waltz.data.flow_diagram.FlowDiagramAnnotationDao) PhysicalFlowDao(org.finos.waltz.data.physical_flow.PhysicalFlowDao) EntitySearchOptions(org.finos.waltz.model.entity_search.EntitySearchOptions) DataType(org.finos.waltz.model.datatype.DataType) ChangeLog(org.finos.waltz.model.changelog.ChangeLog) Service(org.springframework.stereotype.Service) PhysicalSpecificationDao(org.finos.waltz.data.physical_specification.PhysicalSpecificationDao) DataTypeService(org.finos.waltz.service.data_type.DataTypeService) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) FlowDiagramEntityDao(org.finos.waltz.data.flow_diagram.FlowDiagramEntityDao) FLOW_DIAGRAM(org.finos.waltz.model.EntityKind.FLOW_DIAGRAM) RandomUtilities(org.finos.waltz.common.RandomUtilities) LogicalFlowIdSelectorFactory(org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ActorDao(org.finos.waltz.data.actor.ActorDao) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) ListUtilities(org.finos.waltz.common.ListUtilities) FlowDiagramIdSelectorFactory(org.finos.waltz.data.flow_diagram.FlowDiagramIdSelectorFactory) InvalidResultException(org.jooq.exception.InvalidResultException) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) Record1(org.jooq.Record1)

Example 5 with PhysicalSpecification

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());
}
Also used : PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Aggregations

PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)21 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)16 ImmutablePhysicalSpecification (org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification)13 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)9 Test (org.junit.jupiter.api.Test)9 PhysicalFlow (org.finos.waltz.model.physical_flow.PhysicalFlow)4 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)3 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 String.format (java.lang.String.format)2 LocalDateTime (java.time.LocalDateTime)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 DateTimeUtilities.nowUtc (org.finos.waltz.common.DateTimeUtilities.nowUtc)2 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)2 StringUtilities.isEmpty (org.finos.waltz.common.StringUtilities.isEmpty)2 PhysicalFlowDao (org.finos.waltz.data.physical_flow.PhysicalFlowDao)2 org.finos.waltz.model (org.finos.waltz.model)2