@Test
    public void testProfileCreation() {
        val client = new DirectBearerAuthClient(new ProfileCreator() {
            @Override
            public Optional<UserProfile> create(final CallContext ctx, final Credentials credentials) {
                UserProfile profile = new CommonProfile();
                profile.setId(KEY);
                return Optional.of(profile);
            }
        });
        val context = MockWebContext.create();
        context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
            HttpConstants.BEARER_HEADER_PREFIX + TOKEN);
        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = (TokenCredentials) client.getCredentials(ctx).get();
        assertEquals(TOKEN, credentials.getToken());
        val authnCredentials = client.validateCredentials(ctx, credentials).get();
        UserProfile profile = (CommonProfile) client.getUserProfile(ctx, authnCredentials).get();
        assertEquals(KEY, profile.getId());
    }
This class tests the {@link DirectBearerAuthClient} class.

@author Graham Leggett
@since 3.5.0
pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBearerAuthClientTests.java