简体   繁体   中英

Wiremock problem with ignore requests except one

I have problem with ignore all requests except one. I have the code that I need to intercept the desired request, but before that I must skip all the other requests to the server. How can i do this?

givenThat(any(anyUrl()).withHeader("SOAPAction", equalTo("\"Mystifly.OnePoint/OnePoint/AirRevalidate\""))
                .willReturn(aResponse().withStatus(200)
                .withBody("{ \"message\": \"Roma Barladyn - a great colleague!\" }")
                ));

I also tried that but I get empty body of response, how I can send body which I get from server?

givenThat(any(anyUrl()).atPriority(100).willReturn(aResponse()));

If you need to make sure that you check the desired request first, you can add it at the highest priority . Priority 1 will get checked before Priority 2, get checked before Priority 3, and so on. So Priority 100 in your example will get checked after Priorities 1 through 99.

givenThat(any(anyUrl())
    .atPriority(1)
    .withHeader("SOAPAction", equalTo("\"Mystifly.OnePoint/OnePoint/AirRevalidate\""))        
    .willReturn(aResponse().withStatus(200)
    .withBody("{ \"message\": \"Roma Barladyn - a great colleague!\" }")
    ));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM