}
@Test
public void shouldReplaceExistingAuthorization() throws Exception {
// pre-conditions
IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_READ, 600);
assertNotNull(authorization.getToken());
assertEquals(authorization.getScopes(), IAuthorization.SCOPE_READ);
// operations
user.createAuthorization("new note", IAuthorization.SCOPE_SESSION);
IAuthorization newAuthorization = user.getAuthorization();
// verifications
assertFalse(authorization.equals(newAuthorization));
assertEquals(newAuthorization.getScopes(), IAuthorization.SCOPE_SESSION);
assertFalse(authorization.getToken().equals(newAuthorization.getToken()));
assertEquals(newAuthorization.getNote(), "new note");
assertTrue(newAuthorization.getExpiresIn() != 600);
// cleanup
authorization.destroy();
newAuthorization.destroy();
}