Search in sources :

Example 1 with ImmutablePhysicalSpecification

use of org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification 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)

Aggregations

BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)1 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)1 ImmutablePhysicalSpecification (org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification)1 PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)1 Test (org.junit.jupiter.api.Test)1