@Test public void should_validate_empty_member(){ Set<ProposalError> errors = memberService.checkSpeakerData(new Member()); assertThat(errors) .hasSize(4) .extracting("property") .contains("firstname", "lastname", "shortDescription", "longDescription"); }
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);  }