@Test public void should_validate_proposal() { Mockito.when(memberRepository.findOne(Matchers.anyLong())).thenReturn(new Member()); Set<ProposalError> errors = proposalService.check( new Proposal() .setFormat(Format.Keynote) .setSummary("summary") .setLang(SessionLanguage.en) .setLevel(Level.Beginner) .setDescription("desc") .setIdeaForNow("idea") .addSpeaker(new Member())); assertThat(errors).isEmpty(); }
public Set<ProposalError> check(Proposal proposal) { Set<ProposalError> errors = Sets.newHashSet(); proposal.getSpeakers().forEach(speaker -> errors.addAll(memberService.checkSpeakerData(memberRepository.findOne(speaker.getId())))); if (proposal.getFormat() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("format")); } if (proposal.getSummary() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("summary")); } if (proposal.getLevel() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("level")); } if (proposal.getDescription() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("description")); } if (proposal.getIdeaForNow() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("ideaForNow")); } if (proposal.getLang() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("lang")); } if (proposal.getSpeakers().isEmpty()) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("speaker")); } return errors; }
ProposalService { public Set<ProposalError> check(Proposal proposal) { Set<ProposalError> errors = Sets.newHashSet(); proposal.getSpeakers().forEach(speaker -> errors.addAll(memberService.checkSpeakerData(memberRepository.findOne(speaker.getId())))); if (proposal.getFormat() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("format")); } if (proposal.getSummary() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("summary")); } if (proposal.getLevel() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("level")); } if (proposal.getDescription() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("description")); } if (proposal.getIdeaForNow() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("ideaForNow")); } if (proposal.getLang() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("lang")); } if (proposal.getSpeakers().isEmpty()) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("speaker")); } return errors; } }
ProposalService { public Set<ProposalError> check(Proposal proposal) { Set<ProposalError> errors = Sets.newHashSet(); proposal.getSpeakers().forEach(speaker -> errors.addAll(memberService.checkSpeakerData(memberRepository.findOne(speaker.getId())))); if (proposal.getFormat() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("format")); } if (proposal.getSummary() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("summary")); } if (proposal.getLevel() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("level")); } if (proposal.getDescription() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("description")); } if (proposal.getIdeaForNow() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("ideaForNow")); } if (proposal.getLang() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("lang")); } if (proposal.getSpeakers().isEmpty()) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("speaker")); } return errors; }  }
ProposalService { public Set<ProposalError> check(Proposal proposal) { Set<ProposalError> errors = Sets.newHashSet(); proposal.getSpeakers().forEach(speaker -> errors.addAll(memberService.checkSpeakerData(memberRepository.findOne(speaker.getId())))); if (proposal.getFormat() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("format")); } if (proposal.getSummary() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("summary")); } if (proposal.getLevel() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("level")); } if (proposal.getDescription() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("description")); } if (proposal.getIdeaForNow() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("ideaForNow")); } if (proposal.getLang() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("lang")); } if (proposal.getSpeakers().isEmpty()) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("speaker")); } return errors; }  Set<ProposalError> check(Proposal proposal); Proposal save(Proposal proposal, Account account); void updateProposalSpeaker(Proposal proposalDb, Proposal proposal, Account account); void delete(Long id); }
ProposalService { public Set<ProposalError> check(Proposal proposal) { Set<ProposalError> errors = Sets.newHashSet(); proposal.getSpeakers().forEach(speaker -> errors.addAll(memberService.checkSpeakerData(memberRepository.findOne(speaker.getId())))); if (proposal.getFormat() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("format")); } if (proposal.getSummary() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("summary")); } if (proposal.getLevel() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("level")); } if (proposal.getDescription() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("description")); } if (proposal.getIdeaForNow() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("ideaForNow")); } if (proposal.getLang() == null) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("lang")); } if (proposal.getSpeakers().isEmpty()) { errors.add(new ProposalError().setEntity(PROPOSAL).setCode(REQUIRED).setProperty("speaker")); } return errors; }  Set<ProposalError> check(Proposal proposal); Proposal save(Proposal proposal, Account account); void updateProposalSpeaker(Proposal proposalDb, Proposal proposal, Account account); void delete(Long id);  }