public String apply(UserProfile profile) { return profile.getUsername(); } }
@Override protected boolean matchesSafely(UserProfile actual, Description mismatchDescription) { if (actual == null) { mismatchDescription.appendValue(null); return false; } if (!equal(actual.getUsername(), expected.getUsername())) { mismatchDescription.appendText("userName=").appendValue(actual.getUsername()); return false; } return true; }
public void describeTo(Description description) { description.appendText("username=").appendValue(expected.getUsername()); } };
public void describeTo(Description description) { description.appendText("username=").appendValue(expected.getUsername()) .appendText(", fullName=").appendValue(expected.getFullName()) .appendText(", email=").appendValue(expected.getEmail()) .appendText(", profilePageUri=").appendValue(expected.getProfilePageUri()) .appendText(", profilePictureUri=").appendValue(expected.getProfilePictureUri()); } };
return false; if (!equal(actual.getUsername(), expected.getUsername())) mismatchDescription.appendText("username=").appendValue(actual.getUsername()); matches = false;
@Override public UserProfile apply(final UserProfile userProfile) { if (historyMetadata.isDefined()) { final HistoryMetadata data = historyMetadata.get(); final HistoryMetadataParticipant actor = data.getActor(); final boolean useActor = actor != null && isAnonymous; final Option<URI> generatorAvatar = (data.getGenerator() != null ? makeUri(data.getGenerator().getAvatarUrl()) : Option.<URI>none()); return new UserProfile.Builder(useActor && actor.getId() != null ? actor.getId() : userProfile.getUsername()) .fullName(useActor ? find(asList(actor.getDisplayName(), actor.getId()), notNull(), userProfile.getFullName()) : userProfile.getFullName()) .profilePageUri(makeUri(useActor ? actor.getUrl() : null).orElse(userProfile.getProfilePageUri())) .profilePictureUri(generatorAvatar.orElse(makeUri(useActor ? actor.getAvatarUrl() : null)).orElse(userProfile.getProfilePictureUri())) .email(userProfile.getEmail()) .build(); } return userProfile; } };
errors.checkString(this.user.getUsername(), "user.username"); errors.checkString(this.user.getFullName(), "user.fullName"); errors.checkAbsoluteUri(this.user.getProfilePageUri(), "user.profilePageUri");