SchemaException extends RuntimeException { static String buildMessage(String pointer, Class<?> actualType, Class<?> expectedType, Class<?>... furtherExpectedTypes) { requireNonNull(pointer, "pointer cannot be null"); String actualTypeDescr = actualTypeDescr(actualType); if (furtherExpectedTypes != null && furtherExpectedTypes.length > 0) { Class<?>[] allExpecteds = new Class<?>[furtherExpectedTypes.length + 1]; allExpecteds[0] = expectedType; System.arraycopy(furtherExpectedTypes, 0, allExpecteds, 1, furtherExpectedTypes.length); return buildMessage(pointer, actualTypeDescr, asList(allExpecteds)); } return format("%s: expected type: %s, found: %s", pointer, expectedType.getSimpleName(), actualTypeDescr); } SchemaException(String schemaLocation, String message);  SchemaException(String schemaLocation, Class<?> actualType, Class<?> expectedType, Class<?>... furtherExpectedTypes);  SchemaException(String schemaLocation, Class<?> actualType, Collection<Class<?>> expectedTypes);  SchemaException(String schemaLocation, Exception cause); @Deprecated  SchemaException(String message); @Deprecated  SchemaException(String key, Class<?> expectedType, Object actualValue); @Deprecated  SchemaException(String key, List<Class<?>> expectedTypes,
            final Object actualValue); @Deprecated  SchemaException(String message, Throwable cause); @Override boolean equals(Object o); @Override int hashCode(); String getSchemaLocation(); JSONObject toJSON();  }
@Test public void testBuildMessageSingleExcType() { String actual = buildMessage(JSONPointer.builder().build().toURIFragment(), INTEGER_CLASS, String.class); assertEquals("#: expected type: String, found: Integer", actual); }
@Test public void nullJSONPointer() { expExc.expect(NullPointerException.class); expExc.expectMessage("pointer cannot be null"); buildMessage(null, INTEGER_CLASS, String.class); }
@Test public void nullActual() { JSONPointer ptr = JSONPointer.builder().append("required").append("2").build(); String actual = buildMessage(ptr.toURIFragment(), null, String.class); assertEquals("#/required/2: expected type: String, found: null", actual); }
@Test public void twoExpected() { String actual = buildMessage(JSONPointer.builder().build().toURIFragment(), INTEGER_CLASS, String.class, Map.class); assertEquals("#: expected type is one of String or Map, found: Integer", actual); }