HFCAIdentity { public int read(User registrar) throws IdentityException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readIdURL = ""; try { readIdURL = HFCA_IDENTITY + "/" + enrollmentID; logger.debug(format("identity url: %s, registrar: %s", readIdURL, registrar.getName())); JsonObject result = client.httpGet(readIdURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { type = result.getString("type"); maxEnrollments = result.getInt("max_enrollments"); affiliation = result.getString("affiliation"); JsonArray attributes = result.getJsonArray("attrs"); Collection<Attribute> attrs = new ArrayList<Attribute>(); if (attributes != null && !attributes.isEmpty()) { for (int i = 0; i < attributes.size(); i++) { JsonObject attribute = attributes.getJsonObject(i); Attribute attr = new Attribute(attribute.getString("name"), attribute.getString("value"), attribute.getBoolean("ecert", false)); attrs.add(attr); } } this.attrs = attrs; logger.debug(format("identity url: %s, registrar: %s done.", readIdURL, registrar)); } this.deleted = false; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), readIdURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while getting user '%s' from url '%s': %s", enrollmentID, readIdURL, 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 getIdentityNoServerResponse() throws Exception { thrown.expect(IdentityException.class); thrown.expectMessage("Error while getting user"); HFCAClient client = HFCAClient.createNewInstance("http: client.setCryptoSuite(crypto); HFCAIdentity ident = client.newHFCAIdentity("testuser1"); ident.read(admin); }