assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
}
@Test
public void oldInvocationsAreIgnored() {
Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
Track track = new Track("Red Sparowes", "Finally, As That Blazing Sun Shone Down Upon Us, Did We Know That True Enemy Was the Voice of Blind Idolatry; and Only Then Did We Begin to Think for Ourselves.");
WebserviceInvocation similarTrack = new WebserviceInvocation(SIMILAR, track);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(similarTrack));
dao.logWebserviceInvocation(similarTrack);
assertFalse(dao.isWebserviceInvocationAllowed(similarTrack));
// make the invocation age in database, by updating it.
DateTime dateTime = new DateTime();
JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
for (int days = 1; days <= 14; days++) {
jdbcTemplate.update("update library.webservice_history set invocation_time = ?",
new Object[]{dateTime.minusDays(days).toDate()});
boolean isAllowed = dao.isWebserviceInvocationAllowed(similarTrack);
boolean cacheIsInvalid = days > SIMILAR.getDaysToCache();
assertTrue(isAllowed == cacheIsInvalid);
}
}