public async void ReverseVerticalAlligmentInContainerInJ2_ShouldSucceed() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutNodeContainerId = TestUtilityNetwork.NodeContainer_J_1; utilityNetwork.TryGetEquipment <NodeContainer>(sutNodeContainerId, out var nodeContainerBeforeFlip); var reverseCmd = new ReverseNodeContainerVerticalContentAlignment(sutNodeContainerId); var reverseResult = await _commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseCmd); var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >( new GetEquipmentDetails(new InterestIdList() { nodeContainerBeforeFlip.InterestId }) ); // Assert nodeContainerBeforeFlip.VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Bottom); reverseResult.IsSuccess.Should().BeTrue(); equipmentQueryResult.IsSuccess.Should().BeTrue(); equipmentQueryResult.Value.NodeContainers[sutNodeContainerId].VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Top); // Check if an event is published to the notification.utility-network topic having an idlist containing the node container we just changed var utilityNetworkNotifications = _externalEventProducer.GetMessagesByTopic("notification.utility-network").OfType <RouteNetworkElementContainedEquipmentUpdated>(); var utilityNetworkUpdatedEvent = utilityNetworkNotifications.First(n => n.Category == "EquipmentModification" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutNodeContainerId))); utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1); }
public async void TestVerticalAlignmentDiagram() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutSpanEquipmentId = TestUtilityNetwork.MultiConduit_5x10_SDU_1_to_SDU_2; utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipmentId, out var sutSpanEquipment); // Act var getDiagramQueryBeforeReverseResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(TestRouteNetwork.J_1)); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(getDiagramQueryBeforeReverseResult.Value.Diagram).Export("c:/temp/diagram/test.geojson"); } var reverseAlignmentCmd = new ReverseNodeContainerVerticalContentAlignment(Guid.NewGuid(), new UserContext("test", Guid.Empty), TestUtilityNetwork.NodeContainer_J_1); var reverseAlignmentCmdResult = await _commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseAlignmentCmd); var getDiagramQueryAfterReverseResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(TestRouteNetwork.J_1)); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(getDiagramQueryAfterReverseResult.Value.Diagram).Export("c:/temp/diagram/test.geojson"); } // Assert var conduit40BeforeMaxY = getDiagramQueryBeforeReverseResult.Value.Diagram.DiagramObjects.Find(d => d.Style == "WestTerminalLabel" && d.Label == "Ø40 5x10").Geometry.EnvelopeInternal.MaxY; var conduit32BeforeMaxY = getDiagramQueryBeforeReverseResult.Value.Diagram.DiagramObjects.Find(d => d.Style == "WestTerminalLabel" && d.Label == "Ø32 3x10").Geometry.EnvelopeInternal.MaxY; conduit40BeforeMaxY.Should().BeGreaterThan(conduit32BeforeMaxY); var conduit40AfterMaxY = getDiagramQueryAfterReverseResult.Value.Diagram.DiagramObjects.Find(d => d.Style == "WestTerminalLabel" && d.Label == "Ø40 5x10").Geometry.EnvelopeInternal.MaxY; var conduit32AfterMaxY = getDiagramQueryAfterReverseResult.Value.Diagram.DiagramObjects.Find(d => d.Style == "WestTerminalLabel" && d.Label == "Ø32 3x10").Geometry.EnvelopeInternal.MaxY; conduit40AfterMaxY.Should().BeLessThan(conduit32AfterMaxY); }
public async void ReverseBackVerticalAlligmentInContainerInJ2_ShouldSucceed() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutNodeContainerId = TestUtilityNetwork.NodeContainer_J_1; utilityNetwork.TryGetEquipment <NodeContainer>(sutNodeContainerId, out var nodeContainerBeforeFlip); var reverseCmd = new ReverseNodeContainerVerticalContentAlignment(sutNodeContainerId); var reverseResult = await _commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseCmd); var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >( new GetEquipmentDetails(new InterestIdList() { nodeContainerBeforeFlip.InterestId }) ); // Assert nodeContainerBeforeFlip.VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Top); reverseResult.IsSuccess.Should().BeTrue(); equipmentQueryResult.IsSuccess.Should().BeTrue(); equipmentQueryResult.Value.NodeContainers[sutNodeContainerId].VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Bottom); }
public NodeContainerMutations(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, IEventStore eventStore) { Description = "Node container mutations"; FieldAsync <CommandResultType>( "placeNodeContainerInRouteNetwork", description: "Place a node container (i.e. conduit closure, well, cabinet whatwever) in a route network node", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "routeNodeId" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerId" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerSpecificationId" }, new QueryArgument <IdGraphType> { Name = "manufacturerId" } ), resolve: async context => { var routeNodeId = context.GetArgument <Guid>("routeNodeId"); var nodeContainerId = context.GetArgument <Guid>("nodeContainerId"); var nodeContainerSpecificationId = context.GetArgument <Guid>("nodeContainerSpecificationId"); var manufacturerId = context.GetArgument <Guid>("manufacturerId"); var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; Guid correlationId = Guid.NewGuid(); // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId) { EditingRouteNodeId = routeNodeId }; // First register the walk in the route network where the client want to place the node container var nodeOfInterestId = Guid.NewGuid(); var walk = new RouteNetworkElementIdList(); var registerNodeOfInterestCommand = new RegisterNodeOfInterest(correlationId, commandUserContext, nodeOfInterestId, routeNodeId); var registerNodeOfInterestCommandResult = await commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand); if (registerNodeOfInterestCommandResult.IsFailed) { return(new CommandResult(registerNodeOfInterestCommandResult)); } // Now place the conduit in the walk var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(correlationId, commandUserContext, nodeContainerId, nodeContainerSpecificationId, registerNodeOfInterestCommandResult.Value) { ManufacturerId = manufacturerId, LifecycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, null, null) }; var placeNodeContainerResult = await commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand); // Unregister interest if place node container failed if (placeNodeContainerResult.IsFailed) { var unregisterCommandResult = await commandDispatcher.HandleAsync <UnregisterInterest, Result>(new UnregisterInterest(correlationId, commandUserContext, nodeOfInterestId)); if (unregisterCommandResult.IsFailed) { return(new CommandResult(unregisterCommandResult)); } } return(new CommandResult(placeNodeContainerResult)); } ); FieldAsync <CommandResultType>( "reverseVerticalContentAlignment", description: "Toggle whether the content in the node container should be drawed from bottom up or top down", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerId" } ), resolve: async context => { var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; Guid correlationId = Guid.NewGuid(); // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId); var nodeContainerId = context.GetArgument <Guid>("nodeContainerId"); var reverseAlignmentCmd = new ReverseNodeContainerVerticalContentAlignment(correlationId, commandUserContext, nodeContainerId); var reverseAlignmentCmdResult = await commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseAlignmentCmd); return(new CommandResult(reverseAlignmentCmdResult)); } ); FieldAsync <CommandResultType>( "updateProperties", description: "Mutation that can be used to change the node container specification and/or manufacturer", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerId" }, new QueryArgument <IdGraphType> { Name = "specificationId" }, new QueryArgument <IdGraphType> { Name = "manufacturerId" } ), resolve: async context => { var nodeContainerId = context.GetArgument <Guid>("nodeContainerId"); var correlationId = Guid.NewGuid(); var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId); var updateCmd = new UpdateNodeContainerProperties(correlationId, commandUserContext, nodeContainerId) { SpecificationId = context.HasArgument("specificationId") ? context.GetArgument <Guid>("specificationId") : null, ManufacturerId = context.HasArgument("manufacturerId") ? context.GetArgument <Guid>("manufacturerId") : null, }; var updateResult = await commandDispatcher.HandleAsync <UpdateNodeContainerProperties, Result>(updateCmd); return(new CommandResult(updateResult)); } ); FieldAsync <CommandResultType>( "remove", description: "Remove node container from the route network node", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerId" } ), resolve: async context => { var nodeContainerId = context.GetArgument <Guid>("nodeContainerId"); var correlationId = Guid.NewGuid(); var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId); var removeNodeContainer = new RemoveNodeContainerFromRouteNetwork( correlationId: correlationId, userContext: commandUserContext, nodeContainerId: nodeContainerId ); var removeResult = await commandDispatcher.HandleAsync <RemoveNodeContainerFromRouteNetwork, Result>(removeNodeContainer); return(new CommandResult(removeResult)); } ); FieldAsync <CommandResultType>( "placeRackInNodeContainer", description: "Place a rack in the node container", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "nodeContainerId" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "rackId" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "rackSpecificationId" }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "rackName" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "rackHeightInUnits" } ), resolve: async context => { var nodeContainerId = context.GetArgument <Guid>("nodeContainerId"); var rackId = context.GetArgument <Guid>("rackId"); var rackSpecificationId = context.GetArgument <Guid>("rackSpecificationId"); var rackName = context.GetArgument <string>("rackName"); var rackHeightInUnits = context.GetArgument <int>("rackHeightInUnits"); var correlationId = Guid.NewGuid(); var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId); var placeRackInNodeContainer = new PlaceRackInNodeContainer( correlationId: correlationId, userContext: commandUserContext, nodeContainerId: nodeContainerId, rackSpecificationId: rackSpecificationId, rackId: Guid.NewGuid(), rackName: rackName, rackHeightInUnits: rackHeightInUnits ); var removeResult = await commandDispatcher.HandleAsync <PlaceRackInNodeContainer, Result>(placeRackInNodeContainer); return(new CommandResult(removeResult)); } ); FieldAsync <CommandResultType>( "placeTerminalEquipmentInNodeContainer", description: "Place a terminal directly in a node container or in a node container rack", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "routeNodeId" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "terminalEquipmentSpecificationId" }, new QueryArgument <IdGraphType> { Name = "manufacturerId" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "numberOfEquipments" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "startSequenceNumber" }, new QueryArgument <NonNullGraphType <TerminalEquipmentNamingMethodEnumType> > { Name = "terminalEquipmentNamingMethod" }, new QueryArgument <NamingInfoInputType> { Name = "namingInfo" }, new QueryArgument <SubrackPlacementInfoInputType> { Name = "subrackPlacementInfo" }, new QueryArgument <AddressInfoInputType> { Name = "addressInfo" } ), resolve: async context => { var routeNodeId = context.GetArgument <Guid>("routeNodeId"); var terminalEquipmentSpecificationId = context.GetArgument <Guid>("terminalEquipmentSpecificationId"); var manufacturerId = context.GetArgument <Guid?>("manufacturerId"); var numberOfEquipments = context.GetArgument <int>("numberOfEquipments"); var startSequenceNumber = context.GetArgument <int>("startSequenceNumber"); var terminalEquipmentNamingMethod = context.GetArgument <TerminalEquipmentNamingMethodEnum>("terminalEquipmentNamingMethod"); var namingInfo = context.GetArgument <NamingInfo>("namingInfo"); var subrackPlacementInfo = context.GetArgument <SubrackPlacementInfo>("subrackPlacementInfo"); var addressInfo = context.GetArgument <AddressInfo>("addressInfo"); var getNodeContainerResult = QueryHelper.GetNodeContainerFromRouteNodeId(queryDispatcher, routeNodeId); if (getNodeContainerResult.IsFailed) { foreach (var error in getNodeContainerResult.Errors) { context.Errors.Add(new ExecutionError(error.Message)); } return(null); } var nodeContainer = getNodeContainerResult.Value; var correlationId = Guid.NewGuid(); var userContext = context.UserContext as GraphQLUserContext; var userName = userContext.Username; // TODO: Get from work manager var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568"); var commandUserContext = new UserContext(userName, workTaskId); var placeEquipmentInNodeContainer = new PlaceTerminalEquipmentInNodeContainer( correlationId: correlationId, userContext: commandUserContext, nodeContainerId: nodeContainer.Id, terminalEquipmentSpecificationId: terminalEquipmentSpecificationId, terminalEquipmentId: Guid.NewGuid(), numberOfEquipments: numberOfEquipments, startSequenceNumber: startSequenceNumber, namingMethod: terminalEquipmentNamingMethod, namingInfo: namingInfo ) { AddressInfo = addressInfo, SubrackPlacementInfo = subrackPlacementInfo, ManufacturerId = manufacturerId }; var removeResult = await commandDispatcher.HandleAsync <PlaceTerminalEquipmentInNodeContainer, Result>(placeEquipmentInNodeContainer); return(new CommandResult(removeResult)); } ); }