### Question:
SamlSettings { String getUserName() { return configuration.get(USER_NAME_ATTRIBUTE).orElseThrow(() -> new IllegalArgumentException("User name attribute is missing")); } SamlSettings(Configuration configuration);   }### Answer:
@Test public void return_user_name_attribute() { settings.setProperty("sonar.auth.saml.user.name", "userName"); assertThat(underTest.getUserName()).isEqualTo("userName"); }
@Test public void fail_to_get_user_name_attribute_when_null() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("User name attribute is missing"); underTest.getUserName(); }