@TestFactory
    @Execution(ExecutionMode.SAME_THREAD)
    Stream<DynamicTest> testNoExtraProps() {
        return buildRelatedResourceTests(clazz -> {
            // Try and find the no args constructor if there is any.
            if (!Modifier.isInterface(clazz.getModifiers()) && !clazz.isEnum()) {
                final Set<String> fieldNames = new HashSet<>();
                final Field[] fields = clazz.getDeclaredFields();
                for (final Field field : fields) {
                    final JsonIgnore jsonIgnore = field.getDeclaredAnnotation(JsonIgnore.class);
                    if (jsonIgnore == null) {
                        final String fieldName = normaliseFieldName(field.getName());
                        fieldNames.add(fieldName);
                    }
                }

                final Set<String> getters = new HashSet<>();
                final Set<String> setters = new HashSet<>();
                final Set<String> uselessIgnore = new HashSet<>();
                final Method[] methods = clazz.getDeclaredMethods();
                for (final Method method : methods) {
                    final JsonIgnore jsonIgnore = method.getDeclaredAnnotation(JsonIgnore.class);
                    final String methodName = method.getName();
                    final boolean getter = isGetter(method);
                    final boolean setter = isSetter(method);
                    if (!getter && !setter) {
                        if (jsonIgnore != null) {
                            uselessIgnore.add(methodName);
                        }
                    } else if (jsonIgnore == null) {
                        final String fieldName = convertMethodToFieldName(methodName);
                        if (setter) {
                            setters.add(fieldName);
                        } else {
                            getters.add(fieldName);
                        }
                    }
                }

                final Set<String> additionalGetters = new HashSet<>(getters);
                additionalGetters.removeAll(fieldNames);

                final Set<String> additionalSetters = new HashSet<>(setters);
                additionalSetters.removeAll(fieldNames);

                SoftAssertions.assertSoftly(softly -> {
                    softly.assertThat(additionalGetters)
                            .describedAs(
                                    "%s - Additional getters: %s",
                                    clazz.getName(),
                                    additionalGetters)
                            .isEmpty();

                    softly.assertThat(additionalSetters)
                            .describedAs(
                                    "%s - Additional setters: %s",
                                    clazz.getName(),
                                    additionalSetters)
                            .isEmpty();

                    softly.assertThat(uselessIgnore)
                            .describedAs(
                                    "%s - Useless @JsonIgnore annotation: %s",
                                    clazz.getName(),
                                    uselessIgnore)
                            .isEmpty();
                });
            }

        });
    }
Test that classes that will be subject to JSON serialisation have no extra properties or redundant JSON
annotations.
stroom-app/src/test/java/stroom/importexport/TestJsonSerialisation.java