Advertisement
ogionfrost

Untitled

Aug 10th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import com.github.tomakehurst.wiremock.WireMockServer;
  2. import com.google.gson.Gson;
  3.  
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. import static com.github.tomakehurst.wiremock.client.WireMock.*;
  8. import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
  9.  
  10. public class Main {
  11.     static private Map<String, Object> payload = new HashMap<>();
  12.     static private Map<String, Object> currentOrder = new HashMap<>();
  13.     static private Gson gson = new Gson();
  14.  
  15.     public static void main(String[] args) {
  16.         payload.put("current_order", currentOrder);
  17.         payload.put("primary_phone", "8887418529");
  18.         payload.put("callback_url", "http://10.5.1.181:8080/post");
  19.         //payload.put("callback_url", "https://revoreq.herokuapp.com/1lmc9mi1");
  20.         //payload.put("callback_url", "http://p9r66.mocklab.io");
  21.         //payload.put("callback_url", "http://requestbin.fullcontact.com/1bx9vqj1");
  22.         payload.put("redirect_url", "https://bash.im");
  23.         currentOrder.put("order_id", "ejg64jFf49");
  24.         currentOrder.put("amount", "12000.00");
  25.         currentOrder.put("term", "6");
  26.         currentOrder.put("valid_till", "22.10.2018 16:16:00+03:00");
  27.  
  28.         WireMockServer wireMockServer = new WireMockServer(
  29.                 wireMockConfig()
  30.                         .asynchronousResponseEnabled(true)); //No-args constructor will start on port 8080, no HTTPS
  31.         wireMockServer.start();
  32.  
  33.         stubFor(post(urlEqualTo("/post")).withMultipartRequestBody(
  34.                 aMultipart()
  35.                         .withHeader("Content-Type", containing("application/json"))
  36.                         .withBody(equalToJson(gson.toJson(payload))))
  37.                 .willReturn(aResponse()
  38.                         .withHeader("Content-Type", "text/plain")
  39.                         .withBody("ok")));
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement