From e10588931164ad78e236f072de870780ae6703c5 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 29 Nov 2021 17:09:46 +0100 Subject: additional tests bug fixes on: - voucher - delay confirmation - parking --- .../org/uic/barcode/asn1/uper/SequenceCoder.java | 12 +- .../org/uic/barcode/asn1/uper/UperEncoder.java | 9 +- .../ticket/api/asn/omv1/DelayConfirmation.java | 27 +- .../ticket/api/asn/omv1/ParkingGroundData.java | 6 +- .../ticket/api/asn/omv1/TicketDetailData.java | 8 +- .../uic/barcode/ticket/api/asn/omv1/ZoneType.java | 4 + .../ticket/api/asn/omv2/DelayConfirmation.java | 26 +- .../ticket/api/asn/omv2/ParkingGroundData.java | 5 +- .../ticket/api/asn/omv2/TicketDetailData.java | 7 +- .../uic/barcode/ticket/api/asn/omv2/ZoneType.java | 4 + .../ticket/api/asn/omv3/DelayConfirmation.java | 27 +- .../ticket/api/asn/omv3/ParkingGroundData.java | 6 +- .../ticket/api/asn/omv3/TicketDetailData.java | 6 +- .../uic/barcode/ticket/api/asn/omv3/ZoneType.java | 3 + .../OpenLuggageRestrictionTestTicketV3.java | 518 +++++++++++++++++++++ .../ticket/api/utils/Api2OpenAsnEncoder.java | 8 +- .../ticket/api/utils/Api2OpenAsnEncoderV2.java | 6 +- .../ticket/api/utils/Api2OpenAsnEncoderV3.java | 4 +- .../ticket/api/utils/OpenAsn2ApiDecoder.java | 4 +- .../ticket/api/utils/OpenAsn2ApiDecoderV2.java | 4 +- .../ticket/api/utils/OpenAsn2ApiDecoderV3.java | 4 +- .../ticket/api/test/AsnLevelCarCarriageTestV3.java | 133 ++++++ .../api/test/AsnLevelCountermarkComplexTestV1.java | 95 ++++ .../api/test/AsnLevelCountermarkComplexTestV3.java | 158 +++++++ .../api/test/AsnLevelDelayConfirmationTestV3.java | 143 ++++++ .../ticket/api/test/AsnLevelParkingTestV3.java | 110 +++++ .../api/test/AsnLevelStationPassageTestV3.java | 95 ++++ .../ticket/api/test/AsnLevelVoucherTestV3.java | 108 +++++ .../ticket/api/test/CounterMarkTimeZoneTestV3.java | 312 +++++++++++++ .../ticket/api/test/CountermarkComplexTestV1.java | 95 ---- .../ticket/api/test/CountermarkComplexTestV3.java | 111 ----- .../ticket/api/test/OpenTicketComplexTestV3.java | 222 +++++---- .../OpenTicketRestrictedLuggageComplexTestV3.java | 131 ++++++ .../barcode/ticket/api/test/PassComplexTestV3.java | 201 ++++---- .../CarCarriageReservationTestTicketV3.java | 325 +++++++++++++ .../CountermarkTestComplexTicketV3.java | 170 +------ .../api/test/testtickets/DelayTestTicketV3.java | 138 +++++- .../api/test/testtickets/LuggageTestTicketV2.java | 150 ++++++ .../api/test/testtickets/ParkingTestTicketV3.java | 87 ++++ .../testtickets/StationPassageTestTicketV3.java | 93 +++- .../api/test/testtickets/VoucherTestTicketV3.java | 81 ++++ .../ticketTestDB/DecodeSparpreisTicketDBTest.java | 4 + 42 files changed, 2980 insertions(+), 680 deletions(-) create mode 100644 src/main/java/org/uic/barcode/ticket/api/test/testtickets/OpenLuggageRestrictionTestTicketV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java delete mode 100644 src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV1.java delete mode 100644 src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/testtickets/LuggageTestTicketV2.java (limited to 'src') diff --git a/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java b/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java index 5e8386e..ce89a3e 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java @@ -13,6 +13,11 @@ import org.uic.barcode.asn1.uper.UperEncoder.Asn1ContainerFieldSorter; class SequenceCoder implements Decoder, Encoder { @Override public boolean canEncode(T obj, Annotation[] extraAnnotations) { + + if (obj == null || obj.getClass() == null) { + return false; + } + Class type = obj.getClass(); AnnotationStore annotations = new AnnotationStore(type.getAnnotations(), extraAnnotations); @@ -53,7 +58,12 @@ class SequenceCoder implements Decoder, Encoder { pos = String.format("Position: %d.%d", bitbuffer.position()/8 , bitbuffer.position() % 8); UperEncoder.logger.debug(String.format("%s: Field %s", pos, f.getName())); try { - UperEncoder.encode2(bitbuffer, f.get(obj), f.getAnnotations()); + Object o = f.get(obj); + if (o != null) { + UperEncoder.encode2(bitbuffer, f.get(obj), f.getAnnotations()); + } else { + throw new Asn1EncodingException("missing object " + f.getName()); + } } catch (Asn1EncodingException e) { throw new Asn1EncodingException("." + f.getName(), e); } catch (IllegalArgumentException e) { diff --git a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java index bba64e2..d5c5d1e 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java @@ -89,7 +89,14 @@ public final class UperEncoder { static void encode2(BitBuffer bitbuffer, T obj, Annotation[] extraAnnotations) throws Asn1EncodingException { - for (Encoder e : encoders) { + + if (obj == null) { + logger.debug(String.format("Object missing")); + return; + } + + + for (Encoder e : encoders) { if (e.canEncode(obj, extraAnnotations)) { e.encode(bitbuffer, obj, extraAnnotations); return; diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java index 4f61ff3..a3df48b 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java @@ -84,28 +84,24 @@ public class DelayConfirmation extends Object { @Asn1Optional public String stationIA5; @FieldOrder(order = 11) - @RestrictedString(CharacterRestriction.UTF8String) - @Asn1Optional public String stationNameUTF8; + @IntRange(minValue=1, maxValue=999) + public Long delay; @FieldOrder(order = 12) - @IntRange(minValue=0, maxValue=999, hasExtensionMarker=false) - @Asn1Optional public Long delay; + public Boolean trainCancelled = false; @FieldOrder(order = 13) - @Asn1Optional public Boolean trainCancelled = false; - - @FieldOrder(order = 14) @Asn1Default(value="travelerDelayConfirmation") @Asn1Optional public ConfirmationTypeType confirmationType; - @FieldOrder(order = 15) + @FieldOrder(order = 14) @Asn1Optional public SequenceOfTicketLinkType affectedTickets; - @FieldOrder(order = 16) + @FieldOrder(order = 15) @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String infoText; - @FieldOrder(order = 17) + @FieldOrder(order = 16) @Asn1Optional public ExtensionData extension; @@ -163,11 +159,7 @@ public class DelayConfirmation extends Object { return this.stationIA5; } - public String getStationNameUTF8() { - - return this.stationNameUTF8; - } - + public Long getDelay() { return this.delay; @@ -255,11 +247,6 @@ public class DelayConfirmation extends Object { this.stationIA5 = stationIA5; } - public void setStationNameUTF8(String stationNameUTF8) { - - this.stationNameUTF8 = stationNameUTF8; - } - public void setDelay(Long delay) { this.delay = delay; diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java index d88d4dd..53cb4c0 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java @@ -51,10 +51,11 @@ public class ParkingGroundData extends Object { @FieldOrder(order = 3) @IntRange(minValue=0,maxValue=370) - @Asn1Optional public Long fromParkingDate; + public Long fromParkingDate; @FieldOrder(order = 4) @IntRange(minValue=-1,maxValue=370) + @Asn1Default(value = "0") @Asn1Optional public Long toParkingDate; @FieldOrder(order = 5) @@ -86,11 +87,10 @@ public class ParkingGroundData extends Object { @Asn1Optional public CodeTableType stationCodeTable; @FieldOrder(order = 12) - @IntRange(minValue=1,maxValue=9999999) @Asn1Optional public Long stationNum; @FieldOrder(order = 13) - @RestrictedString(CharacterRestriction.IA5String) + @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String stationIA5; @FieldOrder(order = 14) diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java index e32bb98..7a86d56 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java @@ -24,6 +24,8 @@ package org.uic.barcode.ticket.api.asn.omv1; import org.uic.barcode.asn1.datatypes.Choice; import org.uic.barcode.asn1.datatypes.FieldOrder; import org.uic.barcode.asn1.datatypes.HasExtensionMarker; +import org.uic.barcode.ticket.api.asn.omv1.DelayConfirmation; +import org.uic.barcode.ticket.api.asn.omv1.ExtensionData; @Choice @HasExtensionMarker @@ -62,10 +64,10 @@ public class TicketDetailData extends Object { public StationPassageData stationPassage; @FieldOrder(order = 10) - public DelayConfirmation delayConfirmation; - + public ExtensionData extension; + @FieldOrder(order = 11) - public ExtensionData extension; + public DelayConfirmation delayConfirmation; public ReservationData getReservation() { diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ZoneType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ZoneType.java index a22e002..efe55f7 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ZoneType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ZoneType.java @@ -124,6 +124,10 @@ public class ZoneType extends Object { public byte[] getBinaryZoneId() { + if (binaryZoneId == null) { + return null; + } + return binaryZoneId.toByteArray(); } diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java index 72abeb0..acf99d5 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java @@ -84,28 +84,24 @@ public class DelayConfirmation extends Object { @Asn1Optional public String stationIA5; @FieldOrder(order = 11) - @RestrictedString(CharacterRestriction.UTF8String) - @Asn1Optional public String stationNameUTF8; + @IntRange(minValue=1, maxValue=999) + public Long delay; @FieldOrder(order = 12) - @IntRange(minValue=0, maxValue=999, hasExtensionMarker=false) - @Asn1Optional public Long delay; + public Boolean trainCancelled = false; @FieldOrder(order = 13) - @Asn1Optional public Boolean trainCancelled = false; - - @FieldOrder(order = 14) @Asn1Default(value="travelerDelayConfirmation") @Asn1Optional public ConfirmationTypeType confirmationType; - @FieldOrder(order = 15) + @FieldOrder(order = 14) @Asn1Optional public SequenceOfTicketLinkType affectedTickets; - @FieldOrder(order = 16) + @FieldOrder(order = 15) @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String infoText; - @FieldOrder(order = 17) + @FieldOrder(order = 16) @Asn1Optional public ExtensionData extension; @@ -163,11 +159,6 @@ public class DelayConfirmation extends Object { return this.stationIA5; } - public String getStationNameUTF8() { - - return this.stationNameUTF8; - } - public Long getDelay() { return this.delay; @@ -255,11 +246,6 @@ public class DelayConfirmation extends Object { this.stationIA5 = stationIA5; } - public void setStationNameUTF8(String stationNameUTF8) { - - this.stationNameUTF8 = stationNameUTF8; - } - public void setDelay(Long delay) { this.delay = delay; diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java index b917bf8..efffe52 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java @@ -51,10 +51,11 @@ public class ParkingGroundData extends Object { @FieldOrder(order = 3) @IntRange(minValue=-1,maxValue=370) - @Asn1Optional public Long fromParkingDate; + public Long fromParkingDate; @FieldOrder(order = 4) @IntRange(minValue=0,maxValue=370) + @Asn1Default(value = "0") @Asn1Optional public Long toParkingDate; @FieldOrder(order = 5) @@ -90,7 +91,7 @@ public class ParkingGroundData extends Object { @Asn1Optional public Long stationNum; @FieldOrder(order = 13) - @RestrictedString(CharacterRestriction.IA5String) + @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String stationIA5; @FieldOrder(order = 14) diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java index 4cdac60..47c48da 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java @@ -24,6 +24,8 @@ package org.uic.barcode.ticket.api.asn.omv2; import org.uic.barcode.asn1.datatypes.Choice; import org.uic.barcode.asn1.datatypes.FieldOrder; import org.uic.barcode.asn1.datatypes.HasExtensionMarker; +import org.uic.barcode.ticket.api.asn.omv2.DelayConfirmation; +import org.uic.barcode.ticket.api.asn.omv2.ExtensionData; @Choice @HasExtensionMarker @@ -62,10 +64,11 @@ public class TicketDetailData extends Object { public StationPassageData stationPassage; @FieldOrder(order = 10) + public ExtensionData extension; + + @FieldOrder(order = 11) public DelayConfirmation delayConfirmation; - @FieldOrder(order = 11) - public ExtensionData extension; public ReservationData getReservation() { diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ZoneType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ZoneType.java index 3f269ee..db008e5 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ZoneType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ZoneType.java @@ -124,6 +124,10 @@ public class ZoneType extends Object { public byte[] getBinaryZoneId() { + if (binaryZoneId == null) { + return null; + } + return binaryZoneId.toByteArray(); } diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/DelayConfirmation.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/DelayConfirmation.java index 8d8b4c6..daa9429 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/DelayConfirmation.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/DelayConfirmation.java @@ -84,28 +84,24 @@ public class DelayConfirmation extends Object { @Asn1Optional public String stationIA5; @FieldOrder(order = 11) - @RestrictedString(CharacterRestriction.UTF8String) - @Asn1Optional public String stationNameUTF8; + @IntRange(minValue=1, maxValue=999, hasExtensionMarker=false) + public Long delay; @FieldOrder(order = 12) - @IntRange(minValue=0, maxValue=999, hasExtensionMarker=false) - @Asn1Optional public Long delay; + public Boolean trainCancelled = false; @FieldOrder(order = 13) - @Asn1Optional public Boolean trainCancelled = false; - - @FieldOrder(order = 14) @Asn1Default(value="travelerDelayConfirmation") @Asn1Optional public ConfirmationTypeType confirmationType; - @FieldOrder(order = 15) + @FieldOrder(order = 14) @Asn1Optional public SequenceOfTicketLinkType affectedTickets; - @FieldOrder(order = 16) + @FieldOrder(order = 15) @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String infoText; - @FieldOrder(order = 17) + @FieldOrder(order = 16) @Asn1Optional public ExtensionData extension; @@ -163,11 +159,7 @@ public class DelayConfirmation extends Object { return this.stationIA5; } - public String getStationNameUTF8() { - - return this.stationNameUTF8; - } - + public Long getDelay() { return this.delay; @@ -255,11 +247,6 @@ public class DelayConfirmation extends Object { this.stationIA5 = stationIA5; } - public void setStationNameUTF8(String stationNameUTF8) { - - this.stationNameUTF8 = stationNameUTF8; - } - public void setDelay(Long delay) { this.delay = delay; diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ParkingGroundData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ParkingGroundData.java index 53f0bca..90a3568 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ParkingGroundData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ParkingGroundData.java @@ -51,10 +51,11 @@ public class ParkingGroundData extends Object { @FieldOrder(order = 3) @IntRange(minValue=-367,maxValue=370) - @Asn1Optional public Long fromParkingDate; + public Long fromParkingDate; @FieldOrder(order = 4) @IntRange(minValue=0,maxValue=370) + @Asn1Default(value="0") @Asn1Optional public Long toParkingDate; @FieldOrder(order = 5) @@ -86,11 +87,10 @@ public class ParkingGroundData extends Object { @Asn1Optional public CodeTableType stationCodeTable; @FieldOrder(order = 12) - @IntRange(minValue=1,maxValue=9999999) @Asn1Optional public Long stationNum; @FieldOrder(order = 13) - @RestrictedString(CharacterRestriction.IA5String) + @RestrictedString(CharacterRestriction.UTF8String) @Asn1Optional public String stationIA5; @FieldOrder(order = 14) diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/TicketDetailData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/TicketDetailData.java index a5e2e56..669241c 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/TicketDetailData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/TicketDetailData.java @@ -62,10 +62,10 @@ public class TicketDetailData extends Object { public StationPassageData stationPassage; @FieldOrder(order = 10) - public DelayConfirmation delayConfirmation; - + public ExtensionData extension; + @FieldOrder(order = 11) - public ExtensionData extension; + public DelayConfirmation delayConfirmation; public ReservationData getReservation() { diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ZoneType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ZoneType.java index 3e3f193..8fdd3af 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ZoneType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/ZoneType.java @@ -124,6 +124,9 @@ public class ZoneType extends Object { public byte[] getBinaryZoneId() { + if (binaryZoneId == null) { + return null; + } return binaryZoneId.toByteArray(); } diff --git a/src/main/java/org/uic/barcode/ticket/api/test/testtickets/OpenLuggageRestrictionTestTicketV3.java b/src/main/java/org/uic/barcode/ticket/api/test/testtickets/OpenLuggageRestrictionTestTicketV3.java new file mode 100644 index 0000000..f14acfa --- /dev/null +++ b/src/main/java/org/uic/barcode/ticket/api/test/testtickets/OpenLuggageRestrictionTestTicketV3.java @@ -0,0 +1,518 @@ +/* + * This file was generated by openASN.1 - an open source ASN.1 toolkit for java + * + * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland + * + * openASN.1 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * openASN.1 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with openASN.1. If not, see . + * + */ +package org.uic.barcode.ticket.api.test.testtickets; + +import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8; +import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong; +import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.ControlData; +import org.uic.barcode.ticket.api.asn.omv3.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.DocumentData; +import org.uic.barcode.ticket.api.asn.omv3.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv3.IssuingData; +import org.uic.barcode.ticket.api.asn.omv3.LinkMode; +import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData; +import org.uic.barcode.ticket.api.asn.omv3.PassengerType; +import org.uic.barcode.ticket.api.asn.omv3.RegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv3.RegisteredLuggageType; +import org.uic.barcode.ticket.api.asn.omv3.RouteSectionType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfIncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfRegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfRegisteredLuggageType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTariffType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTicketLinkType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfVatDetail; +import org.uic.barcode.ticket.api.asn.omv3.StationPassageData; +import org.uic.barcode.ticket.api.asn.omv3.TariffType; +import org.uic.barcode.ticket.api.asn.omv3.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv3.TicketLinkType; +import org.uic.barcode.ticket.api.asn.omv3.TicketType; +import org.uic.barcode.ticket.api.asn.omv3.TokenType; +import org.uic.barcode.ticket.api.asn.omv3.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv3.TravelerData; +import org.uic.barcode.ticket.api.asn.omv3.TravelerType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv3.VatDetailType; +import org.uic.barcode.ticket.api.asn.omv3.ZoneType; +import org.uic.barcode.ticket.api.asn.omv3.LuggageRestrictionType; + + public class OpenLuggageRestrictionTestTicketV3 { + + public static UicRailTicketData getUicTestTicket() { + UicRailTicketData ticket = new UicRailTicketData(); + populateTicket(ticket); + return ticket; + } + + /* +value UicRailTicketData ::= { + issuingDetail { + issuingYear 2018, + issuingDay 1, + issuingTime 600, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "senior" + } + } + } + }, + groupName "myGroup" + }, + transportDocument { + { + token { + tokenProviderIA5 "VDV", + token '82DA'H + }, + ticket openTicket : { + returnIncluded FALSE, + stationCodeTable stationUIC, + validFromDay 0, + validUntilDay 0, + classCode first, + vatDetail { + { + country 80, + percentage 70, + amount 10, + vatId "IUDGTE" + } + }, + infoText "openTicketInfo", + includedAddOns { + { + productOwnerNum 1080, + stationCodeTable stationUIC, + validRegion { + zones : { + stationCodeTable stationUIC, + zoneId { + 100 + } + } + }, + validFromDay 0, + validFromTime 1000, + validUntilDay 1, + validUntilTime 1000, + classCode second, + tariffs { + { + numberOfPassengers 2, + passengerType adult, + restrictedToCountryOfResidence FALSE, + restrictedToRouteSection { + stationCodeTable stationUIC, + fromStationNum 8000001, + toStationNum 8010000 + } + } + }, + infoText "included ticket" + } + }, + luggage { + maxHandLuggagePieces 2, + maxNonHandLuggagePieces 1, + registeredLuggage { + { + registrationId "IODHUV", + maxWeight 20, + maxSize 100 + }, + { + registrationId "XXDHUV", + maxWeight 21, + maxSize 101 + } + } + } + } + }, + { + ticket stationPassage : { + productName "passage", + stationCodeTable stationUIC, + stationNameUTF8 { + "Amsterdam" + }, + validFromDay 0, + validUntilDay 0, + numberOfDaysValid 123 + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd", + includedTickets { + { + referenceIA5 "UED12435867", + issuerName "OEBB", + issuerPNR "PNR", + productOwnerIA5 "test", + ticketType pass, + linkMode onlyValidInCombination + } + } + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + + */ + + + + public static String getEncodingHex() { + return + "7804404004B14374F3E7D72F2A9979F4A13A90086280B4001044A6F686" + + "E03446F770562C99B46B01106E797769DFC81DB5E51DC9BDD5C00940" + + "75A2560282DA1000000101E0101C4F11804281A4D5891EA450E6F706" + + "56E5469636B6574496E666F0140AD06021B8090020080B23E8013E81" + + "00B10008143D09003D1C8787B4B731B63AB232B2103A34B1B5B2BA28" + + "202706933E248AB58998DC1AC588922AD62864120220103B830B9B9B" + + "0B3B28084A0B6B9BA32B93230B696F017B4C0200805900026364015B" + + "85D58B118B268CDAB86CDC113D1509080E84EA409D32F3E850201620" + + "505B402C80A0F680"; + + } + + + + private static void populateTicket(UicRailTicketData ticket) { + + ticket.setControlDetail(new ControlData()); + populate(ticket.getControlDetail()); + + + ticket.setIssuingDetail(new IssuingData()); + populateIssuingData(ticket.getIssuingDetail()); + + TravelerData td = new TravelerData(); + populateTravelerData(td); + ticket.setTravelerDetail(td); + + SequenceOfDocumentData ds = new SequenceOfDocumentData(); + + + //OpenTicket + DocumentData do1 = new DocumentData(); + addOpenTicketData(do1); + ds.add(do1); + + //StationPassage + DocumentData do2 = new DocumentData(); + addStationPassage(do2); + ds.add(do2); + + ticket.setTransportDocument(ds); + + SequenceOfExtensionData ed = new SequenceOfExtensionData(); + populateExtensionSequence(ed); + ticket.setExtension(ed); + + } + + private static void addStationPassage(DocumentData dd) { + TicketDetailData tdd = new TicketDetailData(); + StationPassageData sp = new StationPassageData(); + sp.setProductName("passage"); + sp.setValidFromDay(0L); + sp.setNumberOfDaysValid(123L); + SequenceOfStringUTF8 ss = new SequenceOfStringUTF8(); + ss.add("Amsterdam"); + sp.setStationNameUTF8(ss); + tdd.setStationPassage(sp); + dd.setTicket(tdd); + } + + /* + * + * returnIncluded FALSE + ,classCode first + ,vatDetail { + { country 80 + ,percentage 70 + ,amount 10 + ,vatId "IUDGTE" + } + } + ,infoText "openTicketInfo" + */ + private static void addOpenTicketData(DocumentData dd) { + TokenType to = new TokenType(); + to.setTokenProviderIA5("VDV"); + byte[] ba = { (byte) 0x82, (byte) 0xDA }; + to.setToken(ba); + dd.setToken(to); + + TicketDetailData tdd = new TicketDetailData(); + OpenTicketData otd = new OpenTicketData(); + otd.setInfoText("openTicketInfo"); + otd.setClassCode(TravelClassType.first); + otd.setReturnIncluded(false); + + otd.setIncludedAddOns(new SequenceOfIncludedOpenTicketType()); + otd.getIncludedAddOns().add(getIncludedOpenTicket()); + + otd.setVatDetails(new SequenceOfVatDetail()); + otd.getVatDetails().add(getVatDetail()); + + otd.setLuggage(getLuggage()); + + tdd.setOpenTicket(otd); + dd.setTicket(tdd); + + } + + private static LuggageRestrictionType getLuggage() { + LuggageRestrictionType l = new LuggageRestrictionType(); + l.setMaxHandLuggagePieces(2L); + l.setMaxNonHandLuggagePieces(1L); + l.setRegisteredLuggage(getRegisteredLuggage()); + return l; + } + + private static SequenceOfRegisteredLuggageType getRegisteredLuggage() { + SequenceOfRegisteredLuggageType sl = new SequenceOfRegisteredLuggageType(); + sl.add(getRegisteredLuggage1()); + sl.add(getRegisteredLuggage2()); + return sl; + } + + private static RegisteredLuggageType getRegisteredLuggage1() { + RegisteredLuggageType rl = new RegisteredLuggageType(); + rl.setMaxSize(100L); + rl.setMaxWeight(20L); + rl.setRegistrationId("IODHUV"); + return rl; + } + + private static RegisteredLuggageType getRegisteredLuggage2() { + RegisteredLuggageType rl = new RegisteredLuggageType(); + rl.setMaxSize(101L); + rl.setMaxWeight(21L); + rl.setRegistrationId("XXDHUV"); + return rl; + } + + private static VatDetailType getVatDetail() { + VatDetailType v = new VatDetailType(); + v.setAmount(10L); + v.setCountry(80L); + v.setPercentage(70L); + v.setVatId("IUDGTE"); + return v; + } + + /* + { productOwnerNum 1080 + ,validRegion { zones : { zoneId { 100 } } } + ,validFromDay 0 + ,validFromTime 1000 + ,validUntilDay 1 + ,validUntilTime 1000 + ,classCode second + ,tariffs { + { numberOfPassengers 2 + ,passengerType adult + ,restrictedToCountryOfResidence FALSE + ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 } + } + } + ,infoText "included ticket" + } + */ + + private static IncludedOpenTicketType getIncludedOpenTicket() { + IncludedOpenTicketType t = new IncludedOpenTicketType(); + t.setClassCode(TravelClassType.second); + t.setInfoText("included ticket"); + t.setProductOwnerNum(1080L); + t.setValidRegion(new SequenceOfRegionalValidityType()); + t.getValidRegion().add(getZone()); + t.setValidFromDay(0L); + t.setValidFromTime(1000L); + t.setValidUntilDay(1L); + t.setValidUntilTime(1000L); + t.setTariffs(new SequenceOfTariffType()); + t.getTariffs().add(getTariff()); + return t; + } + + + + + private static RegionalValidityType getZone() { + + RegionalValidityType r = new RegionalValidityType(); + ZoneType z = new ZoneType(); + z.setZoneId(new SequenceOfUnrestrictedLong()); + z.getZoneId().add(100L); + r.setZones(z); + return r; + } + + private static void populateTravelerData(TravelerData td) { + td.setGroupName("myGroup"); + SequenceOfTravelerType trs = new SequenceOfTravelerType(); + TravelerType tr = new TravelerType(); + tr.setIdCard("12345"); + tr.setFirstName("John"); + tr.setSecondName("Dow"); + tr.setTicketHolder(true); + SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType(); + CustomerStatusType cst = new CustomerStatusType(); + cst.setCustomerStatusDescr("senior"); + ts.add(cst); + tr.setStatus(ts); + trs.add(tr); + td.setTraveler(trs); + } + +/* + + */ + private static void populateIssuingData(IssuingData issuingDetail) { + issuingDetail.setIssuingYear(2018L); + issuingDetail.setIssuingDay(1L); + issuingDetail.setIssuingTime(600L); + issuingDetail.setIssuerPNR("issuerTestPNR"); + issuingDetail.setSpecimen(true); + issuingDetail.setSecurePaperTicket(false); + issuingDetail.setActivated(true); + issuingDetail.setIssuedOnLine(12L); + } + + + private static void populateExtensionSequence(SequenceOfExtensionData ed) { + ExtensionData ed1 = new ExtensionData(); + ed1.setExtensionId("1"); + byte[] ba1 = { (byte) 0x82, (byte) 0xDA }; + ed1.setExtensionData(ba1); + ExtensionData ed2 = new ExtensionData(); + ed2.setExtensionId("2"); + byte[] ba2 = { (byte) 0x83, (byte) 0xDA }; + ed2.setExtensionData(ba2); + ed.add(ed1); + ed.add(ed2); + } + + + private static void populate(ControlData controlDetail) { + controlDetail.infoText = "cd"; + controlDetail.setAgeCheckRequired(false); + controlDetail.setIdentificationByIdCard(false); + controlDetail.setIdentificationByPassportId(false); + controlDetail.setOnlineValidationRequired(false); + controlDetail.setPassportValidationRequired(false); + controlDetail.setReductionCardCheckRequired(false); + controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType()); + controlDetail.getIdentificationByCardReference().add(populateCardRefrence()); + SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType(); + populateLinkedTickets(sit); + controlDetail.setIncludedTickets(sit); + } + + + /* + * + */ + private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) { + TicketLinkType tlt = new TicketLinkType(); + tlt.productOwnerIA5="test"; + tlt.setTicketType(TicketType.pass); + tlt.setIssuerPNR("PNR"); + tlt.setReferenceIA5("UED12435867"); + tlt.setLinkMode(LinkMode.onlyValidInCombination); + tlt.setIssuerName("OEBB"); + sequenceOfTicketLinkType.add(tlt); + } + + /* + { + trailingCardIdNum 100 + } + */ + private static CardReferenceType populateCardRefrence() { + CardReferenceType cr = new CardReferenceType(); + cr.setTrailingCardIdNum(100L); + return cr; + } + + private static TariffType getTariff() { + TariffType t = new TariffType(); + t.setNumberOfPassengers(2L); + t.setPassengerType(PassengerType.adult); + t.setRestrictedToRouteSection(getRouteSection()); + t.setRestrictedToCountryOfResidence(false); + return t; + } + + private static RouteSectionType getRouteSection() { + RouteSectionType r = new RouteSectionType(); + r.setFromStationNum(8000001L); + r.setToStationNum(8010000L); + + return r; + } + + } diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java index cab9b53..f4b9569 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java @@ -319,9 +319,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setInfoText(document.getInfoText()); - - asnData.setStationNameUTF8(document.getStationName()); - + asnData.setExtension(encodeExtension(document.getExtension())); return asnDocument; @@ -977,7 +975,9 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { } } - + asnData.setGroupName(document.getGroupName()); + asnData.setNumberOfCountermark(new Long(document.getNumberOfCountermark())); + asnData.setTotalOfCountermarks(new Long(document.getTotalOfCountermarks())); asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference())); asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference())); diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java index 184dfd7..6bffddc 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java @@ -317,8 +317,6 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setInfoText(document.getInfoText()); - asnData.setStationNameUTF8(document.getStationName()); - asnData.setExtension(encodeExtension(document.getExtension())); return asnDocument; @@ -981,7 +979,9 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { } } - + asnData.setGroupName(document.getGroupName()); + asnData.setNumberOfCountermark(new Long(document.getNumberOfCountermark())); + asnData.setTotalOfCountermarks(new Long(document.getTotalOfCountermarks())); asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference())); asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference())); diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java index 9084d7a..6766f59 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java @@ -320,7 +320,6 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setInfoText(document.getInfoText()); - asnData.setStationNameUTF8(document.getStationName()); asnData.setExtension(encodeExtension(document.getExtension())); @@ -984,6 +983,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { } } + asnData.setGroupName(document.getGroupName()); + asnData.setNumberOfCountermark(new Long(document.getNumberOfCountermark())); + asnData.setTotalOfCountermarks(new Long(document.getTotalOfCountermarks())); asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference())); diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java index bf3918c..031d5b3 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java @@ -366,9 +366,7 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder { document.setStationCodeTable(IStationCodeTable.valueOf(asnDocument.getStationCodeTable().name())); } document.setStation(UicEncoderUtils.mapToString(asnDocument.getStationNum(),asnDocument.getStationIA5())); - - document.setStationName(asnDocument.getStationNameUTF8()); - + document.setArrivalDate(asnDocument.getPlannedArrivalDate()); document.setArrivalUTCoffset(asnDocument.getDepartureUTCOffset()); diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java index fc68f91..1d50cb8 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java @@ -368,9 +368,7 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder { document.setStationCodeTable(IStationCodeTable.valueOf(asnDocument.getStationCodeTable().toString())); } document.setStation(UicEncoderUtils.mapToString(asnDocument.getStationNum(),asnDocument.getStationIA5())); - - document.setStationName(asnDocument.getStationNameUTF8()); - + document.setArrivalDate(asnDocument.getPlannedArrivalDate()); document.setArrivalUTCoffset(asnDocument.getDepartureUTCOffset()); diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java index 56efcb1..73971c9 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java @@ -371,9 +371,7 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder { document.setStationCodeTable(IStationCodeTable.valueOf(asnDocument.getStationCodeTable().toString())); } document.setStation(UicEncoderUtils.mapToString(asnDocument.getStationNum(),asnDocument.getStationIA5())); - - document.setStationName(asnDocument.getStationNameUTF8()); - + document.setArrivalDate(asnDocument.getPlannedArrivalDate()); document.setArrivalUTCoffset(asnDocument.getDepartureUTCOffset()); diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java new file mode 100644 index 0000000..294c9d9 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java @@ -0,0 +1,133 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData; +import org.uic.barcode.ticket.api.asn.omv3.LoadingDeckType; +import org.uic.barcode.ticket.api.asn.omv3.PriceTypeType; +import org.uic.barcode.ticket.api.asn.omv3.RoofRackType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.CarCarriageReservationTestTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelCarCarriageTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = CarCarriageReservationTestTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = CarCarriageReservationTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = CarCarriageReservationTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + byte[] encoded = UperEncoder.encode(ticket); + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = CarCarriageReservationTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + assert(ticket.getTransportDocument().get(0).getTicket().getCarCarriageReservation() != null); + + CarCarriageReservationData c = ticket.getTransportDocument().get(0).getTicket().getCarCarriageReservation(); + + assert(c.getAttachedBicycles() == 1L); + assert(c.getAttachedSurfboards() == 2L); + assert(c.getBeginLoadingDate() == 10L); + assert(c.getBeginLoadingTime() == 0L); + assert(c.getCarCategory() == 3L); + assert(c.getCoach().equals("21")); + assert(c.getPlace().equals("41")); + assert(c.getEndLoadingTime() == 500L); + assert(c.getFromStationNum() == 8100001L); + assert(c.getToStationNum() == 800001L); + assert(c.getInfoText().equals("car carriage")); + assert(c.getLoadingDeck().equals(LoadingDeckType.upper)); + assert(c.getLoadingListEntry() == 421L); + assert(c.getTrainNum() == 123L); + assert(c.getNumberPlate().equals("AD-DE-123")); + assert(c.getTrailerPlate().equals("DX-AB-123")); + assert(c.getTextileRoof() == false); + assert(c.getServiceBrandAbrUTF8().equals("AZ")); + assert(c.getServiceBrandNameUTF8().equals("special train")); + assert(c.getServiceBrand() == 100L); + assert(c.getRoofRackType().equals(RoofRackType.bicycleRack)); + assert(c.getTariff() != null); + assert(c.getRoofRackHeight() == 20L); + assert(c.getPriceType().equals(PriceTypeType.travelPrice)); + assert(c.getReferenceNum() == 810123456789L); + assert(c.getVatDetails() != null); + assert(c.getCarrierNum().contains(1080L)); + assert(c.getCarrierNum().contains(1181L)); + assert(c.getPrice() == 12345L); + + + } + + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java new file mode 100644 index 0000000..e7dbd50 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java @@ -0,0 +1,95 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV1; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelCountermarkComplexTestV1 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = CountermarkTestComplexTicketV1.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = CountermarkTestComplexTicketV1.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + //ticket = OpenTestComplexTicketV2.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = CountermarkTestComplexTicketV1.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java new file mode 100644 index 0000000..918615c --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java @@ -0,0 +1,158 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.CountermarkData; +import org.uic.barcode.ticket.api.asn.omv3.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv3.ViaStationType; +import org.uic.barcode.ticket.api.asn.omv3.ZoneType; +import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelCountermarkComplexTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = CountermarkTestComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + assert(ticket.getControlDetail() != null); + + assert(ticket.getIssuingDetail() != null); + + assert(ticket.getTransportDocument() != null); + + assert(ticket.getTransportDocument().get(0).getTicket().getCounterMark() != null); + + CountermarkData cm = ticket.getTransportDocument().get(0).getTicket().getCounterMark(); + + assert(cm.getClassCode().equals(TravelClassType.first)); + assert(cm.getGroupName().equals("groupName")); + assert(cm.getInfoText().equals("counterMark")); + assert(cm.getNumberOfCountermark().equals(12L)); + assert(cm.getTotalOfCountermarks().equals(24L)); + assert(cm.getReturnIncluded().equals(false)); + assert(cm.getValidRegion() != null); + assert(cm.getValidRegion().get(0).getViaStations() != null); + assert(cm.getValidRegion().get(1).getZones() != null); + + ZoneType zone = cm.getValidRegion().get(1).getZones(); + + assert(zone.getZoneId() != null); + assert(zone.getZoneId().get(0).equals(100L)); + assert(zone.getZoneId().get(1).equals(200L)); + + ViaStationType via = cm.getValidRegion().get(0).getViaStations(); + + assert(via.getBorder().equals(false)); + assert(via.getSeriesId().equals(999L)); + assert(via.getRoute().size() == 4); + assert(via.getRoute().get(0).getStationNum() == 123455L); + assert(via.getRoute().get(1).getStationNum() == 123456L); + assert(via.getRoute().get(2).getAlternativeRoutes().size() == 2); + assert(via.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().size() == 2); + assert(via.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().size() == 2); + assert(via.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(0).getStationNum() == 23455L); + assert(via.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).getStationNum() == 23456L); + assert(via.getRoute().get(3).getStationNum() == 123457L); + + assert(ticket.getTravelerDetail() != null); + + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = CountermarkTestComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + //ticket = OpenTestComplexTicketV2.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = CountermarkTestComplexTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + @Test public void encodingDecoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = CountermarkTestComplexTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = CountermarkTestComplexTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java new file mode 100644 index 0000000..72af687 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java @@ -0,0 +1,143 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.LinkMode; +import org.uic.barcode.ticket.api.asn.omv3.TicketType; +import org.uic.barcode.ticket.api.asn.omv3.DelayConfirmation; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.DelayTestTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelDelayConfirmationTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = DelayTestTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = DelayTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = DelayTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + byte[] encoded = UperEncoder.encode(ticket); + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = DelayTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + assert(ticket.getTransportDocument().get(0).getTicket().getDelayConfirmation() != null); + + DelayConfirmation del = ticket.getTransportDocument().get(0).getTicket().getDelayConfirmation(); + + /* + * + referenceIA5 "ABDJ12345", + trainNum 100, + departureYear 2022, + departureDay 12, + departureTime 1000, + stationCodeTable stationUIC, + stationNum 8000001, + delay 31, + trainCancelled FALSE, + confirmationType travelerDelayConfirmation, + affectedTickets { + { + referenceNum 801234567890, + productOwnerNum 1080, + ticketType openTicket, + linkMode issuedTogether + } + }, + infoText "delay confirmation" + */ + + assert(del.getAffectedTickets().size() == 1); + assert(del.getDelay() == 31L); + assert(del.getPlannedArrivalDay() == 12L); + assert(del.getPlannedArrivalTime() == 1000L); + assert(del.getPlannedArrivalYear() == 2022L); + assert(del.getTrainCancelled() == false); + assert(del.getInfoText().equals("delay confirmation")); + assert(del.getReferenceIA5().equals("ABDJ12345")); + assert(del.getTrainNum() == 100L); + + assert(del.getAffectedTickets().get(0).getReferenceNum() == 801234567890L); + assert(del.getAffectedTickets().get(0).getProductOwnerNum() == 1080L); + assert(del.getAffectedTickets().get(0).getTicketType().equals(TicketType.openTicket)); + assert(del.getAffectedTickets().get(0).getLinkMode().equals(LinkMode.issuedTogether)); + + + + + + } + + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java new file mode 100644 index 0000000..e45ae13 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java @@ -0,0 +1,110 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.ParkingGroundData; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.ParkingTestTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelParkingTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = ParkingTestTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = ParkingTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = ParkingTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + byte[] encoded = UperEncoder.encode(ticket); + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = ParkingTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + assert(ticket.getTransportDocument().get(0).getTicket().getParkingGround() != null); + + ParkingGroundData p = ticket.getTransportDocument().get(0).getTicket().getParkingGround(); + + assert(p.getReferenceIA5().equals("ACHE12345")); + assert(p.getParkingGroundId().equals("P47623")); + assert(p.getFromParkingDate() == 1L); + assert(p.getToParkingDate() == 1L); + assert(p.getLocation().equals("Parking Frankfurt Main West")); + assert(p.getStationNum() == 8000001L); + assert(p.getSpecialInformation().equals("outdoor parking")); + assert(p.getPrice() == 500L); + assert(p.getNumberPlate().equals("AA-DE-12345")); + + + } + + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java new file mode 100644 index 0000000..a1496c8 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java @@ -0,0 +1,95 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelStationPassageTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = StationPassageTestTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = StationPassageTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = StationPassageTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + byte[] encoded = UperEncoder.encode(ticket); + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = StationPassageTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + + } + + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java new file mode 100644 index 0000000..eacdabb --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java @@ -0,0 +1,108 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.VoucherData; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.VoucherTestTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class AsnLevelVoucherTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = VoucherTestTicketV3.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = VoucherTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = VoucherTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + byte[] encoded = UperEncoder.encode(ticket); + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = VoucherTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + assert(ticket.getTransportDocument().get(0).getTicket().getVoucher() != null); + + VoucherData vo = ticket.getTransportDocument().get(0).getTicket().getVoucher(); + + + assert(vo.getReferenceIA5().equals("ACHE12345")); + assert(vo.getProductOwnerIA5().equals("COFFEEMACHINE")); + assert(vo.getValidFromYear() == 2022L); + assert(vo.getValidFromDay() == 1L); + assert(vo.getValidUntilYear() == 2022L); + assert(vo.getValidUntilDay() == 1); + assert(vo.value == 500L); + assert(vo.getInfoText().equals("coffee voucher")); + } + + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java new file mode 100644 index 0000000..1a05e6f --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java @@ -0,0 +1,312 @@ +package org.uic.barcode.ticket.api.test; + +import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.EncodingFormatException; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.spec.ICounterMark; +import org.uic.barcode.ticket.api.spec.IUicRailTicket; +import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV3; +import org.uic.barcode.ticket.api.utils.Api2AsnEncoder; +import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3; +import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder; +import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3; + + +/** + * Test of Countermark + * + * + * + */ +public class CounterMarkTimeZoneTestV3 { + + /** The low level encoded test ticket test case 1 . */ + private byte[] encoded1 = null; + + /** The low level encoded test ticket test case 2 . */ + private byte[] encoded2 = null; + + /** The low level encoded test ticket test case 3 . */ + private byte[] encoded3 = null; + + /** The decoder. */ + Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3(); + + /** The encoder. */ + Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3(); + + /** The API ticket low level encoded for case 1. */ + IUicRailTicket iTicketDecodedFromAsn1Case1 = null; + + /** The API ticket low level encoded for case 2. */ + IUicRailTicket iTicketDecodedFromAsn1Case2 = null; + + /** The API ticket low level encoded for case 3. */ + IUicRailTicket iTicketDecodedFromAsn1Case3 = null; + + + /** The ticket decoded 1. */ + IUicRailTicket iTicketDecodedCase1 = null; + + /** The i ticket decoded 2. */ + IUicRailTicket iTicketDecodedCase2 = null; + + /** The i ticket decoded 3. */ + IUicRailTicket iTicketDecodedCase3 = null; + + byte[] encodedInTimeZone1 = null; + byte[] encodedInTimeZone2 = null; + byte[] encodedInTimeZone3 = null; + + String issuingDate1 = null; + String issuingDate2 = null; + String issuingDate3 = null; + + String validFrom1 = null; + String validFrom2 = null; + String validFrom3 = null; + + String validUntil1 = null; + String validUntil2 = null; + String validUntil3 = null; + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + UicRailTicketData ticket1 = CountermarkTestComplexTicketV3.getUicTestTicket(); + UicRailTicketData ticket2 = CountermarkTestComplexTicketV3.getUicTestTicket(); + UicRailTicketData ticket3 = CountermarkTestComplexTicketV3.getUicTestTicket(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + encoded1 = UperEncoder.encode(ticket1); + encoded2 = UperEncoder.encode(ticket2); + encoded3 = UperEncoder.encode(ticket3); + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + decodeTestTicketUTC(); + + //set the dates in the time zone CET + TimeZone.setDefault(TimeZone.getTimeZone("CET")); + iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" )); + iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" )); + iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" )); + + setValidFromTo("2021.03.14-00:00"); + setValidUntilTo("2021.03.24-23:59"); + + encode("CET"); + decode("CET"); + decodedDateToStrings(); + + assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" )); + assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" )); + assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" )); + + assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" )); + assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" )); + assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" )); + + assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" )); + assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" )); + assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" )); + + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + decodeTestTicketUTC(); + + //set the dates in the time zone GMT + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" )); + iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" )); + iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" )); + + setValidFromTo("2021.03.14-00:00"); + setValidUntilTo("2021.03.24-23:59"); + + encode("GMT"); + decode("CET"); + decodedDateToStrings(); + + assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" )); + assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" )); + assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" )); + + assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" )); + assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" )); + assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" )); + + assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" )); + assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" )); + assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" )); + + + } + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + decodeTestTicketUTC(); + + //set the dates in the time zone GMT + TimeZone.setDefault(TimeZone.getTimeZone("CET")); + iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" )); + iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" )); + iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" )); + + setValidFromTo("2021.03.14-00:00"); + setValidUntilTo("2021.03.24-23:59"); + + encode("CET"); + decode("GMT"); + decodedDateToStrings(); + + assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" )); + assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" )); + assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" )); + + assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" )); + assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" )); + assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" )); + + assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" )); + assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" )); + assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" )); + + + } + + private void decodedDateToStrings() { + + issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString(); + issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString(); + issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString(); + + validFrom1 = ((ICounterMark) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString(); + validFrom2 = ((ICounterMark) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString(); + validFrom3 = ((ICounterMark) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString(); + + validUntil1 = ((ICounterMark) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString(); + validUntil2 = ((ICounterMark) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString(); + validUntil3 = ((ICounterMark) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString(); + + } + + + private void setValidFromTo(String dateString) throws ParseException { + DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ); + Date date = dateFormat.parse(dateString); + ((ICounterMark) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date); + ((ICounterMark) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date); + ((ICounterMark) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date); + } + + private void setValidUntilTo(String dateString) throws ParseException { + DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ); + Date date = dateFormat.parse(dateString); + ((ICounterMark) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date); + ((ICounterMark) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date); + ((ICounterMark) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date); + } + + + /** + * Encode in Time Zone + */ + private void encode(String timeZone) { + TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); + try { + encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1); + encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2); + encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3); + } catch (EncodingFormatException e) { + e.printStackTrace(); + } + } + + /** + * Decode in Time Zone + */ + private void decode(String timeZone) { + TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); + + try { + iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1); + iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2); + iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + /** + * Encode decode. + */ + private void decodeTestTicketUTC() { + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + try { + iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1); + iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2); + iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3); + } catch (IOException e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV1.java deleted file mode 100644 index 5226880..0000000 --- a/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV1.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.uic.barcode.ticket.api.test; - -import java.text.ParseException; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.asn1.uper.UperEncoder; -import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; -import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV1; - - -/** - * The Class FipTimeZoneTestV3. - * - * - * - */ -public class CountermarkComplexTestV1 { - - - - /** The ticket decoded 1. */ - UicRailTicketData ticket = null; - - byte[] encodedInTimeZone1 = null; - - - TimeZone defaulttimeZone = null; - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - defaulttimeZone = TimeZone.getDefault(); - - //encode in UTC time zone - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - - - } - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - - /** - * Test encode test tickets in UTC and decode in CET. - * - * @throws IllegalArgumentException the illegal argument exception - * @throws IllegalAccessException the illegal access exception - * @throws ParseException - */ - @Test public void decoding() { - - //get tickets - String hex = CountermarkTestComplexTicketV1.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - assert(ticket != null); - - } - - @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { - - //get tickets - String hex = CountermarkTestComplexTicketV1.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - - //ticket = OpenTestComplexTicketV2.getUicTestTicket(); - byte[] encoded = UperEncoder.encode(ticket); - - - - assert(encoded != null); - assert(encoded.length > 20); - - String encodedHex = UperEncoder.hexStringFromBytes(encoded); - String expectedHex = CountermarkTestComplexTicketV1.getEncodingHex(); - - assert(expectedHex.equals(encodedHex)); - - } - - -} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV3.java deleted file mode 100644 index 86495f0..0000000 --- a/src/test/java/org/uic/barcode/ticket/api/test/CountermarkComplexTestV3.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.uic.barcode.ticket.api.test; - -import java.text.ParseException; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.asn1.uper.UperEncoder; -import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; -import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV3; - - -/** - * The Class FipTimeZoneTestV3. - * - * - * - */ -public class CountermarkComplexTestV3 { - - - - /** The ticket decoded 1. */ - UicRailTicketData ticket = null; - - byte[] encodedInTimeZone1 = null; - - - TimeZone defaulttimeZone = null; - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - defaulttimeZone = TimeZone.getDefault(); - - //encode in UTC time zone - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - - - } - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - - /** - * Test encode test tickets in UTC and decode in CET. - * - * @throws IllegalArgumentException the illegal argument exception - * @throws IllegalAccessException the illegal access exception - * @throws ParseException - */ - @Test public void decoding() { - - //get tickets - String hex = CountermarkTestComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - assert(ticket != null); - - } - - @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { - - //get tickets - String hex = CountermarkTestComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - - //ticket = OpenTestComplexTicketV2.getUicTestTicket(); - byte[] encoded = UperEncoder.encode(ticket); - - - - assert(encoded != null); - assert(encoded.length > 20); - - String encodedHex = UperEncoder.hexStringFromBytes(encoded); - String expectedHex = CountermarkTestComplexTicketV3.getEncodingHex(); - - assert(expectedHex.equals(encodedHex)); - - } - - @Test public void encodingDecoding() throws IllegalArgumentException, IllegalAccessException, ParseException { - - //get tickets - ticket = CountermarkTestComplexTicketV3.getUicTestTicket(); - byte[] encoded = UperEncoder.encode(ticket); - - - - assert(encoded != null); - assert(encoded.length > 20); - - String encodedHex = UperEncoder.hexStringFromBytes(encoded); - String expectedHex = CountermarkTestComplexTicketV3.getEncodingHex(); - - assert(expectedHex.equals(encodedHex)); - - } -} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java index d39a0ba..21266a9 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java @@ -1,95 +1,127 @@ -package org.uic.barcode.ticket.api.test; - -import java.text.ParseException; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.asn1.uper.UperEncoder; -import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; -import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV3; - - -/** - * The Class FipTimeZoneTestV3. - * - * - * - */ -public class OpenTicketComplexTestV3 { - - - - /** The ticket decoded 1. */ - UicRailTicketData ticket = null; - - byte[] encodedInTimeZone1 = null; - - - TimeZone defaulttimeZone = null; - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - defaulttimeZone = TimeZone.getDefault(); - - //encode in UTC time zone - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - - - } - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - - /** - * Test encode test tickets in UTC and decode in CET. - * - * @throws IllegalArgumentException the illegal argument exception - * @throws IllegalAccessException the illegal access exception - * @throws ParseException - */ - @Test public void decoding() { - - //get tickets - String hex = OpenTestComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - assert(ticket != null); - - } - - @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { - - //get tickets - String hex = OpenTestComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - - //ticket = OpenTestComplexTicketV2.getUicTestTicket(); - byte[] encoded = UperEncoder.encode(ticket); - - - - assert(encoded != null); - assert(encoded.length > 20); - - String encodedHex = UperEncoder.hexStringFromBytes(encoded); - String expectedHex = OpenTestComplexTicketV3.getEncodingHex(); - - assert(expectedHex.equals(encodedHex)); - - } - - -} +package org.uic.barcode.ticket.api.test; + + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData; +import org.uic.barcode.ticket.api.asn.omv3.PassengerType; +import org.uic.barcode.ticket.api.asn.omv3.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV3; + + +/** + * The Class FipTimeZoneTestV3. + * + * + * + */ +public class OpenTicketComplexTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = OpenTestComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + assert(ticket.getTransportDocument().get(0).getTicket().getOpenTicket() != null); + + OpenTicketData ot = ticket.getTransportDocument().get(0).getTicket().getOpenTicket(); + + assert(ot.getReturnIncluded() == false); + assert(ot.getClassCode().equals(TravelClassType.first)); + assert(ot.getInfoText().equals("openTicketInfo")); + assert(ot.getVatDetails().size() == 1); + assert(ot.getVatDetails().get(0).getCountry() == 80L); + assert(ot.getVatDetails().get(0).getPercentage() == 70L); + assert(ot.getVatDetails().get(0).getAmount() == 10L); + assert(ot.getVatDetails().get(0).getVatId().equals("IUDGTE")); + + assert(ot.getIncludedAddOns().size() == 1); + IncludedOpenTicketType inc = ot.getIncludedAddOns().get(0); + assert(inc.getProductOwnerNum() == 1080L); + assert(inc.getClassCode().equals(TravelClassType.second)); + assert(inc.getInfoText().equals("included ticket")); + assert(inc.getValidRegion().get(0).getZones() != null); + assert(inc.getValidRegion().get(0).getZones().getZoneId().get(0) == 100L); + assert(inc.getTariffs().size() == 1); + assert(inc.getTariffs().get(0).getNumberOfPassengers() == 2L); + assert(inc.getTariffs().get(0).getPassengerType().equals(PassengerType.adult)); + assert(inc.getTariffs().get(0).getRestrictedToCountryOfResidence() == false); + assert(inc.getTariffs().get(0).getRestrictedToRouteSection().getFromStationNum() == 8000001L); + assert(inc.getTariffs().get(0).getRestrictedToRouteSection().getToStationNum() == 8010000L); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = OpenTestComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + //ticket = OpenTestComplexTicketV2.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = OpenTestComplexTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java new file mode 100644 index 0000000..fe0bdda --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java @@ -0,0 +1,131 @@ +package org.uic.barcode.ticket.api.test; + + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData; +import org.uic.barcode.ticket.api.asn.omv3.PassengerType; +import org.uic.barcode.ticket.api.asn.omv3.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.OpenLuggageRestrictionTestTicketV3; + + +/** + * + * + * + * + */ +public class OpenTicketRestrictedLuggageComplexTestV3 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = OpenLuggageRestrictionTestTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + assert(ticket.getTransportDocument().get(0).getTicket().getOpenTicket() != null); + + OpenTicketData ot = ticket.getTransportDocument().get(0).getTicket().getOpenTicket(); + + assert(ot.getReturnIncluded() == false); + assert(ot.getClassCode().equals(TravelClassType.first)); + assert(ot.getInfoText().equals("openTicketInfo")); + assert(ot.getVatDetails().size() == 1); + assert(ot.getVatDetails().get(0).getCountry() == 80L); + assert(ot.getVatDetails().get(0).getPercentage() == 70L); + assert(ot.getVatDetails().get(0).getAmount() == 10L); + assert(ot.getVatDetails().get(0).getVatId().equals("IUDGTE")); + + assert(ot.getIncludedAddOns().size() == 1); + IncludedOpenTicketType inc = ot.getIncludedAddOns().get(0); + assert(inc.getProductOwnerNum() == 1080L); + assert(inc.getClassCode().equals(TravelClassType.second)); + assert(inc.getInfoText().equals("included ticket")); + assert(inc.getValidRegion().get(0).getZones() != null); + assert(inc.getValidRegion().get(0).getZones().getZoneId().get(0) == 100L); + assert(inc.getTariffs().size() == 1); + assert(inc.getTariffs().get(0).getNumberOfPassengers() == 2L); + assert(inc.getTariffs().get(0).getPassengerType().equals(PassengerType.adult)); + assert(inc.getTariffs().get(0).getRestrictedToCountryOfResidence() == false); + assert(inc.getTariffs().get(0).getRestrictedToRouteSection().getFromStationNum() == 8000001L); + assert(inc.getTariffs().get(0).getRestrictedToRouteSection().getToStationNum() == 8010000L); + + assert(ot.getLuggage() != null); + assert(ot.getLuggage().maxHandLuggagePieces == 2L); + assert(ot.getLuggage().getMaxNonHandLuggagePieces() == 1L); + assert(ot.getLuggage().getRegisteredLuggage().size() == 2); + assert(ot.getLuggage().getRegisteredLuggage().get(0).getMaxSize() == 100L); + assert(ot.getLuggage().getRegisteredLuggage().get(1).getMaxSize() == 101L); + assert(ot.getLuggage().getRegisteredLuggage().get(0).getMaxWeight() == 20L); + assert(ot.getLuggage().getRegisteredLuggage().get(1).getMaxWeight() == 21L); + assert(ot.getLuggage().getRegisteredLuggage().get(0).getRegistrationId().equals("IODHUV")); + assert(ot.getLuggage().getRegisteredLuggage().get(1).getRegistrationId().equals("XXDHUV")); + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = OpenLuggageRestrictionTestTicketV3.getUicTestTicket(); + + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = OpenLuggageRestrictionTestTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java index de7fe88..6b73221 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java @@ -1,92 +1,109 @@ -package org.uic.barcode.ticket.api.test; - -import java.text.ParseException; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.asn1.uper.UperEncoder; -import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; -import org.uic.barcode.ticket.api.test.testtickets.PassComplexTicketV3; - - -/** - * The Class Test asn.1 encoding of a pass. - * - * - * - */ -public class PassComplexTestV3 { - - - /** The ticket decoded 1. */ - UicRailTicketData ticket = null; - - byte[] encodedInTimeZone1 = null; - - - TimeZone defaulttimeZone = null; - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - defaulttimeZone = TimeZone.getDefault(); - - //encode in UTC time zone - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - - - } - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - - /** - * Test encode test tickets in UTC and decode in CET. - * - * @throws IllegalArgumentException the illegal argument exception - * @throws IllegalAccessException the illegal access exception - * @throws ParseException - */ - @Test public void decoding() { - - //get tickets - String hex = PassComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - assert(ticket != null); - - } - - @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { - - //get tickets - String hex = PassComplexTicketV3.getEncodingHex(); - byte[] content = UperEncoder.bytesFromHexString(hex); - ticket = UperEncoder.decode(content, UicRailTicketData.class); - - - byte[] encoded = UperEncoder.encode(ticket); - - - - assert(encoded != null); - assert(encoded.length > 20); - - String encodedHex = UperEncoder.hexStringFromBytes(encoded); - String expectedHex = PassComplexTicketV3.getEncodingHex(); - - assert(expectedHex.equals(encodedHex)); - - } - -} +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv3.BoardingOrArrivalType; +import org.uic.barcode.ticket.api.asn.omv3.PassData; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.PassComplexTicketV3; + + +/** + * The Class Test asn.1 encoding of a pass. + * + * + * + */ +public class PassComplexTestV3 { + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = PassComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = PassComplexTicketV3.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = PassComplexTicketV3.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + assert(ticket.getTransportDocument().get(0).getTicket().getPass() != null); + + PassData p = ticket.getTransportDocument().get(0).getTicket().getPass(); + + + assert(p.getTrainValidity().getBordingOrArrival().equals(BoardingOrArrivalType.boarding)); + assert(p.getTrainValidity().getIncludedCarriersNum().contains(1234L)); + assert(p.getTrainValidity().getIncludedCarriersNum().contains(5678L)); + assert(p.getTrainValidity().getValidFromDay() == 0L); + assert(p.getTrainValidity().getValidFromTime() == 1000L); + assert(p.getTrainValidity().getValidUntilDay() == 1L); + assert(p.getTrainValidity().getValidUntilTime() == 1000L); + + + + } + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java new file mode 100644 index 0000000..157c6db --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java @@ -0,0 +1,325 @@ +package org.uic.barcode.ticket.api.test.testtickets; + +import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.ControlData; +import org.uic.barcode.ticket.api.asn.omv3.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.DocumentData; +import org.uic.barcode.ticket.api.asn.omv3.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.IssuingData; +import org.uic.barcode.ticket.api.asn.omv3.LoadingDeckType; +import org.uic.barcode.ticket.api.asn.omv3.PriceTypeType; +import org.uic.barcode.ticket.api.asn.omv3.RoofRackType; +import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCarrierNum; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfVatDetail; +import org.uic.barcode.ticket.api.asn.omv3.TariffType; +import org.uic.barcode.ticket.api.asn.omv3.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv3.TravelerData; +import org.uic.barcode.ticket.api.asn.omv3.TravelerType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv3.VatDetailType; + + + public class CarCarriageReservationTestTicketV3 { + + /* + * rec1value UicRailTicketData ::= { + issuingDetail { + issuingYear 2018, + issuingDay 1, + issuingTime 600, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "senior" + } + } + } + }, + groupName "myGroup" + }, + transportDocument { + { + ticket carCarriageReservation : { + trainNum 123, + beginLoadingDate 10, + beginLoadingTime 0, + endLoadingTime 500, + referenceNum 810123456789, + serviceBrand 100, + serviceBrandAbrUTF8 "AZ", + serviceBrandNameUTF8 "special train", + stationCodeTable stationUICReservation, + fromStationNum 8100001, + toStationNum 800001, + coach "21", + place "41", + numberPlate "AD-DE-123", + trailerPlate "DX-AB-123", + carCategory 3, + textileRoof FALSE, + roofRackType bicycleRack, + roofRackHeight 20, + attachedBicycles 1, + attachedSurfboards 2, + loadingListEntry 421, + loadingDeck upper, + carrierNum { + 1080, + 1181 + }, + tariff { + numberOfPassengers 1, + restrictedToCountryOfResidence FALSE, + tariffIdNum 72, + tariffDesc "Large Car Full Fare" + }, + priceType travelPrice, + price 12345, + vatDetail { + { + country 80, + percentage 70, + amount 10, + vatId "IUDGTE" + } + }, + infoText "car carriage" + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd" + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + */ + + public static UicRailTicketData getUicTestTicket() { + UicRailTicketData ticket = new UicRailTicketData(); + populateTicket(ticket); + return ticket; + } + + public static String getEncodingHex() { + + return "7804404004B14374F3E7D72F2A9979F4A13A90086280B4001" + + "044A6F686E03446F770562C99B46B01106E797769DFC81" + + "DB5E51DC9BDD5C0040AE43A8D6E9C02F60B0007D01802F" + + "27C7BC4540318120AD06B9B832B1B4B0B6103A3930B4B7" + + "3DCC50061A8001326204D1884C188B62455AC593309896" + + "16C184B58B266639429A502086E127002802902698C2E4" + + "CECA4086C2E4408CEAD8D8408CC2E4CA0460720389E230" + + "0850349AB123D48A18C6C2E440C6C2E4E4D2C2CECA9004" + + "0100B20004C6C80402C40A0B680590141ED00"; + + } + + + private static void populateTicket(UicRailTicketData ticket) { + + ticket.setControlDetail(new ControlData()); + populate(ticket.getControlDetail()); + + + ticket.setIssuingDetail(new IssuingData()); + populateIssuingData(ticket.getIssuingDetail()); + + TravelerData td = new TravelerData(); + populateTravelerData(td); + ticket.setTravelerDetail(td); + + SequenceOfDocumentData ds = new SequenceOfDocumentData(); + + + //OpenTicket + DocumentData do1 = new DocumentData(); + addReservation(do1); + ds.add(do1); + + + ticket.setTransportDocument(ds); + + SequenceOfExtensionData ed = new SequenceOfExtensionData(); + populateExtensionSequence(ed); + ticket.setExtension(ed); + + } + + + + private static void addReservation(DocumentData dd) { + + TicketDetailData tdd = new TicketDetailData(); + CarCarriageReservationData ticket = new CarCarriageReservationData(); + ticket.setTrainNum(123L); + ticket.setReferenceNum(810123456789L); + ticket.setServiceBrandAbrUTF8("XYZ"); + ticket.setServiceBrandNameUTF8("special train"); + SequenceOfCarrierNum carriers = new SequenceOfCarrierNum(); + carriers.add(1080L); + carriers.add(1181L); + ticket.setCarrierNum(carriers); + ticket.setFromStationNum(8100001L); + ticket.setToStationNum(800001L); + ticket.setServiceBrand(100L); + ticket.setPrice(12345L); + ticket.setPriceType(PriceTypeType.travelPrice); + ticket.setAttachedBicycles(1L); + ticket.setCarCategory(3L); + ticket.setInfoText("car carriage"); + ticket.setLoadingDeck(LoadingDeckType.upper); + ticket.setNumberPlate("AD-DE-123"); + ticket.setRoofRackHeight(20L); + ticket.setRoofRackType(RoofRackType.bicycleRack); + ticket.setServiceBrandAbrUTF8("AZ"); + ticket.setServiceBrand(100L); + ticket.setTextileRoof(false); + ticket.setTrailerPlate("DX-AB-123"); + ticket.setAttachedSurfboards(2L); + ticket.setLoadingListEntry(421L); + + ticket.setVatDetails(new SequenceOfVatDetail()); + ticket.getVatDetails().add(getVatDetail()); + + ticket.setTariff(getTariff()); + + ticket.setPlace("41"); + ticket.setCoach("21"); + ticket.setBeginLoadingDate(10L); + ticket.setBeginLoadingTime(0L); + ticket.setEndLoadingTime(500L); + tdd.setCarCarriageReservation(ticket); + dd.setTicket(tdd); + } + + + + private static TariffType getTariff() { + + TariffType tariff = new TariffType(); + tariff.setNumberOfPassengers(1L); + tariff.setRestrictedToCountryOfResidence(false); + tariff.setTariffIdNum(72L); + tariff.setTariffDesc("Large Car Full Fare"); + + return tariff; + } + + private static VatDetailType getVatDetail() { + VatDetailType v = new VatDetailType(); + v.setAmount(10L); + v.setCountry(80L); + v.setPercentage(70L); + v.setVatId("IUDGTE"); + return v; + } + + private static void populateTravelerData(TravelerData td) { + td.setGroupName("myGroup"); + SequenceOfTravelerType trs = new SequenceOfTravelerType(); + TravelerType tr = new TravelerType(); + tr.setIdCard("12345"); + tr.setFirstName("John"); + tr.setSecondName("Dow"); + tr.setTicketHolder(true); + SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType(); + CustomerStatusType cst = new CustomerStatusType(); + cst.setCustomerStatusDescr("senior"); + ts.add(cst); + tr.setStatus(ts); + trs.add(tr); + td.setTraveler(trs); + } + + private static void populateIssuingData(IssuingData issuingDetail) { + issuingDetail.setIssuingYear(2018L); + issuingDetail.setIssuingDay(1L); + issuingDetail.setIssuingTime(600L); + issuingDetail.setIssuerPNR("issuerTestPNR"); + issuingDetail.setSpecimen(true); + issuingDetail.setSecurePaperTicket(false); + issuingDetail.setActivated(true); + issuingDetail.setIssuedOnLine(12L); + } + + + private static void populateExtensionSequence(SequenceOfExtensionData ed) { + ExtensionData ed1 = new ExtensionData(); + ed1.setExtensionId("1"); + byte[] ba1 = { (byte) 0x82, (byte) 0xDA }; + ed1.setExtensionData(ba1); + ExtensionData ed2 = new ExtensionData(); + ed2.setExtensionId("2"); + byte[] ba2 = { (byte) 0x83, (byte) 0xDA }; + ed2.setExtensionData(ba2); + ed.add(ed1); + ed.add(ed2); + } + + private static void populate(ControlData controlDetail) { + controlDetail.infoText = "cd"; + controlDetail.setAgeCheckRequired(false); + controlDetail.setIdentificationByIdCard(false); + controlDetail.setIdentificationByPassportId(false); + controlDetail.setOnlineValidationRequired(false); + controlDetail.setPassportValidationRequired(false); + controlDetail.setReductionCardCheckRequired(false); + controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType()); + controlDetail.getIdentificationByCardReference().add(populateCardRefrence()); + } + + + /* + { + trailingCardIdNum 100 + } + */ + private static CardReferenceType populateCardRefrence() { + CardReferenceType cr = new CardReferenceType(); + cr.setTrailingCardIdNum(100L); + return cr; + } + + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CountermarkTestComplexTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CountermarkTestComplexTicketV3.java index 1843ec3..7e1b127 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CountermarkTestComplexTicketV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CountermarkTestComplexTicketV3.java @@ -116,177 +116,9 @@ value UicRailTicketData ::= { } } -Encoding to the file 'data.uper' using PER UNALIGNED encoding rule... -UicRailTicketData SEQUENCE [root fieldcount (not encoded) = 5] - issuingDetail IssuingData SEQUENCE [root fieldcount (not encoded) = 8] - issuingYear INTEGER [length (not encoded) = 1.0] - 2018 - issuingDay INTEGER [length (not encoded) = 1.1] - 1 - issuingTime INTEGER [length (not encoded) = 1.3] - 600 - specimen BOOLEAN [length (not encoded) = 0.1] - TRUE - securePaperTicket BOOLEAN [length (not encoded) = 0.1] - FALSE - activated BOOLEAN [length (not encoded) = 0.1] - TRUE - issuerPNR IA5String [length = 13.0] - "issuerTestPNR" - issuedOnLine INTEGER [length = 1.0] - 12 - travelerDetail TravelerData SEQUENCE [root fieldcount (not encoded) = 2] - traveler SEQUENCE OF [count = 1] - TravelerType SEQUENCE [root fieldcount (not encoded) = 5] - firstName UTF8String [length = 4.0] - 0x4a6f686e - secondName UTF8String [length = 3.0] - 0x446f77 - idCard IA5String [length = 5.0] - "12345" - ticketHolder BOOLEAN [length (not encoded) = 0.1] - TRUE - status SEQUENCE OF [count = 1] - CustomerStatusType SEQUENCE [fieldcount (not encoded) = 1] - customerStatusDescr IA5String [length = 6.0] - "senior" - groupName UTF8String [length = 7.0] - 0x6d7947726f7570 - transportDocument SEQUENCE OF [count = 1] - DocumentData SEQUENCE [root fieldcount (not encoded) = 1] - ticket CHOICE [index = 6] - counterMark CountermarkData SEQUENCE [root fieldcount (not encoded) = 7] - numberOfCountermark INTEGER [length (not encoded) = 1.0] - 12 - totalOfCountermarks INTEGER [length (not encoded) = 1.0] - 24 - groupName UTF8String [length = 9.0] - 0x67726f75704e616d65 - validRegion SEQUENCE OF [count = 2] - RegionalValidityType CHOICE [index = 1] - viaStations ViaStationType SEQUENCE [root fieldcount (not encoded) = 3] - route SEQUENCE OF [count = 4] - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 123455 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 123456 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - alternativeRoutes SEQUENCE OF [count = 2] - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - route SEQUENCE OF [count = 2] - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 23455 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 23456 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - route SEQUENCE OF [count = 2] - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 3455 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 3456 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - border BOOLEAN [length (not encoded) = 0.1] - FALSE - border BOOLEAN [length (not encoded) = 0.1] - FALSE - ViaStationType SEQUENCE [root fieldcount (not encoded) = 2] - stationNum INTEGER [length (not encoded) = 3.0] - 123457 - border BOOLEAN [length (not encoded) = 0.1] - FALSE - border BOOLEAN [length (not encoded) = 0.1] - FALSE - seriesId INTEGER [length = 2.0] - 999 - RegionalValidityType CHOICE [index = 2] - zones ZoneType SEQUENCE [root fieldcount (not encoded) = 1] - zoneId SEQUENCE OF [count = 2] - INTEGER [length = 1.0] - 100 - INTEGER [length = 2.0] - 200 - returnIncluded BOOLEAN [length (not encoded) = 0.1] - FALSE - classCode TravelClassType ENUMERATED [length (not encoded) = 0.4] - 1 - infoText UTF8String [length = 11.0] - 0x636f756e7465724d61726b - controlDetail ControlData SEQUENCE [root fieldcount (not encoded) = 9] - identificationByCardReference SEQUENCE OF [count = 1] - CardReferenceType SEQUENCE [root fieldcount (not encoded) = 1] - trailingCardIdNum INTEGER [length = 1.0] - 100 - identificationByIdCard BOOLEAN [length (not encoded) = 0.1] - FALSE - identificationByPassportId BOOLEAN [length (not encoded) = 0.1] - FALSE - passportValidationRequired BOOLEAN [length (not encoded) = 0.1] - FALSE - onlineValidationRequired BOOLEAN [length (not encoded) = 0.1] - FALSE - ageCheckRequired BOOLEAN [length (not encoded) = 0.1] - FALSE - reductionCardCheckRequired BOOLEAN [length (not encoded) = 0.1] - FALSE - infoText UTF8String [length = 2.0] - 0x6364 - includedTickets SEQUENCE OF [count = 1] - TicketLinkType SEQUENCE [root fieldcount (not encoded) = 6] - referenceIA5 IA5String [length = 11.0] - "UED12435867" - issuerName UTF8String [length = 4.0] - 0x4f454242 - issuerPNR IA5String [length = 3.0] - "PNR" - productOwnerIA5 IA5String [length = 4.0] - "test" - ticketType TicketType ENUMERATED [length (not encoded) = 0.2] - 1 - linkMode LinkMode ENUMERATED [length (not encoded) = 0.1] - 1 - extension SEQUENCE OF [count = 2] - ExtensionData SEQUENCE [fieldcount (not encoded) = 2] - extensionId IA5String [length = 1.0] - "1" - extensionData OCTET STRING [length = 2.0] - 0x82da - ExtensionData SEQUENCE [fieldcount (not encoded) = 2] - extensionId IA5String [length = 1.0] - "2" - extensionData OCTET STRING [length = 2.0] - 0x83da -Total encoded length = 187.0 -Encoded successfully in 187 bytes: -78044040 04B14374 F3E7D72F 2A9979F4 A13A9008 6280B400 1044A6F6 86E03446 -F770562C 99B46B01 106E7977 69DFC81D B5E51DC9 BDD5C004 30000202 1058B84B -3B937BAB 82730B6B 28108240 210000F1 1F080007 88FC1000 40800440 000B73C2 -00005B9F 01000880 00035F84 00001AFE 08000789 000203E7 20040201 640200C8 -042D8DBD D5B9D195 C93585C9 AD300802 01640009 8D90056E 17562C46 2C9A336A -E1B37044 F4542420 3A13A902 74CBCFA1 40805881 416D00B2 0283DA - */ - - + public static String getEncodingHex() { return "7804404004B14374F3E7D72F2A9979F4A13A90086280B4001044A6F686E03446" + diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java index 9364acd..a74ad18 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java @@ -1,33 +1,126 @@ package org.uic.barcode.ticket.api.test.testtickets; import org.uic.barcode.asn1.datatypes.Asn1BigInteger; -import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType; -import org.uic.barcode.ticket.api.asn.omv1.ControlData; -import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType; -import org.uic.barcode.ticket.api.asn.omv1.DelayConfirmation; -import org.uic.barcode.ticket.api.asn.omv1.DocumentData; -import org.uic.barcode.ticket.api.asn.omv1.ExtensionData; -import org.uic.barcode.ticket.api.asn.omv1.IssuingData; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType; -import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType; -import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData; -import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType; -import org.uic.barcode.ticket.api.asn.omv1.TravelerData; -import org.uic.barcode.ticket.api.asn.omv1.TravelerType; -import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.ControlData; +import org.uic.barcode.ticket.api.asn.omv3.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.DelayConfirmation; +import org.uic.barcode.ticket.api.asn.omv3.DocumentData; +import org.uic.barcode.ticket.api.asn.omv3.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.IssuingData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTicketLinkType; +import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv3.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv3.TicketLinkType; +import org.uic.barcode.ticket.api.asn.omv3.TravelerData; +import org.uic.barcode.ticket.api.asn.omv3.TravelerType; +import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; public class DelayTestTicketV3 { + + /* + * + * +value UicRailTicketData ::= { + issuingDetail { + issuingYear 2021, + issuingDay 63, + issuingTime 750, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "employee" + } + } + } + } + }, + transportDocument { + { + ticket delayConfirmation : { + referenceIA5 "ABDJ12345", + trainNum 100, + departureYear 2022, + departureDay 12, + departureTime 1000, + stationCodeTable stationUIC, + stationNum 8000001, + delay 31, + trainCancelled FALSE, + confirmationType travelerDelayConfirmation, + affectedTickets { + { + referenceNum 801234567890, + productOwnerNum 1080, + ticketType openTicket, + linkMode issuedTogether + } + }, + infoText "delay confirmation" + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd" + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + + */ + public static UicRailTicketData getUicTestTicket() { UicRailTicketData ticket = new UicRailTicketData(); populateTicket(ticket); return ticket; } + public static String getEncodingHex() { + return "780440A3E5DD4374F3E7D72F2A9979F4A13A90086200B4001044A6F686E03446F77" + + "0562C99B46B01108CBB786CDFE72E50116AE4C130614494C593368D405901816" + + "FA1E848001E009201802EA35350B4821B893232B630BC9031B7B73334B936B0B" + + "A34B7B7240100402C800131B20100B10282DA01640507B4"; + + } + private static void populateTicket(UicRailTicketData ticket) { @@ -77,15 +170,14 @@ import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; TicketDetailData tdd = new TicketDetailData(); DelayConfirmation ticket = new DelayConfirmation(); - ticket.setPlannedArrivalDay(0L); + ticket.setPlannedArrivalDay(12L); ticket.setPlannedArrivalTime(1000L); - ticket.setDelay(30L); + ticket.setDelay(31L); ticket.setInfoText("delay confirmation"); ticket.setAffectedTickets(getAffectedTickets()); ticket.setPlannedArrivalYear(2022L); ticket.setReferenceIA5("ABDJ12345"); ticket.setStationNum(8000001L); - ticket.setStationNameUTF8("station of delay"); ticket.setTrainCancelled(false); ticket.setTrainNum(Asn1BigInteger.toAsn1(100L)); tdd.setDelayConfirmation(ticket); @@ -96,7 +188,6 @@ import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; SequenceOfTicketLinkType lts = new SequenceOfTicketLinkType(); TicketLinkType t1 = new TicketLinkType(); - t1.setReferenceNum(1080L); t1.setReferenceNum(801234567890L); t1.setProductOwnerNum(1080L); lts.add(t1); @@ -160,4 +251,7 @@ import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/LuggageTestTicketV2.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/LuggageTestTicketV2.java new file mode 100644 index 0000000..abc6690 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/LuggageTestTicketV2.java @@ -0,0 +1,150 @@ +package org.uic.barcode.ticket.api.test.testtickets; + +import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv1.ControlData; +import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv1.DocumentData; +import org.uic.barcode.ticket.api.asn.omv1.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv1.IssuingData; +import org.uic.barcode.ticket.api.asn.omv1.LinkMode; +import org.uic.barcode.ticket.api.asn.omv1.PassData; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType; +import org.uic.barcode.ticket.api.asn.omv1.TicketType; +import org.uic.barcode.ticket.api.asn.omv1.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv1.TravelerData; +import org.uic.barcode.ticket.api.asn.omv1.TravelerType; +import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; + + public class LuggageTestTicketV2 { + + public static UicRailTicketData getUicTestTicket() { + UicRailTicketData ticket = new UicRailTicketData(); + populateTicket(ticket); + return ticket; + } + + + private static void populateTicket(UicRailTicketData ticket) { + + ticket.setControlDetail(new ControlData()); + populate(ticket.getControlDetail()); + + + ticket.setIssuingDetail(new IssuingData()); + populateIssuingData(ticket.getIssuingDetail()); + + TravelerData td = new TravelerData(); + populateTravelerData(td); + ticket.setTravelerDetail(td); + + SequenceOfDocumentData ds = new SequenceOfDocumentData(); + + + //OpenTicket + DocumentData do1 = new DocumentData(); + addPass(do1); + ds.add(do1); + + ticket.setTransportDocument(ds); + + SequenceOfExtensionData ed = new SequenceOfExtensionData(); + populateExtensionSequence(ed); + ticket.setExtension(ed); + + } + + + private static void addPass(DocumentData dd) { + + TicketDetailData tdd = new TicketDetailData(); + PassData otd = new PassData(); + otd.setInfoText("pass"); + otd.setClassCode(TravelClassType.first); + otd.setPassDescription("ONE COUNTRY"); + tdd.setPass(otd); + dd.setTicket(tdd); + } + + + private static void populateTravelerData(TravelerData td) { + td.setGroupName("myGroup"); + SequenceOfTravelerType trs = new SequenceOfTravelerType(); + TravelerType tr = new TravelerType(); + tr.setIdCard("12345"); + tr.setFirstName("John"); + tr.setSecondName("Dow"); + tr.setTicketHolder(true); + SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType(); + CustomerStatusType cst = new CustomerStatusType(); + cst.setCustomerStatusDescr("senior"); + ts.add(cst); + tr.setStatus(ts); + trs.add(tr); + td.setTraveler(trs); + } + + private static void populateIssuingData(IssuingData issuingDetail) { + issuingDetail.setIssuingYear(2018L); + issuingDetail.setIssuingDay(1L); + issuingDetail.setIssuerPNR("issuerTestPNR"); + issuingDetail.setSpecimen(true); + issuingDetail.setSecurePaperTicket(false); + issuingDetail.setActivated(true); + issuingDetail.setIssuedOnLine(12L); + } + + private static void populateExtensionSequence(SequenceOfExtensionData ed) { + ExtensionData ed1 = new ExtensionData(); + ed1.setExtensionId("1"); + byte[] ba1 = { (byte) 0x82, (byte) 0xDA }; + ed1.setExtensionData(ba1); + ExtensionData ed2 = new ExtensionData(); + ed2.setExtensionId("2"); + byte[] ba2 = { (byte) 0x83, (byte) 0xDA }; + ed2.setExtensionData(ba2); + ed.add(ed1); + ed.add(ed2); + } + + private static void populate(ControlData controlDetail) { + controlDetail.infoText = "cd"; + controlDetail.setAgeCheckRequired(false); + controlDetail.setIdentificationByIdCard(false); + controlDetail.setIdentificationByPassportId(false); + controlDetail.setOnlineValidationRequired(false); + controlDetail.setPassportValidationRequired(false); + controlDetail.setReductionCardCheckRequired(false); + controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType()); + controlDetail.getIdentificationByCardReference().add(populateCardRefrence()); + SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType(); + populateLinkedTickets(sit); + controlDetail.setIncludedTickets(sit); + } + + private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) { + TicketLinkType tlt = new TicketLinkType(); + tlt.productOwnerIA5="test"; + tlt.setTicketType(TicketType.pass); + tlt.setIssuerPNR("PNR"); + tlt.setReferenceIA5("UED12435867"); + tlt.setLinkMode(LinkMode.onlyValidInCombination); + tlt.setIssuerName("OEBB"); + sequenceOfTicketLinkType.add(tlt); + } + + private static CardReferenceType populateCardRefrence() { + CardReferenceType cr = new CardReferenceType(); + cr.setTrailingCardIdNum(100L); + return cr; + } + + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/ParkingTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/ParkingTestTicketV3.java index bacdb41..54be392 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/ParkingTestTicketV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/ParkingTestTicketV3.java @@ -19,12 +19,96 @@ import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; public class ParkingTestTicketV3 { + /* + * +value UicRailTicketData ::= { + issuingDetail { + issuingYear 2021, + issuingDay 63, + issuingTime 750, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "employee" + } + } + } + } + }, + transportDocument { + { + ticket parkingGround : { + referenceIA5 "ACHE12345", + parkingGroundId "P47623", + fromParkingDate 1, + untilParkingDate 1, + location "Parking Frankfurt Main West", + stationCodeTable stationUIC, + stationNum 8000001, + specialInformation "outdoor parking", + numberPlate "AA-DE-12345", + price 500 + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd" + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + + */ + public static UicRailTicketData getUicTestTicket() { UicRailTicketData ticket = new UicRailTicketData(); populateTicket(ticket); return ticket; } + + public static String getEncodingHex() { + return "780440A3E5DD4374F3E7D72F2A9979F4A13A90086200B400104" + + "4A6F686E03446F770562C99B46B01108CBB786CDFE72E501" + + "0EA05604C187222B164CDA3506A0D1BB664CD70008DA830B" + + "935B4B73390233930B735B33AB93A1026B0B4B7102BB2B9B" + + "A01BD090087B7BABA3237B7B9103830B935B4B73385C182B" + + "62455AC593368D40807D1200802016400098D90080588141" + + "6D00B20283DA0"; + } private static void populateTicket(UicRailTicketData ticket) { @@ -144,4 +228,7 @@ import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV3.java index b2f1816..e7127e0 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV3.java @@ -22,6 +22,87 @@ import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData; public class StationPassageTestTicketV3 { + /* + * +value UicRailTicketData ::= { + issuingDetail { + issuingYear 2018, + issuingDay 1, + issuingTime 600, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "senior" + } + } + } + }, + groupName "myGroup" + }, + transportDocument { + { + ticket stationPassage : { + productName "passage", + stationCodeTable stationUIC, + stationNameUTF8 { + "Amsterdam" + }, + validFromDay 5, + validFromTime 0, + validUntilDay 5, + validUntilTime 1000, + numberOfDaysValid 5 + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd", + includedTickets { + { + productOwnerIA5 "test", + ticketType openTicket, + linkMode issuedTogether + } + } + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + */ + public static UicRailTicketData getUicTestTicket() { UicRailTicketData ticket = new UicRailTicketData(); @@ -29,7 +110,13 @@ public class StationPassageTestTicketV3 { return ticket; } - + public static String getEncodingHex() { + return + "7804404004B14374F3E7D72F2A9979F4A13A90086280B4001044A6F686E03446" + + "F770562C99B46B01106E797769DFC81DB5E51DC9BDD5C00448088B40EE0C2E" + + "6E6C2CECA021282DAE6E8CAE4C8C2DA5D000019F40082A60100402C800131B" + + "20081013A65E7D00805881416D00B20283DA"; + } private static void populateTicket(UicRailTicketData ticket) { @@ -181,4 +268,8 @@ public class StationPassageTestTicketV3 { + + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/VoucherTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/VoucherTestTicketV3.java index 20bfdaa..4098232 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/VoucherTestTicketV3.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/VoucherTestTicketV3.java @@ -19,11 +19,91 @@ import org.uic.barcode.ticket.api.asn.omv3.VoucherData; public class VoucherTestTicketV3 { + /* + * rec1value UicRailTicketData ::= { + issuingDetail { + issuingYear 2021, + issuingDay 63, + issuingTime 600, + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + currency "EUR", + currencyFract 2, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + }, + travelerDetail { + traveler { + { + firstName "John", + secondName "Dow", + idCard "12345", + ticketHolder TRUE, + status { + { + customerStatusDescr "employee" + } + } + } + } + }, + transportDocument { + { + ticket voucher : { + referenceIA5 "ACHE12345", + productOwnerIA5 "COFFEEMACHINE", + validFromYear 2022, + validFromDay 1, + validUntilYear 2022, + validUntilDay 1, + value 500, + infoText "coffee voucher" + } + } + }, + controlDetail { + identificationByCardReference { + { + trailingCardIdNum 100 + } + }, + identificationByIdCard FALSE, + identificationByPassportId FALSE, + passportValidationRequired FALSE, + onlineValidationRequired FALSE, + ageCheckRequired FALSE, + reductionCardCheckRequired FALSE, + infoText "cd" + }, + extension { + { + extensionId "1", + extensionData '82DA'H + }, + { + extensionId "2", + extensionData '83DA'H + } + } +} + + */ + public static UicRailTicketData getUicTestTicket() { UicRailTicketData ticket = new UicRailTicketData(); populateTicket(ticket); return ticket; } + + public static String getEncodingHex() { + + return "780440A3E4B14374F3E7D72F2A9979F4A13A90086200B4001044A6F686" + + "E03446F770562C99B46B01108CBB786CDFE72E50108928260C39115" + + "8B266D1A86C39F1A3458B360C391267450600830040807D0398DBD9" + + "999959481D9BDD58DA195C9200802016400098D900805881416D00B" + + "20283DA"; + } private static void populateTicket(UicRailTicketData ticket) { @@ -138,4 +218,5 @@ import org.uic.barcode.ticket.api.asn.omv3.VoucherData; + } diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java index 1f1be30..326eb99 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java @@ -1,6 +1,7 @@ package org.uic.barcode.ticketTestDB; +import java.util.Iterator; import java.util.TimeZone; import org.junit.After; @@ -10,8 +11,10 @@ import org.junit.Test; import org.uic.barcode.Decoder; import org.uic.barcode.asn1.uper.UperEncoder; import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; +import org.uic.barcode.ticket.api.impl.SimpleTrainLink; import org.uic.barcode.ticket.api.spec.IOpenTicket; import org.uic.barcode.ticket.api.spec.IPassengerType; +import org.uic.barcode.ticket.api.spec.IRegionalValidity; import org.uic.barcode.ticket.api.spec.ITariff; import org.uic.barcode.ticket.api.spec.ITrainLink; import org.uic.barcode.ticket.api.spec.ITraveler; @@ -89,6 +92,7 @@ public class DecodeSparpreisTicketDBTest { assert(tariff.getPassengerType().equals(IPassengerType.adult)); assert(tariff.getTariffDescription().equals("Super Sparpreis")); + ITrainLink tl = (ITrainLink) openTicket.getValidRegionList().iterator().next(); Assert.assertNotNull(tl); assert(tl.getTrain().equals("ICE973")); -- cgit v1.2.3