### Question:
DateUtil { @Nonnull public static LocalDate parseStringToDateOrReturnNow(@Nullable String stringDate) { LocalDate date = LocalDate.now(); if (stringDate != null && !stringDate.isEmpty()) { date = parseStringToDate(stringDate); } return date; } private  DateUtil(); @Nonnull static LocalDate parseStringToDateNullSafe(@Nonnull String stringDate); @Nonnull static LocalDate parseStringToDateOrReturnNow(@Nullable String stringDate); @Nonnull static LocalDate parseStringToDate(@Nonnull String stringDate); @Nonnull static LocalDateTime parseStringToDateTimeOrReturnNow(@Nonnull String stringDateTime); static boolean isWeekend(@Nonnull LocalDate date); static boolean isHoliday(@Nonnull LocalDate date); static LocalDate getMax(@Nonnull LocalDate date1, @Nonnull LocalDate date2); static LocalDate getMin(@Nonnull LocalDate date1, @Nonnull LocalDate date2);  }### Answer:
@Test public void parseStringToDateOrReturnNowTestNullString() { final LocalDate now = LocalDate.now(); final LocalDate returnedDate = DateUtil.parseStringToDateOrReturnNow(null); Assert.assertNotNull(returnedDate); Assert.assertTrue(now.isEqual(returnedDate)); }
@Test public void parseStringToDateOrReturnNowTestEmptyString() { final LocalDate now = LocalDate.now(); final LocalDate returnedDate = DateUtil.parseStringToDateOrReturnNow(""); Assert.assertNotNull(returnedDate); Assert.assertTrue(now.isEqual(returnedDate)); }
@Test public void parseStringToDateOrReturnNowTest() { final LocalDate now = LocalDate.now(); final LocalDate returnedDate = DateUtil.parseStringToDateOrReturnNow("2015-12-31"); Assert.assertNotNull(returnedDate); Assert.assertEquals(2015, returnedDate.getYear()); Assert.assertEquals(12, returnedDate.getMonthValue()); Assert.assertEquals(31, returnedDate.getDayOfMonth()); }