From 9b27bced03940c2e28223f7cceb59833bcfc7857 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Wed, 25 Sep 2019 20:08:52 -0500 Subject: [PATCH] Fixed problem with AuthorityTest & LatencyNodeProviderTest --- .../cy/agorise/graphenej/AuthorityTest.java | 3 ++- .../network/LatencyNodeProviderTest.java | 22 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/graphenej/src/test/java/cy/agorise/graphenej/AuthorityTest.java b/graphenej/src/test/java/cy/agorise/graphenej/AuthorityTest.java index 23109f1..f364fbc 100644 --- a/graphenej/src/test/java/cy/agorise/graphenej/AuthorityTest.java +++ b/graphenej/src/test/java/cy/agorise/graphenej/AuthorityTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import java.util.HashMap; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * Created by nelson on 12/16/16. @@ -48,7 +49,7 @@ public class AuthorityTest { @Test public void equals() throws Exception { assertEquals("Equal authorities", authority, sameAuthority); - assertEquals("Different authorities ", authority, differentAuthority); + assertNotEquals("Different authorities ", authority, differentAuthority); assertEquals("Two public keys with the same public key should be equal", keyAuthority1, keyAuthority2); } diff --git a/graphenej/src/test/java/cy/agorise/graphenej/network/LatencyNodeProviderTest.java b/graphenej/src/test/java/cy/agorise/graphenej/network/LatencyNodeProviderTest.java index 2501053..5f8c9a3 100644 --- a/graphenej/src/test/java/cy/agorise/graphenej/network/LatencyNodeProviderTest.java +++ b/graphenej/src/test/java/cy/agorise/graphenej/network/LatencyNodeProviderTest.java @@ -1,11 +1,11 @@ package cy.agorise.graphenej.network; -import junit.framework.Assert; - import org.junit.Test; import java.util.List; +import static org.junit.Assert.assertEquals; + public class LatencyNodeProviderTest { private FullNode nodeA, nodeB, nodeC; private LatencyNodeProvider latencyNodeProvider; @@ -34,9 +34,9 @@ public class LatencyNodeProviderTest { // Confirming that the getSortedNodes gives us a sorted list of nodes in increasing latency order List fullNodeList = latencyNodeProvider.getSortedNodes(); - Assert.assertSame(nodeC, fullNodeList.get(0)); - Assert.assertSame(nodeB, fullNodeList.get(1)); - Assert.assertSame(nodeA, fullNodeList.get(2)); + assertEquals(nodeC, fullNodeList.get(0)); + assertEquals(nodeB, fullNodeList.get(1)); + assertEquals(nodeA, fullNodeList.get(2)); // Adding more nodes with different latencies measurements FullNode nodeD = new FullNode("wss://nodeD"); @@ -55,11 +55,11 @@ public class LatencyNodeProviderTest { FullNode bestNode = latencyNodeProvider.getBestNode(); // Checking for best node - Assert.assertSame("Verifying that the nodeE is the best now", nodeE, bestNode); + assertEquals("Verifying that the nodeE is the best now", nodeE, bestNode); fullNodeList = latencyNodeProvider.getSortedNodes(); FullNode worstNode = fullNodeList.get(fullNodeList.size() - 1); // Checking for worst node - Assert.assertSame("Verifying that the nodeF is the worst now", nodeF, worstNode); + assertEquals("Verifying that the nodeF is the worst now", nodeF, worstNode); } @Test @@ -68,7 +68,7 @@ public class LatencyNodeProviderTest { // Confirming that the best node is nodeC FullNode bestNode = latencyNodeProvider.getBestNode(); - Assert.assertSame("Check that the best node is nodeC", nodeC, bestNode); + assertEquals("Check that the best node is nodeC", nodeC, bestNode); // Improving nodeA score by feeding it with new better latency measurements latencyNodeProvider.updateNode(nodeA, 10); @@ -80,7 +80,7 @@ public class LatencyNodeProviderTest { latencyNodeProvider.updateNode(nodeA); bestNode = latencyNodeProvider.getBestNode(); System.out.println("Best node latency after update: "+bestNode.getLatencyValue()); - Assert.assertSame("Check that the best node now is the nodeA", nodeA, bestNode); + assertEquals("Check that the best node now is the nodeA", nodeA, bestNode); } @Test @@ -89,7 +89,7 @@ public class LatencyNodeProviderTest { nodeA.addLatencyValue(Long.MAX_VALUE); latencyNodeProvider.updateNode(nodeA); FullNode best = latencyNodeProvider.getBestNode(); - Assert.assertSame(nodeC, best); + assertEquals(nodeC, best); } @Test @@ -174,6 +174,6 @@ public class LatencyNodeProviderTest { provider.updateNode(node20); FullNode best = provider.getBestNode(); - Assert.assertSame("Expects node4 to be the best", node4, best); + assertEquals("Expects node4 to be the best", node4, best); } }