From 8932f0d9ef4d6247005877e360a0eca2e2b74839 Mon Sep 17 00:00:00 2001 From: Ricardo de Cillo Date: Wed, 8 Mar 2017 13:47:17 +0100 Subject: [PATCH] issue-596 added one more test case and fixed null pointer --- .../validation/schema/diff/StringSchemaDiff.java | 3 ++- .../invalid-schema-evolution-examples.json | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/zalando/nakadi/validation/schema/diff/StringSchemaDiff.java b/src/main/java/org/zalando/nakadi/validation/schema/diff/StringSchemaDiff.java index a47f84714b..49984531fd 100644 --- a/src/main/java/org/zalando/nakadi/validation/schema/diff/StringSchemaDiff.java +++ b/src/main/java/org/zalando/nakadi/validation/schema/diff/StringSchemaDiff.java @@ -17,7 +17,8 @@ static void recursiveCheck(final StringSchema stringSchemaOriginal, final String addChange("maxLength", ATTRIBUTE_VALUE_CHANGED, jsonPath, changes); } else if (!Objects.equals(stringSchemaOriginal.getMinLength(), stringSchemaUpdate.getMinLength())) { addChange("minLength", ATTRIBUTE_VALUE_CHANGED, jsonPath, changes); - } else if (!stringSchemaOriginal.getPattern().pattern().equals(stringSchemaUpdate.getPattern().pattern())) { + } else if (stringSchemaOriginal.getPattern() != null && stringSchemaUpdate.getPattern() != null + && !stringSchemaOriginal.getPattern().pattern().equals(stringSchemaUpdate.getPattern().pattern())) { addChange("pattern", ATTRIBUTE_VALUE_CHANGED, jsonPath, changes); } } diff --git a/src/test/resources/org/zalando/nakadi/validation/invalid-schema-evolution-examples.json b/src/test/resources/org/zalando/nakadi/validation/invalid-schema-evolution-examples.json index 91287ddba3..6091742091 100644 --- a/src/test/resources/org/zalando/nakadi/validation/invalid-schema-evolution-examples.json +++ b/src/test/resources/org/zalando/nakadi/validation/invalid-schema-evolution-examples.json @@ -75,6 +75,18 @@ }, "errors": ["ATTRIBUTE_VALUE_CHANGED #/pattern"] }, + { + "description": "Correctly identifies changes to pattern", + "original_schema": { + "type": "string", + "pattern": "date-time" + }, + "update_schema": { + "type": "string", + "pattern": "date-time" + }, + "errors": [] + }, { "description": "Do not allow changes to maximum number schema", "original_schema": {