### Question:
JsonReference { static JsonReference parse(String ref) { int urlEndIndex = ref.indexOf('#'); if (urlEndIndex < 0) { throw new IllegalArgumentException("Invalid reference format: " + ref); } String url = urlEndIndex == 0 ? null : ref.substring(0, urlEndIndex); String pointerText = ref.substring(urlEndIndex + 1); JsonPointer pointer = JsonPointer.compile(pointerText); return new JsonReference(url, pointer); } JsonReference(JsonPointer pointer);  JsonReference(String url, JsonPointer pointer); boolean isExternal(); @Override String toString();  }### Answer:
@Test public void shouldParseInternalRef() { JsonReference reference = JsonReference.parse("#/parse/internal"); assertThat(reference.url).isNull(); assertThat(reference.pointer).hasToString("/parse/internal"); }
@Test public void shouldParseExternalRef() { JsonReference reference = JsonReference.parse("schema.json#/parse/external"); assertThat(reference.url).isEqualTo("schema.json"); assertThat(reference.pointer).hasToString("/parse/external"); }
@Test public void shouldNotParseInvalidRef() { assertThatThrownBy(() -> JsonReference.parse("/parse/invalid")) .isInstanceOf(IllegalArgumentException.class); }
@Test public void shouldFormatInternalRefToString() { assertThat(JsonReference.parse("#/format/internal")).hasToString("#/format/internal"); }
@Test public void shouldFormatExternalRefToString() { assertThat(JsonReference.parse("schema.json#/format/external")) .hasToString("schema.json#/format/external"); }