@@ -97,6 +97,39 @@ public void testMissingEventName() {
9797 }
9898 }
9999
100+ @ Test
101+ public void testMissingId () {
102+ final Event event1 = new Event ().setEventName ("test-id" );
103+ try {
104+ Event .create (event1 );
105+ fail ("an event with no id or email should be invalid" );
106+ } catch (InvalidException e ) {
107+ assertTrue (e .getFirstError () != null );
108+ }
109+
110+ final Event event2 = new Event ()
111+ .setEventName ("test-id" )
112+ .setId ("" )
113+ .putMetadata ("invitee_email" , "jayne@serenity.io" );
114+ try {
115+ Event .create (event2 );
116+ fail ("an event with an empty id should be invalid" );
117+ } catch (InvalidException e ) {
118+ assertTrue (e .getFirstError () != null );
119+ }
120+
121+ final Event event3 = new Event ()
122+ .setId ("49bf6b081d661db4408a51e1" )
123+ .setEmail ("" );
124+ try {
125+ Event .create (event3 );
126+ fail ("an event with an empty email should be invalid" );
127+ } catch (InvalidException e ) {
128+ assertTrue (e .getFirstError () != null );
129+ }
130+
131+ }
132+
100133 @ Test
101134 public void testValid () {
102135 Event event1 = new Event ()
@@ -126,7 +159,25 @@ public void testValid() {
126159 } catch (InvalidException e ) {
127160 fail ("an event with a user id, email and a name should be valid" );
128161 }
129- }
130162
163+ Event event4 = new Event ()
164+ .setId ("49bf6b081d661db4408a51e1" )
165+ .setEventName ("test-id" );
166+ try {
167+ Event .validateCreateEvent (event4 );
168+ } catch (InvalidException e ) {
169+ fail ("an event with an id and a name should be valid" );
170+ }
131171
172+ Event event5 = new Event ()
173+ .setId ("49bf6b081d661db4408a51e1" )
174+ .setEmail ("jayne@serenity.io" )
175+ .setEventName ("test-id" );
176+ try {
177+ Event .validateCreateEvent (event5 );
178+ } catch (InvalidException e ) {
179+ fail ("an event with an id, email and a name should be valid" );
180+ }
181+
182+ }
132183}
0 commit comments