Account extends AcmeJsonResource { public EditableAccount modify() { return new EditableAccount(); } protected  Account(Login login); @Nullable Boolean getTermsOfServiceAgreed(); List<URI> getContacts(); Status getStatus(); boolean hasExternalAccountBinding(); @Nullable String getKeyIdentifier(); Iterator<Order> getOrders(); OrderBuilder newOrder(); Authorization preAuthorizeDomain(String domain); Authorization preAuthorize(Identifier identifier); void changeKey(KeyPair newKeyPair); void deactivate(); EditableAccount modify();  }
@Test public void testModify() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public int sendSignedRequest(URL url, JSONBuilder claims, Login login) { assertThat(url, is(locationUrl)); assertThat(claims.toString(), sameJSONAs(getJSON("modifyAccount").toString())); assertThat(login, is(notNullValue())); return HttpURLConnection.HTTP_OK; } @Override public JSON readJsonResponse() { return getJSON("modifyAccountResponse"); } @Override public URL getLocation() { return locationUrl; } }; Account account = new Account(provider.createLogin()); account.setJSON(getJSON("newAccount")); EditableAccount editable = account.modify(); assertThat(editable, notNullValue()); editable.addContact("mailto:foo2@example.com"); editable.getContacts().add(URI.create("mailto:foo3@example.com")); editable.commit(); assertThat(account.getLocation(), is(locationUrl)); assertThat(account.getContacts().size(), is(3)); assertThat(account.getContacts().get(0), is(URI.create("mailto:foo@example.com"))); assertThat(account.getContacts().get(1), is(URI.create("mailto:foo2@example.com"))); assertThat(account.getContacts().get(2), is(URI.create("mailto:foo3@example.com"))); provider.close(); }