PaddedCell { public String canonical() { switch (type) { case CONVERGE: return steps.get(steps.size() - 1); case CYCLE: return Collections.min(steps, Comparator.comparing(String::length).thenComparing(Function.identity())); case DIVERGE: throw new IllegalArgumentException("No canonical form for a diverging result"); default: throw new IllegalArgumentException("Unknown type: " + type); } } private  PaddedCell(File file, Type type, List<String> steps); File file(); Type type(); List<String> steps(); static PaddedCell check(Formatter formatter, File file); static PaddedCell check(Formatter formatter, File file, String originalUnix); boolean misbehaved(); boolean isResolvable(); String canonical(); String userMessage(); static DirtyState calculateDirtyState(Formatter formatter, File file); static DirtyState calculateDirtyState(Formatter formatter, File file, byte[] rawBytes); static DirtyState isClean();  }
@Test public void cycleOrder() { BiConsumer<String, String> testCase = (unorderedStr, canonical) -> { List<String> unordered = Arrays.asList(unorderedStr.split(",")); for (int i = 0; i < unordered.size(); ++i) { Collections.rotate(unordered, 1); PaddedCell result = CYCLE.create(folder.getRoot(), unordered); Assert.assertEquals(canonical, result.canonical()); } }; testCase.accept("a,b,c", "a"); testCase.accept("a,aa,aaa", "a"); testCase.accept("b,aa,aaa", "b"); }