Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic test on URI create to improve coverage #923

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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