Realocated the VoterRegistry.proto file and changed the usage of it
parent
c8e747285c
commit
230dfe6d3f
|
@ -0,0 +1,23 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meerkat;
|
||||
|
||||
option java_package = "meerkat.protobuf";
|
||||
|
||||
message VoterID{
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message VoterInfo{
|
||||
VoterID id = 1;
|
||||
string info = 2;
|
||||
}
|
||||
|
||||
message GroupID{
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message VoterGroup{
|
||||
VoterID voterId = 1;
|
||||
GroupID groupId = 2;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,8 @@ import meerkat.crypto.DigitalSignature;
|
|||
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
||||
import meerkat.protobuf.BulletinBoardAPI.UnsignedBulletinBoardMessage;
|
||||
import meerkat.protobuf.Crypto;
|
||||
import meerkat.protobuf.VoterRegistry.*;
|
||||
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.security.SignatureException;
|
||||
|
@ -63,7 +65,7 @@ public class SimpleRegistry implements VoterRegistry{
|
|||
bulletinBoardClient .postMessage(Message, callback);
|
||||
}
|
||||
|
||||
public void AddVoter(RegistryMessages.VoterInfo voterInfo, RegistryCallBack callback) {
|
||||
public void AddVoter(VoterInfo voterInfo, RegistryCallBack callback) {
|
||||
UnsignedBulletinBoardMessage.Builder basicMessage =
|
||||
UnsignedBulletinBoardMessage.newBuilder().
|
||||
addTag(RegistryTags.ID_TAG + voterInfo.getId().getId())
|
||||
|
@ -75,7 +77,7 @@ public class SimpleRegistry implements VoterRegistry{
|
|||
SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback));
|
||||
}
|
||||
|
||||
public void AddToGroup(RegistryMessages.VoterGroup voterGroup, RegistryCallBack callback) {
|
||||
public void AddToGroup(VoterGroup voterGroup, RegistryCallBack callback) {
|
||||
UnsignedBulletinBoardMessage.Builder basicMessage =
|
||||
UnsignedBulletinBoardMessage.newBuilder()
|
||||
.addTag(RegistryTags.ID_TAG + voterGroup.getVoterId().getId())
|
||||
|
@ -86,7 +88,7 @@ public class SimpleRegistry implements VoterRegistry{
|
|||
SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback));
|
||||
}
|
||||
|
||||
public void SetVoted(RegistryMessages.VoterID voterId, RegistryCallBack callback) {
|
||||
public void SetVoted(VoterID voterId, RegistryCallBack callback) {
|
||||
UnsignedBulletinBoardMessage.Builder basicMessage =
|
||||
UnsignedBulletinBoardMessage.newBuilder()
|
||||
.addTag(RegistryTags.ID_TAG + voterId.getId())
|
||||
|
@ -96,7 +98,7 @@ public class SimpleRegistry implements VoterRegistry{
|
|||
SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback));
|
||||
}
|
||||
|
||||
public void GetGroups(RegistryMessages.GroupID groupID, RegistryCallBack callback) {
|
||||
public void GetGroups(GroupID groupID, RegistryCallBack callback) {
|
||||
List<String> GroupsActionsTags = new ArrayList<String>() {{
|
||||
add(RegistryTags.GROUP_ID_TAG + groupID.getId());
|
||||
}};
|
||||
|
@ -104,7 +106,7 @@ public class SimpleRegistry implements VoterRegistry{
|
|||
new RelevantDataCallBack(callback, signer, signature, certificateStream));
|
||||
}
|
||||
|
||||
public void GetPersonIDDetails(RegistryMessages.VoterID voterID, RegistryCallBack callback) {
|
||||
public void GetPersonIDDetails(VoterID voterID, RegistryCallBack callback) {
|
||||
List<String> GroupsActionsTags = new ArrayList<String>() {{
|
||||
add(RegistryTags.ID_TAG + voterID.getId());
|
||||
add(RegistryTags.VOTER_ENTRY_TAG.toString());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package meerkat;
|
||||
|
||||
import meerkat.protobuf.VoterRegistry.*;
|
||||
|
||||
/**
|
||||
* Created by Vladimir Eliezer Tokarev on 1/22/2016.
|
||||
* provides voters management options
|
||||
|
@ -22,7 +24,7 @@ public interface VoterRegistry {
|
|||
* @param callBack when the adding voter done callBack.HandleResult will be called
|
||||
* @return void
|
||||
*/
|
||||
void AddVoter(RegistryMessages.VoterInfo voterInfo, RegistryCallBack callBack);
|
||||
void AddVoter(VoterInfo voterInfo, RegistryCallBack callBack);
|
||||
|
||||
/**
|
||||
* Adding given voter to given group
|
||||
|
@ -32,7 +34,7 @@ public interface VoterRegistry {
|
|||
* @param callBack when the adding voter done callBack.HandleResult will be called
|
||||
* @return true if the adding action succeeded else return false
|
||||
*/
|
||||
void AddToGroup(RegistryMessages.VoterGroup voterGroup, RegistryCallBack callBack);
|
||||
void AddToGroup(VoterGroup voterGroup, RegistryCallBack callBack);
|
||||
|
||||
/**
|
||||
* Sets that the voter have voted
|
||||
|
@ -42,7 +44,7 @@ public interface VoterRegistry {
|
|||
* @param callBack when the adding voter done callBack.HandleResult will be called
|
||||
* @return true if the set voted succeed else false
|
||||
*/
|
||||
void SetVoted(RegistryMessages.VoterID voterId, RegistryCallBack callBack);
|
||||
void SetVoted(VoterID voterId, RegistryCallBack callBack);
|
||||
|
||||
/**
|
||||
* Requests all the groups that the given id voter is in
|
||||
|
@ -51,7 +53,7 @@ public interface VoterRegistry {
|
|||
* @param groupID id tag string
|
||||
* @param callBack when the adding voter done callBack.HandleResult will be called
|
||||
*/
|
||||
void GetGroups(RegistryMessages.GroupID groupID, RegistryCallBack callBack);
|
||||
void GetGroups(GroupID groupID, RegistryCallBack callBack);
|
||||
|
||||
/**
|
||||
* Retrieves list of strings that represents voter
|
||||
|
@ -61,6 +63,6 @@ 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(RegistryMessages.VoterID voterID, RegistryCallBack callBack);
|
||||
void GetPersonIDDetails(VoterID voterID, RegistryCallBack callBack);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
|||
import junit.framework.TestCase;
|
||||
import meerkat.Registry.CollectionMessagesUtils;
|
||||
import meerkat.Registry.RegistryTags;
|
||||
import meerkat.RegistryMessages;
|
||||
import meerkat.SimpleRegistry;
|
||||
import meerkat.VoterRegistry;
|
||||
import meerkat.SimpleRegistry;
|
||||
import meerkat.protobuf.VoterRegistry.*;
|
||||
import meerkat.VoterRegistryMessage;
|
||||
import meerkat.bulletinboard.BulletinBoardClient;
|
||||
import meerkat.bulletinboard.ThreadedBulletinBoardClient;
|
||||
|
@ -167,8 +167,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
|
||||
String id = new BigInteger(130, random).toString(32);
|
||||
String data = new BigInteger(130, random).toString(32);
|
||||
RegistryMessages.VoterInfo voterInfo = RegistryMessages.VoterInfo.newBuilder().
|
||||
setId(RegistryMessages.VoterID.newBuilder().setId(id)).setInfo(data).build();
|
||||
VoterInfo voterInfo = VoterInfo.newBuilder().setId(VoterID.newBuilder().setId(id)).setInfo(data).build();
|
||||
|
||||
SimpleRegistry registry = new SimpleRegistry(signer, bulletinBoardClient, certStream);
|
||||
registry.AddVoter(voterInfo, handler);
|
||||
|
@ -196,7 +195,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
DummyRegistryCallBackHandler<Boolean> handler = new DummyRegistryCallBackHandler<>();
|
||||
|
||||
String id = new BigInteger(130, random).toString(32);
|
||||
RegistryMessages.VoterID voterInfo = RegistryMessages.VoterID.newBuilder().setId(id).build();
|
||||
VoterID voterInfo = VoterID.newBuilder().setId(id).build();
|
||||
|
||||
SimpleRegistry registry = new SimpleRegistry(signer, bulletinBoardClient, certStream);
|
||||
registry.SetVoted(voterInfo, handler);
|
||||
|
@ -224,9 +223,8 @@ public class SimpleRegistryTest extends TestCase {
|
|||
|
||||
String voterId = new BigInteger(130, random).toString(32);
|
||||
String groupId = new BigInteger(130, random).toString(32);
|
||||
RegistryMessages.VoterGroup voterInfo = RegistryMessages.VoterGroup.newBuilder()
|
||||
.setVoterId(RegistryMessages.VoterID.newBuilder().setId(voterId))
|
||||
.setGroupId(RegistryMessages.GroupID.newBuilder().setId(groupId)).build();
|
||||
VoterGroup voterInfo = VoterGroup.newBuilder().setVoterId(VoterID.newBuilder().setId(voterId))
|
||||
.setGroupId(GroupID.newBuilder().setId(groupId)).build();
|
||||
|
||||
SimpleRegistry registry = new SimpleRegistry(signer, bulletinBoardClient, certStream);
|
||||
registry.AddToGroup(voterInfo, handler);
|
||||
|
@ -258,9 +256,8 @@ public class SimpleRegistryTest extends TestCase {
|
|||
|
||||
String voterId = new BigInteger(130, random).toString(32);
|
||||
String groupId = new BigInteger(130, random).toString(32);
|
||||
RegistryMessages.VoterGroup voterInfo = RegistryMessages.VoterGroup.newBuilder()
|
||||
.setVoterId(RegistryMessages.VoterID.newBuilder().setId(voterId))
|
||||
.setGroupId(RegistryMessages.GroupID.newBuilder().setId(groupId)).build();
|
||||
VoterGroup voterInfo = VoterGroup.newBuilder().setVoterId(VoterID.newBuilder().setId(voterId))
|
||||
.setGroupId(GroupID.newBuilder().setId(groupId)).build();
|
||||
|
||||
this.certStream = getClass().getResourceAsStream(CERT1_PEM_EXAMPLE);
|
||||
|
||||
|
@ -271,7 +268,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
assertEquals(1, handler.counter );
|
||||
|
||||
DummyRegistryCallBackHandler<List<String>> groupsHandler = new DummyRegistryCallBackHandler<>();
|
||||
registry.GetGroups(RegistryMessages.GroupID.newBuilder().setId(groupId).build(), groupsHandler);
|
||||
registry.GetGroups(GroupID.newBuilder().setId(groupId).build(), groupsHandler);
|
||||
|
||||
jobSemaphore.acquire(1);
|
||||
List<String> userGroups = groupsHandler.data;
|
||||
|
@ -288,8 +285,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
|
||||
String id = new BigInteger(130, random).toString(32);
|
||||
String data = new BigInteger(130, random).toString(32);
|
||||
RegistryMessages.VoterInfo voterInfo = RegistryMessages.VoterInfo.newBuilder().
|
||||
setId(RegistryMessages.VoterID.newBuilder().setId(id)).setInfo(data).build();
|
||||
VoterInfo voterInfo = VoterInfo.newBuilder().setId(VoterID.newBuilder().setId(id)).setInfo(data).build();
|
||||
|
||||
SimpleRegistry registry = new SimpleRegistry(signer, bulletinBoardClient, certStream);
|
||||
registry.AddVoter(voterInfo, handler);
|
||||
|
@ -298,7 +294,7 @@ public class SimpleRegistryTest extends TestCase {
|
|||
assertEquals(1, handler.counter );
|
||||
|
||||
DummyRegistryCallBackHandler<VoterRegistryMessage> personalHandler = new DummyRegistryCallBackHandler<>();
|
||||
registry.GetPersonIDDetails(RegistryMessages.VoterID.newBuilder().setId(id).build(), personalHandler);
|
||||
registry.GetPersonIDDetails(VoterID.newBuilder().setId(id).build(), personalHandler);
|
||||
|
||||
jobSemaphore.acquire();
|
||||
assertEquals(RegistryTags.ID_TAG + id,
|
||||
|
|
Loading…
Reference in New Issue