Search in sources :

Example 1 with HTTPStubHitAssertionVerificationResult

use of io.irontest.models.assertion.HTTPStubHitAssertionVerificationResult in project irontest by zheng-wang.

the class HTTPStubHitAssertionVerifier method verify.

@Override
public AssertionVerificationResult verify(Object... inputs) {
    HTTPStubHitAssertionVerificationResult result = new HTTPStubHitAssertionVerificationResult();
    HTTPStubHitAssertionProperties otherProperties = (HTTPStubHitAssertionProperties) getAssertion().getOtherProperties();
    List<ServeEvent> allServeEvents = (List<ServeEvent>) inputs[0];
    UUID stubInstanceUUID = (UUID) inputs[1];
    short stubInstanceHitCount = 0;
    for (ServeEvent serveEvent : allServeEvents) {
        if (serveEvent.getStubMapping().getId().equals(stubInstanceUUID)) {
            // the stub instance has been hit
            stubInstanceHitCount++;
        }
    }
    result.setActualHitCount(stubInstanceHitCount);
    if (stubInstanceHitCount != otherProperties.getExpectedHitCount()) {
        result.setResult(TestResult.FAILED);
    } else {
        result.setResult(TestResult.PASSED);
    }
    return result;
}
Also used : HTTPStubHitAssertionVerificationResult(io.irontest.models.assertion.HTTPStubHitAssertionVerificationResult) HTTPStubHitAssertionProperties(io.irontest.models.assertion.HTTPStubHitAssertionProperties) ServeEvent(com.github.tomakehurst.wiremock.stubbing.ServeEvent) List(java.util.List) UUID(java.util.UUID)

Aggregations

ServeEvent (com.github.tomakehurst.wiremock.stubbing.ServeEvent)1 HTTPStubHitAssertionProperties (io.irontest.models.assertion.HTTPStubHitAssertionProperties)1 HTTPStubHitAssertionVerificationResult (io.irontest.models.assertion.HTTPStubHitAssertionVerificationResult)1 List (java.util.List)1 UUID (java.util.UUID)1