-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implements routenode moved without connecting segments
- Loading branch information
1 parent
8482b89
commit 7e45205
Showing
6 changed files
with
209 additions
and
5 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/OpenFTTH.GDBIntegrator.Integrator/EventMessages/RouteNodeGeometryModified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace OpenFTTH.GDBIntegrator.Integrator.EventMessages | ||
{ | ||
public class RouteNodeGeometryModified | ||
{ | ||
public readonly string EventType = nameof(RouteSegmentGeometryModified); | ||
public readonly string EventTs = DateTime.UtcNow.ToString("o"); | ||
public readonly Guid EventId = Guid.NewGuid(); | ||
public Guid CmdId { get; } | ||
public string CmdType { get; } | ||
public Guid NodeId { get; } | ||
public string Geometry { get; } | ||
|
||
public RouteNodeGeometryModified(Guid cmdId, Guid nodeId, string cmdType, string geometry) | ||
{ | ||
CmdId = cmdId; | ||
NodeId = nodeId; | ||
CmdType = cmdType; | ||
Geometry = geometry; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/OpenFTTH.GDBIntegrator.Integrator/Notifications/RouteNodeLocationChanged.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using OpenFTTH.GDBIntegrator.RouteNetwork; | ||
using OpenFTTH.GDBIntegrator.Config; | ||
using OpenFTTH.GDBIntegrator.Producer; | ||
using MediatR; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace OpenFTTH.GDBIntegrator.Integrator.Notifications | ||
{ | ||
public class RouteNodeLocationChanged : INotification | ||
{ | ||
public RouteNode RouteNode { get; set; } | ||
public Guid CmdId { get; set; } | ||
} | ||
|
||
public class RouteNodeLocationChangedHandler : INotificationHandler<RouteNodeLocationChanged> | ||
{ | ||
private readonly ILogger<RouteNodeAddedHandler> _logger; | ||
private readonly KafkaSetting _kafkaSettings; | ||
private readonly IProducer _producer; | ||
|
||
public RouteNodeLocationChangedHandler( | ||
ILogger<RouteNodeAddedHandler> logger, | ||
IOptions<KafkaSetting> kafkaSettings, | ||
IProducer producer) | ||
{ | ||
_logger = logger; | ||
_kafkaSettings = kafkaSettings.Value; | ||
_producer = producer; | ||
} | ||
|
||
public async Task Handle(RouteNodeLocationChanged request, CancellationToken token) | ||
{ | ||
_logger.LogInformation($"Sending {nameof(RouteNodeLocationChanged)} with mrid '{request.RouteNode.Mrid}' to producer"); | ||
|
||
await _producer.Produce(_kafkaSettings.EventRouteNetworkTopicName, | ||
new EventMessages.RouteNodeGeometryModified | ||
( | ||
request.CmdId, | ||
request.RouteNode.Mrid, | ||
nameof(RouteNodeLocationChanged), | ||
request.RouteNode.GetGeoJsonCoordinate() | ||
)); | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
src/OpenFTTH.GDBIntegrator.Integrator/Notifications/RouteSegmentLocationChanged.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
test/OpenFTTH.GDBIntegrator.Integrator.Tests/EventMessages/RouteNodeGeometryModifiedTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using Xunit; | ||
using FluentAssertions; | ||
using FluentAssertions.Execution; | ||
using OpenFTTH.GDBIntegrator.Integrator.EventMessages; | ||
|
||
namespace OpenFTTH.GDBIntegrator.Integrator.Tests.EventMessages | ||
{ | ||
public class RouteNodeGeometryModifiedTest | ||
{ | ||
[Fact] | ||
public void RouteNodeGeometryModified_ShouldSetInitialValues_OnConstruction() | ||
{ | ||
var cmdId = Guid.NewGuid(); | ||
var nodeId = Guid.NewGuid(); | ||
var geometry = "[565931.444690517626197297.75114815]"; | ||
var cmdType = "RouteSegmentLocationChanged"; | ||
|
||
var routeNodeGeometryModified = new RouteNodeGeometryModified | ||
( | ||
cmdId, | ||
nodeId, | ||
cmdType, | ||
geometry | ||
); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
routeNodeGeometryModified.Geometry.Should().Be(geometry); | ||
routeNodeGeometryModified.EventId.Should().NotBeEmpty(); | ||
routeNodeGeometryModified.NodeId.Should().Be(nodeId); | ||
routeNodeGeometryModified.CmdId.Should().Be(cmdId); | ||
routeNodeGeometryModified.EventType.Should().Be(nameof(RouteSegmentGeometryModified)); | ||
routeNodeGeometryModified.EventTs.Should().NotBeEmpty(); | ||
routeNodeGeometryModified.CmdType.Should().Be(cmdType); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters