Problem implements Serializable { public Problem(JSON problem, URL baseUrl) { this.problemJson = problem; this.baseUrl = baseUrl; } Problem(JSON problem, URL baseUrl); URI getType(); @Nullable String getTitle(); @Nullable String getDetail(); @Nullable URI getInstance(); @Nullable Identifier getIdentifier(); List<Problem> getSubProblems(); JSON asJSON(); @Override String toString();  }
@Test public void testProblem() { URL baseUrl = url("https: JSON original = TestUtils.getJSON("problem"); Problem problem = new Problem(original, baseUrl); assertThat(problem.getType(), is(URI.create("urn:ietf:params:acme:error:malformed"))); assertThat(problem.getTitle(), is("Some of the identifiers requested were rejected")); assertThat(problem.getDetail(), is("Identifier \"abc12_\" is malformed")); assertThat(problem.getInstance(), is(URI.create("https: assertThat(problem.getIdentifier(), is(nullValue())); assertThat(problem.asJSON().toString(), is(sameJSONAs(original.toString()))); assertThat(problem.toString(), is( "Identifier \"abc12_\" is malformed (" + "Invalid underscore in DNS name \"_example.com\" ‒ " + "This CA will not issue for \"example.net\")")); List<Problem> subs = problem.getSubProblems(); assertThat(subs, not(nullValue())); assertThat(subs, hasSize(2)); Problem p1 = subs.get(0); assertThat(p1.getType(), is(URI.create("urn:ietf:params:acme:error:malformed"))); assertThat(p1.getTitle(), is(nullValue())); assertThat(p1.getDetail(), is("Invalid underscore in DNS name \"_example.com\"")); assertThat(p1.getIdentifier().getDomain(), is("_example.com")); assertThat(p1.toString(), is("Invalid underscore in DNS name \"_example.com\"")); Problem p2 = subs.get(1); assertThat(p2.getType(), is(URI.create("urn:ietf:params:acme:error:rejectedIdentifier"))); assertThat(p2.getTitle(), is(nullValue())); assertThat(p2.getDetail(), is("This CA will not issue for \"example.net\"")); assertThat(p2.getIdentifier().getDomain(), is("example.net")); assertThat(p2.toString(), is("This CA will not issue for \"example.net\"")); }