@Test
public void loadUserDetails_WithMatchingAttributes_MergedRoles() {

    // JDK10 var needed :)
    GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService userDetailsService =
            new GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService(
                    new String[] {"role", "group"}, DEFAULT_ROLES);
    when(assertion.getPrincipal()).thenReturn(principal);
    when(principal.getName()).thenReturn("JohnWick");
    when(principal.getAttributes()).thenReturn(ATTRIBUTES);
    assertThat(userDetailsService.loadUserDetails(assertion).getAuthorities())
            .extracting("authority", String.class)
            .containsExactlyInAnyOrder("ROLE_USER", "ROLE_MEMBER", "ROLE_ADMIN");
    verify(assertion, times(2)).getPrincipal();
    verify(principal, times(1)).getName();
    verify(principal, times(1)).getAttributes();
}