@Test public void findByUserId() { final UserProfile expected = mock(UserProfile.class); Principal principal = PrincipalMother.davyvanroy(); when(profileService.getNonLoggedInUserProfile(principal.getName())).thenReturn(expected); final Optional<UserProfile> result = profiles.findByUserId(principal.getName()); assertThat(result).contains(expected); }
public Optional<UserProfile> findByUserId(final String userId) { try { return StringUtils.isBlank(userId) ? Optional.empty() : Optional.ofNullable(profileService.getNonLoggedInUserProfile(userId)); } catch (Exception e) { LOGGER.error("Error getting profile for: \"" + userId + "\"", e); return Optional.empty(); } }
ProfilesExpressionObject { public Optional<UserProfile> findByUserId(final String userId) { try { return StringUtils.isBlank(userId) ? Optional.empty() : Optional.ofNullable(profileService.getNonLoggedInUserProfile(userId)); } catch (Exception e) { LOGGER.error("Error getting profile for: \"" + userId + "\"", e); return Optional.empty(); } } }
ProfilesExpressionObject { public Optional<UserProfile> findByUserId(final String userId) { try { return StringUtils.isBlank(userId) ? Optional.empty() : Optional.ofNullable(profileService.getNonLoggedInUserProfile(userId)); } catch (Exception e) { LOGGER.error("Error getting profile for: \"" + userId + "\"", e); return Optional.empty(); } } ProfilesExpressionObject(final ProfileService profileService); }
ProfilesExpressionObject { public Optional<UserProfile> findByUserId(final String userId) { try { return StringUtils.isBlank(userId) ? Optional.empty() : Optional.ofNullable(profileService.getNonLoggedInUserProfile(userId)); } catch (Exception e) { LOGGER.error("Error getting profile for: \"" + userId + "\"", e); return Optional.empty(); } } ProfilesExpressionObject(final ProfileService profileService); Optional<UserProfile> findByUserId(final String userId); Function<UserProfile, String> getName(); }
ProfilesExpressionObject { public Optional<UserProfile> findByUserId(final String userId) { try { return StringUtils.isBlank(userId) ? Optional.empty() : Optional.ofNullable(profileService.getNonLoggedInUserProfile(userId)); } catch (Exception e) { LOGGER.error("Error getting profile for: \"" + userId + "\"", e); return Optional.empty(); } } ProfilesExpressionObject(final ProfileService profileService); Optional<UserProfile> findByUserId(final String userId); Function<UserProfile, String> getName();  }