// Path: api/src/main/java/ch/liip/timeforcoffee/api/deserializers/DateDeserializer.java
// public class DateDeserializer implements JsonDeserializer<Date> {
// 
//   private final String[] DATE_FORMATS = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ssZ" };
// 
//   @Override
//   public Date deserialize(JsonElement jsonElement, Type typeOF, JsonDeserializationContext context) throws JsonParseException {
//     for (String format : DATE_FORMATS) {
//       try {
//         return new SimpleDateFormat(format).parse(jsonElement.getAsString());
//       } catch (ParseException e) { }
//     }
// 
//     throw new JsonParseException("Unparseable date: \"" + jsonElement.getAsString() + "\". Supported formats: " + Arrays.toString(DATE_FORMATS));
//   }
// }
// 
// Path: backend/src/main/java/ch/liip/timeforcoffee/backend/Departure.java
// public class Departure {
// 
//     private int id;
//     private String name;
//     private String platform;
//     private String to;
//     private boolean accessible;
//     private Color colors;
//     private Time departure;
//     private Time arrival;
// 
//     public Departure() {}
// 
//     public int getId() {
//         return id;
//     }
// 
//     public String getName() { return name; }
// 
//     public String getPlatform() {
//         return platform;
//     }
// 
//     public String getTo() { return to; }
// 
//     public boolean isAccessible() {
//         return accessible;
//     }
// 
//     public Color getColors() {
//         return colors;
//     }
// 
//     public Time getDeparture() {
//         return departure;
//     }
// 
//     public Time getArrival() {
//         return arrival;
//     }
// }
// 
// Path: backend/src/main/java/ch/liip/timeforcoffee/backend/Departures.java
// public class Departures {
// 
//     private List<Departure> departures;
// 
//     private Meta meta;
// 
//     public Departures() {}
// 
//     public List<Departure> getDepartures() {
//         return departures;
//     }
// 
//     public Meta getMeta() { return meta; }
// }


import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.junit.Test;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import ch.liip.timeforcoffee.api.deserializers.DateDeserializer;
import ch.liip.timeforcoffee.backend.Departure;
import ch.liip.timeforcoffee.backend.Departures;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
package ch.liip.timeforcoffee.api;






public class DepartureDeserializationTest {

    private final SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    private final Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new DateDeserializer())
            .create();

    @Test
    public void departuresDeserialization_Works() throws UnsupportedEncodingException {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("departures.json");
        InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);

        Departures departures = gson.fromJson(reader, Departures.class);

        assertEquals(3, departures.getDepartures().size());

// Path: api/src/main/java/ch/liip/timeforcoffee/api/deserializers/DateDeserializer.java
// public class DateDeserializer implements JsonDeserializer<Date> {
// 
//   private final String[] DATE_FORMATS = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ssZ" };
// 
//   @Override
//   public Date deserialize(JsonElement jsonElement, Type typeOF, JsonDeserializationContext context) throws JsonParseException {
//     for (String format : DATE_FORMATS) {
//       try {
//         return new SimpleDateFormat(format).parse(jsonElement.getAsString());
//       } catch (ParseException e) { }
//     }
// 
//     throw new JsonParseException("Unparseable date: \"" + jsonElement.getAsString() + "\". Supported formats: " + Arrays.toString(DATE_FORMATS));
//   }
// }
// 
// Path: backend/src/main/java/ch/liip/timeforcoffee/backend/Departure.java
// public class Departure {
// 
//     private int id;
//     private String name;
//     private String platform;
//     private String to;
//     private boolean accessible;
//     private Color colors;
//     private Time departure;
//     private Time arrival;
// 
//     public Departure() {}
// 
//     public int getId() {
//         return id;
//     }
// 
//     public String getName() { return name; }
// 
//     public String getPlatform() {
//         return platform;
//     }
// 
//     public String getTo() { return to; }
// 
//     public boolean isAccessible() {
//         return accessible;
//     }
// 
//     public Color getColors() {
//         return colors;
//     }
// 
//     public Time getDeparture() {
//         return departure;
//     }
// 
//     public Time getArrival() {
//         return arrival;
//     }
// }
// 
// Path: backend/src/main/java/ch/liip/timeforcoffee/backend/Departures.java
// public class Departures {
// 
//     private List<Departure> departures;
// 
//     private Meta meta;
// 
//     public Departures() {}
// 
//     public List<Departure> getDepartures() {
//         return departures;
//     }
// 
//     public Meta getMeta() { return meta; }
// }


// Path: api/src/test/java/ch/liip/timeforcoffee/api/DepartureDeserializationTest.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.junit.Test;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import ch.liip.timeforcoffee.api.deserializers.DateDeserializer;
import ch.liip.timeforcoffee.backend.Departure;
import ch.liip.timeforcoffee.backend.Departures;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

package ch.liip.timeforcoffee.api;






public class DepartureDeserializationTest {

    private final SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    private final Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new DateDeserializer())
            .create();

    @Test
    public void departuresDeserialization_Works() throws UnsupportedEncodingException {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("departures.json");
        InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);

        Departures departures = gson.fromJson(reader, Departures.class);

        assertEquals(3, departures.getDepartures().size());

        Departure departure1 = departures.getDepartures().get(0);