use of com.github.tomakehurst.wiremock.verification.LoggedRequest in project RoboZombie by sahan.
the class HttpMethodEndpointTest method testPostMethod.
/**
* <p>Test for the request method POST.</p>
*
* @since 1.3.0
*/
@Test
public final void testPostMethod() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String path = "/postrequest";
stubFor(post(urlEqualTo(path)).willReturn(aResponse().withStatus(200)));
String name = "DoctorWho", age = "953", location = "Tardis";
httpMethodEndpoint.postRequest(name, age, location);
List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching(path)));
assertFalse(requests == null);
assertFalse(requests.isEmpty());
LoggedRequest request = requests.get(0);
assertTrue(request.getMethod().equals(RequestMethod.POST));
String body = request.getBodyAsString();
assertTrue(body.contains("name=" + name));
assertTrue(body.contains("age=" + age));
assertTrue(body.contains("location=" + location));
}
use of com.github.tomakehurst.wiremock.verification.LoggedRequest in project RoboZombie by sahan.
the class HttpMethodEndpointTest method testGetMethod.
/**
* <p>Test for the request method GET.</p>
*
* @since 1.3.0
*/
@Test
public final void testGetMethod() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String name = "James-Howlett", age = "116", location = "X-Mansion";
String path = "/getrequest?name=" + name + "&age=" + age + "&location=" + location;
stubFor(get(urlEqualTo(path)).willReturn(aResponse().withStatus(200)));
httpMethodEndpoint.getRequest(name, age, location);
List<LoggedRequest> requests = findAll(getRequestedFor(urlEqualTo(path)));
assertFalse(requests == null);
assertFalse(requests.isEmpty());
LoggedRequest request = requests.get(0);
assertTrue(request.getMethod().equals(RequestMethod.GET));
}
use of com.github.tomakehurst.wiremock.verification.LoggedRequest in project RoboZombie by sahan.
the class HttpMethodEndpointTest method testPutMethod.
/**
* <p>Test for the request method PUT.</p>
*
* @since 1.3.0
*/
@Test
public final void testPutMethod() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String path = "/putrequest";
stubFor(put(urlEqualTo(path)).willReturn(aResponse().withStatus(200)));
String user = "{ '_id':1, 'alias':'Black Bolt' }";
httpMethodEndpoint.putRequest(user);
List<LoggedRequest> requests = findAll(putRequestedFor(urlMatching(path)));
assertFalse(requests == null);
assertFalse(requests.isEmpty());
LoggedRequest request = requests.get(0);
assertTrue(request.getMethod().equals(RequestMethod.PUT));
String body = request.getBodyAsString();
assertTrue(body.contains(user));
}
Aggregations