@Test public void testIsValidTermsOfServiceAcceptanceDateCheckDateFail() { context.checking(new Expectations() { { oneOf(systemSettingsDAO).execute(null); will(returnValue(systemSettings)); oneOf(systemSettings).getTermsOfService(); will(returnValue("ToS")); oneOf(systemSettings).getTosPromptInterval(); will(returnValue(1)); } }); Date lastAcceptedDate = new Date(Calendar.getInstance().getTimeInMillis() - (2 * MILLISECONDS_IN_A_DAY)); assertTrue(!sut.isValidTermsOfServiceAcceptanceDate(lastAcceptedDate)); context.assertIsSatisfied(); }
@Override public boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted) { SystemSettings settings = systemSettingsDAO.execute(null); String tos = settings.getTermsOfService(); int tosPromptInterval = settings.getTosPromptInterval(); if (StringUtils.isBlank(tos) || tosPromptInterval <= 0) { return true; } if (inDateLastAccepted == null) { return false; } long validFor = MILLISECONDS_IN_A_DAY * tosPromptInterval; Date now = new Date(); return validFor >= (now.getTime() - inDateLastAccepted.getTime()); }
TermsOfServiceAcceptanceStrategyImpl implements TermsOfServiceAcceptanceStrategy { @Override public boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted) { SystemSettings settings = systemSettingsDAO.execute(null); String tos = settings.getTermsOfService(); int tosPromptInterval = settings.getTosPromptInterval(); if (StringUtils.isBlank(tos) || tosPromptInterval <= 0) { return true; } if (inDateLastAccepted == null) { return false; } long validFor = MILLISECONDS_IN_A_DAY * tosPromptInterval; Date now = new Date(); return validFor >= (now.getTime() - inDateLastAccepted.getTime()); } }
TermsOfServiceAcceptanceStrategyImpl implements TermsOfServiceAcceptanceStrategy { @Override public boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted) { SystemSettings settings = systemSettingsDAO.execute(null); String tos = settings.getTermsOfService(); int tosPromptInterval = settings.getTosPromptInterval(); if (StringUtils.isBlank(tos) || tosPromptInterval <= 0) { return true; } if (inDateLastAccepted == null) { return false; } long validFor = MILLISECONDS_IN_A_DAY * tosPromptInterval; Date now = new Date(); return validFor >= (now.getTime() - inDateLastAccepted.getTime()); } TermsOfServiceAcceptanceStrategyImpl(final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO); }
TermsOfServiceAcceptanceStrategyImpl implements TermsOfServiceAcceptanceStrategy { @Override public boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted) { SystemSettings settings = systemSettingsDAO.execute(null); String tos = settings.getTermsOfService(); int tosPromptInterval = settings.getTosPromptInterval(); if (StringUtils.isBlank(tos) || tosPromptInterval <= 0) { return true; } if (inDateLastAccepted == null) { return false; } long validFor = MILLISECONDS_IN_A_DAY * tosPromptInterval; Date now = new Date(); return validFor >= (now.getTime() - inDateLastAccepted.getTime()); } TermsOfServiceAcceptanceStrategyImpl(final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO); @Override boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted); }
TermsOfServiceAcceptanceStrategyImpl implements TermsOfServiceAcceptanceStrategy { @Override public boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted) { SystemSettings settings = systemSettingsDAO.execute(null); String tos = settings.getTermsOfService(); int tosPromptInterval = settings.getTosPromptInterval(); if (StringUtils.isBlank(tos) || tosPromptInterval <= 0) { return true; } if (inDateLastAccepted == null) { return false; } long validFor = MILLISECONDS_IN_A_DAY * tosPromptInterval; Date now = new Date(); return validFor >= (now.getTime() - inDateLastAccepted.getTime()); } TermsOfServiceAcceptanceStrategyImpl(final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO); @Override boolean isValidTermsOfServiceAcceptanceDate(final Date inDateLastAccepted);  }