Repository: hyperledger/quilt
Pull request #387 (2019-11-28 01:31:36)

make incoming and outgoing link settings optional #373
Signed-off-by: Ian Simpson <ian.g.simpson@gmail.com>


Patch:
diff --git a/examples-parent/send-money/README.md b/examples-parent/send-money/README.md
index 1426ee3..cbfe460 100644
--- a/examples-parent/send-money/README.md
+++ b/examples-parent/send-money/README.md
@@ -60,11 +60,11 @@ We can create a link using the following code:
 ```java
 String sharedSecret = "some random secret you generated";
 IlpOverHttpLinkSettings linkSettings = IlpOverHttpLinkSettings.builder()
-    .incomingHttpLinkSettings(IncomingLinkSettings.builder()
+    .incomingLinkSettings(IncomingLinkSettings.builder()
         .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE)
         .encryptedTokenSharedSecret(sharedSecret)
         .build())
-    .outgoingHttpLinkSettings(OutgoingLinkSettings.builder()
+    .outgoingLinkSettings(OutgoingLinkSettings.builder()
         .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE)
         .tokenSubject(SENDER_ACCOUNT_USERNAME)
         .url(HttpUrl.parse(TESTNET_URI + "/ilp"))
diff --git a/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java b/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
index 3554730..bedc55e 100644
--- a/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
+++ b/examples-parent/send-money/src/main/java/org/interledger/examples/SendMoneyExample.java
@@ -88,11 +88,11 @@ public class SendMoneyExample {
   private static Link newIlpOverHttpLink() {
     String sharedSecret = "some random secret here";
     final IlpOverHttpLinkSettings linkSettings = IlpOverHttpLinkSettings.builder()
-        .incomingHttpLinkSettings(IncomingLinkSettings.builder()
+        .incomingLinkSettings(IncomingLinkSettings.builder()
             .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE)
             .encryptedTokenSharedSecret(sharedSecret)
             .build())
-        .outgoingHttpLinkSettings(OutgoingLinkSettings.builder()
+        .outgoingLinkSettings(OutgoingLinkSettings.builder()
             .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE)
             .tokenSubject(SENDER_ACCOUNT_USERNAME)
             .url(HttpUrl.parse(TESTNET_URI + "/ilp"))
diff --git a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java
index 2dd10f4..72f9a9f 100644
--- a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java
+++ b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java
@@ -177,7 +177,12 @@ public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> imple
    * the endpoint does not support ILP-over-HTTP requests, then we expect a 415 UNSUPPORTED_MEDIA_TYPE.</p>
    */
   public void testConnection() {
-    final OutgoingLinkSettings outgoingLinkSettings = this.getLinkSettings().outgoingHttpLinkSettings();
+    final OutgoingLinkSettings outgoingLinkSettings = this.getLinkSettings().outgoingLinkSettings()
+      .orElseGet(() -> {
+        logger.warn("Falling back to deprecated means of loading outgoing settings. " +
+          "Please switch to using outgoingLinkSettings() instead");
+        return this.getLinkSettings().outgoingHttpLinkSettings();
+      });
     final String tokenSubject = outgoingLinkSettings.tokenSubject();
     try {
 
@@ -282,6 +287,12 @@ public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> imple
    */
   private Request constructSendPacketRequest(final InterledgerPreparePacket preparePacket) {
     Objects.requireNonNull(preparePacket);
+    final OutgoingLinkSettings outgoingLinkSettings = this.getLinkSettings().outgoingLinkSettings()
+      .orElseGet(() -> {
+        logger.warn("Falling back to deprecated means of loading outgoing settings. " +
+          "Please switch to using outgoingLinkSettings() instead");
+        return this.getLinkSettings().outgoingHttpLinkSettings();
+      });
 
     try {
       final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@@ -289,7 +300,7 @@ public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> imple
 
       return new Builder()
           .headers(constructHttpRequestHeaders())
-          .url(this.getLinkSettings().outgoingHttpLinkSettings().url())
+          .url(outgoingLinkSettings.url())
           .post(
               RequestBody.create(byteArrayOutputStream.toByteArray(), APPLICATION_OCTET_STREAM)
           )
@@ -299,4 +310,5 @@ public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> imple
       throw new LinkException(e.getMessage(), e, getLinkId());
     }
   }
+
 }
diff --git a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkFactory.java b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkFactory.java
index db2d9e1..e2d8494 100644
--- a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkFactory.java
+++ b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkFactory.java
@@ -14,6 +14,8 @@ import org.interledger.link.http.auth.SimpleBearerTokenSupplier;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import okhttp3.OkHttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.Objects;
 import java.util.function.Supplier;
@@ -28,6 +30,8 @@ public class IlpOverHttpLinkFactory implements LinkFactory {
   private final ObjectMapper objectMapper;
   private final CodecContext ilpCodecContext;
 
+  private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
   /**
    * Required-args Constructor.
    *
@@ -77,11 +81,17 @@ public class IlpOverHttpLinkFactory implements LinkFactory {
         IlpOverHttpLinkSettings.applyCustomSettings(builder, linkSettings.getCustomSettings()).build();
 
     final BearerTokenSupplier bearerTokenSupplier;
-    if (ilpOverHttpLinkSettings.outgoingHttpLinkSettings().authType().equals(IlpOverHttpLinkSettings.AuthType.SIMPLE)) {
+    OutgoingLinkSettings outgoingLinkSettings = ilpOverHttpLinkSettings.outgoingLinkSettings()
+      .orElseGet(() -> {
+        logger.warn("Falling back to deprecated means of loading outgoing settings. " +
+          "Please switch to using outgoingLinkSettings() instead");
+        return ilpOverHttpLinkSettings.outgoingHttpLinkSettings();
+      });
+    if (outgoingLinkSettings.authType().equals(IlpOverHttpLinkSettings.AuthType.SIMPLE)) {
       // Decrypt whatever is inside of the encryptedTokenSharedSecret. For the SIMPLE profile, this will decrypt to the
       // actual bearer token.
       bearerTokenSupplier = new SimpleBearerTokenSupplier(new String(
-          decryptor.decrypt(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().encryptedTokenSharedSecret().getBytes())
+        decryptor.decrypt(outgoingLinkSettings.encryptedTokenSharedSecret().getBytes())
       ));
     } else {
       // TODO: For now, we assume the bytes are a String that conform to the Crypt CLI. However, this should be made
@@ -91,10 +101,10 @@ public class IlpOverHttpLinkFactory implements LinkFactory {
       // NOTE: This supplier will always create a copy of the decrypted bytes so that the consumer of each call can
       // safely wipe the bytes from memory without affecting other callers.
       final SharedSecretBytesSupplier sharedSecretSupplier = () -> decryptor
-          .decrypt(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().encryptedTokenSharedSecret().getBytes());
+        .decrypt(outgoingLinkSettings.encryptedTokenSharedSecret().getBytes());
 
       bearerTokenSupplier = new JwtHs256BearerTokenSupplier(
-          sharedSecretSupplier, ilpOverHttpLinkSettings.outgoingHttpLinkSettings()
+        sharedSecretSupplier, outgoingLinkSettings
       );
     }
 
diff --git a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkSettings.java b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkSettings.java
index 8cd4136..b2c7dcc 100644
--- a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkSettings.java
+++ b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLinkSettings.java
@@ -9,6 +9,8 @@ import org.immutables.value.Value.Modifiable;
 
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
+import javax.annotation.Nullable;
 
 /**
  * An extension of {@link LinkSettings} for ILP-over-HTTP links.
@@ -67,8 +69,14 @@ public interface IlpOverHttpLinkSettings extends LinkSettings {
     final ImmutableOutgoingLinkSettings.Builder outgoingLinkSettingsBuilder =
         OutgoingLinkSettings.fromCustomSettings(customSettings);
 
-    builder.incomingHttpLinkSettings(incomingLinkSettingsBuilder.build());
-    builder.outgoingHttpLinkSettings(outgoingLinkSettingsBuilder.build());
+    ImmutableIncomingLinkSettings incoming = incomingLinkSettingsBuilder.build();
+    builder.incomingLinkSettings(incoming);
+    ImmutableOutgoingLinkSettings outgoing = outgoingLinkSettingsBuilder.build();
+    builder.outgoingLinkSettings(outgoing);
+
+    // FIXME initialize in deprecated as well until removed
+    builder.incomingHttpLinkSettings(incoming);
+    builder.outgoingHttpLinkSettings(outgoing);
 
     builder.customSettings(customSettings);
 
@@ -81,19 +89,39 @@ public interface IlpOverHttpLinkSettings extends LinkSettings {
   }
 
   /**
+   * @deprecated use {@link #incomingLinkSettings()}. To be removed in 1.0.4
    * Link settings for the incoming HTTP link.
    *
    * @return A {@link IncomingLinkSettings}.
    */
+  @Deprecated
+  @Nullable
   IncomingLinkSettings incomingHttpLinkSettings();
 
   /**
+   * @deprecated use {@link #outgoingLinkSettings()}. To be removed in 1.0.4
    * Link settings for the outgoing HTTP link.
    *
    * @return A {@link OutgoingLinkSettings}.
    */
+  @Deprecated
+  @Nullable
   OutgoingLinkSettings outgoingHttpLinkSettings();
 
+  /**
+   * Optional link settings for the incoming HTTP link.
+   *
+   * @return An {@link Optional} {@link IncomingLinkSettings}.
+   */
+  Optional<IncomingLinkSettings> incomingLinkSettings();
+
+  /**
+   * Optional link settings for the outgoing HTTP link.
+   *
+   * @return An {@link Optional} {@link OutgoingLinkSettings}.
+   */
+  Optional<OutgoingLinkSettings> outgoingLinkSettings();
+
   /**
    * <p>Defines currently-supported ILP-over-HTTP authentication profiles.</p>
    *


Test patch:
diff --git a/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkSettingsTest.java b/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkSettingsTest.java
index 4f77c48..09c9f35 100644
--- a/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkSettingsTest.java
+++ b/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkSettingsTest.java
@@ -24,28 +24,29 @@ public class IlpOverHttpLinkSettingsTest extends AbstractHttpLinkSettingsTest {
     final IlpOverHttpLinkSettings ilpOverHttpLinkSettings =
         IlpOverHttpLinkSettings.applyCustomSettings(builder, flattenedCustomSettings).build();
 
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().authType())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().tokenIssuer().get())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://incoming-issuer.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().tokenAudience().get())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://incoming-audience.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("incoming-credential");
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().getMinMessageWindow())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().getMinMessageWindow())
         .isEqualTo(Duration.ofMillis(2500));
 
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().authType())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenIssuer().get())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-issuer.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenAudience().get())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-audience.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenSubject()).isEqualTo("outgoing-subject");
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenSubject()).isEqualTo("outgoing-subject");
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("outgoing-credential");
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenExpiry().get()).isEqualTo(Duration.ofHours(24));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().url())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenExpiry().get())
+      .isEqualTo(Duration.ofHours(24));
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().url())
         .isEqualTo(HttpUrl.parse("https://outgoing.example.com/"));
   }
 
@@ -60,27 +61,27 @@ public class IlpOverHttpLinkSettingsTest extends AbstractHttpLinkSettingsTest {
     final ImmutableIlpOverHttpLinkSettings httpLinkSettings =
         IlpOverHttpLinkSettings.applyCustomSettings(builder, customSettings).build();
 
-    assertThat(httpLinkSettings.incomingHttpLinkSettings().authType())
+    assertThat(httpLinkSettings.incomingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
-    assertThat(httpLinkSettings.incomingHttpLinkSettings().tokenIssuer().get())
+    assertThat(httpLinkSettings.incomingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://incoming-issuer.example.com/"));
-    assertThat(httpLinkSettings.incomingHttpLinkSettings().tokenAudience().get())
+    assertThat(httpLinkSettings.incomingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://incoming-audience.example.com/"));
-    assertThat(httpLinkSettings.incomingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(httpLinkSettings.incomingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("incoming-credential");
-    assertThat(httpLinkSettings.incomingHttpLinkSettings().getMinMessageWindow()).isEqualTo(Duration.ofMillis(2500));
+    assertThat(httpLinkSettings.incomingLinkSettings().get().getMinMessageWindow()).isEqualTo(Duration.ofMillis(2500));
 
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().authType())
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().tokenIssuer().get())
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-issuer.example.com/"));
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().tokenAudience().get())
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-audience.example.com/"));
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().tokenSubject()).isEqualTo("outgoing-subject");
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().tokenSubject()).isEqualTo("outgoing-subject");
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("outgoing-credential");
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().tokenExpiry().get()).isEqualTo(Duration.ofHours(48));
-    assertThat(httpLinkSettings.outgoingHttpLinkSettings().url())
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().tokenExpiry().get()).isEqualTo(Duration.ofHours(48));
+    assertThat(httpLinkSettings.outgoingLinkSettings().get().url())
         .isEqualTo(HttpUrl.parse("https://outgoing.example.com/"));
   }
 
@@ -107,34 +108,35 @@ public class IlpOverHttpLinkSettingsTest extends AbstractHttpLinkSettingsTest {
             .build();
 
     final IlpOverHttpLinkSettings ilpOverHttpLinkSettings = IlpOverHttpLinkSettings.builder()
-        .incomingHttpLinkSettings(incomingLinksettings)
-        .outgoingHttpLinkSettings(outgoingLinksettings)
+        .incomingLinkSettings(incomingLinksettings)
+        .outgoingLinkSettings(outgoingLinksettings)
         .build();
 
     assertThat(ilpOverHttpLinkSettings.getLinkType()).isEqualTo(IlpOverHttpLink.LINK_TYPE);
 
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().authType())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.SIMPLE);
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().tokenIssuer().get())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://incoming-issuer.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().tokenAudience().get())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://incoming-audience.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("incoming-credential");
-    assertThat(ilpOverHttpLinkSettings.incomingHttpLinkSettings().getMinMessageWindow())
+    assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().getMinMessageWindow())
         .isEqualTo(Duration.ofMillis(30));
 
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().authType())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().authType())
         .isEqualTo(IlpOverHttpLinkSettings.AuthType.SIMPLE);
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenIssuer().get())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenIssuer().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-issuer.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenAudience().get())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenAudience().get())
         .isEqualTo(HttpUrl.parse("https://outgoing-audience.example.com/"));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenSubject()).isEqualTo("outgoing-subject");
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().encryptedTokenSharedSecret())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenSubject()).isEqualTo("outgoing-subject");
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().encryptedTokenSharedSecret())
         .isEqualTo("outgoing-credential");
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().tokenExpiry().get()).isEqualTo(Duration.ofMillis(40));
-    assertThat(ilpOverHttpLinkSettings.outgoingHttpLinkSettings().url())
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().tokenExpiry().get())
+      .isEqualTo(Duration.ofMillis(40));
+    assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().url())
         .isEqualTo(HttpUrl.parse("https://outgoing.example.com/"));
   }
 }
diff --git a/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkTest.java b/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkTest.java
index 56c4297..91c626b 100644
--- a/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkTest.java
+++ b/link-parent/link-ilp-over-http/src/test/java/org/interledger/link/http/IlpOverHttpLinkTest.java
@@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 
 import java.io.IOException;
+import java.util.Optional;
 
 /**
  * Unit tests for {@link IlpOverHttpLink}.
@@ -75,8 +76,8 @@ public class IlpOverHttpLinkTest {
         bearerTokenSupplier
     );
     link.setLinkId(LinkId.of("pepe silvia"));
-    when(settings.outgoingHttpLinkSettings()).thenReturn(outgoingLinkSettings);
-    when(settings.incomingHttpLinkSettings()).thenReturn(incomingLinkSettings);
+    when(settings.outgoingLinkSettings()).thenReturn(Optional.of(outgoingLinkSettings));
+    when(settings.incomingLinkSettings()).thenReturn(Optional.of(incomingLinkSettings));
     when(outgoingLinkSettings.url()).thenReturn(HttpUrl.get("https://cannotspellsurgerywithouturges.com"));
     packet = mock(InterledgerPreparePacket.class);
   }