@@ -0,0 +1,2463 @@
+/*%0A * Copyright (C) 2017 Republic Wireless%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.rw.legion.columncheck;%0A%0Aimport com.google.gson.JsonObject;%0Aimport com.google.gson.JsonParseException;%0Aimport com.google.gson.JsonParser;%0A%0Aimport java.util.regex.Pattern;%0Aimport java.util.regex.PatternSyntaxException;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport static org.junit.jupiter.api.Assertions.*;%0A%0Aclass RegexCheckerTest %7B%0A%0A    private JsonObject buildJson (String pattern) %7B%0A        if (pattern == null) %7B%0A            return new JsonObject();%0A        %7D%0A%0A        String json = %22%5Cn%22 +%0A                %22%7B%5Cn%22 +%0A                %22  %5C%22regex%5C%22: %5C%22%22 + pattern + %22%5C%22%5Cn%22 +%0A                %22%7D%22;%0A%0A        JsonParser parser = new JsonParser();%0A        JsonObject obj = parser.parse(json).getAsJsonObject();%0A%0A        return obj;%0A    %7D%0A%0A    @Test%0A    void validatesValid() %7B%0A        String validRegex = %22(1?)(-?)(%5B0-9%5D%7B3%7D)(-?)(%5B0-9%5D%7B3%7D)(-?)(%5B0-9%5D%7B4%7D)%22;%0A        String validMatch1 = %220001112233%22;%0A        String validMatch2 = %22000-111-2233%22;%0A        String validMatch3 = %2210001112233%22;%0A        String validMatch4 = %221-000-111-2233%22;%0A        String validNonMatch = %2299988877776666%22;%0A        RegexChecker rc = new RegexChecker(buildJson(validRegex));%0A%0A        assertEquals(Pattern.compile(validRegex).pattern(), rc.getPattern().pattern());%0A        assertEquals(true, rc.validates(validMatch1));%0A        assertEquals(true, rc.validates(validMatch2));%0A        assertEquals(true, rc.validates(validMatch3));%0A        assertEquals(true, rc.validates(validMatch4));%0A        assertEquals(false, rc.validates(validNonMatch));%0A    %7D%0A%0A    @Test%0A    void validatesInvalid() %7B%0A        String invalidRegex = %22(mismatched%22;%0A        assertThrows(PatternSyntaxException.class, () -%3E new RegexChecker(buildJson(invalidRegex)));%0A    %7D%0A%0A    @Test%0A    void validatesMissing() %7B%0A        assertThrows(JsonParseException.class, () -%3E new RegexChecker(buildJson(null)));%0A    %7D%0A%0A%7D%0A

Add RegexChecker unit tests