@Test public void testExecuteWithSameDisplayName() { final String oldDisplayName = "sdlfjsdfkdfjsdf"; final String newDisplayName = oldDisplayName; final CommentDTO comment = context.mock(CommentDTO.class); final Person person = context.mock(Person.class); context.checking(new Expectations() { { oneOf(comment).getAuthorDisplayName(); will(returnValue(oldDisplayName)); oneOf(person).getDisplayName(); will(returnValue(newDisplayName)); } }); sut.execute(comment, person); context.assertIsSatisfied(); }
@Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldDisplayName = inCommentDTO.getAuthorDisplayName(); String newDisplayName = inPerson.getDisplayName(); if (oldDisplayName == null || !oldDisplayName.equals(newDisplayName)) { inCommentDTO.setAuthorDisplayName(newDisplayName); return true; } return false; }
UpdateCommentDTOAuthorDisplayName implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldDisplayName = inCommentDTO.getAuthorDisplayName(); String newDisplayName = inPerson.getDisplayName(); if (oldDisplayName == null || !oldDisplayName.equals(newDisplayName)) { inCommentDTO.setAuthorDisplayName(newDisplayName); return true; } return false; } }
UpdateCommentDTOAuthorDisplayName implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldDisplayName = inCommentDTO.getAuthorDisplayName(); String newDisplayName = inPerson.getDisplayName(); if (oldDisplayName == null || !oldDisplayName.equals(newDisplayName)) { inCommentDTO.setAuthorDisplayName(newDisplayName); return true; } return false; }  }
UpdateCommentDTOAuthorDisplayName implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldDisplayName = inCommentDTO.getAuthorDisplayName(); String newDisplayName = inPerson.getDisplayName(); if (oldDisplayName == null || !oldDisplayName.equals(newDisplayName)) { inCommentDTO.setAuthorDisplayName(newDisplayName); return true; } return false; }  @Override boolean execute(final CommentDTO inCommentDTO, final Person inPerson); }
UpdateCommentDTOAuthorDisplayName implements UpdateCommentDTOFromPerson { @Override public boolean execute(final CommentDTO inCommentDTO, final Person inPerson) { String oldDisplayName = inCommentDTO.getAuthorDisplayName(); String newDisplayName = inPerson.getDisplayName(); if (oldDisplayName == null || !oldDisplayName.equals(newDisplayName)) { inCommentDTO.setAuthorDisplayName(newDisplayName); return true; } return false; }  @Override boolean execute(final CommentDTO inCommentDTO, final Person inPerson);  }