public static boolean unifiedDiff(final Path expectedFile, final Path actualFile, final int contextLines) {

        boolean areFilesTheSame = true;
        try (final Stream<String> expectedStream = Files.lines(expectedFile);
                final Stream<String> actualStream = Files.lines(actualFile)) {

            final List<String> expectedLines = expectedStream.toList();
            final List<String> actualLines = actualStream.collect(Collectors.toList());

            final Patch<String> patch = DiffUtils.diff(expectedLines, actualLines);

            final List<String> unifiedDiff = DiffUtils.generateUnifiedDiff(
                    expectedFile.toString(),
                    actualFile.toString(),
                    expectedLines,
                    patch,
                    contextLines);

            if (!unifiedDiff.isEmpty()) {
                areFilesTheSame = false;

                LOGGER.error("Differences exist between:\nexpected - {}\nand\nactual - {}",
                        FileUtil.getCanonicalPath(expectedFile),
                        FileUtil.getCanonicalPath(actualFile));

                System.out.println();
                unifiedDiff.forEach(diffLine -> {

                    final ConsoleColour lineColour;
                    if (diffLine.startsWith("+")) {
                        lineColour = ConsoleColour.GREEN;
                    } else if (diffLine.startsWith("-")) {
                        lineColour = ConsoleColour.RED;
                    } else {
                        lineColour = ConsoleColour.NO_COLOUR;
                    }

                    System.out.println(ConsoleColour.colourise(diffLine, lineColour));
                });
                System.out.println(LogUtil.message("\nvimdiff {} {}",
                        FileUtil.getCanonicalPath(expectedFile), FileUtil.getCanonicalPath(actualFile)));

                System.out.println(LogUtil.message(
                        "\nIf you are fully satisfied the differences are valid then you can do\ncp {} {}",
                        FileUtil.getCanonicalPath(actualFile),
                        FileUtil.getCanonicalPath(expectedFile)));
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return areFilesTheSame;
    }
Generate a unified diff of the two files using the specified number of lines of context.
The diff output is sent to system out in coloured form.

@return True if the files are the same
stroom-test-common/src/main/java/stroom/test/common/ComparisonHelper.java