CompositeTokenProvider implements TokenProvider { @Nullable @Override public TokenInfo createToken(@NotNull Credentials credentials) { for (TokenProvider tp : providers) { TokenInfo info = tp.createToken(credentials); if (info != null) { return info; } } return null; } private  CompositeTokenProvider(@NotNull List<? extends TokenProvider> providers); @NotNull static TokenProvider newInstance(@NotNull TokenProvider... providers); @NotNull static TokenProvider newInstance(@NotNull List<? extends TokenProvider> providers); @Override boolean doCreateToken(@NotNull Credentials credentials); @Nullable @Override TokenInfo createToken(@NotNull Credentials credentials); @Nullable @Override TokenInfo createToken(@NotNull String userId, @NotNull Map<String, ?> attributes); @Nullable @Override TokenInfo getTokenInfo(@NotNull String token);  }
@Test public void testCreateTokenFromCredentials() { assertSame(info, composite.createToken(new SimpleCredentials(USERID, new char[0]))); assertNull(composite.createToken(new GuestCredentials())); assertNull(composite.createToken(new Credentials() { })); }
@Test public void testCreateTokenFromId() { assertSame(info, composite.createToken(USERID, ImmutableMap.of())); }
@Test public void testCreateTokenFromUnknownId() { assertNull(composite.createToken("unknown", ImmutableMap.of())); }