7
7
import static org .apache .flink .types .PojoTestUtils .assertSerializedAsPojo ;
8
8
import static org .junit .jupiter .api .Assertions .*;
9
9
10
+ import java .time .ZoneId ;
11
+ import java .time .ZonedDateTime ;
12
+
10
13
class SunsetAirFlightDataTest {
11
14
12
15
ObjectMapper mapper = new ObjectMapper ().registerModule (new JavaTimeModule ());
@@ -93,10 +96,20 @@ public void serializer_shouldSerializeAndDeserializeTheCorrectObject() throws Ex
93
96
94
97
@ Test
95
98
public void serializer_shouldHandleUnknownFields () throws Exception {
96
- String json =
"{\" emailAddress \" :\" [email protected] \" ,\" flightDepartureTime \" :\" 2023-10-16T22:25:00.000Z\" ,\" iataDepartureCode \" :\" LAS\" ,\" flightArrivalTime \" :\" 2023-10-17T09:38:00.000Z\" ,\" iataArrivalCode \" :\" BOS\" ,\" flightNumber \" :\" SKY1522\" ,\" confirmation \" :\" SKY1OUJUUK\" ,\" unknownField\" :\" ignore\" }" ;
97
-
99
+ String json =
"{\" customerEmailAddress \" :\" [email protected] \" ,\" departureTime \" :\" 2023-10-16T22:25:00.000Z\" ,\" departureAirport \" :\" LAS\" ,\" arrivalTime \" :\" 2023-10-17T09:38:00.000Z\" ,\" arrivalAirport \" :\" BOS\" ,\" flightId \" :\" SKY1522\" ,\" referenceNumber \" :\" SKY1OUJUUK\" ,\" unknownField\" :\" ignore\" }" ;
100
+
98
101
SunsetAirFlightData object = mapper .readValue (json , SunsetAirFlightData .class );
102
+
103
+ SunsetAirFlightData expected = new SunsetAirFlightData ();
104
+ expected .
setCustomerEmailAddress (
"[email protected] " );
105
+ expected .setDepartureTime (ZonedDateTime .parse ("2023-10-16T22:25:00.000Z" ).withZoneSameInstant (ZoneId .of ("UTC" )));
106
+ expected .setDepartureAirport ("LAS" );
107
+ expected .setArrivalTime (ZonedDateTime .parse ("2023-10-17T09:38:00.000Z" ).withZoneSameInstant (ZoneId .of ("UTC" )));
108
+ expected .setArrivalAirport ("BOS" );
109
+ expected .setFlightId ("SKY1522" );
110
+ expected .setReferenceNumber ("SKY1OUJUUK" );
99
111
100
112
assertInstanceOf (SunsetAirFlightData .class , object );
113
+ assertEquals (expected , object );
101
114
}
102
- }
115
+ }
0 commit comments