SchemaResolver class is not testable for resolution of `https://` related refs
Problem:
The SchemaResolver class performs the task of resolving all kinds of references provided in request. The references are provided with $ref
keyword. The references could be internal one, pointing to a schema within the system or it could be external reference, like this one '"$ref": "https://geojson.org/schema/FeatureCollection.json"'. These are resolved by making https calls to given URL, like this:
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet getRequest = new HttpGet(url);
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
Now, this code works absolutely fine, but it's not testable in unit tests.
Ask:
Move out this logic to a resolve external schemas to a new class, something like ExternalSchemaResolver
and use it in has-a
relationship with SchemaResolver
.
@pbehede assigning this to you. Please reassign accordingly.