@Test(dataProvider = "loopTestData") public void loopsAreDetected(final SchemaNode node) { try { resolver.resolve(node); fail("No exception thrown!"); } catch (JsonSchemaException e) { assertEquals(e.getMessage(), "ref loop detected"); } }
@Test public void sameLocatorIsOnlyLookedUpOnce() throws JsonSchemaException { final String locator = "schema://schema4#"; final URI uri = URI.create(locator); final JsonNode schema = JsonNodeFactory.instance.objectNode().put("$ref", locator); final SchemaContainer container = new SchemaContainer(schema); final SchemaNode node = new SchemaNode(container, schema); resolver.resolve(node); verify(manager, times(1)).getContent(uri); }
@Test(dataProvider = "resolveData") public void resolveWorksAsExpected(final SchemaNode node, final JsonNode expected) throws JsonSchemaException { final SchemaNode ret = resolver.resolve(node); assertEquals(ret.getNode(), expected); }