@@ -223,6 +223,90 @@ class EventsTests {
223223 assertEquals(" 2024-06-18" , whenDate.date)
224224 }
225225
226+ @Test
227+ fun `Event deserializes maybe status properly` () {
228+ val adapter = JsonHelper .moshi().adapter(Event ::class .java)
229+ val jsonBuffer =
230+ Buffer ().writeUtf8(
231+ """
232+ {
233+ "id": "5d3qmne77v32r8l4phyuksl2x",
234+ "grant_id": "41009df5-bf11-4c97-aa18-b285b5f2e386",
235+ "calendar_id": "7d93zl2palhxqdy6e5qinsakt",
236+ "object": "event",
237+ "status": "maybe",
238+ "when": {
239+ "date": "2024-06-18",
240+ "object": "date"
241+ }
242+ }
243+ """ .trimIndent(),
244+ )
245+
246+ val event = adapter.fromJson(jsonBuffer)!!
247+
248+ assertEquals(EventStatus .MAYBE , event.status)
249+ }
250+
251+ @Test
252+ fun `Event deserializes tentative status as maybe` () {
253+ val adapter = JsonHelper .moshi().adapter(Event ::class .java)
254+ val jsonBuffer =
255+ Buffer ().writeUtf8(
256+ """
257+ {
258+ "id": "5d3qmne77v32r8l4phyuksl2x",
259+ "grant_id": "41009df5-bf11-4c97-aa18-b285b5f2e386",
260+ "calendar_id": "7d93zl2palhxqdy6e5qinsakt",
261+ "object": "event",
262+ "status": "tentative",
263+ "when": {
264+ "date": "2024-06-18",
265+ "object": "date"
266+ }
267+ }
268+ """ .trimIndent(),
269+ )
270+
271+ val event = adapter.fromJson(jsonBuffer)!!
272+
273+ assertEquals(EventStatus .MAYBE , event.status)
274+ }
275+
276+ @Test
277+ fun `Event deserializes unknown status as null` () {
278+ val adapter = JsonHelper .moshi().adapter(Event ::class .java)
279+ val jsonBuffer =
280+ Buffer ().writeUtf8(
281+ """
282+ {
283+ "id": "5d3qmne77v32r8l4phyuksl2x",
284+ "grant_id": "41009df5-bf11-4c97-aa18-b285b5f2e386",
285+ "calendar_id": "7d93zl2palhxqdy6e5qinsakt",
286+ "object": "event",
287+ "status": "unexpected_status",
288+ "when": {
289+ "date": "2024-06-18",
290+ "object": "date"
291+ }
292+ }
293+ """ .trimIndent(),
294+ )
295+
296+ val event = adapter.fromJson(jsonBuffer)!!
297+
298+ assertEquals(null , event.status)
299+ }
300+
301+ @Suppress(" DEPRECATION" )
302+ @Test
303+ fun `Event status serializes tentative as maybe` () {
304+ val adapter = JsonHelper .moshi().adapter(EventStatus ::class .java)
305+
306+ assertEquals(" \" maybe\" " , adapter.toJson(EventStatus .MAYBE ))
307+ assertEquals(" \" maybe\" " , adapter.toJson(EventStatus .TENTATIVE ))
308+ }
309+
226310 @Test
227311 fun `CreateEventAutoConferencingProvider serializes properly` () {
228312 val adapter = JsonHelper .moshi().adapter(CreateEventAutoConferencingProvider ::class .java)
0 commit comments