@Test public void testExecuteWithSameAvatarId() { final String oldAvatarId = "sdlfjsdfkdfjsdf"; final String newAvatarId = oldAvatarId; final CommentDTO comment = context.mock(CommentDTO.class); final Person person = context.mock(Person.class); context.checking(new Expectations() { { oneOf(comment).getAuthorAvatarId(); will(returnValue(oldAvatarId)); oneOf(person).getAvatarId(); will(returnValue(newAvatarId)); } }); sut.execute(comment, person); context.assertIsSatisfied(); }
@Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldAvatarId = inCommentDTO.getAuthorAvatarId(); String newAvatarId = inPerson.getAvatarId(); if (oldAvatarId == null || !oldAvatarId.equals(newAvatarId)) { inCommentDTO.setAuthorAvatarId(newAvatarId); return true; } return false; }
UpdateCommentDTOAuthorAvatarId implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldAvatarId = inCommentDTO.getAuthorAvatarId(); String newAvatarId = inPerson.getAvatarId(); if (oldAvatarId == null || !oldAvatarId.equals(newAvatarId)) { inCommentDTO.setAuthorAvatarId(newAvatarId); return true; } return false; } }
UpdateCommentDTOAuthorAvatarId implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldAvatarId = inCommentDTO.getAuthorAvatarId(); String newAvatarId = inPerson.getAvatarId(); if (oldAvatarId == null || !oldAvatarId.equals(newAvatarId)) { inCommentDTO.setAuthorAvatarId(newAvatarId); return true; } return false; }  }
UpdateCommentDTOAuthorAvatarId implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldAvatarId = inCommentDTO.getAuthorAvatarId(); String newAvatarId = inPerson.getAvatarId(); if (oldAvatarId == null || !oldAvatarId.equals(newAvatarId)) { inCommentDTO.setAuthorAvatarId(newAvatarId); return true; } return false; }  @Override boolean execute(final CommentDTO inCommentDTO, final Person inPerson); }
UpdateCommentDTOAuthorAvatarId implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldAvatarId = inCommentDTO.getAuthorAvatarId(); String newAvatarId = inPerson.getAvatarId(); if (oldAvatarId == null || !oldAvatarId.equals(newAvatarId)) { inCommentDTO.setAuthorAvatarId(newAvatarId); return true; } return false; }  @Override boolean execute(final CommentDTO inCommentDTO, final Person inPerson);  }