Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v1.2 XML parser #342

Merged
merged 4 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FasTnT.Domain/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public sealed class Constants

public int MaxEventsCapturePerCall { get; init; } = 500;
public int MaxEventsReturnedInQuery { get; init; } = 20_000;
public Version VendorVersion { get; init; } = Version.Parse("2.4.2");
public Version VendorVersion { get; init; } = Version.Parse("2.4.3");
}
582 changes: 266 additions & 316 deletions src/FasTnT.Host/Features/v1_2/Communication/Parsers/XmlEventParser.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
<epc>urn:epc:id:sscc:4001356.5900000822</epc>
</epcList>
<action>OBSERVE</action>
<baseExtension>
<eventID>object:test:event</eventID>
<errorDeclaration>
<declarationTime>2021-02-15T14:00:00+00:00</declarationTime>
<reason>Test reason</reason>
<correctiveEventIDs>
<correctiveEventID>1234</correctiveEventID>
<correctiveEventID>5678</correctiveEventID>
</correctiveEventIDs>
</errorDeclaration>
<extension>
<testExt>value</testExt>
</extension>
</baseExtension>
<bizStep>urn:epcglobal:cbv:bizstep:inspecting</bizStep>
<disposition>urn:epcglobal:cbv:disp:active</disposition>
<readPoint>
Expand All @@ -28,6 +42,13 @@
<uom>KGM</uom>
</quantityElement>
</quantityList>
<sourceList>
<source type="testSource">src</source>
</sourceList>
<destinationList>
<destination type="testDest">src</destination>
<destination type="testDest2">src2</destination>
</destinationList>
<ilmd>
<lotnumber xmlns="https://fastnt.net/epcis">230501</lotnumber>
</ilmd>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TransformationEvent xmlns:example="http://ns.example.com/epcis">
<eventTime>2013-10-31T14:58:56.591Z</eventTime>
<eventTimeZoneOffset>-02:00</eventTimeZoneOffset>
<inputEPCList>
<epc>urn:epc:id:sgtin:4012345.011122.25</epc>
<epc>urn:epc:id:sgtin:4000001.065432.99886655</epc>
</inputEPCList>
<inputQuantityList>
<quantityElement>
<epcClass>urn:epc:class:lgtin:4012345.011111.4444</epcClass>
<quantity>10</quantity>
<uom>KGM</uom>
</quantityElement>
<quantityElement>
<epcClass>urn:epc:class:lgtin:0614141.077777.987</epcClass>
<quantity>30</quantity>
<!-- As the uom field has been omitted, 30 instances (e.g., pieces) of
GTIN '00614141777778' belonging to lot '987' have been used. -->
</quantityElement>
<quantityElement>
<epcClass>urn:epc:idpat:sgtin:4012345.066666.*</epcClass>
<quantity>220</quantity>
<!-- As the uom field has been omitted and as an EPC pattern is
indicated, 220 instances (e.g., pieces) of GTIN '04012345666663' have been used. -->
</quantityElement>
</inputQuantityList>
<outputEPCList>
<epc>urn:epc:id:sgtin:4012345.077889.25</epc>
<epc>urn:epc:id:sgtin:4012345.077889.26</epc>
<epc>urn:epc:id:sgtin:4012345.077889.27</epc>
<epc>urn:epc:id:sgtin:4012345.077889.28</epc>
</outputEPCList>
<bizStep>urn:epcglobal:cbv:bizstep:commissioning</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:4012345.00001.0</id>
</readPoint>
<ilmd>
<!-- Section, in which the instance/ lot master data referring to the objects
indicated in the outputEPCList are defined.-->
<example:bestBeforeDate>2014-12-10</example:bestBeforeDate>
<!-- The namespace 'example' is just a placeholder for the domain under
which the ILMD attributes are defined (for instance, by a GS1 working group).
Meaning: the best before date of the above GTIN + lot is the 10th December 2014. -->
<example:batch>XYZ</example:batch>
</ilmd>
<example:myField>Example of a vendor/user extension</example:myField>
</TransformationEvent>
<extension>
<TransformationEvent xmlns:example="http://ns.example.com/epcis">
<eventTime>2013-10-31T14:58:56.591Z</eventTime>
<recordTime>2013-10-31T15:00:00.000Z</recordTime>
<eventTimeZoneOffset>-02:00</eventTimeZoneOffset>
<inputEPCList>
<epc>urn:epc:id:sgtin:4012345.011122.25</epc>
<epc>urn:epc:id:sgtin:4000001.065432.99886655</epc>
</inputEPCList>
<inputQuantityList>
<quantityElement>
<epcClass>urn:epc:class:lgtin:4012345.011111.4444</epcClass>
<quantity>10</quantity>
<uom>KGM</uom>
</quantityElement>
<quantityElement>
<epcClass>urn:epc:class:lgtin:0614141.077777.987</epcClass>
<quantity>30</quantity>
<!-- As the uom field has been omitted, 30 instances (e.g., pieces) of
GTIN '00614141777778' belonging to lot '987' have been used. -->
</quantityElement>
<quantityElement>
<epcClass>urn:epc:idpat:sgtin:4012345.066666.*</epcClass>
<quantity>220</quantity>
<!-- As the uom field has been omitted and as an EPC pattern is
indicated, 220 instances (e.g., pieces) of GTIN '04012345666663' have been used. -->
</quantityElement>
</inputQuantityList>
<outputEPCList>
<epc>urn:epc:id:sgtin:4012345.077889.25</epc>
<epc>urn:epc:id:sgtin:4012345.077889.26</epc>
<epc>urn:epc:id:sgtin:4012345.077889.27</epc>
<epc>urn:epc:id:sgtin:4012345.077889.28</epc>
</outputEPCList>
<bizStep>urn:epcglobal:cbv:bizstep:commissioning</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:4012345.00001.0</id>
</readPoint>
<ilmd>
<!-- Section, in which the instance/ lot master data referring to the objects
indicated in the outputEPCList are defined.-->
<example:bestBeforeDate>2014-12-10</example:bestBeforeDate>
<!-- The namespace 'example' is just a placeholder for the domain under
which the ILMD attributes are defined (for instance, by a GS1 working group).
Meaning: the best before date of the above GTIN + lot is the 10th December 2014. -->
<example:batch>XYZ</example:batch>
</ilmd>
<example:myField>Example of a vendor/user extension</example:myField>
</TransformationEvent>
</extension>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WhenParsingAValidAggregationEvent : XmlParsingTestCase
[TestInitialize]
public void When()
{
Event = new XmlEventParser().ParseAggregationEvent(ParseResource(ResourceName).Root);
Event = XmlEventParser.ParseEvent(ParseResource(ResourceName).Root);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WhenParsingAValidObjectEvent : XmlParsingTestCase
[TestInitialize]
public void When()
{
Event = new XmlEventParser().ParseObjectEvent(ParseResource(ResourceName).Root);
Event = XmlEventParser.ParseEvent(ParseResource(ResourceName).Root);
}

[TestMethod]
Expand Down Expand Up @@ -73,7 +73,7 @@ public void BizTransactionsShouldBeParsedCorrectly()
[TestMethod]
public void ExtensionFieldsShouldBeParsedCorrectly()
{
Assert.AreEqual(1, Event.Fields.Where(x => x.Type == FieldType.Extension).Count());
Assert.AreEqual(1, Event.Fields.Count(x => x.Type == FieldType.Extension));

Assert.AreEqual(3, Event.Fields.Count(x => x.ParentIndex.HasValue), "children fields should be parsed");
}
Expand All @@ -99,4 +99,19 @@ public void IlmdShouldBeParsedCorrectly()
{
Assert.AreEqual(1, Event.Fields.Count(x => x.Type == FieldType.Ilmd));
}

[TestMethod]
public void ErrorDeclarationShouldBeParsed()
{
Assert.IsNotNull(Event.CorrectiveDeclarationTime);
Assert.IsNotNull(Event.CorrectiveReason);
Assert.AreEqual(2, Event.CorrectiveEventIds.Count);
}

[TestMethod]
public void ItShouldParseSourceAndDestination()
{
Assert.AreEqual(1, Event.Sources.Count);
Assert.AreEqual(2, Event.Destinations.Count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WhenParsingAValidTransformationEvent : XmlParsingTestCase
[TestInitialize]
public void When()
{
Event = new XmlEventParser().ParseTransformationEvent(ParseResource(ResourceName).Root);
Event = XmlEventParser.ParseEvent(ParseResource(ResourceName).Root);
}

[TestMethod]
Expand Down