LinkBean extends BaseBean { public boolean isOnTime(Link link) { Date nowDate = new Date(); Date insertDate = link.getInsertDate(); Calendar cal = Calendar.getInstance(); cal.setTime(insertDate); int dayOfInsertion = cal.get(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, dayOfInsertion+1); return nowDate.before(cal.getTime()); } LinkBean();  LinkBean(String name); void setName(String name); String getName(); void setLink(String link); String getLink(); List<User> getUserWithName(String name); Link generateLink(String name); void sendMail(Link link, String mailAddress); String passwordResetRequest(); List<Link> getLinksWithLink(String link); void deleteLinkFromBD(Link link); String checkLinkAndResetPassword(String link); String resetPassword(User user); boolean isOnTime(Link link); String goPasswordChange();  }
@Test public void shouldCheckLinkIsOnTime() { Link onTimeLink = new Link(); onTimeLink.setInsertDate(new Date()); boolean isOnTime = sut.isOnTime(onTimeLink); assertThat(isOnTime, is(true)); }
@Test public void shouldCheckLinkIsNotOnTime() { Link outOfTimeLink = new Link(); Date yesterday = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(yesterday); cal.add(Calendar.DATE, -1); yesterday = cal.getTime(); outOfTimeLink.setInsertDate(yesterday); boolean isOnTime = sut.isOnTime(outOfTimeLink); assertThat(isOnTime, is(false)); }