JSONSerialiser { @Deprecated public static void update(final String jsonSerialiserClass, final String jsonSerialiserModules) { update(jsonSerialiserClass, jsonSerialiserModules, null); } protected  JSONSerialiser(); protected  JSONSerialiser(final ObjectMapper mapper); static void addSimpleClassNames(final boolean includeSubtypes, final Class... classes); @Deprecated static void update(final String jsonSerialiserClass, final String jsonSerialiserModules); static void update(final String jsonSerialiserClass,
                              final String jsonSerialiserModules,
                              final Boolean strictJson); static void update(); static ObjectMapper createDefaultMapper(); static FilterProvider getFilterProvider(final String... fieldsToExclude); static boolean canHandle(final Class clazz); static byte[] serialise(final Object object, final String... fieldsToExclude); static byte[] serialise(final Object object, final boolean prettyPrint, final String... fieldsToExclude); static void serialise(final Object object, final JsonGenerator jsonGenerator, final boolean prettyPrint, final String... fieldsToExclude); static T deserialise(final String json, final Class<T> clazz); static T deserialise(final byte[] bytes, final Class<T> clazz); static T deserialise(final InputStream stream, final Class<T> clazz); static T deserialise(final byte[] bytes, final TypeReference<T> type); static T deserialise(final InputStream stream, final TypeReference<T> type); static JsonNode getJsonNodeFromString(final String content); @JsonIgnore static ObjectMapper getMapper(); @JsonIgnore static JSONSerialiser getInstance(); static final String JSON_SERIALISER_CLASS_KEY; static final String JSON_SERIALISER_MODULES; static final String DEFAULT_SERIALISER_CLASS_NAME; static final String STRICT_JSON; static final boolean STRICT_JSON_DEFAULT; static final String FILTER_FIELDS_BY_NAME; }
@Test public void shouldThrowExceptionWhenUpdateInstanceWithInvalidClassName() throws Exception { System.setProperty(JSONSerialiser.JSON_SERIALISER_CLASS_KEY, "invalidClassName"); try { JSONSerialiser.update(); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("invalidClassName")); } }
@Test public void shouldThrowExceptionWhenUpdateInstanceWithInvalidModuleClass() throws Exception { System.setProperty(JSONSerialiser.JSON_SERIALISER_MODULES, "module1"); try { JSONSerialiser.update(); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("module1")); } }
@Test public void shouldThrowExceptionWhenUpdateInstanceWithInvalidModulesValue() throws Exception { final String invalidValue = TestCustomJsonModules1.class.getName() + "-" + TestCustomJsonModules2.class.getName(); System.setProperty(JSONSerialiser.JSON_SERIALISER_MODULES, invalidValue); try { JSONSerialiser.update(); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains(invalidValue)); } }