diff --git a/src/main/app/scheme-adapter.xml b/src/main/app/scheme-adapter.xml
index 7fda62f..13575cd 100644
--- a/src/main/app/scheme-adapter.xml
+++ b/src/main/app/scheme-adapter.xml
@@ -93,7 +93,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
-
+
@@ -218,7 +218,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
expression="#[sessionVars.originalQuoteRequestMap.get("amount").put("amount",sessionVars.destinationAmount); sessionVars.originalQuoteRequestMap]"
doc:name="Update dfsp request with destination amount from ilp-service /quoteSourceAmount" />
-
+
@@ -302,6 +302,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
+
diff --git a/src/test/java/com/l1p/interop/scheme/adapter/TestSchemeAdapter.java b/src/test/java/com/l1p/interop/scheme/adapter/TestSchemeAdapter.java
index 88aa6ca..47f7462 100644
--- a/src/test/java/com/l1p/interop/scheme/adapter/TestSchemeAdapter.java
+++ b/src/test/java/com/l1p/interop/scheme/adapter/TestSchemeAdapter.java
@@ -1,5 +1,14 @@
package com.l1p.interop.scheme.adapter;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertEquals;
+
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
@@ -8,17 +17,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import io.restassured.response.Response;
-import static io.restassured.RestAssured.given;
-import static org.junit.Assert.assertEquals;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.hamcrest.CoreMatchers.equalTo;
public class TestSchemeAdapter extends FunctionalTestCase {
protected Logger logger = LoggerFactory.getLogger(getClass());
+ private static WireMockServer wireMockServer;
@Rule
public WireMockRule mockReceiverSchemeAdapter = new WireMockRule(8090);
@@ -31,6 +38,9 @@ public class TestSchemeAdapter extends FunctionalTestCase {
@Rule
public WireMockRule ilpService = new WireMockRule(3045);
+
+ @Rule
+ public WireMockRule notificationsService = new WireMockRule(8088);
@Override
@@ -59,7 +69,7 @@ public void testQuery() throws Exception {
body("name", equalTo("alice")).
body("balance", equalTo("1000.00")).
body("currencyCode", equalTo("USD")).
- body("currencySymbol", equalTo("$")).
+ body("currencySymbol", equalTo("$")).
body("is_disabled", equalTo(false)).
body("ledger", equalTo("http://ec2-35-166-180-190.us-west-2.compute.amazonaws.com:8088/ilp/ledger/v1"));
@@ -116,9 +126,81 @@ public void testQuotes() throws Exception {
assertEquals("expiresAt","2017-06-14T00:00:01.000Z",(String)response.jsonPath().get("expiresAt"));
}
+
@Test
- @Ignore
public void testPayments() throws Exception {
+
+ String proxyPaymentRequestJson = loadResourceAsString("test_data/proxyPaymentRequest.json");
+ String paymentMockResponseJson = loadResourceAsString("test_data/paymentMockResponse.json");
+
+ ilpService.stubFor(post(urlMatching("/payIPR")).willReturn(aResponse().withBody(paymentMockResponseJson).withStatus(201)).atPriority(2));
+
+ Response response =
+ given().
+ contentType("application/json").
+ body(proxyPaymentRequestJson).
+ when().
+ post("http://localhost:8088/scheme/adapter/v1/payments");
+
+ logger.info("Response: "+response.asString());
+
+ assertEquals("paymentId","123456",(String)response.jsonPath().get("paymentId"));
+ assertEquals("connectorAccount","123456",(String)response.jsonPath().get("connectorAccount"));
+ assertEquals("status","1",(String)response.jsonPath().get("status"));
+ assertEquals("rejectionMessage","rejection message",(String)response.jsonPath().get("rejectionMessage"));
+ assertEquals("fulfillment","fulfillment",(String)response.jsonPath().get("fulfillment"));
+
+ }
+
+
+ @Test
+ public void testIlpAddress() throws Exception {
+
+ String ilpAddressResponseJson = loadResourceAsString("test_data/ilpAddressMockResponse.json");
+ ilpService.stubFor(get(urlMatching("/ilpAddress.*")).willReturn(aResponse().withBody(ilpAddressResponseJson).withStatus(200)));
+
+ given().
+ contentType("application/json").
+ queryParam("account", "123459").
+ when().
+ get("http://localhost:8088/scheme/adapter/v1/ilpAddress").
+ then().
+ statusCode(200).
+ body("ilpAddress", equalTo("ok"));
+
+ }
+
+
+ @Test
+ public void testNotifications() throws Exception {
+
+ String notificationRequestBodyJson = loadResourceAsString("test_data/notificationMockRequestBody.json");
+ notificationsService.stubFor(post(urlPathMatching("/scheme/adapter/v1/notificationsXXX")).willReturn(aResponse().withStatus(500)));
+
+ given().
+ contentType("application/json").
+ body(notificationRequestBodyJson).
+ when().
+ post("http://localhost:8088/scheme/adapter/v1/notifications").
+ then().
+ statusCode(200);
+
+ }
+
+
+ @Test
+ public void testHealth() throws Exception {
+
+ String healthMockResponseJson = loadResourceAsString("test_data/healthMockResponse.json");
+ dfspAPIService.stubFor(get(urlPathMatching("/health")).willReturn(aResponse().withBody(healthMockResponseJson)));
+
+ given().
+ contentType("application/json").
+ when().
+ get("http://localhost:8088/scheme/adapter/v1/health").
+ then().
+ statusCode(200).
+ body("status", equalTo("ok"));
}
diff --git a/src/test/resources/test_data/healthMockResponse.json b/src/test/resources/test_data/healthMockResponse.json
new file mode 100644
index 0000000..466162b
--- /dev/null
+++ b/src/test/resources/test_data/healthMockResponse.json
@@ -0,0 +1,3 @@
+{
+ "status" : "ok"
+}
\ No newline at end of file
diff --git a/src/test/resources/test_data/ilpAddressMockResponse.json b/src/test/resources/test_data/ilpAddressMockResponse.json
new file mode 100644
index 0000000..5707e9a
--- /dev/null
+++ b/src/test/resources/test_data/ilpAddressMockResponse.json
@@ -0,0 +1,3 @@
+{
+ "ilpAddress" : "ok"
+}
\ No newline at end of file
diff --git a/src/test/resources/test_data/notificationMockRequestBody.json b/src/test/resources/test_data/notificationMockRequestBody.json
new file mode 100644
index 0000000..24bc5f8
--- /dev/null
+++ b/src/test/resources/test_data/notificationMockRequestBody.json
@@ -0,0 +1 @@
+{ "ipr": "some ipr string","paymentId":"string","destinationAccount":"string","status":"prepared","fulfillment":"string" }
\ No newline at end of file
diff --git a/src/test/resources/test_data/paymentMockResponse.json b/src/test/resources/test_data/paymentMockResponse.json
new file mode 100644
index 0000000..e883a73
--- /dev/null
+++ b/src/test/resources/test_data/paymentMockResponse.json
@@ -0,0 +1,7 @@
+{
+ "paymentId" : "123456",
+ "connectorAccount" : "123456",
+ "status" : "1",
+ "rejectionMessage" : "rejection message",
+ "fulfillment" : "fulfillment"
+}
\ No newline at end of file
diff --git a/src/test/resources/test_data/proxyPaymentRequest.json b/src/test/resources/test_data/proxyPaymentRequest.json
new file mode 100644
index 0000000..2102ae4
--- /dev/null
+++ b/src/test/resources/test_data/proxyPaymentRequest.json
@@ -0,0 +1,7 @@
+{
+ "ipr" : "123456",
+ "sourceAmount" : "123.12",
+ "sourceAccount" : "123456",
+ "connectorAccount" : "123456",
+ "sourceExpiryDuration" : "30"
+}
\ No newline at end of file