summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-03-25 16:49:30 +0100
committerGitHub <noreply@github.com>2021-03-25 16:49:30 +0100
commita4d6f33abac708b831a73bf175e64dd3ebeb6650 (patch)
tree3e14bb13b851d2228b765db0cb0191bb5e9e9403 /src
parentnew release (diff)
parent- bug fix for time zones (diff)
downloadUIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar.gz
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar.bz2
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar.lz
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar.xz
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.tar.zst
UIC-barcode-a4d6f33abac708b831a73bf175e64dd3ebeb6650.zip
Diffstat (limited to 'src')
-rw-r--r--src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java2
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java86
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java3
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java77
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/PassData.java463
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn35
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java2
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java198
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java35
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java30
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/PassData.java28
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn2
-rw-r--r--src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java2
-rw-r--r--src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java345
-rw-r--r--src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java345
-rw-r--r--src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java345
-rw-r--r--src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV2.java345
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java455
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java345
-rw-r--r--src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java312
-rw-r--r--src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java312
-rw-r--r--src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java312
-rw-r--r--src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java312
-rw-r--r--src/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java54
-rw-r--r--src/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java53
-rw-r--r--src/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java1
-rw-r--r--src/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java1
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/AsnLevelPassTimeZoneTestTicketV1.java578
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV1.java155
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV2.java155
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/OpenTestTicketV1.java578
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV1.java157
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV2.java157
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/PassTestTicketV1.java150
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase1V1.java168
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase2V1.java165
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase3V1.java204
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketV2.java168
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV1.java201
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV2.java201
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/SimpleTicketLinkTestTicket.java (renamed from src/org/uic/barcode/ticket/api/test/SimpleTicketLinkTestTicket.java)2
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/SimpleUicTestTicket.java (renamed from src/org/uic/barcode/ticket/api/test/SimpleUicTestTicket.java)2
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV1.java183
-rw-r--r--src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV2.java183
-rw-r--r--src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java19
-rw-r--r--src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java19
-rw-r--r--src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java (renamed from src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java)87
-rw-r--r--src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java23
-rw-r--r--src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java23
64 files changed, 7675 insertions, 418 deletions
diff --git a/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java b/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java
index af7dcd0..0060fcd 100644
--- a/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java
+++ b/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java
@@ -10,7 +10,7 @@ import org.uic.barcode.dynamicFrame.Level2DataType;
import org.uic.barcode.dynamicFrame.SequenceOfDataType;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
-import org.uic.barcode.ticket.api.test.SimpleUicTestTicket;
+import org.uic.barcode.ticket.api.test.testtickets.SimpleUicTestTicket;
public class SimpleDynamicFrameTestBarcode {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
index 97ac3d5..1eb0533 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java b/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
index c223900..76625d4 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
@@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
index 47e4959..bb0d273 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
@@ -29,10 +29,15 @@ import org.uic.barcode.asn1.datatypes.Asn1Default;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
+import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
+@Sequence
+@HasExtensionMarker
public class FIPTicketData extends Object {
public FIPTicketData() {
}
@@ -253,15 +258,12 @@ public class FIPTicketData extends Object {
}
public Date getValidFromDate(Date issuingDate){
-
- return DateTimeUtils.getDate(issuingDate, this.validFromDay,null);
-
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay,0L);
}
public Date getValidUntilDate(Date issuingDate){
if (issuingDate == null) return null;
-
if (this.validFromDay == null) {
this.validFromDay = 0L;
}
@@ -269,63 +271,77 @@ public class FIPTicketData extends Object {
if (this.validUntilDay == null) {
return null;
}
-
-
- return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, null);
-
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, 1439L);
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
-
+ public void addActivatedDays(Collection<Long> days) {
+ if (days == null || days.isEmpty()) return;
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
+ }
+ for (Long l : days) {
+ this.activatedDay.add(l);
+ }
+ }
+
+ /**
+ * Sets the activated days.
+ *
+ * @param dates the dates
+ * @param issuingDate the issuing date
+ * @param validFromDate the valid from date
+ */
+ public void setActivatedDays(Collection<Date> dates, Date issuingDate, Date validFromDate){
if (this.activatedDay != null) {
this.activatedDay.clear();
} else {
this.activatedDay= new SequenceOfActivatedDays();
}
-
+ long dateDif = 0L;
+ if (validFromDate != null) {
+ dateDif = DateTimeUtils.getDateDifference(issuingDate,validFromDate);
+ }
if (dates != null && !dates.isEmpty()) {
-
for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
+ this.addActivatedDay(issuingDate, dateDif, day);
}
-
}
-
}
-
- public void addActivatedDay(Date issuingDate, Date day){
-
- Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
-
+
+ /**
+ * Adds the activated day.
+ *
+ * @param issuingDate the issuing date in UTC
+ * @param dateOffset the date offset to be added to the issuing date
+ * @param day the day to be added
+ */
+ public void addActivatedDay(Date issuingDate, long dateOffset, Date day){
+ Long vDiff = DateTimeUtils.getDateDifferenceLocal(this.getValidFromDate(issuingDate), day);
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
-
- if (dayDiff != null) {
- this.activatedDay.add(dayDiff);
+ if (vDiff != null) {
+ this.activatedDay.add(vDiff);
}
-
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
-
if (this.activatedDay == null) return null;
-
ArrayList<Date> dates = new ArrayList<Date>();
-
for (Long diff: this.getActivatedDay()) {
-
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
-
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
}
-
- }
-
+ }
return dates;
-
}
-
+
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java b/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
index 6b6c538..a4b4049 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
@@ -31,6 +31,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class IncludedOpenTicketType extends Object {
public IncludedOpenTicketType() {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java b/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
index cb2d126..5f0e345 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
@@ -351,7 +351,8 @@ public class IssuingData extends Object {
}
- return cal.getTime();
+ Date d = cal.getTime();
+ return d;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
index 13ceb84..7d82232 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
@@ -35,6 +35,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -594,69 +595,85 @@ public class OpenTicketData extends Object {
if (this.validFromDay == null) {
this.validFromDay = 0L;
}
-
if (this.validUntilDay == null) {
return null;
}
-
-
return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, this.validUntilTime);
}
-
-
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
-
+
+ public void addActivatedDays(Collection<Long> days) {
+ if (days == null || days.isEmpty()) return;
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
+ }
+ for (Long l : days) {
+ this.activatedDay.add(l);
+ }
+ }
+
+ /**
+ * Sets the activated days.
+ *
+ * @param dates the dates
+ * @param issuingDate the issuing date
+ * @param validFromDate the valid from date
+ */
+ public void setActivatedDays(Collection<Date> dates, Date issuingDate, Date validFromDate){
if (this.activatedDay != null) {
this.activatedDay.clear();
} else {
this.activatedDay= new SequenceOfActivatedDays();
}
-
+ long dateDif = 0L;
+ if (validFromDate != null) {
+ dateDif = DateTimeUtils.getDateDifference(issuingDate,validFromDate);
+ }
if (dates != null && !dates.isEmpty()) {
-
for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
+ this.addActivatedDay(issuingDate, dateDif, day);
}
-
}
-
}
+
- public void addActivatedDay(Date issuingDate, Date day){
-
- Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
-
+ /**
+ * Adds the activated day.
+ *
+ * @param issuingDate the issuing date in UTC
+ * @param dateOffset the date offset to be added to the issuing date
+ * @param day the day to be added
+ */
+ public void addActivatedDay(Date issuingDate, long dateOffset, Date day){
+ Long vDiff = DateTimeUtils.getDateDifferenceLocal(this.getValidFromDate(issuingDate), day);
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
-
- if (dayDiff != null) {
- this.activatedDay.add(dayDiff);
+ if (vDiff != null) {
+ this.activatedDay.add(vDiff);
}
-
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
-
if (this.activatedDay == null) return null;
-
ArrayList<Date> dates = new ArrayList<Date>();
-
for (Long diff: this.getActivatedDay()) {
-
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
-
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
}
-
- }
-
+ }
return dates;
-
}
+
+
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java b/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
index b6be1a4..8119502 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
@@ -30,6 +30,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java b/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
index 6a56a40..701b076 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
@@ -34,127 +34,169 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PassData.
+ */
@Sequence
@HasExtensionMarker
public class PassData extends Object {
+
+ /**
+ * Instantiates a new pass data.
+ */
public PassData() {
}
+ /** The reference num. */
@FieldOrder(order = 0)
@Asn1Optional public Asn1BigInteger referenceNum;
+ /** The reference IA 5. */
@FieldOrder(order = 1)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String referenceIA5;
+ /** The product owner num. */
@FieldOrder(order = 2)
@IntRange(minValue=1,maxValue=32000)
@Asn1Optional public Long productOwnerNum;
+ /** The product owner IA 5. */
@FieldOrder(order = 3)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String productOwnerIA5;
+ /** The product id num. */
@FieldOrder(order = 4)
@IntRange(minValue=1,maxValue=32000)
@Asn1Optional public Long productIdNum;
+ /** The product id IA 5. */
@FieldOrder(order = 5)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String productIdIA5;
+ /** The pass type. */
@FieldOrder(order = 6)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long passType;
+ /** The pass description. */
@FieldOrder(order = 7)
@RestrictedString(CharacterRestriction.UTF8String)
@Asn1Optional public String passDescription;
+ /** The class code. */
@FieldOrder(order = 8)
@Asn1Default (value="second")
@Asn1Optional public TravelClassType classCode;
+ /** The valid from day. */
@FieldOrder(order = 9)
@IntRange(minValue=-1,maxValue=700)
@Asn1Optional public Long validFromDay;
+ /** The valid from time. */
@FieldOrder(order = 10)
@IntRange(minValue=0,maxValue=1440)
@Asn1Optional public Long validFromTime;
+ /** The valid from UTC offset. */
@FieldOrder(order = 11)
@IntRange(minValue=-60, maxValue=60)
@Asn1Optional public Long validFromUTCOffset;
+ /** The valid until day. */
@FieldOrder(order = 12)
@IntRange(minValue=0,maxValue=370)
@Asn1Optional public Long validUntilDay;
+ /** The valid until time. */
@FieldOrder(order = 13)
@IntRange(minValue=0,maxValue=1440)
@Asn1Optional public Long validUntilTime;
+ /** The valid until UTC offset. */
@FieldOrder(order = 14)
@IntRange(minValue=-60, maxValue=60)
@Asn1Optional public Long validUntilUTCOffset;
+ /** The validity period details. */
@FieldOrder(order = 15)
@Asn1Optional public ValidityPeriodDetailType validityPeriodDetails;
+ /** The number of validity days. */
@FieldOrder(order = 16)
@IntRange(minValue=0,maxValue=370)
@Asn1Optional public Long numberOfValidityDays;
+ /** The number of possible trips. */
@FieldOrder(order = 17)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long numberOfPossibleTrips;
+ /** The number of days of travel. */
@FieldOrder(order = 18)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long numberOfDaysOfTravel;
+ /** The activated day. */
@FieldOrder(order = 19)
@Asn1Optional public SequenceOfActivatedDays activatedDay;
+ /** The countries. */
@FieldOrder(order = 20)
@Asn1Optional public SequenceOfCountries countries;
+ /** The included carriers num. */
@FieldOrder(order = 21)
@Asn1Optional public SequenceOfCarrierNum includedCarriersNum;
+ /** The included carriers IA 5. */
@FieldOrder(order = 22)
@Asn1Optional public SequenceOfStringIA5 includedCarriersIA5;
+ /** The excluded carriers num. */
@FieldOrder(order = 23)
@Asn1Optional public SequenceOfCarrierNum excludedCarriersNum;
+ /** The excluded carriers IA 5. */
@FieldOrder(order = 24)
@Asn1Optional public SequenceOfStringIA5 excludedCarriersIA5;
+ /** The included service brands. */
@FieldOrder(order = 25)
@Asn1Optional public SequenceOfServiceBrands includedServiceBrands;
+ /** The excluded service brands. */
@FieldOrder(order = 26)
@Asn1Optional public SequenceOfServiceBrands excludedServiceBrands;
+ /** The valid region. */
@FieldOrder(order = 27)
@Asn1Optional public SequenceOfRegionalValidityType validRegion;
+ /** The tariffs. */
@FieldOrder(order = 28)
@Asn1Optional public SequenceOfTariffType tariffs;
+ /** The price. */
@FieldOrder(order = 29)
@Asn1Optional Asn1BigInteger price;
+ /** The vat details. */
@FieldOrder(order = 30)
@Asn1Optional SequenceOfVatDetail vatDetails;
+ /** The info text. */
@FieldOrder(order = 31)
@RestrictedString(CharacterRestriction.UTF8String)
@Asn1Optional public String infoText;
+ /** The extension. */
@FieldOrder(order = 32)
@Asn1Optional public ExtensionData extension;
@@ -162,46 +204,91 @@ public class PassData extends Object {
+ /**
+ * Gets the reference num.
+ *
+ * @return the reference num
+ */
public Asn1BigInteger getReferenceNum() {
return this.referenceNum;
}
+ /**
+ * Gets the reference IA 5.
+ *
+ * @return the reference IA 5
+ */
public String getReferenceIA5() {
return this.referenceIA5;
}
+ /**
+ * Gets the product owner num.
+ *
+ * @return the product owner num
+ */
public Long getProductOwnerNum() {
return this.productOwnerNum;
}
+ /**
+ * Gets the product owner IA 5.
+ *
+ * @return the product owner IA 5
+ */
public String getProductOwnerIA5() {
return this.productOwnerIA5;
}
+ /**
+ * Gets the product id num.
+ *
+ * @return the product id num
+ */
public Long getProductIdNum() {
return this.productIdNum;
}
+ /**
+ * Gets the product id IA 5.
+ *
+ * @return the product id IA 5
+ */
public String getProductIdIA5() {
return this.productIdIA5;
}
+ /**
+ * Gets the pass type.
+ *
+ * @return the pass type
+ */
public Long getPassType() {
return this.passType;
}
+ /**
+ * Gets the pass description.
+ *
+ * @return the pass description
+ */
public String getPassDescription() {
return this.passDescription;
}
+ /**
+ * Gets the class code.
+ *
+ * @return the class code
+ */
public TravelClassType getClassCode() {
if (classCode == null){
@@ -211,267 +298,537 @@ public class PassData extends Object {
return this.classCode;
}
+ /**
+ * Gets the valid from day.
+ *
+ * @return the valid from day
+ */
public Long getValidFromDay() {
return this.validFromDay;
}
+ /**
+ * Gets the valid from time.
+ *
+ * @return the valid from time
+ */
public Long getValidFromTime() {
return this.validFromTime;
}
+ /**
+ * Gets the valid until day.
+ *
+ * @return the valid until day
+ */
public Long getValidUntilDay() {
return this.validUntilDay;
}
+ /**
+ * Gets the valid until time.
+ *
+ * @return the valid until time
+ */
public Long getValidUntilTime() {
return this.validUntilTime;
}
+ /**
+ * Gets the validity period details.
+ *
+ * @return the validity period details
+ */
public ValidityPeriodDetailType getValidityPeriodDetails() {
return this.validityPeriodDetails;
}
+ /**
+ * Gets the number of validity days.
+ *
+ * @return the number of validity days
+ */
public Long getNumberOfValidityDays() {
return this.numberOfValidityDays;
}
+ /**
+ * Gets the number of possible trips.
+ *
+ * @return the number of possible trips
+ */
public Long getNumberOfPossibleTrips() {
return this.numberOfPossibleTrips;
}
+ /**
+ * Gets the number of days of travel.
+ *
+ * @return the number of days of travel
+ */
public Long getNumberOfDaysOfTravel() {
return this.numberOfDaysOfTravel;
}
+ /**
+ * Gets the activated day.
+ *
+ * @return the activated day
+ */
public List<Long> getActivatedDay() {
return this.activatedDay;
}
+ /**
+ * Gets the countries.
+ *
+ * @return the countries
+ */
public List<Long> getCountries() {
return this.countries;
}
+ /**
+ * Gets the included carriers num.
+ *
+ * @return the included carriers num
+ */
public List<Long> getIncludedCarriersNum() {
return this.includedCarriersNum;
}
+ /**
+ * Gets the included carriers IA 5.
+ *
+ * @return the included carriers IA 5
+ */
public List<String> getIncludedCarriersIA5() {
return this.includedCarriersIA5;
}
+ /**
+ * Gets the excluded carriers num.
+ *
+ * @return the excluded carriers num
+ */
public List<Long> getExcludedCarriersNum() {
return this.excludedCarriersNum;
}
+ /**
+ * Gets the excluded carriers IA 5.
+ *
+ * @return the excluded carriers IA 5
+ */
public SequenceOfStringIA5 getExcludedCarriersIA5() {
return this.excludedCarriersIA5;
}
+ /**
+ * Gets the included service brands.
+ *
+ * @return the included service brands
+ */
public SequenceOfServiceBrands getIncludedServiceBrands() {
return this.includedServiceBrands;
}
+ /**
+ * Gets the excluded service brands.
+ *
+ * @return the excluded service brands
+ */
public SequenceOfServiceBrands getExcludedServiceBrands() {
return this.excludedServiceBrands;
}
+ /**
+ * Gets the valid region.
+ *
+ * @return the valid region
+ */
public List<RegionalValidityType> getValidRegion() {
return this.validRegion;
}
+ /**
+ * Gets the tariffs.
+ *
+ * @return the tariffs
+ */
public List<TariffType> getTariffs() {
return this.tariffs;
}
+ /**
+ * Gets the info text.
+ *
+ * @return the info text
+ */
public String getInfoText() {
return this.infoText;
}
+ /**
+ * Gets the extension.
+ *
+ * @return the extension
+ */
public ExtensionData getExtension() {
return this.extension;
}
+ /**
+ * Sets the reference num.
+ *
+ * @param referenceNum the new reference num
+ */
public void setReferenceNum(Asn1BigInteger referenceNum) {
this.referenceNum = referenceNum;
}
+ /**
+ * Sets the reference IA 5.
+ *
+ * @param referenceIA5 the new reference IA 5
+ */
public void setReferenceIA5(String referenceIA5) {
this.referenceIA5 = referenceIA5;
}
+ /**
+ * Sets the product owner num.
+ *
+ * @param productOwnerNum the new product owner num
+ */
public void setProductOwnerNum(Long productOwnerNum) {
this.productOwnerNum = productOwnerNum;
}
+ /**
+ * Sets the product owner IA 5.
+ *
+ * @param productOwnerIA5 the new product owner IA 5
+ */
public void setProductOwnerIA5(String productOwnerIA5) {
this.productOwnerIA5 = productOwnerIA5;
}
+ /**
+ * Sets the product id num.
+ *
+ * @param productIdNum the new product id num
+ */
public void setProductIdNum(Long productIdNum) {
this.productIdNum = productIdNum;
}
+ /**
+ * Sets the product id IA 5.
+ *
+ * @param productIdIA5 the new product id IA 5
+ */
public void setProductIdIA5(String productIdIA5) {
this.productIdIA5 = productIdIA5;
}
+ /**
+ * Sets the pass type.
+ *
+ * @param passType the new pass type
+ */
public void setPassType(Long passType) {
this.passType = passType;
}
+ /**
+ * Sets the pass description.
+ *
+ * @param passDescription the new pass description
+ */
public void setPassDescription(String passDescription) {
this.passDescription = passDescription;
}
+ /**
+ * Sets the class code.
+ *
+ * @param classCode the new class code
+ */
public void setClassCode(TravelClassType classCode) {
this.classCode = classCode;
}
+ /**
+ * Sets the valid from day.
+ *
+ * @param validFromDay the new valid from day
+ */
public void setValidFromDay(Long validFromDay) {
this.validFromDay = validFromDay;
}
+ /**
+ * Sets the valid from time.
+ *
+ * @param validFromTime the new valid from time
+ */
public void setValidFromTime(Long validFromTime) {
this.validFromTime = validFromTime;
}
+ /**
+ * Sets the valid until day.
+ *
+ * @param validUntilDay the new valid until day
+ */
public void setValidUntilDay(Long validUntilDay) {
this.validUntilDay = validUntilDay;
}
+ /**
+ * Sets the valid until time.
+ *
+ * @param validUntilTime the new valid until time
+ */
public void setValidUntilTime(Long validUntilTime) {
this.validUntilTime = validUntilTime;
}
+ /**
+ * Sets the validity period details.
+ *
+ * @param validityPeriodDetails the new validity period details
+ */
public void setValidityPeriodDetails(ValidityPeriodDetailType validityPeriodDetails) {
this.validityPeriodDetails = validityPeriodDetails;
}
+ /**
+ * Sets the number of validity days.
+ *
+ * @param numberOfValidityDays the new number of validity days
+ */
public void setNumberOfValidityDays(Long numberOfValidityDays) {
this.numberOfValidityDays = numberOfValidityDays;
}
+ /**
+ * Sets the number of possible trips.
+ *
+ * @param numberOfPossibleTrips the new number of possible trips
+ */
public void setNumberOfPossibleTrips(Long numberOfPossibleTrips) {
this.numberOfPossibleTrips = numberOfPossibleTrips;
}
+ /**
+ * Sets the number of days of travel.
+ *
+ * @param numberOfDaysOfTravel the new number of days of travel
+ */
public void setNumberOfDaysOfTravel(Long numberOfDaysOfTravel) {
this.numberOfDaysOfTravel = numberOfDaysOfTravel;
}
+ /**
+ * Sets the activated day.
+ *
+ * @param activatedDay the new activated day
+ */
public void setActivatedDay(SequenceOfActivatedDays activatedDay) {
this.activatedDay = activatedDay;
}
+ /**
+ * Sets the countries.
+ *
+ * @param countries the new countries
+ */
public void setCountries(SequenceOfCountries countries) {
this.countries = countries;
}
+ /**
+ * Sets the included carriers num.
+ *
+ * @param includedCarriersNum the new included carriers num
+ */
public void setIncludedCarriersNum(SequenceOfCarrierNum includedCarriersNum) {
this.includedCarriersNum = includedCarriersNum;
}
+ /**
+ * Sets the included carriers IA 5.
+ *
+ * @param includedCarriersIA5 the new included carriers IA 5
+ */
public void setIncludedCarriersIA5(SequenceOfStringIA5 includedCarriersIA5) {
this.includedCarriersIA5 = includedCarriersIA5;
}
+ /**
+ * Sets the excluded carriers num.
+ *
+ * @param excludedCarriersNum the new excluded carriers num
+ */
public void setExcludedCarriersNum(SequenceOfCarrierNum excludedCarriersNum) {
this.excludedCarriersNum = excludedCarriersNum;
}
+ /**
+ * Sets the excluded carriers IA 5.
+ *
+ * @param excludedCarriersIA5 the new excluded carriers IA 5
+ */
public void setExcludedCarriersIA5(SequenceOfStringIA5 excludedCarriersIA5) {
this.excludedCarriersIA5 = excludedCarriersIA5;
}
+ /**
+ * Sets the included service brands.
+ *
+ * @param includedServiceBrands the new included service brands
+ */
public void setIncludedServiceBrands(SequenceOfServiceBrands includedServiceBrands) {
this.includedServiceBrands = includedServiceBrands;
}
+ /**
+ * Sets the excluded service brands.
+ *
+ * @param excludedServiceBrands the new excluded service brands
+ */
public void setExcludedServiceBrands(SequenceOfServiceBrands excludedServiceBrands) {
this.excludedServiceBrands = excludedServiceBrands;
}
+ /**
+ * Sets the valid region.
+ *
+ * @param validRegion the new valid region
+ */
public void setValidRegion(SequenceOfRegionalValidityType validRegion) {
this.validRegion = validRegion;
}
+ /**
+ * Sets the tariffs.
+ *
+ * @param tariffs the new tariffs
+ */
public void setTariffs(SequenceOfTariffType tariffs) {
this.tariffs = tariffs;
}
+ /**
+ * Sets the info text.
+ *
+ * @param infoText the new info text
+ */
public void setInfoText(String infoText) {
this.infoText = infoText;
}
+ /**
+ * Sets the extension.
+ *
+ * @param extension the new extension
+ */
public void setExtension(ExtensionData extension) {
this.extension = extension;
}
+ /**
+ * Gets the price.
+ *
+ * @return the price
+ */
public Long getPrice() {
return Asn1BigInteger.toLong(price);
}
+ /**
+ * Sets the price.
+ *
+ * @param price the new price
+ */
public void setPrice(Long price) {
this.price = Asn1BigInteger.toAsn1(price);
}
+ /**
+ * Gets the vat details.
+ *
+ * @return the vat details
+ */
public SequenceOfVatDetail getVatDetails() {
return vatDetails;
}
+ /**
+ * Sets the vat details.
+ *
+ * @param vatDetails the new vat details
+ */
public void setVatDetails(SequenceOfVatDetail vatDetails) {
this.vatDetails = vatDetails;
}
+ /**
+ * Adds the vat detail.
+ *
+ * @param vatDetail the vat detail
+ */
public void addVatDetail(VatDetailType vatDetail) {
if (this.vatDetails == null) {
this.vatDetails = new SequenceOfVatDetail();
@@ -479,6 +836,13 @@ public class PassData extends Object {
this.vatDetails.add(vatDetail);
}
+ /**
+ * Sets the validity dates.
+ *
+ * @param fromDate the from date
+ * @param untilDate the until date
+ * @param issuingDate the issuing date
+ */
public void setValidityDates (Date fromDate, Date untilDate, Date issuingDate){
if (issuingDate == null || fromDate == null) return;
@@ -493,12 +857,24 @@ public class PassData extends Object {
}
+ /**
+ * Gets the valid from date.
+ *
+ * @param issuingDate the issuing date
+ * @return the valid from date
+ */
public Date getValidFromDate(Date issuingDate){
return DateTimeUtils.getDate(issuingDate, this.validFromDay, this.validFromTime);
}
+ /**
+ * Gets the valid until date.
+ *
+ * @param issuingDate the issuing date
+ * @return the valid until date
+ */
public Date getValidUntilDate(Date issuingDate){
if (issuingDate == null) return null;
@@ -516,70 +892,109 @@ public class PassData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+
+ public void addActivatedDays(Collection<Long> days) {
+ if (days == null || days.isEmpty()) return;
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
+ }
+ for (Long l : days) {
+ this.activatedDay.add(l);
+ }
+ }
+
+ /**
+ * Sets the activated days.
+ *
+ * @param dates the dates
+ * @param issuingDate the issuing date
+ * @param validFromDate the valid from date
+ */
+ public void setActivatedDays(Collection<Date> dates, Date issuingDate, Date validFromDate){
if (this.activatedDay != null) {
this.activatedDay.clear();
} else {
this.activatedDay= new SequenceOfActivatedDays();
}
-
+ long dateDif = 0L;
+ if (validFromDate != null) {
+ dateDif = DateTimeUtils.getDateDifference(issuingDate,validFromDate);
+ }
if (dates != null && !dates.isEmpty()) {
-
for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
+ this.addActivatedDay(issuingDate, dateDif, day);
}
-
}
-
}
- public void addActivatedDay(Date issuingDate, Date day){
-
- Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
-
+ /**
+ * Adds the activated day.
+ *
+ * @param issuingDate the issuing date in UTC
+ * @param dateOffset the date offset to be added to the issuing date
+ * @param day the day to be added
+ */
+ public void addActivatedDay(Date issuingDate, long dateOffset, Date day){
+ Long vDiff = DateTimeUtils.getDateDifferenceLocal(this.getValidFromDate(issuingDate), day);
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
-
- if (dayDiff != null) {
- this.activatedDay.add(dayDiff);
+ if (vDiff != null) {
+ this.activatedDay.add(vDiff);
}
-
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
-
if (this.activatedDay == null) return null;
-
ArrayList<Date> dates = new ArrayList<Date>();
-
for (Long diff: this.getActivatedDay()) {
-
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
-
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
}
-
- }
-
+ }
return dates;
-
}
+ /**
+ * Gets the valid from UTC offset.
+ *
+ * @return the valid from UTC offset
+ */
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}
+ /**
+ * Sets the valid from UTC offset.
+ *
+ * @param validFromUTCOffset the new valid from UTC offset
+ */
public void setValidFromUTCOffset(Long validFromUTCOffset) {
this.validFromUTCOffset = validFromUTCOffset;
}
+ /**
+ * Gets the valid until UTC offset.
+ *
+ * @return the valid until UTC offset
+ */
public Long getValidUntilUTCOffset() {
return validUntilUTCOffset;
}
+ /**
+ * Sets the valid until UTC offset.
+ *
+ * @param validUntilUTCOffset the new valid until UTC offset
+ */
public void setValidUntilUTCOffset(Long validUntilUTCOffset) {
this.validUntilUTCOffset = validUntilUTCOffset;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
index 73fa5aa..adc5f71 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
@@ -33,6 +33,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java b/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
index a8718d7..36dc6bf 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java b/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
index 3eb0871..5469c2f 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
@@ -28,6 +28,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class TrainLinkType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java b/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
index a41fa03..5667ad9 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
@@ -26,6 +26,7 @@ import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class ValidityPeriodType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn b/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
index 24df140..fb19462 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
@@ -81,7 +81,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # local date (CET): 01.01.2018 23:05
-- # -> difference in days = 0
-- #
--- # the day difference could become -1 although this can happen for localtions in America or New Zeeland only.
+-- # the day difference could become -1 although this can happen for locations in America or New Zeeland only.
-- #
-- # implementation example:
-- #
@@ -97,6 +97,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # issuingCal.set(Calendar.MINUTE, 0);
-- # issuingCal.set(Calendar.SECOND, 0);
-- # issuingCal.set(Calendar.MILLISECOND, 0);
+-- # Date start = startCal.getTime();
-- #
-- # Calendar fromCal = Calendar.getInstance();
-- # fromCal.clear();
@@ -106,11 +107,11 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # fromCal.set(Calendar.MINUTE, 0);
-- # fromCal.set(Calendar.SECOND, 0);
-- # fromCal.set(Calendar.MILLISECOND, 0);
+-- # Date end = endCal.getTime();
-- #
--- # long diff = localDate.getTime() - issuingDate.getTime();
--- # long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
+-- # long diff = TimeUnit.DAYS.convert(end.getTime() - start.getTime(), TimeUnit.MILLISECONDS );
-- #
--- # return new Long(dayDiff);
+-- # return new Long(diff);
-- #
-- # }
-- #
@@ -843,7 +844,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
productIdIA5 IA5String OPTIONAL,
-- type of the pass, code list provided by the product owner
- -- in case of Eurail:
+ -- in case of Eurail:
-- 1 = Interrail
-- 2 = Eurail
-- 3 = Eurail Global (all countries)
@@ -858,16 +859,16 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- number of days from issuing date
validFromDay INTEGER (-1..700) DEFAULT 0,
validFromTime INTEGER (0..1440) OPTIONAL,
- validFromUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
- -- (UTC = local + offset * 15 Minutes)
+ validFromUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
+ -- (UTC = local + offset * 15 Minutes)
-- end of validity (local time)
-- number of days from valid from day, 0 = valid on valid-from-date
validUntilDay INTEGER (0..370) DEFAULT 0,
validUntilTime INTEGER (0..1440) OPTIONAL,
- validUntilUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
- -- (UTC = local + offset * 15 Minutes)
- -- should be omtted in case it is the same as for depature
+ validUntilUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
+ -- (UTC = local + offset * 15 Minutes)
+ -- should be omitted in case it is the same as for depature
@@ -883,21 +884,21 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- list of activated days in case the entire ticket is not activated
-- the day is given by the number of days from the first day of validity
- -- 0 = first day of validity
+ -- 0 = first day of validity
activatedDay SEQUENCE OF INTEGER (0..370) OPTIONAL,
-- included countries, code table according to UIC leaflet 918.9
- countries SEQUENCE OF INTEGER (1..250) OPTIONAL,
+ countries SEQUENCE OF INTEGER (1..250) OPTIONAL,
-- included carriers (RICS codes)
- includedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
- includedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
+ includedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
+ includedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
-- excluded carriers (RICS codes)
- excludedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
- excludedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
+ excludedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
+ excludedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
- -- service brand: code list https://uic.org/service-brand-code-list
+ -- service brand: code list https://uic.org/service-brand-code-list
includedServiceBrands SEQUENCE OF INTEGER (1..32000) OPTIONAL,
excludedServiceBrands SEQUENCE OF INTEGER (1..32000) OPTIONAL,
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
index 9bab332..4e0bb5f 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
@@ -33,7 +33,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
-import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
index 41c73b5..435c6ef 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
@@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java b/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java
deleted file mode 100644
index 04b1c2e..0000000
--- a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package org.uic.barcode.ticket.api.asn.omv2;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-
-public class DateTimeUtils {
-
- public static Long getDateDifference(Date issuingDate, Date localDate) {
-
- if (issuingDate == null || localDate == null) return null;
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
- issuingCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- issuingCal.set(Calendar.HOUR_OF_DAY, 0);
- issuingCal.set(Calendar.MINUTE, 0);
- issuingCal.set(Calendar.SECOND, 0);
- issuingCal.set(Calendar.MILLISECOND, 0);
-
- Calendar fromCal = Calendar.getInstance();
- fromCal.clear();
- fromCal.setTime(localDate);
- fromCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- fromCal.set(Calendar.HOUR_OF_DAY, 0);
- fromCal.set(Calendar.MINUTE, 0);
- fromCal.set(Calendar.SECOND, 0);
- fromCal.set(Calendar.MILLISECOND, 0);
-
- long diff = localDate.getTime() - issuingDate.getTime();
- long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
-
- return new Long(dayDiff);
-
- }
-
- public static Date getLocalDateFromDifference(Date issuingDate, int diff , Long time ) {
-
- if (issuingDate == null) return null;
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(issuingDate);
- cal.add(Calendar.DAY_OF_YEAR, diff);
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
- return cal.getTime();
-
- }
-
-
- public static void setTime(Calendar cal, Long time){
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
-
- }
-
- public static Long getTime (Calendar cal) {
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Long getTime (Date date) {
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(date);
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Date getDate(Date issuingDate, Long date, Long time){
-
- if (issuingDate == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
-
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- DateTimeUtils.setTime(cal,time);
-
- return cal.getTime();
-
- }
-
-
-
- /**
- * Gets the UTC offset.
- *
- * @param date and time of the issuing date
- * @param date and time of the departure
- * @return the UTC offset in multiples of 15 minutes
- * the offset needs to be added to local time to get the UTC time (UTC = local + offset)
- */
- public static Long getUTCoffset(Date local) {
-
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(local);
-
- /*
- * Returns the amount of time in milliseconds to add to UTC to get standard time in this
- * time zone. Because this value is not affected by daylight saving time, it is called raw offset.
- * If an underlying TimeZone implementation subclass supports historical GMT offset changes, the method
- * returns the raw offset value of the current date. In Honolulu, for example, its raw offset
- * changed from GMT-10:30 to GMT-10:00 in 1947, and this method
- * always returns -36000000 milliseconds (i.e., -10 hours).
- */
- int minuteOffset = - cal.getTimeZone().getRawOffset()/ ( 1000 * 60 * 15 );
-
- return new Long (minuteOffset);
-
- }
-
- public static Date getUTCDate(Date issuingDate, Long date, Long time, Long UTCOffset) {
-
- if (issuingDate == null) return null;
-
- if (UTCOffset == null) return null;
-
- if (time == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
-
- cal.add(Calendar.MINUTE, (int) (UTCOffset * 15) );
-
- cal.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- return cal.getTime();
-
- }
-
-
-}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
index e11a66f..c6a98e4 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
@@ -29,10 +29,15 @@ import org.uic.barcode.asn1.datatypes.Asn1Default;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
+import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
+@Sequence
+@HasExtensionMarker
public class FIPTicketData extends Object {
public FIPTicketData() {
}
@@ -254,7 +259,7 @@ public class FIPTicketData extends Object {
public Date getValidFromDate(Date issuingDate){
- return DateTimeUtils.getDate(issuingDate, this.validFromDay,null);
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay,0L);
}
@@ -271,24 +276,20 @@ public class FIPTicketData extends Object {
}
- return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, null);
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, 1439L);
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -307,6 +308,12 @@ public class FIPTicketData extends Object {
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -315,7 +322,7 @@ public class FIPTicketData extends Object {
for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
index dc43d75..cef0b02 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
@@ -31,6 +31,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class IncludedOpenTicketType extends Object {
public IncludedOpenTicketType() {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
index 402323e..9900640 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
@@ -35,6 +35,8 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -601,21 +603,16 @@ public class OpenTicketData extends Object {
}
-
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -634,6 +631,12 @@ public class OpenTicketData extends Object {
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -642,7 +645,7 @@ public class OpenTicketData extends Object {
for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
@@ -653,6 +656,7 @@ public class OpenTicketData extends Object {
return dates;
}
+
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
index 1e14394..4f6f6d8 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
@@ -30,6 +30,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
index b3b02e7..dbc81c3 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
@@ -34,6 +34,8 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -516,20 +518,16 @@ public class PassData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -548,6 +546,12 @@ public class PassData extends Object {
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -556,7 +560,7 @@ public class PassData extends Object {
for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
index a474e7d..31b3fa8 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
@@ -33,6 +33,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
index 6c6d36d..a378bb7 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
index 7c3de46..f269497 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
@@ -28,6 +28,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class TrainLinkType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
index 6c36c97..7b08f73 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
@@ -26,6 +26,7 @@ import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class ValidityPeriodType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
index b67ac06..2c2eda7 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
@@ -535,7 +535,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
vatDetail SEQUENCE OF VatDetailType OPTIONAL,
- -- type of supplement - code list from 018.1
+ -- type of supplement - code list from 918.1
typeOfSupplement INTEGER (0..9) DEFAULT 0,
numberOfSupplements INTEGER (0..200) DEFAULT 0,
diff --git a/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java b/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
index 5435c6b..5b2e578 100644
--- a/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
+++ b/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
@@ -3,7 +3,7 @@ package org.uic.barcode.ticket.api.test;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
-import org.uic.barcode.ticket.api.asn.omv1.DateTimeUtils;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class DateTimeUtilsTest{
diff --git a/src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java
new file mode 100644
index 0000000..c9b0f31
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java
@@ -0,0 +1,345 @@
+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.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.FipTimeZoneTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class FipTimeZoneTestV1 {
+
+ /** 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. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = FipTimeZoneTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket2 = FipTimeZoneTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket3 = FipTimeZoneTestTicketV1.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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) 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);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) 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/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java b/src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java
new file mode 100644
index 0000000..89b6562
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java
@@ -0,0 +1,345 @@
+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.omv2.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.FipTimeZoneTestTicketV2;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class FipTimeZoneTestV2 {
+
+ /** 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. */
+ OpenAsn2ApiDecoderV2 decoder = new OpenAsn2ApiDecoderV2();
+
+ /** The encoder. */
+ Api2OpenAsnEncoderV2 encoder = new Api2OpenAsnEncoderV2();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = FipTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket2 = FipTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket3 = FipTimeZoneTestTicketV2.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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) 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);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) 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/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java
new file mode 100644
index 0000000..c2d288e
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java
@@ -0,0 +1,345 @@
+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.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.OpenTicketTimeZoneTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class OpenTicketTimeZoneTestV1 {
+
+ /** 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. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = OpenTicketTimeZoneTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket2 = OpenTicketTimeZoneTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket3 = OpenTicketTimeZoneTestTicketV1.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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) 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);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) 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/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV2.java b/src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV2.java
new file mode 100644
index 0000000..ab16716
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV2.java
@@ -0,0 +1,345 @@
+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.omv2.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.OpenTicketTimeZoneTestTicketV2;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2;
+
+
+/**
+ * The Class FipTimeZoneTestV2.
+ *
+ *
+ *
+ */
+public class OpenTicketTimeZoneTestV2 {
+
+ /** 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. */
+ OpenAsn2ApiDecoderV2 decoder = new OpenAsn2ApiDecoderV2();
+
+ /** The encoder. */
+ Api2OpenAsnEncoderV2 encoder = new Api2OpenAsnEncoderV2();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = OpenTicketTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket2 = OpenTicketTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket3 = OpenTicketTimeZoneTestTicketV2.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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) 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);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) 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/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
new file mode 100644
index 0000000..e7aeae8
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
@@ -0,0 +1,455 @@
+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.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketCase1V1;
+import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketCase2V1;
+import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketCase3V1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class PassTimeZoneTestV1.
+ *
+ *
+ * test validity dates and activated days in different time zones
+ *
+ Case 1:
+ issue date: 04-03-2021 12:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 750
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 2:
+ issue date: 04-03-2021 00:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 30
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 3:
+ issue date: 03-03-2021 23:30 UTC
+ issuingYear: 2021
+ issuingDay: 62
+ issuingTime: 1410
+ validFromDay: 11
+ activatedDays: [0]
+
+ expected: activated for 03-03-2021 + 11 + 0 00:00 UTC --> 14-03-2021
+ *
+ * - Test tickets defined on the level of the asn.1 object model
+ * - set the local time zone
+ * - decoded to get an API ticket object
+ * - encode again to
+ *
+ *
+ *
+ *
+ */
+public class PassTimeZoneTestV1 {
+
+ /** 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. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = PassTimeZoneTestTicketCase1V1.getUicTestTicket();
+ UicRailTicketData ticket2 = PassTimeZoneTestTicketCase2V1.getUicTestTicket();
+ UicRailTicketData ticket3 = PassTimeZoneTestTicketCase3V1.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 decode test tickets in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ */
+ @Test public void testCETdecodeOnly() throws IllegalArgumentException, IllegalAccessException {
+
+ encodedInTimeZone1 = encoded1;
+ encodedInTimeZone2 = encoded2;
+ encodedInTimeZone3 = encoded3;
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test decode test tickets in GMT.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ */
+ @Test public void testGMTdecodeOnly() throws IllegalArgumentException, IllegalAccessException {
+
+ encodedInTimeZone1 = encoded1;
+ encodedInTimeZone2 = encoded2;
+ encodedInTimeZone3 = encoded3;
+
+ //test decoded ticket
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 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 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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) 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);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) 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/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java
new file mode 100644
index 0000000..decc26b
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java
@@ -0,0 +1,345 @@
+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.omv2.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketV2;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2;
+
+
+/**
+ * The Class FipTimeZoneTestV2.
+ *
+ *
+ *
+ */
+public class PassTimeZoneTestV2 {
+
+ /** 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. */
+ OpenAsn2ApiDecoderV2 decoder = new OpenAsn2ApiDecoderV2();
+
+ /** The encoder. */
+ Api2OpenAsnEncoderV2 encoder = new Api2OpenAsnEncoderV2();
+
+ /** 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;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = PassTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket2 = PassTimeZoneTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket3 = PassTimeZoneTestTicketV2.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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00: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");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ 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" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) 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);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) 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/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java
new file mode 100644
index 0000000..5bf78cb
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.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.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.ReservationTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class ReservationTimeZoneTestV1 {
+
+ /** 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. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** 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 departureDate1 = null;
+ String departureDate2 = null;
+ String departureDate3 = null;
+
+ String arrivalDate1 = null;
+ String arrivalDate2 = null;
+ String arrivalDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = ReservationTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket2 = ReservationTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket3 = ReservationTestTicketV1.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate3.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();
+
+ departureDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getDepartureDate().toString();
+
+ arrivalDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getArrivalDate().toString();
+
+
+ }
+
+
+ private void setdepartureDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setDepartureDate(date);
+ }
+
+ private void setarrivalDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setArrivalDate(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/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java b/src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java
new file mode 100644
index 0000000..34d3bc2
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.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.omv2.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.ReservationTestTicketV2;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class ReservationTimeZoneTestV2 {
+
+ /** 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. */
+ OpenAsn2ApiDecoderV2 decoder = new OpenAsn2ApiDecoderV2();
+
+ /** The encoder. */
+ Api2OpenAsnEncoderV2 encoder = new Api2OpenAsnEncoderV2();
+
+ /** 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 departureDate1 = null;
+ String departureDate2 = null;
+ String departureDate3 = null;
+
+ String arrivalDate1 = null;
+ String arrivalDate2 = null;
+ String arrivalDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = ReservationTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket2 = ReservationTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket3 = ReservationTestTicketV2.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.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" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("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(departureDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate3.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();
+
+ departureDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getDepartureDate().toString();
+
+ arrivalDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getArrivalDate().toString();
+
+
+ }
+
+
+ private void setdepartureDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setDepartureDate(date);
+ }
+
+ private void setarrivalDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setArrivalDate(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/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java
new file mode 100644
index 0000000..aedf569
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.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.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IStationPassage;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class StationPassageTimeZoneTestV1 {
+
+ /** 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. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** 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 validFromDate1 = null;
+ String validFromDate2 = null;
+ String validFromDate3 = null;
+
+ String validUntilDate1 = null;
+ String validUntilDate2 = null;
+ String validUntilDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = StationPassageTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket2 = StationPassageTestTicketV1.getUicTestTicket();
+ UicRailTicketData ticket3 = StationPassageTestTicketV1.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate3.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();
+
+ validFromDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntilDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+
+ }
+
+
+ private void setValidFromDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setUntilDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) 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/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java b/src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java
new file mode 100644
index 0000000..e87e968
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.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.omv2.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IStationPassage;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV2;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2;
+
+
+/**
+ * The Class FipTimeZoneTestV2.
+ *
+ *
+ *
+ */
+public class StationPassageTimeZoneTestV2 {
+
+ /** 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. */
+ OpenAsn2ApiDecoderV2 decoder = new OpenAsn2ApiDecoderV2();
+
+ /** The encoder. */
+ Api2OpenAsnEncoderV2 encoder = new Api2OpenAsnEncoderV2();
+
+ /** 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 validFromDate1 = null;
+ String validFromDate2 = null;
+ String validFromDate3 = null;
+
+ String validUntilDate1 = null;
+ String validUntilDate2 = null;
+ String validUntilDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = StationPassageTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket2 = StationPassageTestTicketV2.getUicTestTicket();
+ UicRailTicketData ticket3 = StationPassageTestTicketV2.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.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" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("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(validFromDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate3.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();
+
+ validFromDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntilDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+
+ }
+
+
+ private void setValidFromDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setUntilDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) 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/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java b/src/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java
new file mode 100644
index 0000000..cb20d79
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java
@@ -0,0 +1,54 @@
+package org.uic.barcode.ticket.api.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.logging.Level;
+
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.OpenTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+public class UperEncodeOpenTicketTestV1 {
+
+
+
+ @Test public void testDecodeTicket() throws IllegalArgumentException, IllegalAccessException {
+ UicRailTicketData ticket = OpenTestTicketV1.getUicTestTicket();
+ byte[] encoded = UperEncoder.encode(ticket);
+ String hex = UperEncoder.hexStringFromBytes(encoded);
+ UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex));
+ //String expectedHex = "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D000822537B43701A237BB82B164CDA358088373CBBB4EFE40EDAF28EE4DEEAE004A03AD12B01416D08000000004039BDC195B951A58DAD95D125B999BC48088040EE0C2E6E6C2CECA021282DAE6E8CAE4C8C2DA0080BDA60100402C800131B20081013A65E7D00805881416D00B20283DA0";
+ //assertEquals(hex,expectedHex);
+ UicRailTicketData decodedTicket = UperEncoder.decode(encoded, UicRailTicketData.class);
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+ IUicRailTicket iTicket = null;
+ try {
+ iTicket = decoder.decodeFromAsn(encoded);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+ try {
+ encoded = encoder.encode(iTicket);
+ } catch (EncodingFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assert(decodedTicket != null);
+ assertEquals(decodedTicket.controlDetail.ageCheckRequired , false );
+ assertEquals(decodedTicket.controlDetail.getInfoText() , "cd" );
+ assertEquals(decodedTicket.controlDetail.getIncludedTickets().get(0).getProductOwnerIA5() , "test" );
+ assert(decodedTicket.controlDetail.getIdentificationByCardReference().get(0).getTrailingCardIdNum() == 100L );
+ }
+
+}
diff --git a/src/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java b/src/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java
new file mode 100644
index 0000000..7436f5d
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java
@@ -0,0 +1,53 @@
+package org.uic.barcode.ticket.api.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.logging.Level;
+
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.PassTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+public class UperEncodePassTestV1 {
+
+
+ @Test public void testDecodeTicket() throws IllegalArgumentException, IllegalAccessException {
+ UicRailTicketData ticket = PassTestTicketV1.getUicTestTicket();
+ byte[] encoded = UperEncoder.encode(ticket);
+ String hex = UperEncoder.hexStringFromBytes(encoded);
+ UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex));
+
+ UicRailTicketData decodedTicket = UperEncoder.decode(encoded, UicRailTicketData.class);
+
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+ IUicRailTicket iTicket = null;
+ try {
+ iTicket = decoder.decodeFromAsn(encoded);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+ try {
+ encoded = encoder.encode(iTicket);
+ } catch (EncodingFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assert(decodedTicket != null);
+ assertEquals(decodedTicket.controlDetail.ageCheckRequired , false );
+ assertEquals(decodedTicket.controlDetail.getInfoText() , "cd" );
+ assertEquals(decodedTicket.controlDetail.getIncludedTickets().get(0).getProductOwnerIA5() , "test" );
+ assert(decodedTicket.controlDetail.getIdentificationByCardReference().get(0).getTrailingCardIdNum() == 100L );
+ }
+
+}
diff --git a/src/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java b/src/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
index 96d003d..0a4b04c 100644
--- a/src/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
+++ b/src/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
@@ -12,6 +12,7 @@ import org.uic.barcode.ticket.api.spec.ILinkMode;
import org.uic.barcode.ticket.api.spec.ITicketLink;
import org.uic.barcode.ticket.api.spec.ITicketType;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.SimpleTicketLinkTestTicket;
import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
diff --git a/src/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java b/src/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
index e2a5558..cf8eec6 100644
--- a/src/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
+++ b/src/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
@@ -7,6 +7,7 @@ import java.util.logging.Level;
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.SimpleUicTestTicket;
public class UperEncodeTicketTestV1 {
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/AsnLevelPassTimeZoneTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/AsnLevelPassTimeZoneTestTicketV1.java
new file mode 100644
index 0000000..5408638
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/AsnLevelPassTimeZoneTestTicketV1.java
@@ -0,0 +1,578 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
+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.OpenTicketData;
+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.StationPassageData;
+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.TokenType;
+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 AsnLevelPassTimeZoneTestTicketV1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+ /*
+ value UicRailTicketData ::= {
+ issuingDetail {
+ issuingYear 2018
+ issuingDay 1
+ specimen TRUE,
+ securePaperTicket FALSE,
+ activated TRUE,
+ 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
+ ,infoText "openTicketInfo"
+ ,classCode "second"
+ }
+ }
+ ,{
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 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 }
+ }
+ }
+ */
+
+ /*
+ * asn.1 version 1.3 encoding:
+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) = 7]
+ issuingYear INTEGER [length (not encoded) = 1.0]
+ 2018
+ issuingDay INTEGER [length (not encoded) = 1.1]
+ 1
+ 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 = 2]
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 2]
+ token TokenType SEQUENCE [fieldcount (not encoded) = 2]
+ tokenProviderIA5 IA5String [length = 3.0]
+ "VDV"
+ token OCTET STRING [length = 2.0]
+ 0x82da
+ ticket CHOICE [index = 2]
+ openTicket OpenTicketData SEQUENCE [root fieldcount (not encoded) = 2]
+ returnIncluded BOOLEAN [length (not encoded) = 0.1]
+ FALSE
+ infoText UTF8String [length = 14.0]
+ 0x6f70656e5469636b6574496e666f
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 1]
+ ticket CHOICE [index = 9]
+ stationPassage StationPassageData SEQUENCE [root fieldcount (not encoded) = 4]
+ productName UTF8String [length = 7.0]
+ 0x70617373616765
+ stationNameUTF8 SEQUENCE OF [count = 1]
+ UTF8String [length = 9.0]
+ 0x416d7374657264616d
+ validFromDay INTEGER [length (not encoded) = 1.2]
+ 0
+ numberOfDaysValid INTEGER [length = 1.0]
+ 123
+ 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 = 154.3
+Encoded successfully in 155 bytes:
+78022020 050DD3CF 9F5CBCAA 65E7D284 EA40218A 02D00082 2537B437 01A237BB
+82B164CD A3580883 73CBBB4E FE40EDAF 28EE4DEE AE004A03 AD12B014 16D08000
+00000403 9BDC195B 951A58DA D95D125B 999BC480 88040EE0 C2E6E6C2 CECA0212
+82DAE6E8 CAE4C8C2 DA0080BD A6010040 2C800131 B200ADC2 EAC588C5 93466D5C
+366E089E 8A848407 4275204E 9979F428 100B1028 2DA01640 507B40
+ *
+ *
+ */
+
+ /*
+ * asn.1 version 2.0 encoding
+ *
+ 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) = 7]
+ issuingYear INTEGER [length (not encoded) = 1.0]
+ 2018
+ issuingDay INTEGER [length (not encoded) = 1.1]
+ 1
+ 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 = 2]
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 2]
+ token TokenType SEQUENCE [fieldcount (not encoded) = 2]
+ tokenProviderIA5 IA5String [length = 3.0]
+ "VDV"
+ token OCTET STRING [length = 2.0]
+ 0x82da
+ ticket CHOICE [index = 2]
+ openTicket OpenTicketData SEQUENCE [root fieldcount (not encoded) = 2]
+ returnIncluded BOOLEAN [length (not encoded) = 0.1]
+ FALSE
+ infoText UTF8String [length = 14.0]
+ 0x6f70656e5469636b6574496e666f
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 1]
+ ticket CHOICE [index = 9]
+ stationPassage StationPassageData SEQUENCE [root fieldcount (not encoded) = 4]
+ productName UTF8String [length = 7.0]
+ 0x70617373616765
+ stationNameUTF8 SEQUENCE OF [count = 1]
+ UTF8String [length = 9.0]
+ 0x416d7374657264616d
+ validFromDay INTEGER [length (not encoded) = 1.2]
+ 0
+ numberOfDaysValid INTEGER [length = 1.0]
+ 123
+ 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 = 154.6
+Encoded successfully in 155 bytes:
+78022020 050DD3CF 9F5CBCAA 65E7D284 EA40218A 02D00041 129BDA1B 80D11BDD
+C158B266 D1AC0441 B9E5DDA7 7F2076D7 947726F7 57002501 D689580A 0B684000
+00000200 737B832B 72A34B1B 5B2BA24B 73337890 110081DC 185CDCD8 59D94042
+505B5CDD 195C9918 5B401017 B4C02008 05900026 364015B8 5D58B118 B268CDAB
+86CDC113 D1509080 E84EA409 D32F3E85 02016205 05B402C8 0A0F68
+ *
+ *
+ *
+ */
+
+ public static String getEncodingV1Hex() {
+ return "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D000822537B43701A237BB" +
+ "82B164CDA358088373CBBB4EFE40EDAF28EE4DEEAE004A03AD12B01416D08000" +
+ "000004039BDC195B951A58DAD95D125B999BC48088040EE0C2E6E6C2CECA0212" +
+ "82DAE6E8CAE4C8C2DA0080BDA60100402C800131B200ADC2EAC588C593466D5C" +
+ "366E089E8A8484074275204E9979F428100B10282DA01640507B40";
+ }
+
+ public static String getEncodingV2Hex() {
+ return "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D00041129BDA1B80D11BDD" +
+ "C158B266D1AC0441B9E5DDA77F2076D7947726F757002501D689580A0B684000" +
+ "00000200737B832B72A34B1B5B2BA24B73337890110081DC185CDCD859D94042" +
+ "505B5CDD195C99185B401017B4C0200805900026364015B85D58B118B268CDAB" +
+ "86CDC113D1509080E84EA409D32F3E850201620505B402C80A0F68";
+ }
+
+
+ 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);
+
+ }
+
+ /*
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 0
+ ,numberOfDaysValid 123
+ }
+ */
+ 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);
+ }
+
+ /*
+ {
+ token {tokenProviderIA5 "VDV", token '82DA'H }
+ ,ticket openTicket : {
+ returnIncluded FALSE
+ 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);
+ tdd.setOpenTicket(otd);
+ dd.setTicket(tdd);
+ }
+
+
+ /*
+ ,travelerDetail{
+ traveler {
+ {
+ firstName "John"
+ ,secondName "Dow"
+ ,idCard "12345"
+ ,ticketHolder TRUE
+ ,status {{customerStatusDescr "senior" }}
+ }
+ }
+ ,groupName "myGroup"
+ }
+ */
+
+ 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);
+ }
+
+ /*
+ ,issuingDetail {
+ issuingYear 2018
+ issuingDay 1
+ specimen TRUE,
+ securePaperTicket FALSE,
+ activated TRUE,
+ issuerPNR "issuerTestPNR",
+ issuedOnLine 12
+ }
+ */
+ 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);
+ }
+
+ /*
+ ,extension {
+ { extensionId "1", extensionData '82DA'H }
+ ,{ extensionId "2", extensionData '83DA'H }
+ }
+ */
+ 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);
+ }
+
+ /*
+ ,controlDetail {
+ identificationByCardReference {
+ { trailingCardIdNum 100 }
+ }
+ ,identificationByIdCard FALSE
+ ,identificationByPassportId FALSE
+ ,passportValidationRequired FALSE
+ ,onlineValidationRequired FALSE
+ ,ageCheckRequired FALSE
+ ,reductionCardCheckRequired FALSE
+ ,infoText "cd"
+ ,includedTickets {
+ { productOwnerIA5 "test"
+ ,
+
+
+ }
+ }
+ }
+ */
+ 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;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV1.java
new file mode 100644
index 0000000..bfd54fe
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV1.java
@@ -0,0 +1,155 @@
+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.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.FIPTicketData;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+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.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+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 FipTimeZoneTestTicketV1 {
+
+ 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();
+
+
+ //FipTicket
+ DocumentData do1 = new DocumentData();
+ addFip(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 12:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(750L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addFip(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ FIPTicketData otd = new FIPTicketData();
+ otd.setClassCode(TravelClassType.first);
+ otd.setNumberOfTravelDays(8L);
+ otd.setValidFromDay(10L);
+ otd.setValidUntilDay(10L);
+ SequenceOfCarrierNum carriers = new SequenceOfCarrierNum();
+ carriers.add(1080L);
+ carriers.add(1181L);
+ otd.setCarrierNum(carriers);
+ otd.setIncludesSupplements(true);
+ otd.setReferenceNum(Asn1BigInteger.toAsn1(123456789));
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ s.add(0L);
+ otd.setActivatedDay(s);
+
+ tdd.setFipTicket(otd);
+ dd.setTicket(tdd);
+ }
+
+
+
+ private static void populateTravelerData(TravelerData td) {
+ 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("employee");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+
+
+
+
+ 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());
+ }
+
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV2.java b/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV2.java
new file mode 100644
index 0000000..08b4507
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/FipTimeZoneTestTicketV2.java
@@ -0,0 +1,155 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
+import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.ControlData;
+import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.FIPTicketData;
+import org.uic.barcode.ticket.api.asn.omv2.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
+
+ public class FipTimeZoneTestTicketV2 {
+
+ 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();
+
+
+ //FipTicket
+ DocumentData do1 = new DocumentData();
+ addFip(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 12:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(750L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addFip(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ FIPTicketData otd = new FIPTicketData();
+ otd.setClassCode(TravelClassType.first);
+ otd.setNumberOfTravelDays(8L);
+ otd.setValidFromDay(10L);
+ otd.setValidUntilDay(10L);
+ SequenceOfCarrierNum carriers = new SequenceOfCarrierNum();
+ carriers.add(1080L);
+ carriers.add(1181L);
+ otd.setCarrierNum(carriers);
+ otd.setIncludesSupplements(true);
+ otd.setReferenceNum(Asn1BigInteger.toAsn1(123445));
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ s.add(0L);
+ otd.setActivatedDay(s);
+
+ tdd.setFipTicket(otd);
+ dd.setTicket(tdd);
+ }
+
+
+
+ private static void populateTravelerData(TravelerData td) {
+ 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("employee");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+
+
+
+
+ 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());
+ }
+
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/OpenTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTestTicketV1.java
new file mode 100644
index 0000000..69a61a9
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTestTicketV1.java
@@ -0,0 +1,578 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
+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.OpenTicketData;
+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.StationPassageData;
+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.TokenType;
+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 OpenTestTicketV1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+ /*
+ value UicRailTicketData ::= {
+ issuingDetail {
+ issuingYear 2018
+ issuingDay 1
+ specimen TRUE,
+ securePaperTicket FALSE,
+ activated TRUE,
+ 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
+ ,infoText "openTicketInfo"
+ ,classCode "second"
+ }
+ }
+ ,{
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 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 }
+ }
+ }
+ */
+
+ /*
+ * asn.1 version 1.3 encoding:
+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) = 7]
+ issuingYear INTEGER [length (not encoded) = 1.0]
+ 2018
+ issuingDay INTEGER [length (not encoded) = 1.1]
+ 1
+ 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 = 2]
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 2]
+ token TokenType SEQUENCE [fieldcount (not encoded) = 2]
+ tokenProviderIA5 IA5String [length = 3.0]
+ "VDV"
+ token OCTET STRING [length = 2.0]
+ 0x82da
+ ticket CHOICE [index = 2]
+ openTicket OpenTicketData SEQUENCE [root fieldcount (not encoded) = 2]
+ returnIncluded BOOLEAN [length (not encoded) = 0.1]
+ FALSE
+ infoText UTF8String [length = 14.0]
+ 0x6f70656e5469636b6574496e666f
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 1]
+ ticket CHOICE [index = 9]
+ stationPassage StationPassageData SEQUENCE [root fieldcount (not encoded) = 4]
+ productName UTF8String [length = 7.0]
+ 0x70617373616765
+ stationNameUTF8 SEQUENCE OF [count = 1]
+ UTF8String [length = 9.0]
+ 0x416d7374657264616d
+ validFromDay INTEGER [length (not encoded) = 1.2]
+ 0
+ numberOfDaysValid INTEGER [length = 1.0]
+ 123
+ 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 = 154.3
+Encoded successfully in 155 bytes:
+78022020 050DD3CF 9F5CBCAA 65E7D284 EA40218A 02D00082 2537B437 01A237BB
+82B164CD A3580883 73CBBB4E FE40EDAF 28EE4DEE AE004A03 AD12B014 16D08000
+00000403 9BDC195B 951A58DA D95D125B 999BC480 88040EE0 C2E6E6C2 CECA0212
+82DAE6E8 CAE4C8C2 DA0080BD A6010040 2C800131 B200ADC2 EAC588C5 93466D5C
+366E089E 8A848407 4275204E 9979F428 100B1028 2DA01640 507B40
+ *
+ *
+ */
+
+ /*
+ * asn.1 version 2.0 encoding
+ *
+ 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) = 7]
+ issuingYear INTEGER [length (not encoded) = 1.0]
+ 2018
+ issuingDay INTEGER [length (not encoded) = 1.1]
+ 1
+ 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 = 2]
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 2]
+ token TokenType SEQUENCE [fieldcount (not encoded) = 2]
+ tokenProviderIA5 IA5String [length = 3.0]
+ "VDV"
+ token OCTET STRING [length = 2.0]
+ 0x82da
+ ticket CHOICE [index = 2]
+ openTicket OpenTicketData SEQUENCE [root fieldcount (not encoded) = 2]
+ returnIncluded BOOLEAN [length (not encoded) = 0.1]
+ FALSE
+ infoText UTF8String [length = 14.0]
+ 0x6f70656e5469636b6574496e666f
+ DocumentData SEQUENCE [root fieldcount (not encoded) = 1]
+ ticket CHOICE [index = 9]
+ stationPassage StationPassageData SEQUENCE [root fieldcount (not encoded) = 4]
+ productName UTF8String [length = 7.0]
+ 0x70617373616765
+ stationNameUTF8 SEQUENCE OF [count = 1]
+ UTF8String [length = 9.0]
+ 0x416d7374657264616d
+ validFromDay INTEGER [length (not encoded) = 1.2]
+ 0
+ numberOfDaysValid INTEGER [length = 1.0]
+ 123
+ 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 = 154.6
+Encoded successfully in 155 bytes:
+78022020 050DD3CF 9F5CBCAA 65E7D284 EA40218A 02D00041 129BDA1B 80D11BDD
+C158B266 D1AC0441 B9E5DDA7 7F2076D7 947726F7 57002501 D689580A 0B684000
+00000200 737B832B 72A34B1B 5B2BA24B 73337890 110081DC 185CDCD8 59D94042
+505B5CDD 195C9918 5B401017 B4C02008 05900026 364015B8 5D58B118 B268CDAB
+86CDC113 D1509080 E84EA409 D32F3E85 02016205 05B402C8 0A0F68
+ *
+ *
+ *
+ */
+
+ public static String getEncodingV1Hex() {
+ return "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D000822537B43701A237BB" +
+ "82B164CDA358088373CBBB4EFE40EDAF28EE4DEEAE004A03AD12B01416D08000" +
+ "000004039BDC195B951A58DAD95D125B999BC48088040EE0C2E6E6C2CECA0212" +
+ "82DAE6E8CAE4C8C2DA0080BDA60100402C800131B200ADC2EAC588C593466D5C" +
+ "366E089E8A8484074275204E9979F428100B10282DA01640507B40";
+ }
+
+ public static String getEncodingV2Hex() {
+ return "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D00041129BDA1B80D11BDD" +
+ "C158B266D1AC0441B9E5DDA77F2076D7947726F757002501D689580A0B684000" +
+ "00000200737B832B72A34B1B5B2BA24B73337890110081DC185CDCD859D94042" +
+ "505B5CDD195C99185B401017B4C0200805900026364015B85D58B118B268CDAB" +
+ "86CDC113D1509080E84EA409D32F3E850201620505B402C80A0F68";
+ }
+
+
+ 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);
+
+ }
+
+ /*
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 0
+ ,numberOfDaysValid 123
+ }
+ */
+ 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);
+ }
+
+ /*
+ {
+ token {tokenProviderIA5 "VDV", token '82DA'H }
+ ,ticket openTicket : {
+ returnIncluded FALSE
+ 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);
+ tdd.setOpenTicket(otd);
+ dd.setTicket(tdd);
+ }
+
+
+ /*
+ ,travelerDetail{
+ traveler {
+ {
+ firstName "John"
+ ,secondName "Dow"
+ ,idCard "12345"
+ ,ticketHolder TRUE
+ ,status {{customerStatusDescr "senior" }}
+ }
+ }
+ ,groupName "myGroup"
+ }
+ */
+
+ 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);
+ }
+
+ /*
+ ,issuingDetail {
+ issuingYear 2018
+ issuingDay 1
+ specimen TRUE,
+ securePaperTicket FALSE,
+ activated TRUE,
+ issuerPNR "issuerTestPNR",
+ issuedOnLine 12
+ }
+ */
+ 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);
+ }
+
+ /*
+ ,extension {
+ { extensionId "1", extensionData '82DA'H }
+ ,{ extensionId "2", extensionData '83DA'H }
+ }
+ */
+ 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);
+ }
+
+ /*
+ ,controlDetail {
+ identificationByCardReference {
+ { trailingCardIdNum 100 }
+ }
+ ,identificationByIdCard FALSE
+ ,identificationByPassportId FALSE
+ ,passportValidationRequired FALSE
+ ,onlineValidationRequired FALSE
+ ,ageCheckRequired FALSE
+ ,reductionCardCheckRequired FALSE
+ ,infoText "cd"
+ ,includedTickets {
+ { productOwnerIA5 "test"
+ ,
+
+
+ }
+ }
+ }
+ */
+ 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;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV1.java
new file mode 100644
index 0000000..5ca6b73
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV1.java
@@ -0,0 +1,157 @@
+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.OpenTicketData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+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.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TokenType;
+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 OpenTicketTimeZoneTestTicketV1 {
+
+ 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();
+ addOpenTicketData(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+
+ 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.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+ tdd.setOpenTicket(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());
+ }
+
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV2.java b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV2.java
new file mode 100644
index 0000000..3acc754
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/OpenTicketTimeZoneTestTicketV2.java
@@ -0,0 +1,157 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.ControlData;
+import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv2.OpenTicketData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv2.TokenType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
+
+
+ public class OpenTicketTimeZoneTestTicketV2 {
+
+ 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();
+ addOpenTicketData(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+
+ 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.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+ tdd.setOpenTicket(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());
+ }
+
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/PassTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/PassTestTicketV1.java
new file mode 100644
index 0000000..a165308
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/PassTestTicketV1.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 PassTestTicketV1 {
+
+ 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/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase1V1.java b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase1V1.java
new file mode 100644
index 0000000..8bea50a
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase1V1.java
@@ -0,0 +1,168 @@
+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.SequenceOfActivatedDays;
+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 PassTimeZoneTestTicketCase1V1 {
+
+ 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();
+ addPass1(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 12:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(750L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ 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 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/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase2V1.java b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase2V1.java
new file mode 100644
index 0000000..cc30e72
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase2V1.java
@@ -0,0 +1,165 @@
+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.SequenceOfActivatedDays;
+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 PassTimeZoneTestTicketCase2V1 {
+
+ 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();
+ addPass1(do1);
+
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 00:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(30L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ 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 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/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase3V1.java b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase3V1.java
new file mode 100644
index 0000000..715a292
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketCase3V1.java
@@ -0,0 +1,204 @@
+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.SequenceOfActivatedDays;
+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 PassTimeZoneTestTicketCase3V1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+ /*
+ *
+ * Case 1:
+ issue date: 04-03-2021 12:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 750
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 2:
+ issue date: 04-03-2021 00:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 30
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 3:
+ issue date: 03-03-2021 23:30 UTC
+ issuingYear: 2021
+ issuingDay: 62
+ issuingTime: 1410
+ validFromDay: 11
+ activatedDays: [0]
+
+ expected: activated for 03-03-2021 + 11 + 0 00:00 UTC --> 14-03-2021
+
+
+ */
+
+
+
+ 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();
+ addPass1(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //03-03-2021 23:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(1410L);
+ issuingDetail.setIssuingDay(62L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(11L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ 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 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/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketV2.java b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketV2.java
new file mode 100644
index 0000000..7539f0d
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/PassTimeZoneTestTicketV2.java
@@ -0,0 +1,168 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.ControlData;
+import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv2.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv2.PassData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv2.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv2.TicketType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
+
+ public class PassTimeZoneTestTicketV2 {
+
+ 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();
+ addPass1(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 12:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(750L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidUntilDay(10L);
+ otd.setValidUntilTime(1439L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ 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 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/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV1.java
new file mode 100644
index 0000000..840b584
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV1.java
@@ -0,0 +1,201 @@
+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.PassengerType;
+import org.uic.barcode.ticket.api.asn.omv1.PlacesType;
+import org.uic.barcode.ticket.api.asn.omv1.PriceTypeType;
+import org.uic.barcode.ticket.api.asn.omv1.ReservationData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+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.SequenceOfTariffType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.ServiceType;
+import org.uic.barcode.ticket.api.asn.omv1.TariffType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+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 ReservationTestTicketV1 {
+
+ 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();
+ 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();
+ ReservationData ticket = new ReservationData();
+ ticket.setTrainNum(123L);
+ ticket.setService(ServiceType.seat);
+ 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.setNumberOfSupplements(1L);
+ ticket.setServiceBrand(100L);
+ ticket.setPrice(12345L);
+ ticket.setPriceType(PriceTypeType.supplement);
+
+ ticket.setPlaces(getPlaces());
+ ticket.setTariff(getTariffs());
+
+ ticket.setInfoText("reservation");
+ ticket.setClassCode(TravelClassType.first);
+ ticket.setDepartureDate(10L);
+ ticket.setDepartureTime(0L);
+ ticket.setArrivalDate(10L);
+ ticket.setArrivalTime(1439L);
+ tdd.setReservation(ticket);
+ dd.setTicket(tdd);
+ }
+
+
+
+ private static SequenceOfTariffType getTariffs() {
+ SequenceOfTariffType tariffs = new SequenceOfTariffType();
+
+ TariffType tariff = new TariffType();
+ tariff.setNumberOfPassengers(1L);
+ tariff.setRestrictedToCountryOfResidence(false);
+ tariff.setPassengerType(PassengerType.adult);
+ tariff.setTariffIdNum(72L);
+ tariff.setTariffDesc("Full Fare Adult");
+ tariffs.add(tariff);
+ TariffType tariff2 = new TariffType();
+ tariff2.setRestrictedToCountryOfResidence(false);
+ tariff2.setNumberOfPassengers(2L);
+ tariff2.setPassengerType(PassengerType.child);
+ tariff2.setTariffIdNum(73L);
+ tariff2.setTariffDesc("Full Fare Child");
+ tariffs.add(tariff2);
+ return tariffs;
+ }
+
+
+ private static PlacesType getPlaces() {
+ PlacesType places = new PlacesType();
+ places.setPlaceDescription("11-13");
+ places.setCoach("12");
+ return places;
+ }
+
+
+ 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());
+ }
+
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV2.java b/src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV2.java
new file mode 100644
index 0000000..ef84644
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/ReservationTestTicketV2.java
@@ -0,0 +1,201 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.ControlData;
+import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv2.PassengerType;
+import org.uic.barcode.ticket.api.asn.omv2.PlacesType;
+import org.uic.barcode.ticket.api.asn.omv2.PriceTypeType;
+import org.uic.barcode.ticket.api.asn.omv2.ReservationData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTariffType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.ServiceType;
+import org.uic.barcode.ticket.api.asn.omv2.TariffType;
+import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
+
+
+ public class ReservationTestTicketV2 {
+
+ 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();
+ 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();
+ ReservationData ticket = new ReservationData();
+ ticket.setTrainNum(123L);
+ ticket.setService(ServiceType.seat);
+ 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.setNumberOfSupplements(1L);
+ ticket.setServiceBrand(100L);
+ ticket.setPrice(12345L);
+ ticket.setPriceType(PriceTypeType.supplement);
+
+ ticket.setPlaces(getPlaces());
+ ticket.setTariff(getTariffs());
+
+ ticket.setInfoText("reservation");
+ ticket.setClassCode(TravelClassType.first);
+ ticket.setDepartureDate(10L);
+ ticket.setDepartureTime(0L);
+ ticket.setArrivalDate(10L);
+ ticket.setArrivalTime(1439L);
+ tdd.setReservation(ticket);
+ dd.setTicket(tdd);
+ }
+
+
+
+ private static SequenceOfTariffType getTariffs() {
+ SequenceOfTariffType tariffs = new SequenceOfTariffType();
+
+ TariffType tariff = new TariffType();
+ tariff.setNumberOfPassengers(1L);
+ tariff.setRestrictedToCountryOfResidence(false);
+ tariff.setPassengerType(PassengerType.adult);
+ tariff.setTariffIdNum(72L);
+ tariff.setTariffDesc("Full Fare Adult");
+ tariffs.add(tariff);
+ TariffType tariff2 = new TariffType();
+ tariff2.setRestrictedToCountryOfResidence(false);
+ tariff2.setNumberOfPassengers(2L);
+ tariff2.setPassengerType(PassengerType.child);
+ tariff2.setTariffIdNum(73L);
+ tariff2.setTariffDesc("Full Fare Child");
+ tariffs.add(tariff2);
+ return tariffs;
+ }
+
+
+ private static PlacesType getPlaces() {
+ PlacesType places = new PlacesType();
+ places.setPlaceDescription("11-13");
+ places.setCoach("12");
+ return places;
+ }
+
+
+ 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());
+ }
+
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/SimpleTicketLinkTestTicket.java b/src/org/uic/barcode/ticket/api/test/testtickets/SimpleTicketLinkTestTicket.java
index 483d97e..d752043 100644
--- a/src/org/uic/barcode/ticket/api/test/SimpleTicketLinkTestTicket.java
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/SimpleTicketLinkTestTicket.java
@@ -1,4 +1,4 @@
-package org.uic.barcode.ticket.api.test;
+package org.uic.barcode.ticket.api.test.testtickets;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
diff --git a/src/org/uic/barcode/ticket/api/test/SimpleUicTestTicket.java b/src/org/uic/barcode/ticket/api/test/testtickets/SimpleUicTestTicket.java
index dc191a5..d8adb3d 100644
--- a/src/org/uic/barcode/ticket/api/test/SimpleUicTestTicket.java
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/SimpleUicTestTicket.java
@@ -1,4 +1,4 @@
-package org.uic.barcode.ticket.api.test;
+package org.uic.barcode.ticket.api.test.testtickets;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV1.java
new file mode 100644
index 0000000..b0626f1
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV1.java
@@ -0,0 +1,183 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
+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.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.StationPassageData;
+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;
+
+public class StationPassageTestTicketV1 {
+
+
+ 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();
+
+
+ //StationPassage
+ DocumentData do2 = new DocumentData();
+ addStationPassage(do2);
+ ds.add(do2);
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+ /*
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 0
+ ,numberOfDaysValid 123
+ }
+ */
+ private static void addStationPassage(DocumentData dd) {
+ TicketDetailData tdd = new TicketDetailData();
+ StationPassageData sp = new StationPassageData();
+ sp.setProductName("passage");
+ sp.setValidFromDay(5L);
+ sp.setValidFromTime(0L);
+ sp.setValidUntilDay(5L);
+ sp.setValidUntilTime(1000L);
+ sp.setNumberOfDaysValid(5L);
+ SequenceOfStringUTF8 ss = new SequenceOfStringUTF8();
+ ss.add("Amsterdam");
+ sp.setStationNameUTF8(ss);
+ tdd.setStationPassage(sp);
+ 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);
+ }
+
+ /*
+ ,controlDetail {
+ identificationByCardReference {
+ { trailingCardIdNum 100 }
+ }
+ ,identificationByIdCard FALSE
+ ,identificationByPassportId FALSE
+ ,passportValidationRequired FALSE
+ ,onlineValidationRequired FALSE
+ ,ageCheckRequired FALSE
+ ,reductionCardCheckRequired FALSE
+ ,infoText "cd"
+ ,includedTickets {
+ { productOwnerIA5 "test" }
+ }
+ }
+ */
+ 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";
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+}
diff --git a/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV2.java b/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV2.java
new file mode 100644
index 0000000..c551293
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/testtickets/StationPassageTestTicketV2.java
@@ -0,0 +1,183 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
+import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.ControlData;
+import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.StationPassageData;
+import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv2.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
+
+public class StationPassageTestTicketV2 {
+
+
+ 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();
+
+
+ //StationPassage
+ DocumentData do2 = new DocumentData();
+ addStationPassage(do2);
+ ds.add(do2);
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+ /*
+ ticket stationPassage : {
+ productName "passage"
+ ,stationNameUTF8 { "Amsterdam" }
+ ,validFromDay 0
+ ,numberOfDaysValid 123
+ }
+ */
+ private static void addStationPassage(DocumentData dd) {
+ TicketDetailData tdd = new TicketDetailData();
+ StationPassageData sp = new StationPassageData();
+ sp.setProductName("passage");
+ sp.setValidFromDay(5L);
+ sp.setValidFromTime(0L);
+ sp.setValidUntilDay(5L);
+ sp.setValidUntilTime(1000L);
+ sp.setNumberOfDaysValid(5L);
+ SequenceOfStringUTF8 ss = new SequenceOfStringUTF8();
+ ss.add("Amsterdam");
+ sp.setStationNameUTF8(ss);
+ tdd.setStationPassage(sp);
+ 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);
+ }
+
+ /*
+ ,controlDetail {
+ identificationByCardReference {
+ { trailingCardIdNum 100 }
+ }
+ ,identificationByIdCard FALSE
+ ,identificationByPassportId FALSE
+ ,passportValidationRequired FALSE
+ ,onlineValidationRequired FALSE
+ ,ageCheckRequired FALSE
+ ,reductionCardCheckRequired FALSE
+ ,infoText "cd"
+ ,includedTickets {
+ { productOwnerIA5 "test" }
+ }
+ }
+ */
+ 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";
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ /*
+ {
+ trailingCardIdNum 100
+ }
+ */
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+}
diff --git a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
index 78deb8a..d3136e1 100644
--- a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
+++ b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
@@ -881,7 +881,9 @@ public class Api2OpenAsnEncoder {
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
+ }
if (document.getClassCode() != ITravelClassType.second){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
@@ -1557,13 +1559,8 @@ public class Api2OpenAsnEncoder {
}
}
-
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- if (document.getValidFrom() != null) {
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
- } else {
- asnData.setActivatedDays(document.getActivatedDays(),issuingDate);
- }
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
}
asnData.setClassCode(convertTravelClass(document.getClassCode()));
@@ -1697,9 +1694,9 @@ public class Api2OpenAsnEncoder {
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- asnData.setActivatedDays(document.getActivatedDays(), document.getValidFrom());
- }
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
+ }
asnData.setExtension(encodeExtension(document.getExtension()));
diff --git a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
index 97abcfa..61bdba1 100644
--- a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
+++ b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
@@ -886,8 +886,9 @@ public class Api2OpenAsnEncoderV2 {
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
-
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
+ }
if (document.getClassCode() != ITravelClassType.second && document.getClassCode() != null){
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
@@ -1562,13 +1563,8 @@ public class Api2OpenAsnEncoderV2 {
}
}
-
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- if (document.getValidFrom() != null) {
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
- } else {
- asnData.setActivatedDays(document.getActivatedDays(),issuingDate);
- }
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
}
if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
@@ -1703,10 +1699,9 @@ public class Api2OpenAsnEncoderV2 {
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- asnData.setActivatedDays(document.getActivatedDays(), document.getValidFrom());
+ if (document.getActivatedDays() != null && !document.getActivatedDays().isEmpty()) {
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
}
-
asnData.setExtension(encodeExtension(document.getExtension()));
return asnDocument;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java b/src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java
index 6e62a4a..c8664a5 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java
+++ b/src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java
@@ -1,6 +1,8 @@
-package org.uic.barcode.ticket.api.asn.omv1;
+package org.uic.barcode.ticket.api.utils;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
@@ -11,10 +13,41 @@ public class DateTimeUtils {
if (issuingDate == null || localDate == null) return null;
+ Calendar startCal = Calendar.getInstance();
+ startCal.clear();
+ startCal.setTime(issuingDate);
+ startCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ startCal.set(Calendar.HOUR_OF_DAY, 0);
+ startCal.set(Calendar.MINUTE, 0);
+ startCal.set(Calendar.SECOND, 0);
+ startCal.set(Calendar.MILLISECOND, 0);
+ Date start = startCal.getTime();
+
+ Calendar endCal = Calendar.getInstance();
+ endCal.clear();
+ endCal.setTime(localDate);
+ endCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ endCal.set(Calendar.HOUR_OF_DAY, 0);
+ endCal.set(Calendar.MINUTE, 0);
+ endCal.set(Calendar.SECOND, 0);
+ endCal.set(Calendar.MILLISECOND, 0);
+ Date end = endCal.getTime();
+
+ long diff = TimeUnit.DAYS.convert(end.getTime() - start.getTime(), TimeUnit.MILLISECONDS );
+ //long diff = localDate.getTime() - issuingDate.getTime();
+ //long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
+
+ return new Long(diff);
+
+ }
+
+ public static Long getDateDifferenceLocal(Date referenceDate, Date localDate) {
+
+ if (referenceDate == null || localDate == null) return null;
+
Calendar issuingCal = Calendar.getInstance();
issuingCal.clear();
- issuingCal.setTime(issuingDate);
- issuingCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ issuingCal.setTime(referenceDate);
issuingCal.set(Calendar.HOUR_OF_DAY, 0);
issuingCal.set(Calendar.MINUTE, 0);
issuingCal.set(Calendar.SECOND, 0);
@@ -23,13 +56,12 @@ public class DateTimeUtils {
Calendar fromCal = Calendar.getInstance();
fromCal.clear();
fromCal.setTime(localDate);
- fromCal.setTimeZone(TimeZone.getTimeZone("UTC"));
fromCal.set(Calendar.HOUR_OF_DAY, 0);
fromCal.set(Calendar.MINUTE, 0);
fromCal.set(Calendar.SECOND, 0);
fromCal.set(Calendar.MILLISECOND, 0);
- long diff = localDate.getTime() - issuingDate.getTime();
+ long diff = localDate.getTime() - referenceDate.getTime();
long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
return new Long(dayDiff);
@@ -78,10 +110,7 @@ public class DateTimeUtils {
}
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
+ return new Long (time );
}
public static Long getTime (Date date) {
@@ -89,18 +118,9 @@ public class DateTimeUtils {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.setTime(date);
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
+
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
+ return new Long (time );
}
public static Date getDate(Date issuingDate, Long date, Long time){
@@ -122,12 +142,14 @@ public class DateTimeUtils {
cal.add(Calendar.DAY_OF_YEAR, date.intValue());
- DateTimeUtils.setTime(cal,time);
-
+ if (time == null) {
+ DateTimeUtils.setTime(cal,0L);
+ } else {
+ DateTimeUtils.setTime(cal,time);
+ }
return cal.getTime();
}
-
/**
@@ -193,6 +215,25 @@ public class DateTimeUtils {
return cal.getTime();
}
+
+
+ public static Collection<Long> getActivatedDays(Date referenceDate, Collection<Date> days) {
+
+ ArrayList<Long> lDays = new ArrayList<Long>();
+
+ if (referenceDate == null) return lDays;
+
+ for (Date day : days) {
+ long dateDiff2 = DateTimeUtils.getDateDifference(referenceDate,day);
+ lDays.add(dateDiff2);
+ }
+
+ return lDays;
+
+ }
+ public static Date dateToUTC(Date date){
+ return new Date(date.getTime() - Calendar.getInstance().getTimeZone().getOffset(date.getTime()));
+ }
}
diff --git a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
index 46f201d..d203487 100644
--- a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
+++ b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
@@ -189,7 +189,12 @@ public class OpenAsn2ApiDecoder {
}
if (asnUicRailTicketData.getTransportDocument() != null && !asnUicRailTicketData.getTransportDocument().isEmpty()) {
- populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket,uicRailTicket.getIssuerDetails().getIssuingDate() );
+
+ // date is already converted to local time, use UTC for internal calculations
+ Date localIssuingDate = uicRailTicket.getIssuerDetails().getIssuingDate();
+ Date issuingDate = DateTimeUtils.dateToUTC(localIssuingDate);
+
+ populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket, issuingDate);
}
@@ -1588,9 +1593,9 @@ public class OpenAsn2ApiDecoder {
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
- if (asnDocument.getActivatedDay()!=null && !asnDocument.getActivatedDay().isEmpty()) {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
- }
+ if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
+ document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
+ }
if(asnDocument.getIncludesSupplements()!=null) {
document.setIncludesSupplements(asnDocument.getIncludesSupplements());
@@ -1627,13 +1632,9 @@ public class OpenAsn2ApiDecoder {
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
document.setValidUntilUTCoffset(asnDocument.getValidUntilUTCOffset());
- if (asnDocument.getActivatedDay()!=null && !asnDocument.getActivatedDay().isEmpty()) {
- if (document.getValidFrom() != null) {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(document.getValidFrom()));
- } else {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
- }
- }
+ if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
+ document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
+ }
document.setExtension(convertExtension(asnDocument.getExtension()));
document.setInfoText(asnDocument.getInfoText());
diff --git a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
index 4aca9eb..b8ee363 100644
--- a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
+++ b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
@@ -191,7 +191,12 @@ public class OpenAsn2ApiDecoderV2 {
}
if (asnUicRailTicketData.getTransportDocument() != null && !asnUicRailTicketData.getTransportDocument().isEmpty()) {
- populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket,uicRailTicket.getIssuerDetails().getIssuingDate() );
+
+ // date is already converted to local time, use UTC for internal calculations
+ Date localIssuingDate = uicRailTicket.getIssuerDetails().getIssuingDate();
+ Date issuingDate = DateTimeUtils.dateToUTC(localIssuingDate);
+
+ populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket, issuingDate);
}
@@ -1616,9 +1621,9 @@ public class OpenAsn2ApiDecoderV2 {
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
- if (asnDocument.getActivatedDay()!=null && !asnDocument.getActivatedDay().isEmpty()) {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
- }
+ if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
+ document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
+ }
if(asnDocument.getIncludesSupplements()!=null) {
document.setIncludesSupplements(asnDocument.getIncludesSupplements());
@@ -1655,13 +1660,9 @@ public class OpenAsn2ApiDecoderV2 {
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
document.setValidUntilUTCoffset(asnDocument.getValidUntilUTCOffset());
- if (asnDocument.getActivatedDay()!=null && !asnDocument.getActivatedDay().isEmpty()) {
- if (document.getValidFrom() != null) {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(document.getValidFrom()));
- } else {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
- }
- }
+ if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
+ document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
+ }
document.setExtension(convertExtension(asnDocument.getExtension()));
document.setInfoText(asnDocument.getInfoText());