Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Created October 18, 2016 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkingserious/0fabc5f36d3bb0d5a2447afbdf339931 to your computer and use it in GitHub Desktop.
Save thinkingserious/0fabc5f36d3bb0d5a2447afbdf339931 to your computer and use it in GitHub Desktop.
Example of a Mock HTTP Server
package com.sendgrid;
import java.io.IOException;
import java.util.HashMap;
public class MockSendGrid extends SendGrid {
Request request;
public MockSendGrid(String apiKey) {
super(apiKey);
}
public Response makeCall(Request request) throws IOException {
this.request = request;
Response response = new Response();
response.statusCode = 200;
response.body = "{\"message\":\"success\"}";
response.headers = new HashMap<String, String>();
response.headers.put("Test", "Header");
return response;
}
public Request getRequest() {
return this.request;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment