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