RuleEntityServiceImpl implements RuleEntityService { @Override public RuleEntity findById(final Long id) { final RuleEntity ruleEntity = ruleEntityRepository.findOne(id); if (ruleEntity == null) { log.info("No such RuleEntity found! Id: {}", id); return null; } return ruleEntity; }  @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 testFindByIdFails() throws Exception { when(ruleEntityRepository.findOne(anyLong())).thenReturn(null); final RuleEntity updatedRule = ruleEntityServiceImpl.findById(1L); assertThat(updatedRule).isEqualTo(null); verify(ruleEntityRepository).findOne(anyLong()); }