From 90b12d146481242d8c19a9bbaa8c96fa1ec2be13 Mon Sep 17 00:00:00 2001 From: rolleander Date: Sun, 5 May 2024 18:26:49 +0200 Subject: [PATCH] fix tests --- .../broll/networklib/test/ScannerTest.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/broll/networklib/test/ScannerTest.java b/src/test/java/com/broll/networklib/test/ScannerTest.java index 5d56d85..0afa5d2 100644 --- a/src/test/java/com/broll/networklib/test/ScannerTest.java +++ b/src/test/java/com/broll/networklib/test/ScannerTest.java @@ -13,45 +13,49 @@ public class ScannerTest { @Test - public void scansMethodsCorrectly(){ + public void scansMethodsCorrectly() { Assert.assertArrayEquals(new String[]{"com.broll.networklib.test.ScannerTest$A:test"}, scanPackageReceivers(new A())); Assert.assertArrayEquals(new String[]{"com.broll.networklib.test.ScannerTest$B:test", "com.broll.networklib.test.ScannerTest$B:test2"}, scanPackageReceivers(new B())); - Assert.assertArrayEquals(new String[]{"com.broll.networklib.test.ScannerTest$C:test2", - "com.broll.networklib.test.ScannerTest$A:test"}, + Assert.assertArrayEquals(new String[]{"com.broll.networklib.test.ScannerTest$A:test", + "com.broll.networklib.test.ScannerTest$C:test2" + }, scanPackageReceivers(new C())); } - private String[] scanPackageReceivers(Object o){ - return AnnotationScanner.findAnnotatedMethods(o, PackageReceiver.class).stream().map(m-> - m.getDeclaringClass().getName()+":"+ m.getName()).toArray(String[]::new); + private String[] scanPackageReceivers(Object o) { + return AnnotationScanner.findAnnotatedMethods(o, PackageReceiver.class).stream().map(m -> + m.getDeclaringClass().getName() + ":" + m.getName()).sorted().toArray(String[]::new); } - public static class A{ + public static class A { @PackageReceiver - void test(){ + void test() { } } - public static class B extends A{ + public static class B extends A { @PackageReceiver - void test(){ + @Override + void test() { super.test(); } + @PackageReceiver - void test2(){ + void test2() { } } - public static class C extends A{ + + public static class C extends A { @PackageReceiver - void test2(){ + void test2() { }