Skip to content

Commit

Permalink
Basic test on URI create to improve coverage (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradoshtnair authored Jan 18, 2024
1 parent 48ca8c3 commit 5dd0be3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/test/java/com/networknt/schema/UriMappingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ public class UriMappingTest {
private final ClasspathURLFactory classpathURLFactory = new ClasspathURLFactory();
private final URLFactory urlFactory = new URLFactory();

/**
* Validate URI Create API
*/
@Test
public void testUrlFactoryCreate() {
try {
this.urlFactory.create("://example.com/invalid/schema/url");
fail("Invalid URI, should throw error.");
}
catch(IllegalArgumentException e){

}
catch(Exception e){
fail("Unknown Exception occured ");
}

}

/**
* Validate that a JSON URI Mapping file containing the URI Mapping schema is
* schema valid.
Expand Down Expand Up @@ -113,7 +131,7 @@ public void testValidatorConfigUriMappingUri() throws IOException {
SchemaValidatorsConfig config = new SchemaValidatorsConfig();
config.addUriTranslator(getUriMappingsFromUrl(mappings));
JsonSchema schema = instance.getSchema(this.urlFactory.create(
"https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json"),
"https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json"),
config);
assertEquals(0, schema.validate(mapper.readTree(mappings)).size());
}
Expand Down

0 comments on commit 5dd0be3

Please sign in to comment.