summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/uic/barcode
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-12 14:12:55 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-12 14:12:55 +0200
commitc830c865409321401504ac1ca296ced194811a16 (patch)
tree25ad47b81418b7ba6c2df68022a7fa7c5d6f1e43 /src/test/java/org/uic/barcode
parenttest on algorithm name resolver (diff)
downloadUIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar.gz
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar.bz2
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar.lz
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar.xz
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.tar.zst
UIC-barcode-c830c865409321401504ac1ca296ced194811a16.zip
Diffstat (limited to 'src/test/java/org/uic/barcode')
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java168
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java5
2 files changed, 173 insertions, 0 deletions
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java
new file mode 100644
index 0000000..b711c84
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java
@@ -0,0 +1,168 @@
+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.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.ILoadingDeckType;
+import org.uic.barcode.ticket.api.spec.IPriceTypeType;
+import org.uic.barcode.ticket.api.spec.IRoofRackType;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.CarCarriageReservationTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class CarCarriageTestV1.
+ *
+ *
+ *
+ */
+public class CarCarriageTestV3 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ byte[] encodedInTimeZone1 = null;
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * 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 testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+
+ defaulttimeZone = TimeZone.getDefault();
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+ ticketDecoded = decoder.decodeFromAsn(CarCarriageReservationTestTicketV3.getEncodingBytes());
+ } catch (IOException e) {
+ assert(false);
+ }
+
+ IDocumentData document = ticketDecoded.getDocumentData().iterator().next();
+ assert(document != null);
+ assert(document instanceof ICarCarriageReservation);
+
+ ICarCarriageReservation c = (ICarCarriageReservation) document;
+
+ assert(c.getAttachedBicycles() == 1L);
+ assert(c.getAttachedSurfboards() == 2L);
+
+ assert(c.getCarCategory() == 3L);
+ assert(c.getCoach().equals("21"));
+ assert(c.getPlace().equals("41"));
+ assert(c.getFromStation().equals("8100001"));
+ assert(c.getToStation().equals("800001"));
+ assert(c.getInfoText().equals("car carriage"));
+ assert(c.getLoadingDeck().equals(ILoadingDeckType.upper));
+ assert(c.getLoadingListEntry() == 421L);
+ assert(c.getTrain().equals("123"));
+ assert(c.getNumberPlate().equals("AD-DE-123"));
+ assert(c.getTrailerPlate().equals("DX-AB-123"));
+ assert(c.isTextileRoof() == false);
+ assert(c.getServiceBrand().getServiceBrandAbbreviation().equals("AZ"));
+ assert(c.getServiceBrand().getServiceBrandDescription().equals("special train"));
+ assert(c.getServiceBrand().getServiceBrand() == 100L);
+ assert(c.getRoofRackType().equals(IRoofRackType.bicycleRack));
+ assert(c.getTariff() != null);
+ assert(c.getRoofRackHeight() == 20L);
+ assert(c.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(c.getReference().equals("810123456789"));
+ assert(c.getVatDetails() != null);
+ assert(c.getCarriers().contains("1080"));
+ assert(c.getCarriers().contains("1181"));
+ assert(c.getPrice() == 12345L);
+
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ String pdb = dateFormat.format(c.getBeginLoading());
+ assert(pdb.equals("2018.01.11-00:00"));
+
+ String pde = dateFormat.format(c.getEndLoading());
+ assert(pde.equals("2018.01.11-08:20"));
+
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (IOException e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ String hex1 = UperEncoder.hexStringFromBytes(encoded);
+ String hex2 = CarCarriageReservationTestTicketV3.getEncodingHex();
+ assert(hex1.equals(hex2));
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
index 157c6db..0095239 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
@@ -9,6 +9,7 @@ import org.uic.barcode.ticket.api.asn.omv3.IssuingData;
import org.uic.barcode.ticket.api.asn.omv3.LoadingDeckType;
import org.uic.barcode.ticket.api.asn.omv3.PriceTypeType;
import org.uic.barcode.ticket.api.asn.omv3.RoofRackType;
+import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCarrierNum;
@@ -320,6 +321,10 @@ import org.uic.barcode.ticket.api.asn.omv3.VatDetailType;
return cr;
}
+ public static byte[] getEncodingBytes() {
+ return UperEncoder.bytesFromHexString(getEncodingHex());
+ }
+
}