2424import static org .hamcrest .MatcherAssert .assertThat ;
2525import static org .hamcrest .Matchers .is ;
2626import static org .hamcrest .Matchers .nullValue ;
27+ import static org .junit .jupiter .params .provider .EnumSource .Mode .EXCLUDE ;
2728import static uk .nhs .hee .tis .trainee .forms .dto .enumeration .EmailValidityType .INVALID ;
2829
2930import java .time .Duration ;
3435import org .junit .jupiter .api .BeforeEach ;
3536import org .junit .jupiter .api .Test ;
3637import org .junit .jupiter .params .ParameterizedTest ;
38+ import org .junit .jupiter .params .provider .EnumSource ;
3739import org .junit .jupiter .params .provider .ValueSource ;
3840import uk .nhs .hee .tis .trainee .forms .dto .enumeration .EmailValidityType ;
3941import uk .nhs .hee .tis .trainee .forms .dto .enumeration .LifecycleState ;
@@ -87,7 +89,7 @@ void shouldReturnSortedJoinedStringWhenListHasMultipleStrings() {
8789 }
8890
8991 @ Test
90- void shouldReturnNullShortNoticeWhenStatusNull () {
92+ void shouldReturnNullShortNoticeAdminWhenStatusNull () {
9193 LtftForm entity = new LtftForm ();
9294 entity .setStatus (null );
9395
@@ -97,7 +99,7 @@ void shouldReturnNullShortNoticeWhenStatusNull() {
9799 }
98100
99101 @ Test
100- void shouldReturnNullShortNoticeWhenSubmittedNull () {
102+ void shouldReturnNullShortNoticeAdminWhenSubmittedNull () {
101103 LtftForm entity = new LtftForm ();
102104 entity .setStatus (Status .builder ()
103105 .submitted (null )
@@ -109,7 +111,7 @@ void shouldReturnNullShortNoticeWhenSubmittedNull() {
109111 }
110112
111113 @ Test
112- void shouldReturnNullShortNoticeWhenContentNull () {
114+ void shouldReturnNullShortNoticeAdminWhenContentNull () {
113115 LtftForm entity = new LtftForm ();
114116 entity .setStatus (Status .builder ()
115117 .current (StatusInfo .builder ().build ())
@@ -124,7 +126,7 @@ void shouldReturnNullShortNoticeWhenContentNull() {
124126 }
125127
126128 @ Test
127- void shouldReturnNullShortNoticeWhenChangeNull () {
129+ void shouldReturnNullShortNoticeAdminWhenChangeNull () {
128130 LtftForm entity = new LtftForm ();
129131 entity .setStatus (Status .builder ()
130132 .current (StatusInfo .builder ().build ())
@@ -141,7 +143,7 @@ void shouldReturnNullShortNoticeWhenChangeNull() {
141143 }
142144
143145 @ Test
144- void shouldReturnNullShortNoticeWhenStartDateNull () {
146+ void shouldReturnNullShortNoticeAdminWhenStartDateNull () {
145147 LtftForm entity = new LtftForm ();
146148 entity .setStatus (Status .builder ()
147149 .current (StatusInfo .builder ().build ())
@@ -161,7 +163,7 @@ void shouldReturnNullShortNoticeWhenStartDateNull() {
161163
162164 @ ParameterizedTest
163165 @ ValueSource (ints = {0 , 111 })
164- void shouldReturnTrueShortNoticeWhenSubmissionWithinNoticePeriod (int days ) {
166+ void shouldReturnTrueShortNoticeAdminWhenSubmissionWithinNoticePeriod (int days ) {
165167 LtftForm entity = new LtftForm ();
166168 entity .setStatus (Status .builder ()
167169 .current (StatusInfo .builder ().build ())
@@ -181,7 +183,7 @@ void shouldReturnTrueShortNoticeWhenSubmissionWithinNoticePeriod(int days) {
181183
182184 @ ParameterizedTest
183185 @ ValueSource (ints = {112 , 113 })
184- void shouldReturnFalseShortNoticeWhenSubmissionOutsideOrEqualToNoticePeriod (int days ) {
186+ void shouldReturnFalseShortNoticeAdminWhenSubmissionOutsideOrEqualToNoticePeriod (int days ) {
185187 LtftForm entity = new LtftForm ();
186188 entity .setStatus (Status .builder ()
187189 .current (StatusInfo .builder ().build ())
@@ -201,7 +203,7 @@ void shouldReturnFalseShortNoticeWhenSubmissionOutsideOrEqualToNoticePeriod(int
201203
202204 @ ParameterizedTest
203205 @ ValueSource (ints = {0 , 111 })
204- void shouldReturnUseCurrentDateForShortNoticeWhenCurrentStatusUnsubmitted (int days ) {
206+ void shouldReturnUseCurrentDateForShortNoticeAdminWhenCurrentStatusUnsubmitted (int days ) {
205207 LtftForm entity = new LtftForm ();
206208 entity .setStatus (Status .builder ()
207209 .current (StatusInfo .builder ()
@@ -255,4 +257,161 @@ void shouldReturnEmailInvalidWhenStatusNotMapped() {
255257
256258 assertThat ("Unexpected email validity." , emailValidity , is (INVALID ));
257259 }
260+
261+ @ Test
262+ void shouldReturnNullShortNoticeTraineeWhenStatusNull () {
263+ LtftForm entity = new LtftForm ();
264+ entity .setStatus (null );
265+
266+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
267+
268+ assertThat ("Unexpected short notice value." , isShortNotice , nullValue ());
269+ }
270+
271+ @ Test
272+ void shouldReturnNullShortNoticeTraineeWhenCurrentNull () {
273+ LtftForm entity = new LtftForm ();
274+ entity .setStatus (Status .builder ()
275+ .current (null )
276+ .build ());
277+
278+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
279+
280+ assertThat ("Unexpected short notice value." , isShortNotice , nullValue ());
281+ }
282+
283+ @ Test
284+ void shouldReturnNullShortNoticeTraineeWhenContentNull () {
285+ LtftForm entity = new LtftForm ();
286+ entity .setStatus (Status .builder ()
287+ .current (StatusInfo .builder ().build ())
288+ .submitted (Instant .now ())
289+ .build ());
290+
291+ entity .setContent (null );
292+
293+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
294+
295+ assertThat ("Unexpected short notice value." , isShortNotice , nullValue ());
296+ }
297+
298+ @ Test
299+ void shouldReturnNullShortNoticeTraineeWhenChangeNull () {
300+ LtftForm entity = new LtftForm ();
301+ entity .setStatus (Status .builder ()
302+ .current (StatusInfo .builder ().build ())
303+ .submitted (Instant .now ())
304+ .build ());
305+
306+ entity .setContent (LtftContent .builder ()
307+ .change (null )
308+ .build ());
309+
310+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
311+
312+ assertThat ("Unexpected short notice value." , isShortNotice , nullValue ());
313+ }
314+
315+ @ Test
316+ void shouldReturnNullShortNoticeTraineeWhenStartDateNull () {
317+ LtftForm entity = new LtftForm ();
318+ entity .setStatus (Status .builder ()
319+ .current (StatusInfo .builder ().build ())
320+ .submitted (Instant .now ())
321+ .build ());
322+
323+ entity .setContent (LtftContent .builder ()
324+ .change (CctChange .builder ()
325+ .startDate (null )
326+ .build ())
327+ .build ());
328+
329+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
330+
331+ assertThat ("Unexpected short notice value." , isShortNotice , nullValue ());
332+ }
333+
334+ @ ParameterizedTest
335+ @ ValueSource (ints = {0 , 111 })
336+ void shouldReturnTrueShortNoticeTraineeWhenSubmissionWithinNoticePeriod (int days ) {
337+ LtftForm entity = new LtftForm ();
338+ entity .setStatus (Status .builder ()
339+ .current (StatusInfo .builder ().build ())
340+ .submitted (Instant .now ())
341+ .build ());
342+
343+ entity .setContent (LtftContent .builder ()
344+ .change (CctChange .builder ()
345+ .startDate (LocalDate .now ().plusDays (days ))
346+ .build ())
347+ .build ());
348+
349+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
350+
351+ assertThat ("Unexpected short notice value." , isShortNotice , is (true ));
352+ }
353+
354+ @ ParameterizedTest
355+ @ ValueSource (ints = {112 , 113 })
356+ void shouldReturnFalseShortNoticeTraineeWhenSubmissionOutsideOrEqualToNoticePeriod (int days ) {
357+ LtftForm entity = new LtftForm ();
358+ entity .setStatus (Status .builder ()
359+ .current (StatusInfo .builder ().build ())
360+ .submitted (Instant .now ())
361+ .build ());
362+
363+ entity .setContent (LtftContent .builder ()
364+ .change (CctChange .builder ()
365+ .startDate (LocalDate .now ().plusDays (days ))
366+ .build ())
367+ .build ());
368+
369+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
370+
371+ assertThat ("Unexpected short notice value." , isShortNotice , is (false ));
372+ }
373+
374+ @ ParameterizedTest
375+ @ EnumSource (value = LifecycleState .class , names = {"DRAFT" , "UNSUBMITTED" })
376+ void shouldReturnUseCurrentDateForShortNoticeTraineeWhenDraftUnsubmitted (LifecycleState state ) {
377+ LtftForm entity = new LtftForm ();
378+ entity .setStatus (Status .builder ()
379+ .current (StatusInfo .builder ()
380+ .state (state )
381+ .build ())
382+ .submitted (Instant .now ().minus (Duration .ofDays (120 )))
383+ .build ());
384+
385+ entity .setContent (LtftContent .builder ()
386+ .change (CctChange .builder ()
387+ .startDate (LocalDate .now ().plusDays (100 ))
388+ .build ())
389+ .build ());
390+
391+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
392+
393+ assertThat ("Unexpected short notice value." , isShortNotice , is (true ));
394+ }
395+
396+ @ ParameterizedTest
397+ @ EnumSource (value = LifecycleState .class , mode = EXCLUDE , names = {"DRAFT" , "UNSUBMITTED" })
398+ void shouldReturnUseSubmissionDateForShortNoticeTraineeWhenSubmitted (LifecycleState state ) {
399+ LtftForm entity = new LtftForm ();
400+ entity .setStatus (Status .builder ()
401+ .current (StatusInfo .builder ()
402+ .state (state )
403+ .build ())
404+ .submitted (Instant .now ().minus (Duration .ofDays (120 )))
405+ .build ());
406+
407+ entity .setContent (LtftContent .builder ()
408+ .change (CctChange .builder ()
409+ .startDate (LocalDate .now ().plusDays (100 ))
410+ .build ())
411+ .build ());
412+
413+ Boolean isShortNotice = mapper .isShortNoticeTrainee (entity );
414+
415+ assertThat ("Unexpected short notice value." , isShortNotice , is (false ));
416+ }
258417}
0 commit comments