RunDao extends BaseHibernateEntityDao<RunHibernateEntity> { public RunHibernateEntity findFirstInSequenceWithoutRawTime(EventHibernateEntity event) { Query query = namedQuery(RunHibernateEntity.QUERY_FIND_FIRST_WITHOUT_TIME_AT_EVENT); query.setParameter(RunHibernateEntity.PARAMETER_EVENT_ID, event.getId()); List<RunHibernateEntity> runsWithoutRawTimes = list(query); if (runsWithoutRawTimes != null && !runsWithoutRawTimes.isEmpty()) { return runsWithoutRawTimes.get(0); } else { return null; } } @Inject  RunDao(SessionFactory sessionFactory); @Override void create(RunHibernateEntity entity); @Override List<RunHibernateEntity> findAll(); @Override RunHibernateEntity findById(String id); RunHibernateEntity findLastInSequenceFor(EventHibernateEntity event); RunHibernateEntity findFirstInSequenceWithoutRawTime(EventHibernateEntity event); List<RunHibernateEntity> getAllWith(EventHibernateEntity event); List<RunHibernateEntity> getAllWith(RegistrationHibernateEntity registration);  }
@Test public void whenNoRunsThenFirstInSequenceWithoutRawTimeShouldBeNull() { daoTestRule.inTransaction(() -> { RunHibernateEntity actual = dao.findFirstInSequenceWithoutRawTime(prerequisites.event); assertThat(actual).isNull(); }); }