SubschemaRegistry { JsonObject getById(String id) { return storage.get(id); } SubschemaRegistry(JsonValue rootJson);   }
@Test public void topLevelIdIsRecognized() { JsonValue obj = JsonValue.of(ResourceLoader.DEFAULT.readObj("testschemas.json").getJSONObject("schemaWithIdV6")); new LoadingState(CONFIG, emptyMap(), obj, obj, null, SchemaLocation.empty()); SubschemaRegistry registry = new SubschemaRegistry(obj); JsonObject actual = registry.getById("http: assertSame(obj, actual); }
@Test public void childInObjById_isRecognized() { JsonValue obj = JsonValue.of(ResourceLoader.DEFAULT.readObj("ref-lookup-tests.json")); new LoadingState(CONFIG, emptyMap(), obj, obj, null, SchemaLocation.empty()); SubschemaRegistry registry = new SubschemaRegistry(obj); JsonObject actual = registry.getById("has-id"); JsonValue expected = obj.requireObject().require("definitions").requireObject().require("HasId"); assertEquals(expected.unwrap(), actual.unwrap()); }
@Test public void childInArrayById_isRecognized() { JsonValue obj = JsonValue.of(ResourceLoader.DEFAULT.readObj("ref-lookup-tests.json")); new LoadingState(CONFIG, emptyMap(), obj, obj, null, SchemaLocation.empty()); SubschemaRegistry registry = new SubschemaRegistry(obj); JsonObject actual = registry.getById("all-of-part-0"); JsonValue expected = obj.requireObject().require("definitions").requireObject().require("someAllOf") .requireObject().require("allOf").requireArray().at(0); assertEquals(expected.unwrap(), actual.unwrap()); }