@@ -511,28 +511,34 @@ class EventsTests {
511511
512512 @Test
513513 fun `UpdateEventRequest Timespan with zero duration throws exception` () {
514- val exception = org.junit.jupiter.api.assertThrows<IllegalArgumentException > {
514+ val exception = org.junit.jupiter.api.assertThrows<NylasApiError > {
515515 UpdateEventRequest .When .Timespan .Builder ()
516516 .startTime(1620000000 )
517517 .endTime(1620000000 )
518518 .build()
519519 }
520520
521- assert (exception.message!! .contains(" endTime (1620000000) must be after startTime (1620000000)" ))
522- assert (exception.message!! .contains(" For point-in-time events, use UpdateEventRequest.When.Time instead" ))
521+ assertEquals(400 , exception.statusCode)
522+ assert (exception.message.contains(" endTime to be after startTime" ))
523+ assert (exception.validationErrors != null )
524+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" End time (1620000000) must be after start time (1620000000)" ))
525+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" For point-in-time events, use UpdateEventRequest.When.Time instead" ))
523526 }
524527
525528 @Test
526529 fun `UpdateEventRequest Timespan with negative duration throws exception` () {
527- val exception = org.junit.jupiter.api.assertThrows<IllegalArgumentException > {
530+ val exception = org.junit.jupiter.api.assertThrows<NylasApiError > {
528531 UpdateEventRequest .When .Timespan .Builder ()
529532 .startTime(1620003600 )
530533 .endTime(1620000000 )
531534 .build()
532535 }
533536
534- assert (exception.message!! .contains(" endTime (1620000000) must be after startTime (1620003600)" ))
535- assert (exception.message!! .contains(" Timespan events require a positive duration" ))
537+ assertEquals(400 , exception.statusCode)
538+ assert (exception.message.contains(" endTime to be after startTime" ))
539+ assert (exception.validationErrors != null )
540+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" End time (1620000000) must be after start time (1620003600)" ))
541+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" For point-in-time events, use UpdateEventRequest.When.Time instead" ))
536542 }
537543
538544 @Test
@@ -586,24 +592,30 @@ class EventsTests {
586592
587593 @Test
588594 fun `CreateEventRequest Timespan with zero duration throws exception` () {
589- val exception = org.junit.jupiter.api.assertThrows<IllegalArgumentException > {
595+ val exception = org.junit.jupiter.api.assertThrows<NylasApiError > {
590596 CreateEventRequest .When .Timespan .Builder (1620000000 , 1620000000 )
591597 .build()
592598 }
593599
594- assert (exception.message!! .contains(" endTime (1620000000) must be after startTime (1620000000)" ))
595- assert (exception.message!! .contains(" For point-in-time events, use CreateEventRequest.When.Time instead" ))
600+ assertEquals(400 , exception.statusCode)
601+ assert (exception.message.contains(" endTime to be after startTime" ))
602+ assert (exception.validationErrors != null )
603+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" End time (1620000000) must be after start time (1620000000)" ))
604+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" For point-in-time events, use CreateEventRequest.When.Time instead" ))
596605 }
597606
598607 @Test
599608 fun `CreateEventRequest Timespan with negative duration throws exception` () {
600- val exception = org.junit.jupiter.api.assertThrows<IllegalArgumentException > {
609+ val exception = org.junit.jupiter.api.assertThrows<NylasApiError > {
601610 CreateEventRequest .When .Timespan .Builder (1620003600 , 1620000000 )
602611 .build()
603612 }
604613
605- assert (exception.message!! .contains(" endTime (1620000000) must be after startTime (1620003600)" ))
606- assert (exception.message!! .contains(" Timespan events require a positive duration" ))
614+ assertEquals(400 , exception.statusCode)
615+ assert (exception.message.contains(" endTime to be after startTime" ))
616+ assert (exception.validationErrors != null )
617+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" End time (1620000000) must be after start time (1620003600)" ))
618+ assert (exception.validationErrors!! [" when.end_time" ]!! .contains(" For point-in-time events, use CreateEventRequest.When.Time instead" ))
607619 }
608620
609621 @Test
0 commit comments