HFCAIdentity { public int update(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String updateURL = ""; try { updateURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", updateURL, registrar.getName())); String body = client.toJson(idToJsonObject()); JsonObject result = client.httpPut(updateURL, body, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", updateURL, registrar)); } return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while updating user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), updateURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while updating user '%s' from url '%s': %s", getEnrollmentId(), updateURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } } HFCAIdentity(String enrollmentID, HFCAClient client);   HFCAIdentity(JsonObject result); String getEnrollmentId(); String getType(); void setType(String type); String getSecret(); void setSecret(String secret); Integer getMaxEnrollments(); void setMaxEnrollments(Integer maxEnrollments); String getAffiliation(); void setAffiliation(String affiliation); void setAffiliation(HFCAAffiliation affiliation); Collection<Attribute> getAttributes(); void setAttributes(Collection<Attribute> attributes); boolean isDeleted(); int read(User registrar); int create(User registrar); int update(User registrar); int delete(User registrar);  }
@Test public void updateIdentityNoServerResponse() throws Exception { thrown.expect(IdentityException.class); thrown.expectMessage("Error while updating user"); HFCAClient client = HFCAClient.createNewInstance("http: client.setCryptoSuite(crypto); HFCAIdentity ident = client.newHFCAIdentity("testuser1"); ident.update(admin); }