DefaultJwtAuthenticationService implements JwtAuthenticationService { @Override public LoginDto createJwtAuthenticationAndAuthenticate(LoginDto loginDto, IdmIdentityDto identity, String moduleId) { IdmTokenDto preparedToken = new IdmTokenDto(); preparedToken.setModuleId(moduleId); return createJwtAuthenticationAndAuthenticate(loginDto, identity, preparedToken); }  @Override LoginDto createJwtAuthenticationAndAuthenticate(LoginDto loginDto, IdmIdentityDto identity, String moduleId); @Override LoginDto createJwtAuthenticationAndAuthenticate(LoginDto loginDto, IdmIdentityDto identity, IdmTokenDto preparedToken); @Override void logout(IdmTokenDto token);  }
@Test public void createJwtAuthenticationAndAuthenticateTest() { String username = getHelper().createName(); IdmIdentityDto identityDto = getHelper().createIdentity(username, (GuardedString) null); LoginDto loginDto = new LoginDto(identityDto.getUsername(), identityDto.getPassword()); LoginDto resultLoginDto = jwtAuthenticationService.createJwtAuthenticationAndAuthenticate(loginDto, identityDto, MODULE); Assert.assertTrue(securityService.isAuthenticated()); Assert.assertEquals(username, securityService.getCurrentUsername()); Assert.assertEquals(username, resultLoginDto.getUsername()); Assert.assertEquals(MODULE, resultLoginDto.getAuthenticationModule()); Assert.assertNotNull(resultLoginDto.getToken()); IdmJwtAuthenticationDto jwtAuthenticationDto = resultLoginDto.getAuthentication(); Assert.assertNotNull(jwtAuthenticationDto); Assert.assertEquals(username, jwtAuthenticationDto.getCurrentUsername()); Assert.assertEquals(MODULE, jwtAuthenticationDto.getFromModule()); Assert.assertTrue(resultLoginDto.getAuthorities().isEmpty()); }