RuleEntityServiceImpl implements RuleEntityService { @Override public List<RuleEntity> findByNotExpired() { return ruleEntityRepository.findByExpiryDateAfter(DateTime.now()); }  @Override RuleEntity save(final RuleDTO ruleDTO); @Override RuleEntity update(final RuleDTO ruleDTO, final Long id); @Override RuleEntity findById(final Long id); @Override List<RuleEntity> findByNotExpired(); @Override List<RuleEntity> findAll(); @Override void expire(final Long id, final DateTime newExpiryDate);  }
@Test public void testFindByNotExpired() throws Exception { when(ruleEntityRepository.findByExpiryDateAfter(any(DateTime.class))).thenReturn(newArrayList(ruleEntity)); final List<RuleEntity> byNotExpired = ruleEntityServiceImpl.findByNotExpired(); assertThat(byNotExpired).hasSize(1); verify(ruleEntityRepository).findByExpiryDateAfter(any(DateTime.class)); }