diff --git a/pom.xml b/pom.xml index b27ee69..00d3cab 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.americanexpress.unify.jdocs unify-jdocs - 1.6.0 + 1.7.0 jar unify-jdocs diff --git a/readme.md b/readme.md index c2274ed..a80dbe8 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ JDocs is available as a jar file in Maven central with the following latest Mave ````pom com.americanexpress.unify.jdocs unify-jdocs -1.6.0 +1.7.0 ```` --- diff --git a/src/main/java/com/americanexpress/unify/jdocs/JDocument.java b/src/main/java/com/americanexpress/unify/jdocs/JDocument.java index 8cb4c64..c40a22a 100644 --- a/src/main/java/com/americanexpress/unify/jdocs/JDocument.java +++ b/src/main/java/com/americanexpress/unify/jdocs/JDocument.java @@ -1403,10 +1403,6 @@ protected final void setValue(String path, List tokenList, Object value) } public static String getStaticPath(String path, String... vargs) { - if (vargs.length == 0) { - return path; - } - int size = path.length(); StringBuffer sb = new StringBuffer(); int counter = 0; diff --git a/src/test/java/com/americanexpress/unify/jdocs/DocumentTest.java b/src/test/java/com/americanexpress/unify/jdocs/DocumentTest.java index 5c6ca75..f7f0986 100644 --- a/src/test/java/com/americanexpress/unify/jdocs/DocumentTest.java +++ b/src/test/java/com/americanexpress/unify/jdocs/DocumentTest.java @@ -818,7 +818,7 @@ void testValidateAtReadWriteOnly() { d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json", true); @@ -827,14 +827,14 @@ void testValidateAtReadWriteOnly() { d.getString("$.phone_cell"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } try { d.getString("$.giberish"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } String s = d.getString("$.first_name"); @@ -855,14 +855,14 @@ void testValidateAtReadWriteOnly() { d.validate("sample_23_model"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } try { d.setType("sample_23_model"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d.setType("sample_23_model", true); @@ -871,7 +871,7 @@ void testValidateAtReadWriteOnly() { d.validate("sample_23_model"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // we now set the default to be true @@ -883,14 +883,14 @@ void testValidateAtReadWriteOnly() { d.validate("sample_23_model"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } try { d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json", true); // this should pass @@ -1297,7 +1297,7 @@ void testValidation() { d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json", CONSTS_JDOCS.VALIDATION_TYPE.ALL_DATA_PATHS); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // test - doc construction will succeed but read of field will fail @@ -1306,7 +1306,7 @@ void testValidation() { d.getString("$.phone_cell"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // test - doc construction will succeed but read of field will fail @@ -1315,7 +1315,7 @@ void testValidation() { d.getString("$.phone_cell"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // valid test @@ -1342,7 +1342,7 @@ void testValidation() { d.setType("sample_23_model"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // test only model paths - will succeed @@ -1353,7 +1353,7 @@ void testValidation() { d.validateAllPaths("sample_23_model"); assert (false); } - catch (UnifyException e) { + catch (Exception e) { } // we now set the default to only at read write @@ -1365,7 +1365,7 @@ void testValidation() { d.validateAllPaths("sample_23_model"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d.validateModelPaths("sample_23_model"); // will succeed @@ -1373,7 +1373,7 @@ void testValidation() { d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json", CONSTS_JDOCS.VALIDATION_TYPE.ONLY_MODEL_PATHS); // this should pass @@ -1391,7 +1391,7 @@ void testValidation() { d.validateAllPaths("sample_23_model"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d.validateModelPaths("sample_23_model"); // will succeed @@ -1399,7 +1399,7 @@ void testValidation() { d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json"); // will fail validation here assert (false); } - catch (UnifyException e) { + catch (Exception e) { } d = getTypedDocument("sample_23_model", "/jdocs/sample_23.json", CONSTS_JDOCS.VALIDATION_TYPE.ONLY_MODEL_PATHS); // this should pass @@ -1409,4 +1409,38 @@ void testValidation() { JDocument.init(CONSTS_JDOCS.VALIDATION_TYPE.ALL_DATA_PATHS); } + @Test + void testMissingParams() { + Document d = new JDocument(); + + try { + String s = d.getString("$.names[name=%].first_name"); + assert (false); + } + catch (Exception e) { + } + + try { + String s = d.getString("$.names[name=%].other[number=%].first_name"); + assert (false); + } + catch (Exception e) { + } + + try { + String s = d.getString("$.names[name=%].other[number=%].first_name", "Deepak"); + assert (false); + } + catch (Exception e) { + } + + try { + String s = d.getString("$.names[%].first_name"); + assert (false); + } + catch (Exception e) { + } + + } + }