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

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



commit b515520fd41f14ebdd0e570b83c10749a3b6efb0
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 16:17:59 2018 +0200

    Use Arrays.asList with varargs.
---
 .../impl/RelayNetworkStatusConsensusImplTest.java  | 10 ++---
 .../impl/RelayNetworkStatusVoteImplTest.java       |  8 ++--
 .../descriptor/impl/ServerDescriptorImplTest.java  | 45 +++++++++++-----------
 .../torproject/descriptor/index/IndexNodeTest.java | 16 ++++----
 4 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index ca8c8e3..53d79c7 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -796,7 +796,7 @@ public class RelayNetworkStatusConsensusImplTest {
     RelayNetworkStatusConsensus consensus = ConsensusBuilder
         .createWithRecommendedClientProtocolsLine(
         "recommended-client-protocols Cons=1,2,3");
-    assertEquals(new TreeSet<Long>(Arrays.asList(new Long[] { 1L, 2L, 3L })),
+    assertEquals(new TreeSet<>(Arrays.asList(1L, 2L, 3L)),
         consensus.getRecommendedClientProtocols().get("Cons"));
   }
 
@@ -806,7 +806,7 @@ public class RelayNetworkStatusConsensusImplTest {
     RelayNetworkStatusConsensus consensus = ConsensusBuilder
         .createWithRecommendedRelayProtocolsLine(
         "recommended-relay-protocols Cons=1,3-4");
-    assertEquals(new TreeSet<Long>(Arrays.asList(new Long[] { 1L, 3L, 4L })),
+    assertEquals(new TreeSet<>(Arrays.asList(1L, 3L, 4L)),
         consensus.getRecommendedRelayProtocols().get("Cons"));
   }
 
@@ -816,8 +816,8 @@ public class RelayNetworkStatusConsensusImplTest {
     RelayNetworkStatusConsensus consensus = ConsensusBuilder
         .createWithRequiredClientProtocolsLine(
         "required-client-protocols Cons=1-3,2-4");
-    assertEquals(new TreeSet<Long>(Arrays.asList(
-        new Long[] { 1L, 2L, 3L, 4L })),
+    assertEquals(new TreeSet<>(Arrays.asList(
+        1L, 2L, 3L, 4L)),
         consensus.getRequiredClientProtocols().get("Cons"));
   }
 
@@ -827,7 +827,7 @@ public class RelayNetworkStatusConsensusImplTest {
     RelayNetworkStatusConsensus consensus = ConsensusBuilder
         .createWithRequiredRelayProtocolsLine(
         "required-relay-protocols Cons=1-1,1-1");
-    assertEquals(new TreeSet<Long>(Arrays.asList(new Long[] { 1L })),
+    assertEquals(new TreeSet<>(Arrays.asList(1L)),
         consensus.getRequiredRelayProtocols().get("Cons"));
   }
 
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index be6567c..9418a9c 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -267,13 +267,13 @@ public class RelayNetworkStatusVoteImplTest {
       return vb.buildVote();
     }
 
-    private List<String> sharedRandCommitLines = Arrays.asList(new String[] {
+    private List<String> sharedRandCommitLines = Arrays.asList(
         "shared-rand-commit 1 sha3-256 "
         + "0232AF901C31A04EE9848595AF9BB7620D4C5B2E "
         + "AAAAAFieVABh3Aauk2h31FVKaW0xIm28T7VPDkzP5nHwoMItxp7iQg==",
         "shared-rand-commit 1 sha3-256 "
         + "14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4 "
-        + "AAAAAFieVAA26LuAu9z2UhalmV7zuczWauSkqp1c/bsPA3AkH85iGw==" });
+        + "AAAAAFieVAA26LuAu9z2UhalmV7zuczWauSkqp1c/bsPA3AkH85iGw==");
 
     private static RelayNetworkStatusVote createWithSharedRandCommitLines(
         List<String> lines) throws DescriptorParseException {
@@ -701,7 +701,7 @@ public class RelayNetworkStatusVoteImplTest {
     RelayNetworkStatusVote vote = vb.buildVote();
     assertEquals(3, vote.getNetworkStatusVersion());
     List<Integer> consensusMethods = Arrays.asList(
-        new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
+        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
     assertEquals(vote.getConsensusMethods(), consensusMethods);
     assertEquals(1322643001000L, vote.getPublishedMillis());
     assertEquals(1322643600000L, vote.getValidAfterMillis());
@@ -1127,7 +1127,7 @@ public class RelayNetworkStatusVoteImplTest {
     RelayNetworkStatusVote vote =
         VoteBuilder.createWithRecommendedRelayProtocolsLine(
         "recommended-relay-protocols Cons=0");
-    assertEquals(new TreeSet<Long>(Arrays.asList(new Long[] { 0L })),
+    assertEquals(new TreeSet<>(Arrays.asList(0L)),
         vote.getRecommendedRelayProtocols().get("Cons"));
   }
 
diff --git a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 977a16e..cd0b5dd 100644
--- a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -470,9 +470,9 @@ public class ServerDescriptorImplTest {
     assertEquals("Tor 0.2.2.35 (git-b04388f9e7546a9f) on Linux i686",
         descriptor.getPlatform());
     assertEquals(new TreeSet<>(Arrays.asList(
-        new Long[]{1L, 2L, 3L, 4L})), descriptor.getProtocols().get("Link"));
+        1L, 2L, 3L, 4L)), descriptor.getProtocols().get("Link"));
     assertEquals(new TreeSet<>(Arrays.asList(
-        new Long[]{1L})), descriptor.getProtocols().get("LinkAuth"));
+        1L)), descriptor.getProtocols().get("LinkAuth"));
     assertEquals(1325390599000L, descriptor.getPublishedMillis());
     assertEquals("D8733048FC8EC9102466AD8F3098622BF1BF71FD",
         descriptor.getFingerprint());
@@ -485,7 +485,7 @@ public class ServerDescriptorImplTest {
     assertTrue(descriptor.isHiddenServiceDir());
     assertEquals("Random Person <nobody AT example dot com>",
         descriptor.getContact());
-    assertEquals(Arrays.asList(new String[] {"reject *:*"}),
+    assertEquals(Arrays.asList("reject *:*"),
         descriptor.getExitPolicyLines());
     assertFalse(descriptor.isHibernating());
     assertNull(descriptor.getFamilyEntries());
@@ -673,9 +673,9 @@ public class ServerDescriptorImplTest {
   public void testProtocolsOpt() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithProtocolsLine("opt protocols Link 1 2 Circuit 1");
-    assertEquals(Arrays.asList(new Integer[] {1, 2}),
+    assertEquals(Arrays.asList(1, 2),
         descriptor.getLinkProtocolVersions());
-    assertEquals(Arrays.asList(new Integer[] {1}),
+    assertEquals(Arrays.asList(1),
         descriptor.getCircuitProtocolVersions());
   }
 
@@ -683,9 +683,9 @@ public class ServerDescriptorImplTest {
   public void testProtocolsNoOpt() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithProtocolsLine("protocols Link 1 2 Circuit 1");
-    assertEquals(Arrays.asList(new Integer[] {1, 2}),
+    assertEquals(Arrays.asList(1, 2),
         descriptor.getLinkProtocolVersions());
-    assertEquals(Arrays.asList(new Integer[] {1}),
+    assertEquals(Arrays.asList(1),
         descriptor.getCircuitProtocolVersions());
   }
 
@@ -710,9 +710,9 @@ public class ServerDescriptorImplTest {
   public void testProtoGreenPurple() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithProtoLine("proto Green=23 Purple=42");
-    assertEquals(new TreeSet<>(Arrays.asList(new Long[]{23L})),
+    assertEquals(new TreeSet<>(Arrays.asList(23L)),
         descriptor.getProtocols().get("Green"));
-    assertEquals(new TreeSet<>(Arrays.asList(new Long[]{42L})),
+    assertEquals(new TreeSet<>(Arrays.asList(42L)),
         descriptor.getProtocols().get("Purple"));
   }
 
@@ -1082,7 +1082,7 @@ public class ServerDescriptorImplTest {
       throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithExitPolicyLines("reject *:*\naccept *:*");
-    assertEquals(Arrays.asList(new String[] {"reject *:*", "accept *:*"}),
+    assertEquals(Arrays.asList("reject *:*", "accept *:*"),
         descriptor.getExitPolicyLines());
   }
 
@@ -1090,7 +1090,7 @@ public class ServerDescriptorImplTest {
   public void testExitPolicyOpt() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithExitPolicyLines("opt reject *:*");
-    assertEquals(Arrays.asList(new String[] {"reject *:*"}),
+    assertEquals(Arrays.asList("reject *:*"),
         descriptor.getExitPolicyLines());
   }
 
@@ -1107,8 +1107,8 @@ public class ServerDescriptorImplTest {
       throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithExitPolicyLines("accept *:80\nreject *:*");
-    assertEquals(Arrays.asList(new String[] {"accept *:80",
-        "reject *:*"}), descriptor.getExitPolicyLines());
+    assertEquals(Arrays.asList("accept *:80",
+        "reject *:*"), descriptor.getExitPolicyLines());
   }
 
   @Test
@@ -1150,8 +1150,8 @@ public class ServerDescriptorImplTest {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithExitPolicyLines("reject 192.168.0.0/16:*\n"
         + "reject 94.134.192.243/255.255.255.0:*");
-    assertEquals(Arrays.asList(new String[] { "reject 192.168.0.0/16:*",
-        "reject 94.134.192.243/255.255.255.0:*"}),
+    assertEquals(Arrays.asList("reject 192.168.0.0/16:*",
+        "reject 94.134.192.243/255.255.255.0:*"),
         descriptor.getExitPolicyLines());
   }
 
@@ -1218,7 +1218,7 @@ public class ServerDescriptorImplTest {
   public void testFamilyOpt() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithFamilyLine("opt family saberrider2008");
-    assertEquals(Arrays.asList(new String[] {"saberrider2008"}),
+    assertEquals(Arrays.asList("saberrider2008"),
         descriptor.getFamilyEntries());
   }
 
@@ -1227,8 +1227,7 @@ public class ServerDescriptorImplTest {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithFamilyLine("family "
         + "$D8733048FC8EC9102466AD8F3098622BF1BF71FD");
-    assertEquals(Arrays.asList(new String[] {
-        "$D8733048FC8EC9102466AD8F3098622BF1BF71FD"}),
+    assertEquals(Arrays.asList("$D8733048FC8EC9102466AD8F3098622BF1BF71FD"),
         descriptor.getFamilyEntries());
   }
 
@@ -1236,7 +1235,7 @@ public class ServerDescriptorImplTest {
   public void testFamilyNickname() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithFamilyLine("family saberrider2008");
-    assertEquals(Arrays.asList(new String[] {"saberrider2008"}),
+    assertEquals(Arrays.asList("saberrider2008"),
         descriptor.getFamilyEntries());
   }
 
@@ -1273,8 +1272,8 @@ public class ServerDescriptorImplTest {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithFamilyLine("family "
         + "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008");
-    assertEquals(Arrays.asList(new String[]
-        { "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008" }),
+    assertEquals(Arrays.asList(
+        "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008"),
         descriptor.getFamilyEntries());
   }
 
@@ -1284,8 +1283,8 @@ public class ServerDescriptorImplTest {
     ServerDescriptor descriptor = DescriptorBuilder
         .createWithFamilyLine("family "
         + "$D8733048FC8EC9102466AD8F3098622BF1BF71FD~saberrider2008");
-    assertEquals(Arrays.asList(new String[]
-        { "$D8733048FC8EC9102466AD8F3098622BF1BF71FD~saberrider2008" }),
+    assertEquals(Arrays.asList(
+        "$D8733048FC8EC9102466AD8F3098622BF1BF71FD~saberrider2008"),
         descriptor.getFamilyEntries());
   }
 
diff --git a/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java b/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
index b5c01e3..6695018 100644
--- a/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
+++ b/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
@@ -95,17 +95,17 @@ public class IndexNodeTest {
     assertTrue(index.retrieveFilesIn(new String[]{"b2"}).isEmpty());
     assertTrue(index.retrieveFilesIn(new String[]{"a1"}).isEmpty());
     SortedMap<String, FileNode> oneFile
-        = index.retrieveFilesIn(new String[]{"a1/p2"});
+        = index.retrieveFilesIn("a1/p2");
     assertFalse(oneFile.isEmpty());
     assertEquals(1330787700_000L,
         oneFile.get("a1/p2/file3").lastModifiedMillis());
     SortedMap<String, FileNode> twoFiles
-        = index.retrieveFilesIn(new String[]{"y", "a1/x", "a1/p1"});
+        = index.retrieveFilesIn("y", "a1/x", "a1/p1");
     assertEquals(2, twoFiles.size());
     assertEquals(1328192040_000L,
         twoFiles.get("a1/p1/file2").lastModifiedMillis());
     SortedMap<String, FileNode> someFile
-        = index.retrieveFilesIn(new String[]{"a1"});
+        = index.retrieveFilesIn("a1");
     assertTrue(someFile.isEmpty());
   }
 
@@ -126,17 +126,17 @@ public class IndexNodeTest {
   public void testRetrieveEmpty() throws Exception {
     URL indexUrl = getClass().getClassLoader().getResource("index1.json");
     IndexNode index = IndexNode.fetchIndex(indexUrl.toString());
-    Map<String, FileNode> map = index.retrieveFilesIn(new String[]{});
+    Map<String, FileNode> map = index.retrieveFilesIn();
     assertTrue("map was " + map, map.isEmpty());
-    map = index.retrieveFilesIn(new String[]{});
+    map = index.retrieveFilesIn();
     assertTrue("map was " + map, map.isEmpty());
-    map = index.retrieveFilesIn(new String[]{"/", null, ""});
+    map = index.retrieveFilesIn("/", null, "");
     assertTrue("map was " + map, map.isEmpty());
     indexUrl = getClass().getClassLoader().getResource("index3.json");
     index = IndexNode.fetchIndex(indexUrl.toString());
-    map = index.retrieveFilesIn(new String[]{"a1/p1"});
+    map = index.retrieveFilesIn("a1/p1");
     assertTrue("map was " + map, map.isEmpty());
-    map = index.retrieveFilesIn(new String[]{"a1/p3"});
+    map = index.retrieveFilesIn("a1/p3");
     assertTrue("map was " + map, map.isEmpty());
   }
 }



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