Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codecov: codecov/codecov@5.0.3
codecov: codecov/codecov@6.0.0

defaults: &defaults
working_directory: ~/project
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/trolley/VerificationGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public String trigger(final String verificationType, final Object body) throws E
return this.client.post(endpoint, new ObjectMapper().writeValueAsString(body));
}

public String triggerIdentityOrBusinessVerification(final Object body) throws Exception {
final String endpoint = "/v1/verifications/trigger";
return this.client.post(endpoint, new ObjectMapper().writeValueAsString(body));
}

public String triggerWatchlist(final Object body) throws Exception {
final String endpoint = "/v1/verifications/watchlist/trigger";
return this.client.post(endpoint, new ObjectMapper().writeValueAsString(body));
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/com/trolley/VerificationGatewayTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.trolley;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.Test;

public class VerificationGatewayTest {
@Test
public void triggerIdentityOrBusinessVerificationUsesDedicatedEndpoint() throws Exception {
final VerificationGateway gateway = new VerificationGateway(new Configuration());
final RecordingClient client = new RecordingClient();
gateway.client = client;

final Map<String, Object> body = new LinkedHashMap<>();
body.put("recipientId", "R-123");
body.put("types", Arrays.asList("individual"));
body.put("retryAllowed", true);

final String response = gateway.triggerIdentityOrBusinessVerification(body);

assertEquals("/v1/verifications/trigger", client.endpoint);
assertEquals(
"{\"recipientId\":\"R-123\",\"types\":[\"individual\"],\"retryAllowed\":true}",
client.body
);
assertEquals("{\"ok\":true}", response);
}

private static class RecordingClient extends Client {
private String endpoint;
private String body;

RecordingClient() {
super(new Configuration());
}

@Override
public String post(final String endpoint, final String body) {
this.endpoint = endpoint;
this.body = body;
return "{\"ok\":true}";
}
}
}