You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm in need of some help with the following: Upon verifying the actual body content to be equal to the expected I run into the following issue:
So the only difference here is the [equalTo] value, making my test fail.
Below is part of my test setup where equalTo() is being used inside the withRequestBody().
@QuarkusIntegrationTest
@ConnectWireMock
public class MYTestIT {
private static final String ENTITY_SAMPLE =
( "Entity{entity=<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<SOAP-ENV:Header><requestingParty xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\">12345678"
+ "</requestingParty></SOAP-ENV:Header><SOAP-ENV:Body SOAP-ENV:encodingStyle=\"UTF-8\"><note>\n"
+ "<to>Tove</to>\n"
+ "<from>Jani</from>\n"
+ "<heading>Reminder</heading>\n"
+ "<body>Don't forget me this weekend!</body>\n"
+ "</note></SOAP-ENV:Body></SOAP-ENV:Envelope>, variant=Variant[mediaType=application/xml;charset=UTF-8, language=null, encoding=null], annotations=[]}" );
@Test
void requestBodyTest() {
// Call expected to get triggered
wireMock.register( post( urlEqualTo( "/my/url" ) ).willReturn( aResponse()
.withStatus( Response.Status.OK.getStatusCode() )
.withHeader( "Content-Type", MediaType.APPLICATION_XML )
.withBody( "<somexml/>" ) ) );
// Call to eventually trigger call above
given()
.auth().preemptive().basic( "john.doe", "password" )
.post( "/api/v2/uploads" )
.then()
.statusCode( RestResponse.StatusCode.CREATED );
// Asserting the requestbody of the triggered request to equal ENTITY_SAMPLE
wireMock.verifyThat( postRequestedFor( urlEqualTo( "/my/url" ) ).withRequestBody( equalTo( ENITTY_SAMPLE ) ) );
}
}
I've tried multiple variants with contains(), matching(...), but often with the same result.
Looking forward to your response.
The text was updated successfully, but these errors were encountered:
3nterAUs3rname
changed the title
RequestBody actual and expected not equal due to added value to the expected avlue
RequestBody actual and expected not equal due to added value to the expected value
Aug 8, 2024
the post does not seem to post a body so I do not understand how the result in the screen shot occur.
the status returned by the Wiremock response is 'OK' whereas the resulting status code is verified to be 'CREATED'.
Personally I have never used the 'verifyThat' of WireMock. I prefer verify the response given by the mock.
So after then().statusCode(..) I would verify the returned body (in this case: "").
Hello,
I'm in need of some help with the following: Upon verifying the actual body content to be equal to the expected I run into the following issue:
So the only difference here is the [equalTo] value, making my test fail.
Below is part of my test setup where equalTo() is being used inside the withRequestBody().
I've tried multiple variants with contains(), matching(...), but often with the same result.
Looking forward to your response.
The text was updated successfully, but these errors were encountered: