### Question:
HandshakeSessionListener implements SessionListener { protected boolean isRequiresConsent(Date lastConsentDate, Date minConsentDate) { if(lastConsentDate != null) { if(minConsentDate != null) { if(minConsentDate.compareTo(new Date()) > 0) { return false; }else { return lastConsentDate.compareTo(minConsentDate) < 0; } }else { return false; } }else { return true; } } @Inject  HandshakeSessionListener(
			BounceConfig bounceConfig,
			PersonDAO personDao, 
			PlaceDAO placeDao
	); @PostConstruct void init(); @Override void onSessionCreated(Session session); @Override void onSessionDestroyed(Session session); @Inject
	@Named(value = "billing.public.api.key")
	private String recurlyPublicAPIKey; }### Answer:
@Test public void testLastConsentBeforeMinConsent() { Date lastConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)); Date minConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30)); assertTrue(listener.isRequiresConsent(lastConsentDate, minConsentDate)); }
@Test public void testLastConsentAfterMinConsent() { Date lastConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)); Date minConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(90)); assertFalse(listener.isRequiresConsent(lastConsentDate, minConsentDate)); }
@Test public void testMinConsentInTheFuture() { Date lastConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)); Date minConsentDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(30)); assertFalse(listener.isRequiresConsent(lastConsentDate, minConsentDate)); }
@Test public void testLastConsentNotSet() { Date minConsentDate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30)); assertTrue(listener.isRequiresConsent(null, minConsentDate)); minConsentDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(60)); assertTrue(listener.isRequiresConsent(null, minConsentDate)); }