diff --git a/src/test/java/eu/m724/wtapi/thunder/BlitzortungTest.java b/src/test/java/eu/m724/wtapi/thunder/BlitzortungTest.java index 1890941..8015522 100644 --- a/src/test/java/eu/m724/wtapi/thunder/BlitzortungTest.java +++ b/src/test/java/eu/m724/wtapi/thunder/BlitzortungTest.java @@ -15,9 +15,7 @@ public class BlitzortungTest { ThunderProvider provider = new BlitzortungProvider(); - provider.registerStrikeHandler(coordinates -> { - coordinatesList.add(coordinates); - }); + provider.registerStrikeHandler(coordinatesList::add); provider.init(); @@ -28,10 +26,10 @@ public class BlitzortungTest { int size = coordinatesList.size(); if (size > 0) System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size); - Thread.sleep(100); + Thread.sleep(25); } - System.out.printf("Strikes in the last 10s: %d\n", coordinatesList.size()); + System.out.printf("Strikes in the last 3s: %d\n", coordinatesList.size()); System.out.printf("Latency: %dms\n", provider.getLatency()); } diff --git a/src/test/java/eu/m724/wtapi/thunder/MockThunderProvider.java b/src/test/java/eu/m724/wtapi/thunder/MockThunderProvider.java index 8272982..f864362 100644 --- a/src/test/java/eu/m724/wtapi/thunder/MockThunderProvider.java +++ b/src/test/java/eu/m724/wtapi/thunder/MockThunderProvider.java @@ -27,7 +27,7 @@ public class MockThunderProvider extends ThunderProvider { long now = System.currentTimeMillis(); for (int i=0; i<40; i++) { - strikes.add(new TimedStrike(now + i * 100, + strikes.add(new TimedStrike(now + i * 50, new Coordinates( rnd.nextDouble(-90, 90), rnd.nextDouble(-180, 180) @@ -46,7 +46,7 @@ public class MockThunderProvider extends ThunderProvider { public void tick() { long now = System.currentTimeMillis(); - while (strikes.size() > 0) { + while (!strikes.isEmpty()) { TimedStrike str = strikes.get(0); if (now > str.timestamp) { System.out.printf("mock thunder given: %d\n", str.timestamp); diff --git a/src/test/java/eu/m724/wtapi/thunder/ThunderProviderTest.java b/src/test/java/eu/m724/wtapi/thunder/ThunderProviderTest.java index 2ca3a29..5c6b299 100644 --- a/src/test/java/eu/m724/wtapi/thunder/ThunderProviderTest.java +++ b/src/test/java/eu/m724/wtapi/thunder/ThunderProviderTest.java @@ -14,8 +14,7 @@ public class ThunderProviderTest { ThunderProvider provider = new MockThunderProvider(); - provider.registerStrikeHandler(coordinates -> - coordinatesList.add(coordinates)); + provider.registerStrikeHandler(coordinatesList::add); provider.init(); @@ -26,14 +25,14 @@ public class ThunderProviderTest { int size = coordinatesList.size(); if (size > 0) System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size); - Thread.sleep(50); + Thread.sleep(20); } provider.stop(); - System.out.printf("Strikes in the last 2.5s: %d\n", coordinatesList.size()); + System.out.printf("Strikes in the last 1s: %d\n", coordinatesList.size()); System.out.printf("Latency: %dms\n", provider.getLatency()); - - assert coordinatesList.size() == 25; // TODO this is time sensitive and fails under loaded system + + assert coordinatesList.size() == 20; // TODO this is time sensitive and fails under loaded system. Also, the entire test is suboptimal } }