From 5dd0be30565054e510e57cb1aed1576461ac34af Mon Sep 17 00:00:00 2001 From: pradoshtnair Date: Fri, 19 Jan 2024 03:33:49 +0530 Subject: [PATCH] Basic test on URI create to improve coverage (#923) --- .../com/networknt/schema/UriMappingTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 0e55f9f41..a4f41786f 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -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. @@ -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()); }