Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolleander committed May 5, 2024
1 parent 7080aea commit 90b12d1
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/test/java/com/broll/networklib/test/ScannerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

}

Expand Down

0 comments on commit 90b12d1

Please sign in to comment.