|
| 1 | +package com.nylas; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.BeforeEach; |
| 4 | +import org.junit.jupiter.api.Test; |
| 5 | + |
| 6 | +import java.time.Instant; |
| 7 | +import java.util.LinkedList; |
| 8 | +import java.util.List; |
| 9 | + |
| 10 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 11 | + |
| 12 | +public class FreeBusyTest { |
| 13 | + private FreeBusy freeBusy; |
| 14 | + |
| 15 | + @BeforeEach |
| 16 | + public void init() throws NoSuchFieldException, IllegalAccessException { |
| 17 | + freeBusy = new FreeBusy(); |
| 18 | + |
| 19 | + TimeSlot timeSlot = new TimeSlot(); |
| 20 | + timeSlot.setStartTime(Instant.ofEpochSecond(1670945645L)); |
| 21 | + timeSlot.setEndTime(Instant.ofEpochSecond(1670945645L)); |
| 22 | + |
| 23 | + List<TimeSlot> timeSlots = new LinkedList<>(); |
| 24 | + timeSlots.add(timeSlot); |
| 25 | + |
| 26 | + FieldReflectionUtils.setField("email", "jdoe@gmail.com", freeBusy); |
| 27 | + FieldReflectionUtils.setField("time_slots", timeSlots, freeBusy); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + public void testGetters() { |
| 32 | + assertEquals(freeBusy.getEmail(), "jdoe@gmail.com"); |
| 33 | + assertEquals(freeBusy.getTimeSlots().size(), 1); |
| 34 | + assertEquals(freeBusy.getTimeSlots().get(0).getStartTime(), Instant.ofEpochSecond(1670945645L)); |
| 35 | + assertEquals(freeBusy.getTimeSlots().get(0).getEndTime(), Instant.ofEpochSecond(1670945645L)); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void testToString() { |
| 40 | + assertEquals(freeBusy.toString(), "FreeBusy [email=jdoe@gmail.com, time_slots=[TimeSlot [status=null, start_time=2022-12-13T15:34:05Z, end_time=2022-12-13T15:34:05Z, emails=[]]]]"); |
| 41 | + } |
| 42 | +} |
0 commit comments