CombinedSchemaLoader implements SchemaExtractor { @Override public ExtractionResult extract(JsonObject schemaJson) { Set<String> presentKeys = COMB_SCHEMA_PROVIDERS.keySet().stream() .filter(schemaJson::containsKey) .collect(toSet()); Collection<Schema.Builder<?>> extractedSchemas = presentKeys.stream().map(key -> loadCombinedSchemaForKeyword(schemaJson, key)) .collect(toList()); return new ExtractionResult(presentKeys, extractedSchemas); } CombinedSchemaLoader(SchemaLoader defaultLoader); @Override ExtractionResult extract(JsonObject schemaJson);  }
@Test public void multipleCombinedSchemasAtTheSameNestingLevel() { SchemaLoader defaultLoader = SchemaLoader.builder().schemaJson(get("multipleKeywords")).build(); JsonObject json = JsonValue.of(get("multipleKeywords")).requireObject(); new LoadingState(LoaderConfig.defaultV4Config(), emptyMap(), json, json, null, SchemaLocation.empty()); CombinedSchemaLoader subject = new CombinedSchemaLoader(defaultLoader); Set<Schema> actual = new HashSet<>( subject.extract(json).extractedSchemas.stream().map(builder -> builder.build()).collect(toList())); HashSet<CombinedSchema> expected = new HashSet<>(asList( CombinedSchema.allOf(singletonList(BooleanSchema.INSTANCE)).build(), CombinedSchema.anyOf(singletonList(StringSchema.builder().build())).build() )); assertEquals(expected, actual); }