From d6a04f416bda9cf1ae33b70dece5840f596860b5 Mon Sep 17 00:00:00 2001 From: Puneetha Karamsetty Date: Wed, 23 Jan 2019 20:35:35 +0000 Subject: [PATCH] Remove OrionConfiguration (#644) Signed-off-by: Adrian Sutton --- ethereum/core/build.gradle | 1 + .../pegasys/pantheon/orion/OrionTest.java | 18 +++---- .../tech/pegasys/pantheon/orion/Orion.java | 12 ++--- .../pantheon/orion/OrionConfiguration.java | 49 ------------------- ...eceiveContent.java => ReceiveRequest.java} | 4 +- .../{SendContent.java => SendRequest.java} | 4 +- 6 files changed, 17 insertions(+), 71 deletions(-) delete mode 100644 orion/src/main/java/tech/pegasys/pantheon/orion/OrionConfiguration.java rename orion/src/main/java/tech/pegasys/pantheon/orion/types/{ReceiveContent.java => ReceiveRequest.java} (91%) rename orion/src/main/java/tech/pegasys/pantheon/orion/types/{SendContent.java => SendRequest.java} (93%) diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index 28a075e5a7..5e238e326c 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -32,6 +32,7 @@ dependencies { implementation project(':ethereum:trie') implementation project(':ethereum:permissioning') implementation project(':metrics') + implementation project(':orion') implementation project(':services:kvstore') implementation 'com.fasterxml.jackson.core:jackson-databind' diff --git a/orion/src/integration-test/java/tech/pegasys/pantheon/orion/OrionTest.java b/orion/src/integration-test/java/tech/pegasys/pantheon/orion/OrionTest.java index 9d03df914e..7fd7d11e7d 100644 --- a/orion/src/integration-test/java/tech/pegasys/pantheon/orion/OrionTest.java +++ b/orion/src/integration-test/java/tech/pegasys/pantheon/orion/OrionTest.java @@ -17,9 +17,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import tech.pegasys.orion.testutil.OrionTestHarness; -import tech.pegasys.pantheon.orion.types.ReceiveContent; +import tech.pegasys.pantheon.orion.types.ReceiveRequest; import tech.pegasys.pantheon.orion.types.ReceiveResponse; -import tech.pegasys.pantheon.orion.types.SendContent; +import tech.pegasys.pantheon.orion.types.SendRequest; import tech.pegasys.pantheon.orion.types.SendResponse; import java.io.IOException; @@ -46,10 +46,7 @@ public class OrionTest { testHarness = OrionTestHarness.create(folder.newFolder().toPath()); - OrionConfiguration orionConfiguration = OrionConfiguration.createDefault(); - orionConfiguration.setUrl(testHarness.getConfig().clientUrl().toString()); - - orion = new Orion(orionConfiguration); + orion = new Orion(testHarness.getConfig().clientUrl().toString()); } @AfterClass @@ -66,10 +63,10 @@ public class OrionTest { public void testSendAndReceive() throws IOException { List publicKeys = testHarness.getPublicKeys(); - SendContent sc = new SendContent(PAYLOAD, publicKeys.get(0), new String[] {publicKeys.get(1)}); + SendRequest sc = new SendRequest(PAYLOAD, publicKeys.get(0), new String[] {publicKeys.get(1)}); SendResponse sr = orion.send(sc); - ReceiveContent rc = new ReceiveContent(sr.getKey(), publicKeys.get(1)); + ReceiveRequest rc = new ReceiveRequest(sr.getKey(), publicKeys.get(1)); ReceiveResponse rr = orion.receive(rc); assertEquals(PAYLOAD, new String(rr.getPayload(), UTF_8)); @@ -77,10 +74,7 @@ public class OrionTest { @Test(expected = IOException.class) public void whenUpCheckFailsThrows() throws IOException { - OrionConfiguration configuration = OrionConfiguration.createDefault(); - configuration.setUrl("http:"); - - Orion broken = new Orion(configuration); + Orion broken = new Orion("http:"); broken.upCheck(); } diff --git a/orion/src/main/java/tech/pegasys/pantheon/orion/Orion.java b/orion/src/main/java/tech/pegasys/pantheon/orion/Orion.java index 76e6c8fe99..32a7766dcd 100644 --- a/orion/src/main/java/tech/pegasys/pantheon/orion/Orion.java +++ b/orion/src/main/java/tech/pegasys/pantheon/orion/Orion.java @@ -12,9 +12,9 @@ */ package tech.pegasys.pantheon.orion; -import tech.pegasys.pantheon.orion.types.ReceiveContent; +import tech.pegasys.pantheon.orion.types.ReceiveRequest; import tech.pegasys.pantheon.orion.types.ReceiveResponse; -import tech.pegasys.pantheon.orion.types.SendContent; +import tech.pegasys.pantheon.orion.types.SendRequest; import tech.pegasys.pantheon.orion.types.SendResponse; import java.io.IOException; @@ -36,8 +36,8 @@ public class Orion { private String url; private OkHttpClient client; - public Orion(final OrionConfiguration orionConfiguration) { - this.url = orionConfiguration.getUrl(); + public Orion(final String orionUrl) { + this.url = orionUrl; this.client = new OkHttpClient(); } @@ -52,11 +52,11 @@ public class Orion { } } - public SendResponse send(final SendContent content) throws IOException { + public SendResponse send(final SendRequest content) throws IOException { return executePost("/send", objectMapper.writeValueAsString(content), SendResponse.class); } - public ReceiveResponse receive(final ReceiveContent content) throws IOException { + public ReceiveResponse receive(final ReceiveRequest content) throws IOException { return executePost("/receive", objectMapper.writeValueAsString(content), ReceiveResponse.class); } diff --git a/orion/src/main/java/tech/pegasys/pantheon/orion/OrionConfiguration.java b/orion/src/main/java/tech/pegasys/pantheon/orion/OrionConfiguration.java deleted file mode 100644 index 534ee49153..0000000000 --- a/orion/src/main/java/tech/pegasys/pantheon/orion/OrionConfiguration.java +++ /dev/null @@ -1,49 +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.orion; - -public class OrionConfiguration { - - private static final String DEFAULT_ORION_URL = "http://localhost:8888"; - - private boolean enabled; - private String url; - - public static OrionConfiguration createDefault() { - final OrionConfiguration config = new OrionConfiguration(); - config.setEnabled(false); - config.setUrl(DEFAULT_ORION_URL); - return config; - } - - @Override - public String toString() { - return "OrionConfiguration{" + "enabled=" + enabled + ", url='" + url + '\'' + '}'; - } - - public void setUrl(final String url) { - this.url = url; - } - - public String getUrl() { - return this.url; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } -} diff --git a/orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveContent.java b/orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveRequest.java similarity index 91% rename from orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveContent.java rename to orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveRequest.java index 3eaa42a657..341081be41 100644 --- a/orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveContent.java +++ b/orion/src/main/java/tech/pegasys/pantheon/orion/types/ReceiveRequest.java @@ -12,11 +12,11 @@ */ package tech.pegasys.pantheon.orion.types; -public class ReceiveContent { +public class ReceiveRequest { private String key; private String to; - public ReceiveContent(final String key, final String to) { + public ReceiveRequest(final String key, final String to) { this.key = key; this.to = to; diff --git a/orion/src/main/java/tech/pegasys/pantheon/orion/types/SendContent.java b/orion/src/main/java/tech/pegasys/pantheon/orion/types/SendRequest.java similarity index 93% rename from orion/src/main/java/tech/pegasys/pantheon/orion/types/SendContent.java rename to orion/src/main/java/tech/pegasys/pantheon/orion/types/SendRequest.java index d5df64bc19..afbf3bc474 100644 --- a/orion/src/main/java/tech/pegasys/pantheon/orion/types/SendContent.java +++ b/orion/src/main/java/tech/pegasys/pantheon/orion/types/SendRequest.java @@ -14,12 +14,12 @@ package tech.pegasys.pantheon.orion.types; import static java.nio.charset.StandardCharsets.UTF_8; -public class SendContent { +public class SendRequest { private byte[] payload; private String from; private String[] to; - public SendContent(final String payload, final String from, final String[] to) { + public SendRequest(final String payload, final String from, final String[] to) { this.payload = payload.getBytes(UTF_8); this.from = from; this.to = to;