PLCOAuthProvider implements OAuthProvider { @Override public OAuthToken newRequestToken(String consumerKey, String callbackUrl, Map<String, List<String>> attributes) { OAuthToken token = new OAuthToken(); token.setConsumer(getConsumer(consumerKey)); token.setToken(RandomStringUtils.randomAlphanumeric(TOKEN_SECRET_LENGTH)); token.setSecret(RandomStringUtils.randomAlphanumeric(TOKEN_SECRET_LENGTH)); MultivaluedMap<String, String> map = new MultivaluedMapImpl(); for (Map.Entry<String, List<String>> entry : attributes.entrySet()) { map.put(entry.getKey(), entry.getValue() == null ? Collections.<String>emptyList() : Collections.unmodifiableList(new ArrayList<String>(entry.getValue()))); } token.setAttributes(map); tokenDao.save(token); return token; } @Inject  PLCOAuthProvider(TokenDao tokenDao, ConsumerDao consumerDao); @Override OAuthConsumer getConsumer(String consumerKey); @Override OAuthToken newRequestToken(String consumerKey, String callbackUrl, Map<String, List<String>> attributes); @Override OAuthToken getRequestToken(String token); @Override OAuthToken newAccessToken(com.sun.jersey.oauth.server.spi.OAuthToken requestToken, String verifier); @Override OAuthToken getAccessToken(String token);  }
@Test public void newRequestToken() { Map<String, List<String>> attr = new HashMap<String, List<String>>(); attr.put("foo", Arrays.asList("bar", "baz")); attr.put("qux", null); OAuthToken token = provider.newRequestToken(consumer.getKey(), "", attr); assertNotNull(token); assertNotNull(token.getConsumer()); assertNotNull(token.getSecret()); assertNotNull(token.getToken()); assertNotNull(token.getAttributes()); }