1
+
2
+ import 'dart:convert' ;
3
+
4
+ import 'package:flutter_test/flutter_test.dart' ;
5
+ import 'package:jmap_dart_client/jmap/core/utc_date.dart' ;
6
+ import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart' ;
7
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee.dart' ;
8
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_expect_reply.dart' ;
9
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_kind.dart' ;
10
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_mail_to.dart' ;
11
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_name.dart' ;
12
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_participation_status.dart' ;
13
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee_role.dart' ;
14
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_duration.dart' ;
15
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_extension_fields.dart' ;
16
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_free_busy_status.dart' ;
17
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_organizer.dart' ;
18
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_priority.dart' ;
19
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_privacy.dart' ;
20
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_sequence.dart' ;
21
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart' ;
22
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_method.dart' ;
23
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/mail_address.dart' ;
24
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/recurrence_rule/day_of_week.dart' ;
25
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/recurrence_rule/recurrence_rule.dart' ;
26
+ import 'package:jmap_dart_client/jmap/mail/calendar/properties/recurrence_rule/recurrence_rule_frequency.dart' ;
27
+
28
+ void main () {
29
+ group ('calendar event object test' , () {
30
+ test ('get should parsing correctly calendar event' , () {
31
+ const calendarEventString = '''{
32
+ "uid": "ea127690-0440-404b-af98-9823c855a283",
33
+ "title": "Gatling: break LemonLDAP!",
34
+ "description": "Let's write some basic OIDC benchmarks",
35
+ "start": "2023-02-09T10:00:00",
36
+ "duration": "PT2H0M0S",
37
+ "end": "2023-02-09T12:00:00",
38
+ "timeZone": "Asia/Ho_Chi_Minh",
39
+ "location": "5 Dien Bien Phu, Ha Noi",
40
+ "method": "REQUEST",
41
+ "sequence": 0,
42
+ "priority": 5,
43
+ "freeBusyStatus": "busy",
44
+ "privacy": "public",
45
+ "organizer": {
46
+ "name": "Benoît TELLIER",
47
+
48
+ },
49
+ "participants": [
50
+ {
51
+ "name": "Benoît TELLIER",
52
+
53
+ "kind": "individual",
54
+ "role": "chair",
55
+ "participationStatus": "accepted",
56
+ "expectReply": false
57
+ },
58
+ {
59
+ "name": "Van Tung TRAN",
60
+
61
+ "kind": "individual",
62
+ "role": "requested-participant",
63
+ "participationStatus": "needs-action",
64
+ "expectReply": true
65
+ }
66
+ ],
67
+ "extensionFields": {
68
+ "X-OPENPAAS-VIDEOCONFERENCE": ["https://jitsi.linagora.com/abcd"],
69
+ "X-OPENPAAS-CUSTOM-HEADER1": ["whatever1", "whatever2"]
70
+ },
71
+ "recurrenceRules": [
72
+ {
73
+ "frequency": "yearly",
74
+ "byDay": [ "mo" ],
75
+ "byMonth": [ "10" ],
76
+ "bySetPosition": [ 1, 2 ],
77
+ "until":"2024-01-11T09:00:00Z"
78
+ }
79
+ ]
80
+ }''' ;
81
+
82
+ final CalendarEvent expectedCalendarEvent = CalendarEvent (
83
+ eventId: EventId ('ea127690-0440-404b-af98-9823c855a283' ),
84
+ title: 'Gatling: break LemonLDAP!' ,
85
+ description: 'Let\' s write some basic OIDC benchmarks' ,
86
+ startDate: DateTime .parse ('2023-02-09T10:00:00' ),
87
+ duration: CalendarDuration ('PT2H0M0S' ),
88
+ endDate: DateTime .parse ('2023-02-09T12:00:00' ),
89
+ timeZone: 'Asia/Ho_Chi_Minh' ,
90
+ location: '5 Dien Bien Phu, Ha Noi' ,
91
+ method: EventMethod .request,
92
+ sequence: CalendarSequence (0 ),
93
+ priority: CalendarPriority (5 ),
94
+ freeBusyStatus: CalendarFreeBusyStatus .busy,
95
+ privacy: CalendarPrivacy .public,
96
+ organizer: CalendarOrganizer (
97
+ name: 'Benoît TELLIER' ,
98
+ mailto
: MailAddress (
'[email protected] ' )
99
+ ),
100
+ participants: [
101
+ CalendarAttendee (
102
+ name: CalendarAttendeeName ('Benoît TELLIER' ),
103
+ mailto
: CalendarAttendeeMailTo (
MailAddress (
'[email protected] ' )),
104
+ kind: CalendarAttendeeKind .individual,
105
+ role: CalendarAttendeeRole .chair,
106
+ participationStatus: CalendarAttendeeParticipationStatus .accepted,
107
+ expectReply: CalendarAttendeeExpectReply (false )
108
+ ),
109
+ CalendarAttendee (
110
+ name: CalendarAttendeeName ('Van Tung TRAN' ),
111
+ mailto
: CalendarAttendeeMailTo (
MailAddress (
'[email protected] ' )),
112
+ kind: CalendarAttendeeKind .individual,
113
+ role: CalendarAttendeeRole .requestedParticipant,
114
+ participationStatus: CalendarAttendeeParticipationStatus .needsAction,
115
+ expectReply: CalendarAttendeeExpectReply (true )
116
+ )
117
+ ],
118
+ extensionFields: CalendarExtensionFields ({
119
+ 'X-OPENPAAS-VIDEOCONFERENCE' : ['https://jitsi.linagora.com/abcd' ],
120
+ 'X-OPENPAAS-CUSTOM-HEADER1' : ['whatever1' , 'whatever2' ]
121
+ }),
122
+ recurrenceRules: [
123
+ RecurrenceRule (
124
+ frequency: RecurrenceRuleFrequency .yearly,
125
+ byDay: [
126
+ DayOfWeek .monday
127
+ ],
128
+ byMonth: ['10' ],
129
+ bySetPosition: [1 , 2 ],
130
+ until: UTCDate (DateTime .parse ('2024-01-11T09:00:00Z' ))
131
+ )
132
+ ]
133
+ );
134
+
135
+ final parsedCalendarEvent = CalendarEvent .fromJson (json.decode (calendarEventString));
136
+
137
+ expect (parsedCalendarEvent, equals (expectedCalendarEvent));
138
+ });
139
+ });
140
+ }
0 commit comments