ProposalService { public Proposal save(Proposal proposal, Account account) { Objects.requireNonNull(proposal, "proposal is required"); Proposal proposalPersisted = proposal.getId() == null ? null : proposalRepository.findOne(proposal.getId()); if (proposalPersisted == null) { proposalPersisted = new Proposal() .setEvent(EventService.getCurrent()) .setStatus(CREATED) .addSpeaker(accountRepository.findOne(account.getId()).getMember()); } proposalPersisted = proposalRepository.save(proposalPersisted .setCategory(proposal.getCategory()) .setDescription(proposal.getDescription()) .setFormat(proposal.getFormat()) .setTitle(proposal.getTitle()) .setSummary(proposal.getSummary()) .setLink(proposal.getLink()) .setLevel(proposal.getLevel()) .setFormat(proposal.getFormat()) .setIdeaForNow(proposal.getIdeaForNow()) .setTypeSession(proposal.getTypeSession()) .setMessageForStaff(proposal.getMessageForStaff()) .setMaxAttendees(proposal.getMaxAttendees()) ); updateProposalInterest(proposalPersisted, proposal); updateProposalSpeaker(proposalPersisted, proposal, account); proposalPersisted.setValid(check(proposalPersisted).isEmpty()); Session session = proposalPersisted.getSession(); if(session !=null){ proposalPersisted.toSession(session); session.clearSpeakers(); proposalPersisted.getSpeakers().forEach(s -> session.addSpeaker(s)); session.clearInterests(); proposalPersisted.getInterests().forEach(s -> session.addInterest(s)); } proposalPersisted = proposalRepository.save(proposalPersisted); if(proposal.getStatus()==null || VALID == proposal.getStatus() || CREATED == proposal.getStatus()) { if (proposalPersisted.isValid()) { proposalPersisted.setStatus(VALID); submit(proposalPersisted, account); } } return proposalPersisted; }  Set<ProposalError> check(Proposal proposal); Proposal save(Proposal proposal, Account account); void updateProposalSpeaker(Proposal proposalDb, Proposal proposal, Account account); void delete(Long id);  }
@Test(expected = NullPointerException.class) public void should_throw_NPE_when_saving_null_proposal() { proposalService.save(null, null); }