Search in sources :

Example 1 with QueryRequestValidator

use of org.opennms.netmgt.measurements.api.QueryRequestValidator 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);
        }
    }
}
Also used : ValidationException(org.opennms.netmgt.measurements.api.exceptions.ValidationException) QueryRequest(org.opennms.netmgt.measurements.model.QueryRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) QueryRequestValidator(org.opennms.netmgt.measurements.api.QueryRequestValidator) QueryRequest(org.opennms.netmgt.measurements.model.QueryRequest) Request(com.github.tomakehurst.wiremock.http.Request) LoggedRequest(com.github.tomakehurst.wiremock.verification.LoggedRequest)

Aggregations

Request (com.github.tomakehurst.wiremock.http.Request)1 LoggedRequest (com.github.tomakehurst.wiremock.verification.LoggedRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 QueryRequestValidator (org.opennms.netmgt.measurements.api.QueryRequestValidator)1 ValidationException (org.opennms.netmgt.measurements.api.exceptions.ValidationException)1 QueryRequest (org.opennms.netmgt.measurements.model.QueryRequest)1