void (@NotNull String json, @NotNull Class<?> clazz, boolean expectedSuccess) { Gson gson = new GsonBuilder() .registerTypeAdapterFactory(NullCheckingFactory.INSTANCE) .create(); boolean success; try { Object result = gson.fromJson(json, clazz); success = true; } catch (JsonMandatoryException e) { success = false; } assertEquals(expectedSuccess, success); }