Removes FindPrivacyGroupResponse in favour of PrivacyGroup (#1709)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
Josh Richardson
2019-07-17 09:33:55 +01:00
committed by MadelineMurray
parent 6717c7c5dd
commit 83f97f6e8d
6 changed files with 22 additions and 72 deletions

View File

@@ -22,7 +22,6 @@ import tech.pegasys.orion.testutil.OrionTestHarnessFactory;
import tech.pegasys.pantheon.enclave.types.CreatePrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.DeletePrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupResponse;
import tech.pegasys.pantheon.enclave.types.PrivacyGroup;
import tech.pegasys.pantheon.enclave.types.ReceiveRequest;
import tech.pegasys.pantheon.enclave.types.ReceiveResponse;
@@ -146,11 +145,10 @@ public class EnclaveTest {
FindPrivacyGroupRequest findPrivacyGroupRequest =
new FindPrivacyGroupRequest(publicKeys.toArray(new String[0]));
FindPrivacyGroupResponse[] findPrivacyGroupResponse =
enclave.findPrivacyGroup(findPrivacyGroupRequest);
PrivacyGroup[] findPrivacyGroupResponse = enclave.findPrivacyGroup(findPrivacyGroupRequest);
assertThat(findPrivacyGroupResponse.length).isEqualTo(1);
assertThat(findPrivacyGroupResponse[0].privacyGroupId())
assertThat(findPrivacyGroupResponse[0].getPrivacyGroupId())
.isEqualTo(privacyGroupResponse.getPrivacyGroupId());
DeletePrivacyGroupRequest deletePrivacyGroupRequest =

View File

@@ -16,7 +16,6 @@ import tech.pegasys.pantheon.enclave.types.CreatePrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.DeletePrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.ErrorResponse;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupResponse;
import tech.pegasys.pantheon.enclave.types.PrivacyGroup;
import tech.pegasys.pantheon.enclave.types.ReceiveRequest;
import tech.pegasys.pantheon.enclave.types.ReceiveResponse;
@@ -77,10 +76,9 @@ public class Enclave {
return executePost(buildPostRequest(JSON, content, "/deletePrivacyGroup"), String.class);
}
public FindPrivacyGroupResponse[] findPrivacyGroup(final FindPrivacyGroupRequest content)
throws Exception {
public PrivacyGroup[] findPrivacyGroup(final FindPrivacyGroupRequest content) throws Exception {
Request request = buildPostRequest(JSON, content, "/findPrivacyGroup");
return executePost(request, FindPrivacyGroupResponse[].class);
return executePost(request, PrivacyGroup[].class);
}
private Request buildPostRequest(

View File

@@ -1,60 +0,0 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.enclave.types;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class FindPrivacyGroupResponse implements Serializable {
private String privacyGroupId;
private String name;
private String description;
private String[] members;
@JsonCreator
public FindPrivacyGroupResponse(
@JsonProperty("privacyGroupId") final String privacyGroupId,
@JsonProperty("name") final String name,
@JsonProperty("description") final String description,
@JsonProperty("members") final String[] members) {
this.privacyGroupId = privacyGroupId;
this.name = name;
this.description = description;
this.members = members;
}
@JsonProperty("privacyGroupId")
public String privacyGroupId() {
return privacyGroupId;
}
@JsonProperty("name")
public String name() {
return name;
}
@JsonProperty("description")
public String description() {
return description;
}
@JsonProperty("members")
public String[] members() {
return members;
}
public FindPrivacyGroupResponse() {}
}

View File

@@ -20,6 +20,7 @@ public class PrivacyGroup implements Serializable {
private String name;
private String description;
private Type type;
private String[] members;
public String getPrivacyGroupId() {
return privacyGroupId;
@@ -53,14 +54,27 @@ public class PrivacyGroup implements Serializable {
this.type = type;
}
public String[] getMembers() {
return members;
}
public void setMembers(final String[] members) {
this.members = members;
}
public PrivacyGroup() {}
public PrivacyGroup(
final String privacyGroupId, final Type type, final String name, final String description) {
final String privacyGroupId,
final Type type,
final String name,
final String description,
final String[] members) {
this.privacyGroupId = privacyGroupId;
this.type = type;
this.name = name;
this.description = description;
this.members = members;
}
public enum Type {

View File

@@ -16,7 +16,7 @@ import static org.apache.logging.log4j.LogManager.getLogger;
import tech.pegasys.pantheon.enclave.Enclave;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupRequest;
import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupResponse;
import tech.pegasys.pantheon.enclave.types.PrivacyGroup;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcMethod;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
@@ -54,7 +54,7 @@ public class EeaFindPrivacyGroup implements JsonRpcMethod {
LOG.trace("Finding a privacy group with members {}", Arrays.toString(addresses));
FindPrivacyGroupRequest findPrivacyGroupRequest = new FindPrivacyGroupRequest(addresses);
FindPrivacyGroupResponse[] response;
PrivacyGroup[] response;
try {
response = enclave.findPrivacyGroup(findPrivacyGroupRequest);
} catch (Exception e) {

View File

@@ -44,7 +44,7 @@ public class EeaCreatePrivacyGroupTest {
@Test
public void verifyCreatePrivacyGroup() throws Exception {
PrivacyGroup privacyGroup =
new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, name, description);
new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, name, description, addresses);
when(enclave.createPrivacyGroup(any())).thenReturn(privacyGroup);
final EeaCreatePrivacyGroup eeaCreatePrivacyGroup =