[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/master] Use more appropriate assert methods in tests.



commit d09bfefe943974b966eb487de0e062cac540ba56
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 14:41:26 2018 +0200

    Use more appropriate assert methods in tests.
---
 .../torproject/onionoo/docs/UptimeStatusTest.java   | 21 +++++++--------------
 .../onionoo/updater/UptimeStatusUpdaterTest.java    | 10 ++++++----
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
index aff5ce5..1b567ac 100644
--- a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
+++ b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
@@ -34,8 +34,7 @@ public class UptimeStatusTest {
         uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not same as provided.",
         DateTimeHelper.parse("2013-12-20 00:00:00"),
         newUptimeHistory.getStartMillis());
@@ -55,8 +54,7 @@ public class UptimeStatusTest {
         uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not same as provided.",
         DateTimeHelper.parse("2013-12-20 00:00:00"),
         newUptimeHistory.getStartMillis());
@@ -84,8 +82,7 @@ public class UptimeStatusTest {
         uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 17:00:00"),
         newUptimeHistory.getStartMillis());
@@ -128,8 +125,7 @@ public class UptimeStatusTest {
         3, uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 16:00:00"),
         newUptimeHistory.getStartMillis());
@@ -150,8 +146,7 @@ public class UptimeStatusTest {
         2, uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 17:00:00"),
         newUptimeHistory.getStartMillis());
@@ -176,8 +171,7 @@ public class UptimeStatusTest {
         1, uptimeStatus.getRelayHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getRelayHistory().first();
-    assertEquals("History not for relay.", true,
-        newUptimeHistory.isRelay());
+    assertTrue("History not for relay.", newUptimeHistory.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 16:00:00"),
         newUptimeHistory.getStartMillis());
@@ -198,8 +192,7 @@ public class UptimeStatusTest {
         + "entry.", 1, uptimeStatus.getBridgeHistory().size());
     UptimeHistory newUptimeHistory =
         uptimeStatus.getBridgeHistory().last();
-    assertEquals("History not for bridge.", false,
-        newUptimeHistory.isRelay());
+    assertFalse("History not for bridge.", newUptimeHistory.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 16:00:00"),
         newUptimeHistory.getStartMillis());
diff --git a/src/test/java/org/torproject/onionoo/updater/UptimeStatusUpdaterTest.java b/src/test/java/org/torproject/onionoo/updater/UptimeStatusUpdaterTest.java
index 4797356..df6dd66 100644
--- a/src/test/java/org/torproject/onionoo/updater/UptimeStatusUpdaterTest.java
+++ b/src/test/java/org/torproject/onionoo/updater/UptimeStatusUpdaterTest.java
@@ -4,6 +4,8 @@
 package org.torproject.onionoo.updater;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.torproject.onionoo.docs.DateTimeHelper;
 import org.torproject.onionoo.docs.DocumentStoreFactory;
@@ -75,7 +77,7 @@ public class UptimeStatusUpdaterTest {
       UptimeHistory history = status.getRelayHistory().first();
       assertEquals("History must contain one entry.", 1,
           status.getRelayHistory().size());
-      assertEquals("History not for relay.", true, history.isRelay());
+      assertTrue("History not for relay.", history.isRelay());
       assertEquals("History start millis not as expected.",
           VALID_AFTER_SAMPLE, history.getStartMillis());
       assertEquals("History uptime hours must be 1.", 1,
@@ -111,7 +113,7 @@ public class UptimeStatusUpdaterTest {
     assertEquals("Relay history must contain one entry.", 1,
         status.getRelayHistory().size());
     UptimeHistory history = status.getRelayHistory().first();
-    assertEquals("History not for relay.", true, history.isRelay());
+    assertTrue("History not for relay.", history.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 17:00:00"),
         history.getStartMillis());
@@ -151,7 +153,7 @@ public class UptimeStatusUpdaterTest {
       UptimeHistory history = status.getBridgeHistory().first();
       assertEquals("Bridge history must contain one entry.", 1,
           status.getBridgeHistory().size());
-      assertEquals("History not for bridge.", false, history.isRelay());
+      assertFalse("History not for bridge.", history.isRelay());
       assertEquals("History start millis not as expected.",
           DateTimeHelper.parse("2014-03-21 20:00:00"),
           history.getStartMillis());
@@ -174,7 +176,7 @@ public class UptimeStatusUpdaterTest {
     assertEquals("Bridge history must contain one entry.", 1,
         status.getBridgeHistory().size());
     UptimeHistory history = status.getBridgeHistory().last();
-    assertEquals("History not for bridge.", false, history.isRelay());
+    assertFalse("History not for bridge.", history.isRelay());
     assertEquals("History start millis not as expected.",
         DateTimeHelper.parse("2013-07-22 17:00:00"),
         history.getStartMillis());



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits