@TestFactory
    @Execution(ExecutionMode.SAME_THREAD)
    Stream<DynamicTest> testDefaultValues() {
        final ObjectMapper objectMapper = JsonUtil.getMapper();

        return buildRelatedResourceTests(clazz -> {
            // Try and find the no args constructor if there is any.
            if (!Modifier.isInterface(clazz.getModifiers())
                    && !Modifier.isAbstract(clazz.getModifiers())) {

                final Constructor<?>[] constructors = clazz.getDeclaredConstructors();
                Constructor<?> noArgsConstructor = null;
                for (final Constructor<?> constructor : constructors) {
                    if (constructor.getParameterCount() == 0) {
                        noArgsConstructor = constructor;
                    }
                }

                if (noArgsConstructor != null) {
                    noArgsConstructor.setAccessible(true);

                    final String json1;
                    final String json2;
                    try {
                        Object o = noArgsConstructor.newInstance();
                        json1 = objectMapper.writeValueAsString(o);
                        Object o2 = objectMapper.readValue(json1, clazz);
                        json2 = objectMapper.writeValueAsString(o2);
                    } catch (InstantiationException
                             | IllegalAccessException
                             | InvocationTargetException
                             | IOException e) {
                        throw new RuntimeException(e);
                    }

                    Assertions.assertThat(json2)
                            .describedAs(
                                    "%s - Checking default values on (de)serialisation", clazz.getName())
                            .isEqualTo(json1);
                }
            }
        });

    }
Tests that constructing an object with the default constructor, serialising, de-serialising, re-serialising,
looks the same.
stroom-app/src/test/java/stroom/importexport/TestJsonSerialisation.java