diff --git a/src/OpenFTTH.GDBIntegrator.GeoDatabase/Postgres/SchemaMigration/Scripts/update_and_create_trigger_changes.sql b/src/OpenFTTH.GDBIntegrator.GeoDatabase/Postgres/SchemaMigration/Scripts/update_and_create_trigger_changes.sql index 8ab283a..c99c266 100644 --- a/src/OpenFTTH.GDBIntegrator.GeoDatabase/Postgres/SchemaMigration/Scripts/update_and_create_trigger_changes.sql +++ b/src/OpenFTTH.GDBIntegrator.GeoDatabase/Postgres/SchemaMigration/Scripts/update_and_create_trigger_changes.sql @@ -3,7 +3,9 @@ CREATE TABLE route_network.route_network_edit_operation ( seq_no BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY, event_id UUID NULL, "before" VARCHAR NULL, + before_coord geometry NULL, "after" VARCHAR NULL, + after_coord geometry NULL, "type" VARCHAR NOT NULL, event_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(), CONSTRAINT route_network_edit_operation_pkey PRIMARY KEY (seq_no) @@ -15,11 +17,13 @@ CREATE OR REPLACE FUNCTION route_network.route_node_create() LANGUAGE plpgsql AS $function$ BEGIN - insert into route_network.route_network_edit_operation (event_id, before, after, type) + insert into route_network.route_network_edit_operation (event_id, before, before_coord, after, after_coord, type) values ( uuid_generate_v4(), null, + null, to_json(NEW), + NEW.coord, 'RouteNode' ); RETURN NEW; @@ -42,11 +46,13 @@ BEGIN RETURN null; END IF; - insert into route_network.route_network_edit_operation (event_id, before, after, type) + insert into route_network.route_network_edit_operation (event_id, before, before_coord, after, after_coord, type) values ( uuid_generate_v4(), to_json(OLD), + OLD.coord, to_json(NEW), + NEW.coord, 'RouteNode' ); @@ -60,11 +66,13 @@ CREATE OR REPLACE FUNCTION route_network.route_segment_create() LANGUAGE plpgsql AS $function$ BEGIN - insert into route_network.route_network_edit_operation (event_id, before, after, type) + insert into route_network.route_network_edit_operation (event_id, before, before_coord, after, after_coord, type) values ( uuid_generate_v4(), null, + null, to_json(NEW), + NEW.coord, 'RouteSegment' ); RETURN NEW; @@ -87,11 +95,13 @@ BEGIN RETURN null; END IF; - insert into route_network.route_network_edit_operation (event_id, before, after, type) + insert into route_network.route_network_edit_operation (event_id, before, before_coord, after, after_coord, type) values ( uuid_generate_v4(), to_json(OLD), + OLD.coord, to_json(NEW), + NEW.coord, 'RouteSegment' ); diff --git a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeCommandFactory.cs b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeCommandFactory.cs index fb46daa..e944bb2 100644 --- a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeCommandFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeCommandFactory.cs @@ -119,7 +119,7 @@ private async Task IsValidNodeUpdate(RouteNode shadowTableNode, RouteNode } private bool AlreadyUpdated(RouteNode routeNode, RouteNode routeNodeShadowTable) - => routeNode.MarkAsDeleted == routeNodeShadowTable.MarkAsDeleted && routeNode.GetGeoJsonCoordinate(true) == routeNodeShadowTable.GetGeoJsonCoordinate(true); + => routeNode.MarkAsDeleted == routeNodeShadowTable.MarkAsDeleted && routeNode.GetGeoJsonCoordinate() == routeNodeShadowTable.GetGeoJsonCoordinate(); private bool IsCreatedByApplication(RouteNode routeNode) => routeNode.ApplicationName == _applicationSettings.ApplicationName; diff --git a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeEventFactory.cs b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeEventFactory.cs index 0e67c65..64864b0 100644 --- a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeEventFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteNodeEventFactory.cs @@ -29,7 +29,7 @@ public RouteNodeAdded CreateAdded(RouteNode routeNode) routeNode?.MappingInfo, routeNode?.SafetyInfo, routeNode.Mrid, - routeNode.GetGeoJsonCoordinate(false), + routeNode.GetGeoJsonCoordinate(), routeNode.RouteNodeInfo); } @@ -57,7 +57,7 @@ public RouteNodeGeometryModified CreateGeometryModified(RouteNode routeNode) routeNode?.ApplicationName, routeNode?.ApplicationInfo, routeNode.Mrid, - routeNode.GetGeoJsonCoordinate(false)); + routeNode.GetGeoJsonCoordinate()); } } } diff --git a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentCommandFactory.cs b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentCommandFactory.cs index d9f54e9..f3181c6 100644 --- a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentCommandFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentCommandFactory.cs @@ -161,7 +161,7 @@ private List HandleExistingRouteSegmentSplitted(int intersectingS private bool AlreadyUpdated(RouteSegment routeSegment, RouteSegment shadowTableRouteSegment) { - return routeSegment.MarkAsDeleted == shadowTableRouteSegment.MarkAsDeleted && routeSegment.GetGeoJsonCoordinate(true) == shadowTableRouteSegment.GetGeoJsonCoordinate(true); + return routeSegment.MarkAsDeleted == shadowTableRouteSegment.MarkAsDeleted && routeSegment.GetGeoJsonCoordinate() == shadowTableRouteSegment.GetGeoJsonCoordinate(); } private bool IsCreatedByApplication(RouteSegment routeSegment) diff --git a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentEventFactory.cs b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentEventFactory.cs index b38b0a3..e66df19 100644 --- a/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentEventFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Integrator/Factories/RouteSegmentEventFactory.cs @@ -45,7 +45,7 @@ public RouteSegmentGeometryModified CreateGeometryModified(RouteSegment routeSeg useApplicationName ? _applicationSettings.ApplicationName : routeSegment?.ApplicationName, routeSegment?.ApplicationInfo, routeSegment.Mrid, - routeSegment.GetGeoJsonCoordinate(false)); + routeSegment.GetGeoJsonCoordinate()); } public RouteSegmentMarkedForDeletion CreateMarkedForDeletion(RouteSegment routeSegment, bool useApplicationName = false) @@ -78,7 +78,7 @@ public RouteSegmentAdded CreateAdded(RouteSegment routeSegment, RouteNode startR routeSegment.Mrid, startRouteNode.Mrid, endRouteNode.Mrid, - routeSegment.GetGeoJsonCoordinate(false), + routeSegment.GetGeoJsonCoordinate(), routeSegment?.RouteSegmentInfo); } } diff --git a/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteNode.cs b/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteNode.cs index 2394ce5..d113705 100644 --- a/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteNode.cs +++ b/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteNode.cs @@ -54,11 +54,11 @@ public virtual Point GetPoint() return (Point)geometry; } - public virtual string GetGeoJsonCoordinate(bool round) + public virtual string GetGeoJsonCoordinate() { var wkbReader = new WKBReader(); var geometry = wkbReader.Read(Coord); - var point = round ? RoundPoint((Point)geometry) : (Point)geometry; + var point = (Point)geometry; var serializer = GeoJsonSerializer.Create(); @@ -69,25 +69,5 @@ public virtual string GetGeoJsonCoordinate(bool round) return JObject.Parse(geoJson)["coordinates"].ToString(Formatting.None); }; } - - private Point RoundPoint(Point inputPoint) - { - const int roundDecimal = 8; - var newCoord = new CoordinateZ(); - - newCoord.X = Math.Round(inputPoint.X, roundDecimal); - newCoord.Y = Math.Round(inputPoint.Y, roundDecimal); - - if (inputPoint.Z != Coordinate.NullOrdinate) - { - newCoord.Z = Math.Round(inputPoint.Z, roundDecimal); - } - else - { - newCoord.Z = Coordinate.NullOrdinate; - } - - return new Point(newCoord); - } } } diff --git a/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteSegment.cs b/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteSegment.cs index 317f137..3a30bc0 100644 --- a/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteSegment.cs +++ b/src/OpenFTTH.GDBIntegrator.RouteNetwork/RouteSegment.cs @@ -44,9 +44,9 @@ public virtual Point FindEndPoint() return endPoint; } - public virtual string GetGeoJsonCoordinate(bool round) + public virtual string GetGeoJsonCoordinate() { - var lineString = round ? RoundLineString(GetLineString()) : GetLineString(); + var lineString = GetLineString(); var serializer = GeoJsonSerializer.Create(); using (var stringWriter = new StringWriter()) @@ -63,30 +63,5 @@ public virtual LineString GetLineString() var geometry = wkbReader.Read(Coord); return (LineString)geometry; } - - private LineString RoundLineString(LineString inputLineString) - { - const int roundDecimal = 8; - - var newCoords = new List(); - foreach (var coord in inputLineString.Coordinates) - { - var c = new CoordinateZ(); - c.X = Math.Round(coord.X, roundDecimal); - c.Y = Math.Round(coord.Y, roundDecimal); - if (coord.Z != Coordinate.NullOrdinate) - { - c.Z = Math.Round(coord.Z, roundDecimal); - } - else - { - c.Z = Coordinate.NullOrdinate; - } - - newCoords.Add(c); - } - - return new LineString(newCoords.ToArray()); - } } } diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/GeoJsonConverter.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/GeoJsonConverter.cs deleted file mode 100644 index e6e7e6e..0000000 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/GeoJsonConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using NetTopologySuite.Geometries; -using NetTopologySuite.IO; -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenFTTH.GDBIntegrator.Subscriber.Postgres; - -public class GeoJsonConverter : JsonConverter where T : Geometry -{ - public override T Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - return new GeoJsonReader().Read(doc.RootElement.GetRawText()); - } - - public override void Write( - Utf8JsonWriter writer, - T point, - JsonSerializerOptions options) - { - // We will never serialize, so no reason to implement. - throw new NotImplementedException(); - } -} diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNetworkSubscriber.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNetworkSubscriber.cs index ce31b91..cff5470 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNetworkSubscriber.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNetworkSubscriber.cs @@ -179,7 +179,7 @@ private async Task SubscribeEditOperationEvents( int intervalMs, CancellationToken token = default) { - const string GET_LATEST_SQL = @"SELECT * + const string GET_LATEST_SQL = @"SELECT seq_no, event_id, before, ST_AsBinary(before_coord) AS before_coord, after, ST_AsBinary(after_coord) AS after_coord, type FROM route_network.route_network_edit_operation WHERE seq_no > @seq_no ORDER BY seq_no"; @@ -199,14 +199,18 @@ WHERE seq_no > @seq_no var sequenceNumber = reader.GetInt64(reader.GetOrdinal("seq_no")); var eventId = reader.GetGuid(reader.GetOrdinal("event_id")); var before = reader.GetValue(reader.GetOrdinal("before")) as string ?? null; + var beforeCoord = reader.GetValue(reader.GetOrdinal("before_coord")) as byte[] ?? null; var after = reader.GetValue(reader.GetOrdinal("after")) as string ?? null; + var afterCoord = reader.GetValue(reader.GetOrdinal("after_coord")) as byte[] ?? null; var type = reader.GetString(reader.GetOrdinal("type")); var editOperation = new RouteNetworkEditOperation( sequenceNumber: sequenceNumber, eventId: eventId, before: before, + beforeCoord: beforeCoord, after: after, + afterCoord: afterCoord, type: type ); diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNode.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNode.cs index 2e07cdb..5d041a7 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNode.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteNode.cs @@ -10,10 +10,6 @@ public sealed record PostgresRouteNode [JsonPropertyName("mrid")] public Guid Mrid { get; init; } - [JsonPropertyName("coord")] - [JsonConverter(typeof(GeoJsonConverter))] - public Point Coord { get; init; } - [JsonPropertyName("marked_to_be_deleted")] public bool MarkedToBeDeleted { get; init; } diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteSegment.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteSegment.cs index e12a14a..8d1b004 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteSegment.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/PostgresRouteSegment.cs @@ -10,10 +10,6 @@ public sealed record PostgresRouteSegment [JsonPropertyName("mrid")] public Guid Mrid { get; init; } - [JsonPropertyName("coord")] - [JsonConverter(typeof(GeoJsonConverter))] - public LineString Coord { get; init; } - [JsonPropertyName("marked_to_be_deleted")] public bool MarkedToBeDeleted { get; init; } diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteNodeMessageFactory.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteNodeMessageFactory.cs index c1bcb2b..2adcedb 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteNodeMessageFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteNodeMessageFactory.cs @@ -1,4 +1,3 @@ -using NetTopologySuite.IO; using OpenFTTH.Events.Core.Infos; using OpenFTTH.Events.RouteNetwork.Infos; using OpenFTTH.GDBIntegrator.Integrator.ConsumerMessages; @@ -34,12 +33,12 @@ public RouteNodeMessage Create(RouteNetworkEditOperation editOperation) return new RouteNodeMessage( eventId: editOperation.EventId, - before: ParseRouteNode(editOperation.Before), - after: ParseRouteNode(editOperation.After) + before: ParseRouteNode(editOperation.Before, editOperation.BeforeCoord), + after: ParseRouteNode(editOperation.After, editOperation.AfterCoord) ); } - private RouteNode ParseRouteNode(string json) + private RouteNode ParseRouteNode(string json, byte[] coord) { if (String.IsNullOrEmpty(json)) { @@ -52,13 +51,11 @@ private RouteNode ParseRouteNode(string json) return null; } - var wkbWriter = new WKBWriter(); - var mappedRouteNode = new RouteNode { ApplicationInfo = pgRouteNode.ApplicationInfo, ApplicationName = pgRouteNode.ApplicationName, - Coord = pgRouteNode.Coord is null ? null : wkbWriter.Write(pgRouteNode.Coord), + Coord = coord, MarkAsDeleted = pgRouteNode.MarkedToBeDeleted, DeleteMe = pgRouteNode.DeleteMe, Mrid = pgRouteNode.Mrid, diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteSegmentMessageFactory.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteSegmentMessageFactory.cs index 5d8c404..d672afa 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteSegmentMessageFactory.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/Postgres/RouteSegmentMessageFactory.cs @@ -1,4 +1,3 @@ -using NetTopologySuite.IO; using OpenFTTH.Events.Core.Infos; using OpenFTTH.Events.RouteNetwork.Infos; using OpenFTTH.GDBIntegrator.Integrator.ConsumerMessages; @@ -34,12 +33,12 @@ public RouteSegmentMessage Create(RouteNetworkEditOperation editOperation) return new RouteSegmentMessage( eventId: editOperation.EventId, - before: ParseRouteSegment(editOperation.Before), - after: ParseRouteSegment(editOperation.After) + before: ParseRouteSegment(editOperation.Before, editOperation.BeforeCoord), + after: ParseRouteSegment(editOperation.After, editOperation.AfterCoord) ); } - private RouteSegment ParseRouteSegment(string json) + private RouteSegment ParseRouteSegment(string json, byte[] coord) { if (String.IsNullOrEmpty(json)) { @@ -52,13 +51,11 @@ private RouteSegment ParseRouteSegment(string json) return null; } - var wkbWriter = new WKBWriter(); - var mappedRouteSegment = new RouteSegment { ApplicationInfo = pgRouteSegment.ApplicationInfo, ApplicationName = pgRouteSegment.ApplicationName, - Coord = pgRouteSegment.Coord is null ? null : wkbWriter.Write(pgRouteSegment.Coord), + Coord = coord, MarkAsDeleted = pgRouteSegment.MarkedToBeDeleted, DeleteMe = pgRouteSegment.DeleteMe, Mrid = pgRouteSegment.Mrid, diff --git a/src/OpenFTTH.GDBIntegrator.Subscriber/RouteNetworkEditOperation.cs b/src/OpenFTTH.GDBIntegrator.Subscriber/RouteNetworkEditOperation.cs index f6331ed..40d9fc6 100644 --- a/src/OpenFTTH.GDBIntegrator.Subscriber/RouteNetworkEditOperation.cs +++ b/src/OpenFTTH.GDBIntegrator.Subscriber/RouteNetworkEditOperation.cs @@ -14,9 +14,15 @@ public sealed record RouteNetworkEditOperation [JsonPropertyName("before")] public string Before { get; init; } + [JsonPropertyName("before_coord")] + public byte[] BeforeCoord { get; init; } + [JsonPropertyName("after")] public string After { get; init; } + [JsonPropertyName("after_coord")] + public byte[] AfterCoord { get; init; } + [JsonPropertyName("type")] public string Type { get; init; } @@ -25,13 +31,17 @@ public RouteNetworkEditOperation( long sequenceNumber, Guid eventId, string before, + byte[] beforeCoord, string after, + byte[] afterCoord, string type) { SequenceNumber = sequenceNumber; EventId = eventId; Before = before; + BeforeCoord = beforeCoord; After = after; + AfterCoord = afterCoord; Type = type; } } diff --git a/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteNodeCommandFactoryTest.cs b/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteNodeCommandFactoryTest.cs index aa6e452..7ccdd3f 100644 --- a/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteNodeCommandFactoryTest.cs +++ b/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteNodeCommandFactoryTest.cs @@ -238,8 +238,8 @@ public async Task CreateUpdatedEvent_ShouldReturnRollbackInvalidRouteNodeOperati A.CallTo(() => geoDatabase.GetIntersectingRouteSegments(afterNode)).Returns(new List()); A.CallTo(() => afterNode.GetPoint()).Returns(CreatePoint(565931.4446905176, 6197297.75114815)); A.CallTo(() => shadowTableRouteNode.GetPoint()).Returns(CreatePoint(565920.4446905176, 6197297.74114815)); - A.CallTo(() => afterNode.GetGeoJsonCoordinate(true)).Returns("[565931.4446905176,6197297.75114815]"); - A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate(true)).Returns("[565920.4446905176,6197297.74114815]"); + A.CallTo(() => afterNode.GetGeoJsonCoordinate()).Returns("[565931.4446905176,6197297.75114815]"); + A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate()).Returns("[565920.4446905176,6197297.74114815]"); A.CallTo(() => geoDatabase.GetIntersectingRouteNodes(afterNode)).Returns(new List { A.Fake() }); var point = A.Fake(); @@ -269,11 +269,11 @@ public async Task CreateUpdatedEvent_ShouldReturnDoNothing_OnRouteNodeMarkedAsDe A.CallTo(() => geoDatabase.GetRouteNodeShadowTable(afterNode.Mrid, false)) .Returns(integratorRouteNode); - A.CallTo(() => afterNode.GetGeoJsonCoordinate(true)) + A.CallTo(() => afterNode.GetGeoJsonCoordinate()) .Returns("[565931.4446905176,6197297.75114815]"); A.CallTo(() => afterNode.MarkAsDeleted).Returns(true); - A.CallTo(() => integratorRouteNode.GetGeoJsonCoordinate(true)) + A.CallTo(() => integratorRouteNode.GetGeoJsonCoordinate()) .Returns("[565931.4446905176,6197297.75114815]"); A.CallTo(() => integratorRouteNode.MarkAsDeleted).Returns(true); @@ -302,10 +302,10 @@ public async Task CreateUpdatedEvent_ShouldReturnRollbackInvalidRouteNode_OnIsMo A.CallTo(() => applicationSetting.Value).Returns(appSettings); A.CallTo(() => afterNode.Mrid).Returns(Guid.NewGuid()); - A.CallTo(() => afterNode.GetGeoJsonCoordinate(true)).Returns("[552428.7508312801, 6188868.185819111]"); + A.CallTo(() => afterNode.GetGeoJsonCoordinate()).Returns("[552428.7508312801, 6188868.185819111]"); A.CallTo(() => afterNode.GetPoint()).Returns(point); A.CallTo(() => geoDatabase.GetRouteNodeShadowTable(afterNode.Mrid, false)).Returns(shadowTableRouteNode); - A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate(true)).Returns("[552428.7515896157,6188868.184787691]"); + A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate()).Returns("[552428.7515896157,6188868.184787691]"); A.CallTo(() => shadowTableRouteNode.GetPoint()).Returns(CreatePoint(552428.7515896157, 6188868.184787691)); var routeNodeValidator = A.Fake(); @@ -409,9 +409,9 @@ public async Task CreateUpdatedEvent_ShouldReturnRollbackInvalidRouteNode_OnInte A.CallTo(() => applicationSetting.Value).Returns(appSettingsValue); A.CallTo(() => afterNode.Mrid).Returns(Guid.NewGuid()); A.CallTo(() => geoDatabase.GetRouteNodeShadowTable(afterNode.Mrid, false)).Returns(shadowTableRouteNode); - A.CallTo(() => afterNode.GetGeoJsonCoordinate(true)).Returns("[665931.4446905176,7197297.75114815]"); + A.CallTo(() => afterNode.GetGeoJsonCoordinate()).Returns("[665931.4446905176,7197297.75114815]"); A.CallTo(() => afterNode.MarkAsDeleted).Returns(false); - A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate(true)).Returns("[565931.4446905176,6197297.75114815]"); + A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate()).Returns("[565931.4446905176,6197297.75114815]"); A.CallTo(() => shadowTableRouteNode.MarkAsDeleted).Returns(false); A.CallTo(() => afterNode.GetPoint()).Returns(CreatePoint(665931.4446905176, 7197297.75114815)); A.CallTo(() => shadowTableRouteNode.GetPoint()).Returns(CreatePoint(565931.4446905176, 6197297.75114815)); @@ -449,9 +449,9 @@ public async Task CreateUpdatedEvent_ShouldReturnRouteNodeLocationChanged_OnRout A.CallTo(() => geoDatabase.GetRouteNodeShadowTable(afterNode.Mrid, false)).Returns(shadowTableRouteNode); A.CallTo(() => afterNode.GetPoint()).Returns(CreatePoint(665931.4446905176, 7197297.75114815)); A.CallTo(() => shadowTableRouteNode.GetPoint()).Returns(CreatePoint(565931.4446905176, 6197297.75114815)); - A.CallTo(() => afterNode.GetGeoJsonCoordinate(true)).Returns("[665931.4446905176,7197297.75114815]"); + A.CallTo(() => afterNode.GetGeoJsonCoordinate()).Returns("[665931.4446905176,7197297.75114815]"); A.CallTo(() => afterNode.MarkAsDeleted).Returns(false); - A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate(true)).Returns("[565931.4446905176,6197297.75114815]"); + A.CallTo(() => shadowTableRouteNode.GetGeoJsonCoordinate()).Returns("[565931.4446905176,6197297.75114815]"); A.CallTo(() => shadowTableRouteNode.MarkAsDeleted).Returns(false); var point = A.Fake(); diff --git a/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteSegmentCommandFactoryTest.cs b/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteSegmentCommandFactoryTest.cs index 7e3c4c9..b5cc345 100644 --- a/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteSegmentCommandFactoryTest.cs +++ b/test/OpenFTTH.GDBIntegrator.Integrator.Tests/Factories/RouteSegmentCommandFactoryTest.cs @@ -522,8 +522,8 @@ public async Task CreateUpdatedEvent_ShouldReturnDoNothing_OnRouteSegmentAfterAn A.CallTo(() => routeSegmentAfter.Mrid).Returns(Guid.NewGuid()); A.CallTo(() => routeSegmentShadowTable.Mrid).Returns(routeSegmentAfter.Mrid); A.CallTo(() => geoDatabase.GetRouteSegmentShadowTable(routeSegmentAfter.Mrid, false)).Returns(routeSegmentShadowTable); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); @@ -550,8 +550,8 @@ public async Task CreateUpdatedEvent_ShouldThrowException_OnGeometryBeingInvalid A.CallTo(() => routeSegmentShadowTable.Mrid).Returns(routeSegmentAfter.Mrid); A.CallTo(() => routeSegmentAfter.GetLineString()).Returns(A.Fake()); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); @@ -600,8 +600,8 @@ public async Task CreateUpdatedEvent_ShouldReturnTwoSplitEventsAndConnectivityCh A.CallTo(() => routeSegmentShadowTable.Mrid).Returns(routeSegmentAfter.Mrid); A.CallTo(() => routeSegmentAfter.GetLineString()).Returns(A.Fake()); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); @@ -645,8 +645,8 @@ public async Task CreateUpdatedEvent_ShouldReturnRouteSegmentLocationChanged_OnG A.CallTo(() => routeSegmentShadowTable.Mrid).Returns(routeSegmentAfter.Mrid); A.CallTo(() => routeSegmentAfter.GetLineString()).Returns(A.Fake()); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); @@ -747,8 +747,8 @@ public async Task CreateUpdatedEvent_ShouldThrowException_OnStartRouteNodeCountB .Returns(new ApplicationSetting { ApplicationName = "GDB_INTEGRATOR" }); A.CallTo(() => routeSegmentAfter.GetLineString()).Returns(A.Fake()); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); @@ -777,8 +777,8 @@ public async Task CreateUpdatedEvent_ShouldThrowException_OnEndRouteNodeCountBei .Returns(new ApplicationSetting { ApplicationName = "GDB_INTEGRATOR" }); A.CallTo(() => routeSegmentAfter.GetLineString()).Returns(A.Fake()); - A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); - A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate(true)).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentAfter.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 578238.4182511 6179279.78494725)"); + A.CallTo(() => routeSegmentShadowTable.GetGeoJsonCoordinate()).Returns("LINESTRING(578223.64355838 6179284.23759438, 378238.4182511 6179279.78494725)"); A.CallTo(() => routeSegmentAfter.MarkAsDeleted).Returns(false); A.CallTo(() => routeSegmentShadowTable.MarkAsDeleted).Returns(false); diff --git a/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteNodeTest.cs b/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteNodeTest.cs index a0c7ae8..a298ed9 100644 --- a/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteNodeTest.cs +++ b/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteNodeTest.cs @@ -132,7 +132,7 @@ public void GetGeoJsonCoordinate_ShouldReturnGeoJsonCoordinate_OnCalled() var routeNode = new RouteNode(mrid, coord, workTaskMrId, username, applicationName); - var result = routeNode.GetGeoJsonCoordinate(false); + var result = routeNode.GetGeoJsonCoordinate(); result.Should().BeEquivalentTo("[565931.4446905176,6197297.75114815]"); } diff --git a/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteSegmentTest.cs b/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteSegmentTest.cs index 113d42f..ba5092f 100644 --- a/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteSegmentTest.cs +++ b/test/OpenFTTH.GDBIntegrator.RouteNetwork.Tests/RouteSegmentTest.cs @@ -92,7 +92,7 @@ public void GetGeoJsonCoordinate_ShouldReturnGeoJsonCoordinate_OnBeingCalled(str Coord = Convert.FromBase64String(coord), }; - var geoJson = routeSegment.GetGeoJsonCoordinate(false); + var geoJson = routeSegment.GetGeoJsonCoordinate(); geoJson.Should().BeEquivalentTo(expected); } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteNodeMessageFactoryTest.cs b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteNodeMessageFactoryTest.cs deleted file mode 100644 index 0d952bf..0000000 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteNodeMessageFactoryTest.cs +++ /dev/null @@ -1,214 +0,0 @@ -using FluentAssertions; -using OpenFTTH.Events.Core.Infos; -using OpenFTTH.Events.RouteNetwork.Infos; -using OpenFTTH.GDBIntegrator.Integrator.ConsumerMessages; -using OpenFTTH.GDBIntegrator.RouteNetwork; -using OpenFTTH.GDBIntegrator.RouteNetwork.Mapping; -using OpenFTTH.GDBIntegrator.Subscriber.Tests; -using System; -using System.Text.Json; -using Xunit; - -namespace OpenFTTH.GDBIntegrator.Subscriber.Postgres; - -public class RouteNodeMessageFactoryTest -{ - [Fact] - public void Create_ShouldThrowArgumentNullException_OnObjectBeingNull() - { - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - - factory.Invoking(x => x.Create(null)) - .Should().Throw(); - } - - // Here is an example where we try to deserialize a RouteNode - // but the content is for a RouteSegment so we should fail. - [Theory] - [JsonFileData("TestData/RouteSegmentSerializerMessageBeforeIsNull.json")] - public void Create_ShouldThrowArgumentException_WhenTypeIsNotRouteNode(string json) - { - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - var editOperation = JsonSerializer.Deserialize(json); - - factory.Invoking(x => x.Create(null)) - .Should() - .Throw(); - } - - [Theory] - [JsonFileData("TestData/RouteNodeSerializerMessageBeforeIsNull.json")] - public void Create_ShouldReturnRouteNodeMessage_WhenBeforeIsNullAndAfterIsNotNull(string json) - { - var expected = new RouteNodeMessage( - Guid.Parse("6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e"), - before: null, - after: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQEAAABHTNwn4OYgQZg8tZCcnldB"), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - - var result = factory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteNodeSerializerMessageAfterIsNull.json")] - public void Create_ShouldReturnRouteNodeMessage_WhenBeforeIsNotNullAndAfterIsNull(string json) - { - var expected = new RouteNodeMessage( - Guid.Parse("6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e"), - before: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQEAAABHTNwn4OYgQZg8tZCcnldB"), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: null - ); - - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - - var result = factory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteNodeSerializerMessage.json")] - public void Create_ShouldReturnRouteNodeMessage_WhenBeforeAndAfterIsSet(string json) - { - var expected = new RouteNodeMessage( - Guid.Parse("6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e"), - before: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQEAAABHTNwn4OYgQZg8tZCcnldB"), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("CD13", "CD13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQEAAABHTNwn4OYgQZg8tZCcnldB"), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - - var result = factory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteNodeSerializerMessageCoordIsNull.json")] - public void Create_ShouldReturnNodeMessageWithNullCorrd_WhenBeforeAndAfterIsSetAndAfterCoordIsNull(string json) - { - var expected = new RouteNodeMessage( - Guid.Parse("6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e"), - before: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQEAAABHTNwn4OYgQZg8tZCcnldB"), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("CD13", "CD13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: new RouteNode - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = null, - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteNodeInfo = new RouteNodeInfo(RouteNodeKindEnum.CabinetBig, RouteNodeFunctionEnum.FlexPoint), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var factory = new RouteNodeMessageFactory(infoMapper); - - var result = factory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } -} diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteSegmentMessageFactoryTest.cs b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteSegmentMessageFactoryTest.cs deleted file mode 100644 index 755e17e..0000000 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/Postgres/RouteSegmentMessageFactoryTest.cs +++ /dev/null @@ -1,214 +0,0 @@ -using FluentAssertions; -using OpenFTTH.Events.Core.Infos; -using OpenFTTH.Events.RouteNetwork.Infos; -using OpenFTTH.GDBIntegrator.Integrator.ConsumerMessages; -using OpenFTTH.GDBIntegrator.RouteNetwork; -using OpenFTTH.GDBIntegrator.RouteNetwork.Mapping; -using OpenFTTH.GDBIntegrator.Subscriber.Tests; -using System; -using System.Text.Json; -using Xunit; - -namespace OpenFTTH.GDBIntegrator.Subscriber.Postgres; - -public class RouteSegmentMessageFactoryTest -{ - [Fact] - public void Create_ShouldThrowArgumentNullException_OnObjectBeingNull() - { - var infoMapper = new InfoMapper(); - var factory = new RouteSegmentMessageFactory(infoMapper); - - factory.Invoking(x => x.Create(null)) - .Should().Throw(); - } - - // Here is an example where we try to deserialize a RouteNode - // but the content is for a RouteNode so we should fail. - [Theory] - [JsonFileData("TestData/RouteNodeSerializerMessageBeforeIsNull.json")] - public void Create_ShouldThrowArgumentException_WhenTypeIsNotRouteSegment(string json) - { - var infoMapper = new InfoMapper(); - var factory = new RouteSegmentMessageFactory(infoMapper); - var editOperation = JsonSerializer.Deserialize(json); - - factory.Invoking(x => x.Create(null)) - .Should() - .Throw(); - } - - [Theory] - [JsonFileData("TestData/RouteSegmentSerializerMessageBeforeIsNull.json")] - public void Create_ShouldReturnRouteSegmentMessage_WhenBeforeIsNullAndAfterIsNotNull(string json) - { - var expected = new RouteSegmentMessage( - Guid.Parse("88ce4357-6cc8-4c02-a652-d3272693c4b8"), - before: null, - after: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E="), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var messageFactory = new RouteSegmentMessageFactory(infoMapper); - - var result = messageFactory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteSegmentSerializerMessageAfterIsNull.json")] - public void Create_ShouldReturnRouteSegmentMessage_WhenBeforeIsNotNullAndAfterIsNull(string json) - { - var expected = new RouteSegmentMessage( - Guid.Parse("88ce4357-6cc8-4c02-a652-d3272693c4b8"), - before: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E="), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: null - ); - - var infoMapper = new InfoMapper(); - var messageFactory = new RouteSegmentMessageFactory(infoMapper); - - var result = messageFactory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteSegmentSerializerMessage.json")] - public void Create_ShouldReturnRouteSegmentMessage_WhenBeforeAndAfterIsSet(string json) - { - var expected = new RouteSegmentMessage( - Guid.Parse("88ce4357-6cc8-4c02-a652-d3272693c4b8"), - before: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E="), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E="), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("FF13", "FF13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var messageFactory = new RouteSegmentMessageFactory(infoMapper); - - var result = messageFactory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } - - [Theory] - [JsonFileData("TestData/RouteSegmentSerializerMessageCoordIsNull.json")] - public void Create_ShouldReturnRouteSegmentMessageWithNullCorrd_WhenBeforeAndAfterIsSetAndAfterCoordIsNull(string json) - { - var expected = new RouteSegmentMessage( - Guid.Parse("88ce4357-6cc8-4c02-a652-d3272693c4b8"), - before: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = Convert.FromBase64String("AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E="), - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("AB13", "AB13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - }, - after: new RouteSegment - { - ApplicationInfo = "Application information bla bla", - ApplicationName = "GDB_INTEGRATOR", - Coord = null, - DeleteMe = false, - MarkAsDeleted = false, - Mrid = new Guid("66563e62-db0e-4184-be75-d55638bf33a5"), - Username = "Rune Nielsen", - WorkTaskMrid = Guid.Parse("d80f6250-8132-4893-b38f-b64fafd74316"), - LifeCycleInfo = new LifecycleInfo(DeploymentStateEnum.InService, DateTime.Parse("2020-08-12 00:00:00"), DateTime.Parse("2020-08-12 00:00:00")), - MappingInfo = new MappingInfo(MappingMethodEnum.Drafting, "1", "2", DateTime.Parse("2020-08-12 00:00:00"), "Source info"), - NamingInfo = new NamingInfo("FF13", "FF13 desc"), - RouteSegmentInfo = new RouteSegmentInfo(RouteSegmentKindEnum.Arial, "10", "20"), - SafetyInfo = new SafetyInfo("Very safe", "Nothing to say") - } - ); - - var infoMapper = new InfoMapper(); - var messageFactory = new RouteSegmentMessageFactory(infoMapper); - - var result = messageFactory.Create( - JsonSerializer.Deserialize(json)); - - result.EventId.Should().Be(expected.EventId); - result.Before.Should().BeEquivalentTo(expected.Before); - result.After.Should().BeEquivalentTo(expected.After); - } -} diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessage.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessage.json index 0eeedb0..2c8f34c 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessage.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessage.json @@ -2,6 +2,6 @@ "seq_no": 4, "event_id": "6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e", "type": "RouteNode", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"Point\",\"coordinates\":[553840.077852615,6191730.26106181]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"CD13\",\"naming_description\":\"CD13 desc\",\"lifecycle_documentation_state\":null}", - "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"Point\",\"coordinates\":[553840.077852615,6191730.26106181]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQEAAABHTNwn4OYgQZg8tZCcnldB\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"CD13\",\"naming_description\":\"CD13 desc\",\"lifecycle_documentation_state\":null}", + "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQEAAABHTNwn4OYgQZg8tZCcnldB\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageAfterIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageAfterIsNull.json index 71047fc..64fd987 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageAfterIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageAfterIsNull.json @@ -2,6 +2,6 @@ "seq_no": 2, "event_id": "6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e", "type": "RouteNode", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"Point\",\"coordinates\":[553840.077852615,6191730.26106181]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQEAAABHTNwn4OYgQZg8tZCcnldB\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", "after": null } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageBeforeIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageBeforeIsNull.json index 6c9975d..29a48c8 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageBeforeIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageBeforeIsNull.json @@ -3,5 +3,5 @@ "event_id": "6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e", "type": "RouteNode", "before": null, - "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"Point\",\"coordinates\":[553840.077852615,6191730.26106181]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" + "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQEAAABHTNwn4OYgQZg8tZCcnldB\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageCoordIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageCoordIsNull.json index b3c12c5..92a8b4e 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageCoordIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteNodeSerializerMessageCoordIsNull.json @@ -2,6 +2,6 @@ "seq_no": 4, "event_id": "6c2c49c9-8c36-4f61-bc41-3eb6f2599b1e", "type": "RouteNode", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"Point\",\"coordinates\":[553840.077852615,6191730.26106181]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"CD13\",\"naming_description\":\"CD13 desc\",\"lifecycle_documentation_state\":null}", + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQEAAABHTNwn4OYgQZg8tZCcnldB\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"CD13\",\"naming_description\":\"CD13 desc\",\"lifecycle_documentation_state\":null}", "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":null,\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routenode_kind\":\"CabinetBig\",\"routenode_function\":\"FlexPoint\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessage.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessage.json index de2554d..5adbdfd 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessage.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessage.json @@ -2,6 +2,6 @@ "seq_no": 2, "event_id": "88ce4357-6cc8-4c02-a652-d3272693c4b8", "type": "RouteSegment", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"LineString\",\"coordinates\":[[553896.338692551,6191655.24660856],[553971.720863708,6191655.24660856]]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", - "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"LineString\",\"coordinates\":[[553896.338692551,6191655.24660856],[553971.720863708,6191655.24660856]]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"FF13\",\"naming_description\":\"FF13 desc\",\"lifecycle_documentation_state\":null}" + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", + "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"FF13\",\"naming_description\":\"FF13 desc\",\"lifecycle_documentation_state\":null}" } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageAfterIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageAfterIsNull.json index 9613c6a..d89c402 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageAfterIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageAfterIsNull.json @@ -2,6 +2,6 @@ "seq_no": 2, "event_id": "88ce4357-6cc8-4c02-a652-d3272693c4b8", "type": "RouteSegment", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"LineString\",\"coordinates\":[[553896.338692551,6191655.24660856],[553971.720863708,6191655.24660856]]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", "after": null } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageBeforeIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageBeforeIsNull.json index 2536800..4f2d258 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageBeforeIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageBeforeIsNull.json @@ -3,5 +3,5 @@ "event_id": "88ce4357-6cc8-4c02-a652-d3272693c4b8", "type": "RouteSegment", "before": null, - "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"LineString\",\"coordinates\":[[553896.338692551,6191655.24660856],[553971.720863708,6191655.24660856]]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" + "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}" } diff --git a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageCoordIsNull.json b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageCoordIsNull.json index 3e45d68..a0ff44b 100644 --- a/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageCoordIsNull.json +++ b/test/OpenFTTH.GDBIntegrator.Subscriber.Tests/TestData/RouteSegmentSerializerMessageCoordIsNull.json @@ -2,6 +2,8 @@ "seq_no": 2, "event_id": "88ce4357-6cc8-4c02-a652-d3272693c4b8", "type": "RouteSegment", - "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":{\"type\":\"LineString\",\"coordinates\":[[553896.338692551,6191655.24660856],[553971.720863708,6191655.24660856]]},\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", - "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":null,\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"FF13\",\"naming_description\":\"FF13 desc\",\"lifecycle_documentation_state\":null}" + "before": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":\"AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=\",\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"AB13\",\"naming_description\":\"AB13 desc\",\"lifecycle_documentation_state\":null}", + "before_coord": "AQIAAAACAAAALBxprVDnIEFFb8jPiZ5XQUUMFXHn5yBBRW/Iz4meV0E=", + "after": "{\"mrid\":\"66563e62-db0e-4184-be75-d55638bf33a5\",\"coord\":null,\"marked_to_be_deleted\":false,\"delete_me\":false,\"work_task_mrid\":\"d80f6250-8132-4893-b38f-b64fafd74316\",\"user_name\":\"Rune Nielsen\",\"application_name\":\"GDB_INTEGRATOR\",\"application_info\":\"Application information bla bla\",\"lifecycle_deployment_state\":\"InService\",\"lifecycle_installation_date\":\"2020-08-12T00:00:00Z\",\"lifecycle_removal_date\":\"2020-08-12T00:00:00Z\",\"mapping_method\":\"Drafting\",\"mapping_vertical_accuracy\":\"1\",\"mapping_horizontal_accuracy\":\"2\",\"mapping_source_info\":\"Source info\",\"mapping_survey_date\":\"2020-08-12T00:00:00Z\",\"safety_classification\":\"Very safe\",\"safety_remark\":\"Nothing to say\",\"routesegment_kind\":\"Arial\",\"routesegment_width\":\"10\",\"routesegment_height\":\"20\",\"naming_name\":\"FF13\",\"naming_description\":\"FF13 desc\",\"lifecycle_documentation_state\":null}", + "after_coord": "null" }