### Question:
KyloRestLoginModule extends AbstractLoginModule implements LoginModule { @Override public void initialize(@Nonnull final Subject subject, @Nonnull final CallbackHandler callbackHandler, @Nonnull final Map<String, ?> sharedState, @Nonnull final Map<String, ?> options) { super.initialize(subject, callbackHandler, sharedState, options); try { config = (LoginJerseyClientConfig) options.get(REST_CLIENT_CONFIG); servicesLogout = (boolean) getOption(SERVICES_LOGOUT).orElse(false); loginUser = (String) getOption(LOGIN_USER).orElse(null); if (loginUser != null) { String passwordObject = (String)getOption(LOGIN_PASSWORD) .orElseThrow(() -> new IllegalArgumentException("A REST login password is required if a login username was provided")); loginPassword = passwordObject.toCharArray(); } } catch (RuntimeException e) { log.error("Unhandled exception during initialization", e); throw e; } }  @Override void initialize(@Nonnull final Subject subject, @Nonnull final CallbackHandler callbackHandler, @Nonnull final Map<String, ?> sharedState, @Nonnull final Map<String, ?> options);  }### Answer:
@Test public void test() throws Exception { final User user = new User(); user.setEnabled(true); user.setGroups(ImmutableSet.of("designers", "operators")); user.setSystemName("dladmin"); final JerseyRestClient client = Mockito.mock(JerseyRestClient.class); Mockito.when(client.get(any(Invocation.Builder.class), eq(User.class))).thenReturn(user); final CallbackHandler callbackHandler = callbacks -> Arrays.stream(callbacks).forEach(callback -> { if (callback instanceof NameCallback) { ((NameCallback) callback).setName("dladmin"); } else if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword("thinkbig".toCharArray()); } }); final KyloRestLoginModule module = new KyloRestLoginModule() { @Nonnull @Override JerseyRestClient getClient(@Nonnull LoginJerseyClientConfig config) { return client; } }; final Subject subject = new Subject(); Map<String, Object> options = new HashMap<>(); options.put(KyloRestLoginModule.REST_CLIENT_CONFIG, new LoginJerseyClientConfig()); options.put(KyloRestLoginModule.SERVICES_LOGOUT, false); module.initialize(subject, callbackHandler, Collections.emptyMap(), options); Assert.assertTrue(module.login()); Assert.assertTrue(module.commit()); final Principal[] principals = subject.getPrincipals().toArray(new Principal[0]); Assert.assertEquals(3, principals.length); Arrays.sort(principals, Comparator.comparing(Principal::getName)); Assert.assertEquals("designers", principals[0].getName()); Assert.assertEquals("dladmin", principals[1].getName()); Assert.assertEquals("operators", principals[2].getName()); }