Skip to content

Commit c00c18b

Browse files
committed
Add test cases for swift-scheduling
1 parent aa7714f commit c00c18b

File tree

3 files changed

+214
-0
lines changed

3 files changed

+214
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.time.LocalDateTime;
2+
3+
public class SwiftScheduling {
4+
public static LocalDateTime convertToDeliveryDate(LocalDateTime meetingStart, String description) {
5+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.time.LocalDateTime;
2+
3+
public class SwiftScheduling {
4+
public static LocalDateTime convertToDeliveryDate(LocalDateTime meetingStart, String description) {
5+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
6+
}
7+
}
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.time.LocalDateTime;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
class SwiftSchedulingTest {
10+
@Test
11+
@DisplayName("NOW at 9 AM")
12+
void testNowAtNineAm() {
13+
LocalDateTime meetingStart = LocalDateTime.parse("2012-02-13T09:00:00");
14+
LocalDateTime expected = LocalDateTime.parse("2012-02-13T11:00:00");
15+
16+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "NOW");
17+
18+
assertThat(actual).isEqualTo(expected);
19+
}
20+
21+
@Disabled("Remove to run test")
22+
@Test
23+
@DisplayName("ASAP before 1 PM")
24+
void testAsapBeforeOnePm() {
25+
LocalDateTime meetingStart = LocalDateTime.parse("1999-06-03T09:45:00");
26+
LocalDateTime expected = LocalDateTime.parse("1999-06-03T17:00:00");
27+
28+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "ASAP");
29+
30+
assertThat(actual).isEqualTo(expected);
31+
}
32+
33+
@Disabled("Remove to run test")
34+
@Test
35+
@DisplayName("ASAP at 1 PM")
36+
void testAsapAtOnePm() {
37+
LocalDateTime meetingStart = LocalDateTime.parse("2008-12-21T13:00:00");
38+
LocalDateTime expected = LocalDateTime.parse("2008-12-22T13:00:00");
39+
40+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "ASAP");
41+
42+
assertThat(actual).isEqualTo(expected);
43+
}
44+
45+
@Disabled("Remove to run test")
46+
@Test
47+
@DisplayName("ASAP after 1 PM")
48+
void testAsapAfterOnePm() {
49+
LocalDateTime meetingStart = LocalDateTime.parse("2008-12-21T14:50:00");
50+
LocalDateTime expected = LocalDateTime.parse("2008-12-22T13:00:00");
51+
52+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "ASAP");
53+
54+
assertThat(actual).isEqualTo(expected);
55+
}
56+
57+
@Disabled("Remove to run test")
58+
@Test
59+
@DisplayName("EOW on Monday")
60+
void testEowOnMonday() {
61+
LocalDateTime meetingStart = LocalDateTime.parse("2025-02-03T16:00:00");
62+
LocalDateTime expected = LocalDateTime.parse("2025-02-07T17:00:00");
63+
64+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
65+
66+
assertThat(actual).isEqualTo(expected);
67+
}
68+
69+
@Disabled("Remove to run test")
70+
@Test
71+
@DisplayName("EOW on Tuesday")
72+
void testEowOnTuesday() {
73+
LocalDateTime meetingStart = LocalDateTime.parse("1997-04-29T10:50:00");
74+
LocalDateTime expected = LocalDateTime.parse("1997-05-02T17:00:00");
75+
76+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
77+
78+
assertThat(actual).isEqualTo(expected);
79+
}
80+
81+
@Disabled("Remove to run test")
82+
@Test
83+
@DisplayName("EOW on Wednesday")
84+
void testEowOnWednesday() {
85+
LocalDateTime meetingStart = LocalDateTime.parse("2005-09-14T11:00:00");
86+
LocalDateTime expected = LocalDateTime.parse("2005-09-16T17:00:00");
87+
88+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
89+
90+
assertThat(actual).isEqualTo(expected);
91+
}
92+
93+
@Disabled("Remove to run test")
94+
@Test
95+
@DisplayName("EOW on Thursday")
96+
void testEowOnThursday() {
97+
LocalDateTime meetingStart = LocalDateTime.parse("2011-05-19T08:30:00");
98+
LocalDateTime expected = LocalDateTime.parse("2011-05-22T20:00:00");
99+
100+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
101+
102+
assertThat(actual).isEqualTo(expected);
103+
}
104+
105+
@Disabled("Remove to run test")
106+
@Test
107+
@DisplayName("EOW on Friday")
108+
void testEowOnFriday() {
109+
LocalDateTime meetingStart = LocalDateTime.parse("2022-08-05T14:00:00");
110+
LocalDateTime expected = LocalDateTime.parse("2022-08-07T20:00:00");
111+
112+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
113+
114+
assertThat(actual).isEqualTo(expected);
115+
}
116+
117+
@Disabled("Remove to run test")
118+
@Test
119+
@DisplayName("EOW in leap year")
120+
void testEowDuringLeapYear() {
121+
LocalDateTime meetingStart = LocalDateTime.parse("2008-02-25T10:30:00");
122+
LocalDateTime expected = LocalDateTime.parse("2008-02-29T17:00:00");
123+
124+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "EOW");
125+
126+
assertThat(actual).isEqualTo(expected);
127+
}
128+
129+
@Disabled("Remove to run test")
130+
@Test
131+
@DisplayName("2M in January")
132+
void test2MInJanuary() {
133+
LocalDateTime meetingStart = LocalDateTime.parse("2007-01-02T14:15:00");
134+
LocalDateTime expected = LocalDateTime.parse("2007-02-01T08:00:00");
135+
136+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "2M");
137+
138+
assertThat(actual).isEqualTo(expected);
139+
}
140+
141+
@Disabled("Remove to run test")
142+
@Test
143+
@DisplayName("11M in November")
144+
void test11MInNovember() {
145+
LocalDateTime meetingStart = LocalDateTime.parse("2013-11-21T15:30:00");
146+
LocalDateTime expected = LocalDateTime.parse("2014-11-03T08:00:00");
147+
148+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "11M");
149+
150+
assertThat(actual).isEqualTo(expected);
151+
}
152+
153+
@Disabled("Remove to run test")
154+
@Test
155+
@DisplayName("4M in November")
156+
void test4MInNovember() {
157+
LocalDateTime meetingStart = LocalDateTime.parse("2019-11-18T15:15:00");
158+
LocalDateTime expected = LocalDateTime.parse("2020-04-01T08:00:00");
159+
160+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "4M");
161+
162+
assertThat(actual).isEqualTo(expected);
163+
}
164+
165+
@Disabled("Remove to run test")
166+
@Test
167+
@DisplayName("Q1 in Q1")
168+
void testQ1InQ1() {
169+
LocalDateTime meetingStart = LocalDateTime.parse("2003-01-01T10:45:00");
170+
LocalDateTime expected = LocalDateTime.parse("2003-03-31T08:00:00");
171+
172+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "Q1");
173+
174+
assertThat(actual).isEqualTo(expected);
175+
}
176+
177+
@Disabled("Remove to run test")
178+
@Test
179+
@DisplayName("Q4 in Q2")
180+
void testQ4InQ2() {
181+
LocalDateTime meetingStart = LocalDateTime.parse("2001-04-09T09:00:00");
182+
LocalDateTime expected = LocalDateTime.parse("2001-12-31T08:00:00");
183+
184+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "Q4");
185+
186+
assertThat(actual).isEqualTo(expected);
187+
}
188+
189+
@Disabled("Remove to run test")
190+
@Test
191+
@DisplayName("Q3 in Q4")
192+
void testQ3InQ4() {
193+
LocalDateTime meetingStart = LocalDateTime.parse("2022-10-06T11:00:00");
194+
LocalDateTime expected = LocalDateTime.parse("2023-09-29T08:00:00");
195+
196+
LocalDateTime actual = SwiftScheduling.convertToDeliveryDate(meetingStart, "Q3");
197+
198+
assertThat(actual).isEqualTo(expected);
199+
}
200+
}

0 commit comments

Comments
 (0)