use of com.github.tomakehurst.wiremock.http.Request in project opennms by OpenNMS.
the class AbstractMeasurementQueryExecutorTest method verifyHttpCalls.
protected void verifyHttpCalls(int number) {
// ensure a request was actually made and was only made <number> times
WireMock.verify(number, WireMock.postRequestedFor(WireMock.urlMatching("/opennms/rest/measurements")).withoutHeader("Authorization").withHeader("Content-Type", WireMock.equalTo("application/xml")));
// VERIFY that the Request Body is a valid QueryRequest
Assert.assertEquals(number, requestList.size());
for (Request eachRequest : requestList) {
QueryRequest queryRequest = JAXB.unmarshal(new ByteArrayInputStream(eachRequest.getBody()), QueryRequest.class);
try {
new QueryRequestValidator().validate(queryRequest);
} catch (ValidationException e) {
Throwables.propagate(e);
}
}
}
use of com.github.tomakehurst.wiremock.http.Request in project opennms by OpenNMS.
the class AbstractMeasurementQueryExecutorTest method before.
@Before
public void before() throws IOException {
requestList.clear();
// we listen to all requests and verify that the POST data can be parsed as a Query Request
wireMockRule.addMockServiceRequestListener(new RequestListener() {
@Override
public void requestReceived(Request request, Response response) {
requestList.add(LoggedRequest.createFrom(request));
}
});
new File("target/reports").mkdirs();
}
Aggregations