### Question:
CrnUserDetailsService implements UserDetailsService { @Override public CrnUser loadUserByUsername(String crn) throws UsernameNotFoundException { return getUmsUser(crn); } CrnUserDetailsService(GrpcUmsClient umsClient); @Override CrnUser loadUserByUsername(String crn);  }### Answer:
@Test public void loadUserByInternalCrn() { InternalCrnBuilder crnBuilder = new InternalCrnBuilder(Crn.Service.ENVIRONMENTS); UserDetails userDetails = underTest.loadUserByUsername(crnBuilder.getInternalCrnForServiceAsString()); assertTrue(userDetails.getAuthorities().iterator().next().getAuthority().equals("ROLE_INTERNAL")); }
@Test public void loadUserByInternalCrnWithAutoscale() { InternalCrnBuilder crnBuilder = new InternalCrnBuilder(Crn.Service.AUTOSCALE); UserDetails userDetails = underTest.loadUserByUsername(crnBuilder.getInternalCrnForServiceAsString()); assertTrue(userDetails.getAuthorities().iterator().next().getAuthority().equals("ROLE_AUTOSCALE")); }
@Test public void loadUserByCrn() { User user = User.newBuilder().setCrn("userCrn").setEmail("dummyuser@cloudera.com").setUserId("1").build(); when(mockedUmsClient.getUserDetails(eq(userCrn), eq(userCrn), any())).thenReturn(user); UserDetails userDetails = underTest.loadUserByUsername(userCrn); assertTrue(userDetails.getAuthorities().iterator().next().getAuthority().equals("CRN_USER")); }