diff --git a/test/aud/exam/prep/SequenceProcessorTest.java b/test/aud/exam/prep/SequenceProcessorTest.java index 3b5ca5a..b6d0ac2 100644 --- a/test/aud/exam/prep/SequenceProcessorTest.java +++ b/test/aud/exam/prep/SequenceProcessorTest.java @@ -239,10 +239,7 @@ public abstract class SequenceProcessorTest { void testThat_maxWorks(List list) { list.add(-1); S s = processor.create(list); - var max = list - .stream() - .max(CMP) - .orElseThrow(); + Integer max = Tests.getMax(list); assertEquals(max, processor.max(s, CMP)); } @@ -252,12 +249,7 @@ public abstract class SequenceProcessorTest { list.add(-1); list.add(-2); S s = processor.create(list); - var max = list - .stream() - .sorted(CMP.reversed()) - .skip(1) - .findFirst() - .orElseThrow(); + Integer max = Tests.getSecondMax(list); assertEquals(max, processor.secondMax(s, CMP)); } diff --git a/test/aud/exam/prep/Tests.java b/test/aud/exam/prep/Tests.java index 761903b..edb0a2d 100644 --- a/test/aud/exam/prep/Tests.java +++ b/test/aud/exam/prep/Tests.java @@ -19,4 +19,20 @@ public class Tests { .boxed() .collect(Collectors.toList()); } -} + + public static Integer getMax(List list) { + return list + .stream() + .max(CMP) + .orElseThrow(); + } + + public static Integer getSecondMax(List list) { + return list + .stream() + .sorted(CMP.reversed()) + .skip(1) + .findFirst() + .orElseThrow(); + } +} \ No newline at end of file