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

[tor-commits] [onionoo/master] Use Arrays.asList with varargs.



commit 81b186c3bf2b97c8eb35cc6e83588ad9d2e94800
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 16:16:12 2018 +0200

    Use Arrays.asList with varargs.
---
 .../onionoo/server/MostFrequentString.java         |  2 +-
 .../torproject/onionoo/server/ResourceServlet.java |  4 +-
 .../onionoo/docs/SummaryDocumentTest.java          | 14 +++---
 .../torproject/onionoo/docs/UptimeStatusTest.java  |  4 +-
 .../onionoo/server/ResourceServletTest.java        | 53 +++++++++++-----------
 .../server/SummaryDocumentComparatorTest.java      | 14 +++---
 .../onionoo/writer/UptimeDocumentWriterTest.java   |  8 ++--
 7 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
index dc9bb02..3d4d4c2 100644
--- a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
+++ b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
@@ -35,7 +35,7 @@ class MostFrequentString {
     for (Map.Entry<String, Integer> e : stringFrequencies.entrySet()) {
       if (!sortedFrequencies.containsKey(e.getValue())) {
         sortedFrequencies.put(e.getValue(), new TreeSet<>(
-            Arrays.asList(new String[] { e.getKey() } )));
+            Arrays.asList(e.getKey())));
       } else {
         sortedFrequencies.get(e.getValue()).add(e.getKey());
       }
diff --git a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
index dce5601..4257348 100644
--- a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
+++ b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
@@ -592,10 +592,10 @@ public class ResourceServlet extends HttpServlet {
       Pattern.compile("^[0-9a-zA-Z_,-]*$");
 
   private static HashSet<String> knownOrderParameters = new HashSet<>(
-      Arrays.asList(new String[] { OrderParameterValues.CONSENSUS_WEIGHT_ASC,
+      Arrays.asList(OrderParameterValues.CONSENSUS_WEIGHT_ASC,
           OrderParameterValues.CONSENSUS_WEIGHT_DES,
           OrderParameterValues.FIRST_SEEN_ASC,
-          OrderParameterValues.FIRST_SEEN_DES }));
+          OrderParameterValues.FIRST_SEEN_DES));
 
   private String[] parseOrderParameter(String parameter) {
     if (!orderParameterPattern.matcher(parameter).matches()) {
diff --git a/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java b/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java
index 120a226..be183e3 100644
--- a/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java
+++ b/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java
@@ -16,18 +16,18 @@ public class SummaryDocumentTest {
   private SummaryDocument createSummaryDocumentRelayTorkaZ() {
     return new SummaryDocument(true, "TorkaZ",
         "000C5F55BD4814B917CC474BD537F1A3B33CCE2A", Arrays.asList(
-        new String[] { "62.216.201.221", "62.216.201.222",
-            "62.216.201.223" }), DateTimeHelper.parse("2013-04-19 05:00:00"),
-        false, new TreeSet<>(Arrays.asList(new String[] { "Running",
-            "Valid" })), 20L, "de",
+        "62.216.201.221", "62.216.201.222",
+        "62.216.201.223"), DateTimeHelper.parse("2013-04-19 05:00:00"),
+        false, new TreeSet<>(Arrays.asList("Running",
+        "Valid")), 20L, "de",
         DateTimeHelper.parse("2013-04-18 05:00:00"), "AS8767",
         "m-net telekommunikations gmbh",
         "torkaz <klaus dot zufall at gmx dot de> "
         + "<fb-token:np5_g_83jmf=>", new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC",
-            "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B" })),
+        "001C13B3A55A71B977CA65EC85539D79C653A3FC",
+        "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B")),
         new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC" })), null,
+            "001C13B3A55A71B977CA65EC85539D79C653A3FC")), null,
         null, null, null, true);
   }
 
diff --git a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
index 1b567ac..31a7ef9 100644
--- a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
+++ b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
@@ -201,7 +201,7 @@ public class UptimeStatusTest {
   }
 
   private static final SortedSet<String> RUNNING_FLAG =
-      new TreeSet<>(Arrays.asList(new String[] { "Running" }));
+      new TreeSet<>(Arrays.asList("Running"));
 
   @Test()
   public void testAddFlagsToNoFlagsEnd() {
@@ -251,7 +251,7 @@ public class UptimeStatusTest {
   }
 
   private static final SortedSet<String> RUNNING_VALID_FLAGS =
-      new TreeSet<>(Arrays.asList(new String[] { "Running", "Valid" }));
+      new TreeSet<>(Arrays.asList("Running", "Valid"));
 
   @Test()
   public void testDontCompressDifferentFlags() {
diff --git a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
index 74fec21..022381b 100644
--- a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
+++ b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
@@ -134,49 +134,50 @@ public class ResourceServletTest {
     org.torproject.onionoo.docs.SummaryDocument relayTorkaZ =
         new org.torproject.onionoo.docs.SummaryDocument(true, "TorkaZ",
         "000C5F55BD4814B917CC474BD537F1A3B33CCE2A", Arrays.asList(
-        new String[] { "62.216.201.221", "62.216.201.222",
-            "62.216.201.223" }), DateTimeHelper.parse("2013-04-19 05:00:00"),
-        false, new TreeSet<>(Arrays.asList(new String[] { "Running",
-            "Valid" })), 20L, "de",
+            "62.216.201.221", "62.216.201.222",
+            "62.216.201.223"), DateTimeHelper.parse("2013-04-19 05:00:00"),
+        false, new TreeSet<>(Arrays.asList("Running",
+            "Valid")), 20L, "de",
         DateTimeHelper.parse("2013-04-18 05:00:00"), "AS8767",
         "m-net telekommunikations gmbh",
         "torkaz <klaus dot zufall at gmx dot de> "
         + "<fb-token:np5_g_83jmf=>", new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC",
-            "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B" })),
+            "001C13B3A55A71B977CA65EC85539D79C653A3FC",
+            "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B")),
         new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC" })),
+            "001C13B3A55A71B977CA65EC85539D79C653A3FC")),
         "0.2.3.25", "linux",
         new TreeSet<>(Arrays.asList(
-            new String[] { "ppp-62-216-201-221.dynamic.mnet-online.de" })),
+            "ppp-62-216-201-221.dynamic.mnet-online.de")),
         null, true);
     this.relays.put("000C5F55BD4814B917CC474BD537F1A3B33CCE2A",
         relayTorkaZ);
     org.torproject.onionoo.docs.SummaryDocument relayFerrari458 =
         new org.torproject.onionoo.docs.SummaryDocument(true, "Ferrari458",
         "001C13B3A55A71B977CA65EC85539D79C653A3FC", Arrays.asList(
-        new String[] { "68.38.171.200", "[2001:4f8:3:2e::51]" }),
+            "68.38.171.200", "[2001:4f8:3:2e::51]"),
         DateTimeHelper.parse("2013-04-24 12:00:00"), true,
-        new TreeSet<>(Arrays.asList(new String[] { "Fast", "Named",
-            "Running", "V2Dir", "Valid" })), 1140L, "us",
+        new TreeSet<>(Arrays.asList("Fast", "Named",
+            "Running", "V2Dir", "Valid")), 1140L, "us",
         DateTimeHelper.parse("2013-04-16 18:00:00"), "AS7922",
         "comcast cable communications, llc", null,
-            new TreeSet<>(Arrays.asList(new String[]{
-                "000C5F55BD4814B917CC474BD537F1A3B33CCE2A"})),
-        new TreeSet<>(Arrays.asList(new String[] {
-            "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), null, null,
         new TreeSet<>(Arrays.asList(
-            new String[] {"c-68-38-171-200.hsd1.in.comcast.net"})),
+            "000C5F55BD4814B917CC474BD537F1A3B33CCE2A")),
+        new TreeSet<>(Arrays.asList(
+            "000C5F55BD4814B917CC474BD537F1A3B33CCE2A")),
+        null, null,
+        new TreeSet<>(Arrays.asList(
+            "c-68-38-171-200.hsd1.in.comcast.net")),
         null, null);
     this.relays.put("001C13B3A55A71B977CA65EC85539D79C653A3FC",
         relayFerrari458);
     org.torproject.onionoo.docs.SummaryDocument relayTimMayTribute =
         new org.torproject.onionoo.docs.SummaryDocument(true, "TimMayTribute",
         "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B", Arrays.asList(
-        new String[] { "89.69.68.246" }),
+            "89.69.68.246"),
         DateTimeHelper.parse("2013-04-22 20:00:00"), false,
-        new TreeSet<>(Arrays.asList(new String[] { "Fast",
-            "Running", "Unnamed", "V2Dir", "Valid" })), 63L, "a1",
+        new TreeSet<>(Arrays.asList("Fast",
+            "Running", "Unnamed", "V2Dir", "Valid")), 63L, "a1",
         DateTimeHelper.parse("2013-04-16 18:00:00"), null,
         "liberty global operations b.v.",
         "1024d/51e2a1c7 \"steven j. murdoch\" "
@@ -189,9 +190,9 @@ public class ResourceServletTest {
     org.torproject.onionoo.docs.SummaryDocument bridgeec2bridgercc7f31fe =
         new org.torproject.onionoo.docs.SummaryDocument(false,
         "ec2bridgercc7f31fe", "0000831B236DFF73D409AD17B40E2A728A53994F",
-        Arrays.asList(new String[] { "10.199.7.176" }),
+        Arrays.asList("10.199.7.176"),
         DateTimeHelper.parse("2013-04-21 18:07:03"), false,
-        new TreeSet<>(Arrays.asList(new String[] { "Valid" })), -1L,
+        new TreeSet<>(Arrays.asList("Valid")), -1L,
         null, DateTimeHelper.parse("2013-04-20 15:37:04"), null, null, null,
         null, null, "0.2.2.39", null, null, null, true);
     this.bridges.put("0000831B236DFF73D409AD17B40E2A728A53994F",
@@ -199,9 +200,9 @@ public class ResourceServletTest {
     org.torproject.onionoo.docs.SummaryDocument bridgeUnnamed =
         new org.torproject.onionoo.docs.SummaryDocument(false, "Unnamed",
         "0002D9BDBBC230BD9C78FF502A16E0033EF87E0C", Arrays.asList(
-        new String[] { "10.0.52.84" }),
+            "10.0.52.84"),
         DateTimeHelper.parse("2013-04-20 17:37:04"), false,
-        new TreeSet<>(Arrays.asList(new String[] { "Valid" })), -1L,
+        new TreeSet<>(Arrays.asList("Valid")), -1L,
         null, DateTimeHelper.parse("2013-04-14 07:07:05"), null, null, null,
         null, null, null, null, null, null, null);
     this.bridges.put("0002D9BDBBC230BD9C78FF502A16E0033EF87E0C",
@@ -209,10 +210,10 @@ public class ResourceServletTest {
     org.torproject.onionoo.docs.SummaryDocument bridgegummy =
         new org.torproject.onionoo.docs.SummaryDocument(false, "gummy",
         "1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756", Arrays.asList(
-        new String[] { "10.63.169.98" }),
+            "10.63.169.98"),
         DateTimeHelper.parse("2013-04-24 01:07:04"), true,
-        new TreeSet<>(Arrays.asList(new String[] { "Running",
-            "Valid" })), -1L, null,
+        new TreeSet<>(Arrays.asList("Running",
+            "Valid")), -1L, null,
         DateTimeHelper.parse("2013-01-16 21:07:04"), null, null, null, null,
         null, "0.2.4.4-alpha-dev", "windows 7", null, null, false);
     this.bridges.put("1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756",
diff --git a/src/test/java/org/torproject/onionoo/server/SummaryDocumentComparatorTest.java b/src/test/java/org/torproject/onionoo/server/SummaryDocumentComparatorTest.java
index 44db510..92922f0 100644
--- a/src/test/java/org/torproject/onionoo/server/SummaryDocumentComparatorTest.java
+++ b/src/test/java/org/torproject/onionoo/server/SummaryDocumentComparatorTest.java
@@ -29,18 +29,18 @@ public class SummaryDocumentComparatorTest {
   private SummaryDocument createSummaryDoc() {
     return new SummaryDocument(true, "TorkaZ",
         "000C5F55BD4814B917CC474BD537F1A3B33CCE2A", Arrays.asList(
-        new String[] { "62.216.201.221", "62.216.201.222",
-            "62.216.201.223" }), DateTimeHelper.parse("2013-04-19 05:00:00"),
-        false, new TreeSet<>(Arrays.asList(new String[] { "Running",
-            "Valid" })), 20L, "de",
+        "62.216.201.221", "62.216.201.222",
+        "62.216.201.223"), DateTimeHelper.parse("2013-04-19 05:00:00"),
+        false, new TreeSet<>(Arrays.asList("Running",
+        "Valid")), 20L, "de",
         DateTimeHelper.parse("2013-04-18 05:00:00"), "AS8767",
         "m-net telekommunikations gmbh",
         "torkaz <klaus dot zufall at gmx dot de> "
         + "<fb-token:np5_g_83jmf=>", new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC",
-            "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B" })),
+        "001C13B3A55A71B977CA65EC85539D79C653A3FC",
+        "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B")),
         new TreeSet<>(Arrays.asList(
-        new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC" })), null,
+            "001C13B3A55A71B977CA65EC85539D79C653A3FC")), null,
         null, null, null, null);
   }
 
diff --git a/src/test/java/org/torproject/onionoo/writer/UptimeDocumentWriterTest.java b/src/test/java/org/torproject/onionoo/writer/UptimeDocumentWriterTest.java
index 2f322bd..795db56 100644
--- a/src/test/java/org/torproject/onionoo/writer/UptimeDocumentWriterTest.java
+++ b/src/test/java/org/torproject/onionoo/writer/UptimeDocumentWriterTest.java
@@ -167,7 +167,7 @@ public class UptimeDocumentWriterTest {
         UptimeDocument.class, GABELMOO_FINGERPRINT);
     this.assertOneWeekGraph(document, 1, "2014-03-23 09:30:00",
         "2014-03-23 11:30:00", 3,
-        Arrays.asList(new Integer[] { 999, 0, 999 }));
+        Arrays.asList(999, 0, 999));
   }
 
   @Test
@@ -183,7 +183,7 @@ public class UptimeDocumentWriterTest {
         UptimeDocument.class, GABELMOO_FINGERPRINT);
     this.assertOneWeekGraph(document, 1, "2014-03-23 09:30:00",
         "2014-03-23 11:30:00", 3,
-        Arrays.asList(new Integer[] { 999, 999, 0 }));
+        Arrays.asList(999, 999, 0));
   }
 
   @Test
@@ -244,7 +244,7 @@ public class UptimeDocumentWriterTest {
         UptimeDocument.class, GABELMOO_FINGERPRINT);
     this.assertOneMonthGraph(document, 2, "2014-03-16 10:00:00",
         "2014-03-16 14:00:00", 2,
-        Arrays.asList(new Integer[] { 999, 499 }));
+        Arrays.asList(999, 499));
   }
 
   @Test
@@ -280,7 +280,7 @@ public class UptimeDocumentWriterTest {
     UptimeDocument document = this.documentStore.getDocument(
         UptimeDocument.class, GABELMOO_FINGERPRINT);
     this.assertFiveYearGraph(document, 1, "2012-03-06 00:00:00",
-        "2012-03-16 00:00:00", 2, Arrays.asList(new Integer[] { 999, 999 }));
+        "2012-03-16 00:00:00", 2, Arrays.asList(999, 999));
   }
 }
 



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