@Test public void should_validate_member(){ Set<ProposalError> errors = memberService.checkSpeakerData( new Member() .setLastname("name") .setFirstname("toto") .setShortDescription("desc") .setLongDescription("long") .setEmail("gui.ehret@gmail.com")); assertThat(errors).isEmpty(); }
public Set<ProposalError> checkSpeakerData(Member member) { Set<ProposalError> errors = Sets.newHashSet(); if (member.getFirstname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("firstname")); } if (member.getLastname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("lastname")); } if (member.getShortDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("shortDescription")); } if (member.getLongDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("longDescription")); } return errors; }
MemberService { public Set<ProposalError> checkSpeakerData(Member member) { Set<ProposalError> errors = Sets.newHashSet(); if (member.getFirstname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("firstname")); } if (member.getLastname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("lastname")); } if (member.getShortDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("shortDescription")); } if (member.getLongDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("longDescription")); } return errors; } }
MemberService { public Set<ProposalError> checkSpeakerData(Member member) { Set<ProposalError> errors = Sets.newHashSet(); if (member.getFirstname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("firstname")); } if (member.getLastname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("lastname")); } if (member.getShortDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("shortDescription")); } if (member.getLongDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("longDescription")); } return errors; }  }
MemberService { public Set<ProposalError> checkSpeakerData(Member member) { Set<ProposalError> errors = Sets.newHashSet(); if (member.getFirstname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("firstname")); } if (member.getLastname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("lastname")); } if (member.getShortDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("shortDescription")); } if (member.getLongDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("longDescription")); } return errors; }  Set<ProposalError> checkSpeakerData(Member member); Member save(Member<T> member); }
MemberService { public Set<ProposalError> checkSpeakerData(Member member) { Set<ProposalError> errors = Sets.newHashSet(); if (member.getFirstname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("firstname")); } if (member.getLastname()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("lastname")); } if (member.getShortDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("shortDescription")); } if (member.getLongDescription()==null) { errors.add(new ProposalError().setEntity(MEMBER).setCode(REQUIRED).setProperty("longDescription")); } return errors; }  Set<ProposalError> checkSpeakerData(Member member); Member save(Member<T> member);  }