IdentityFactory { public static TokenIdentity createFromToken(String token) { return new TokenIdentity(token); } private  IdentityFactory(); static TokenIdentity createFromToken(String token); static UserPasswordIdentity createFromUserPassword(String user, String password);  }
@Test public void testTokenIdentity() { TokenIdentity identity = IdentityFactory.createFromToken("FOO"); Assert.assertThat(identity.getToken(), equalTo("FOO")); }
@Test(expected = IllegalArgumentException.class) public void testNullTokenIdentityNotSupported() { IdentityFactory.createFromToken(null); }