RuleEntityServiceImpl implements RuleEntityService { @Override public RuleEntity save(final RuleDTO ruleDTO) { if (ruleDTO.getExpiryDate() == null) { ruleDTO.setExpiryDate(new DateTime(9999, 1, 1, 0, 0, 0, UTC)); } final RuleEntity ruleEntity = mapDtoToRuleEntity(ruleDTO); final RuleEntity entity = ruleEntityRepository.save(ruleEntity); log.info("New Whitelisting Rule created {}", ruleEntity); return entity; }  @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 testSave() throws Exception { final RuleDTO ruleDTO = new RuleDTO(); ruleDTO.setAccountId("1234"); when(ruleEntityRepository.save(any(RuleEntity.class))).then(AdditionalAnswers.returnsFirstArg()); final RuleEntity savedRuleEntity = ruleEntityServiceImpl.save(ruleDTO); assertThat(savedRuleEntity.getAccountId()).isEqualTo("1234"); assertThat(savedRuleEntity.getExpiryDate()).isEqualTo(new DateTime(9999, 1, 1, 0, 0, 0, UTC)); verify(ruleEntityRepository).save(any(RuleEntity.class)); }