From 4fac4bbb8c0018927978d3183dfe1028317af543 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Sat, 5 Mar 2016 06:38:12 -0800 Subject: [PATCH] Changed the usage of test from (junit 3 to 4) from extend to @Test. --- .../src/main/java/meerkat/Registry.java | 4 ++-- .../src/main/java/meerkat/VoterRegistry.java | 2 +- .../registry/LatestMessagesCallBack.java | 2 +- .../src/test/java/SimpleRegistryTest.java | 18 ++++++++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/voter-registry/src/main/java/meerkat/Registry.java b/voter-registry/src/main/java/meerkat/Registry.java index e631675..4580cfe 100644 --- a/voter-registry/src/main/java/meerkat/Registry.java +++ b/voter-registry/src/main/java/meerkat/Registry.java @@ -125,14 +125,14 @@ public class Registry implements VoterRegistry{ } @Override - public void getPersonIDDetails(VoterID voterID, RegistryCallBack callback) { + public void getVoter(VoterID voterID, RegistryCallBack callback) { List addVoterTags = new ArrayList() {{ add(RegistryTags.ID_TAG + voterID.getId()); add(RegistryTags.VOTER_ENTRY_TAG); }}; bulletinBoardClient.readMessages(MessageCollectionUtils.generateFiltersFromTags(addVoterTags), - new LatestMessagesCallBack(callback, signers, "getPersonIDDetails")); + new LatestMessagesCallBack(callback, signers, "getVoter")); } @Override diff --git a/voter-registry/src/main/java/meerkat/VoterRegistry.java b/voter-registry/src/main/java/meerkat/VoterRegistry.java index 8e85db7..e9581b2 100644 --- a/voter-registry/src/main/java/meerkat/VoterRegistry.java +++ b/voter-registry/src/main/java/meerkat/VoterRegistry.java @@ -76,7 +76,7 @@ public interface VoterRegistry { * @param callBack when the adding voter done callBack.handleResult will be called * @return list of strings (empty list if the lookup failed) */ - void getPersonIDDetails(VoterID voterID, RegistryCallBack callBack); + void getVoter(VoterID voterID, RegistryCallBack callBack); /** * Checks if the given voter (by his id) have already voted diff --git a/voter-registry/src/main/java/meerkat/registry/LatestMessagesCallBack.java b/voter-registry/src/main/java/meerkat/registry/LatestMessagesCallBack.java index dddc821..540562c 100644 --- a/voter-registry/src/main/java/meerkat/registry/LatestMessagesCallBack.java +++ b/voter-registry/src/main/java/meerkat/registry/LatestMessagesCallBack.java @@ -58,7 +58,7 @@ public class LatestMessagesCallBack implements FutureCallback signers; private AsyncBulletinBoardClient bulletinBoardClient; @@ -123,6 +125,7 @@ public class SimpleRegistryTest extends TestCase { /** * Initialize registry object */ + @Before public void setUp() { SetSigner(); CommunicatorSetup(); @@ -320,7 +323,7 @@ public class SimpleRegistryTest extends TestCase { * Test that the personal data outputted about the user is right */ @Test - public void testGetPersonalIDDetails() throws InterruptedException { + public void testGetVoter() throws InterruptedException { DummyRegistryCallBackHandler> handler = new DummyRegistryCallBackHandler<>(); @@ -336,7 +339,7 @@ public class SimpleRegistryTest extends TestCase { assertEquals("The callback handler hasn't been called yet", 1, handler.counter ); DummyRegistryCallBackHandler personalHandler = new DummyRegistryCallBackHandler<>(); - registry.getPersonIDDetails(VoterID.newBuilder().setId(id).build(), personalHandler); + registry.getVoter(VoterID.newBuilder().setId(id).build(), personalHandler); jobSemaphore.acquire(1); assertEquals("The voter id doesn't match the created on ", @@ -345,7 +348,11 @@ public class SimpleRegistryTest extends TestCase { findTagWithPrefix(personalHandler.data, data) != null); } - + /** + * Tests that the hasVoted method of registry works + * @throws InterruptedException + */ + @Test public void testHasVoted () throws InterruptedException { DummyRegistryCallBackHandler handler = new DummyRegistryCallBackHandler<>(); String id = generateString(); @@ -361,6 +368,5 @@ public class SimpleRegistryTest extends TestCase { jobSemaphore.acquire(1); assertTrue("The voter hasn't voted yet.", personalHandler.data); } - }