// going
JizzStation station = JizzStationJpaDaoTest
.createDefaultStation(jizzStationDao);
// One ending in the past (shouldn't be returned)
JizzBroadcast past = new JizzBroadcast();
past.setStation(station);
past.setFinale(new Date(System.currentTimeMillis() - DAY_IN_MILLIS));
past = jizzBroadcastJpaDao.createOrUpdateBroadcast(past);
// One ending in the distant future (shouldn't be returned)
JizzBroadcast future = new JizzBroadcast();
future.setStation(station);
future.setFinale(new Date(System.currentTimeMillis() + MONTHISH_IN_MILLIS));
future = jizzBroadcastJpaDao.createOrUpdateBroadcast(future);
// One ending quite soon (should be returned)
JizzBroadcast next = new JizzBroadcast();
next.setStation(station);
next.setFinale(new Date(System.currentTimeMillis() + DAY_IN_MILLIS));
next = jizzBroadcastJpaDao.createOrUpdateBroadcast(next);
// So finding the next broadcast should match 'next'
JizzBroadcast broadcast = jizzBroadcastJpaDao
.findNearestBroadcast(station);
assertEquals(next.getId(), broadcast.getId());
}