### Question:
SimpleSocialUserDetailsService implements SocialUserDetailsService { @Override public SocialUserDetails loadUserByUserId(String userId) throws UsernameNotFoundException, DataAccessException { LOGGER.debug("Loading user by user id: {}", userId); UserDetails userDetails = userDetailsService.loadUserByUsername(userId); LOGGER.debug("Found user details: {}", userDetails); return (SocialUserDetails) userDetails; } SimpleSocialUserDetailsService(UserDetailsService userDetailsService); @Override SocialUserDetails loadUserByUserId(String userId);  }### Answer:
@Test public void loadByUserId_UserDetailsNotFound_ShouldThrowException() { when(userDetailsServicemock.loadUserByUsername(USER_ID)).thenThrow(new UsernameNotFoundException("")); catchException(service).loadUserByUserId(USER_ID); assertThat(caughtException()) .isExactlyInstanceOf(UsernameNotFoundException.class) .hasNoCause(); verify(userDetailsServicemock, times(1)).loadUserByUsername(USER_ID); verifyNoMoreInteractions(userDetailsServicemock); }
@Test public void loadByUserId_UserDetailsFound_ShouldReturnTheFoundUserDetails() { ExampleUserDetails found = ExampleUserDetails.getBuilder() .firstName(FIRST_NAME) .lastName(LAST_NAME) .password(PASSWORD) .username(USER_ID) .role(Role.ROLE_USER) .build(); when(userDetailsServicemock.loadUserByUsername(USER_ID)).thenReturn(found); UserDetails actual = service.loadUserByUserId(USER_ID); assertThat(actual).isEqualTo(found); verify(userDetailsServicemock, times(1)).loadUserByUsername(USER_ID); verifyNoMoreInteractions(userDetailsServicemock); }