Sheetal Jain
03/13/2023, 1:39 PM/gradlew build.
I am sharing the error here:
com.github.tomakehurst.wiremock.client.VerificationException: Expected exactly 1 requests matching the following pattern but received 2:
Code snippet of my class is:
public void test() {
SignUpEvent event = createTestSignUpEvent(EnumEventType.SIGN_UP, userId);
// create stubs
setSuccessfulUserProfileResponse(userId);
setSuccessfulServerApiTrackReferralStub(userId, personId);
setSuccessfulGetExternalIdStub(userId, false);
setSuccessfulGenerateFirebaseUrlStub();
setSuccessfulUserProfileResponse(userId);
// publish test event
sendEvent(event);
Awaitility.await().pollDelay(Durations.TWO_SECONDS).until(() -> true);
wireMockServer.verify(1, getRequestedFor(urlMatching(
String.format("{url}", userId))));
wireMockServer.verify(0, postRequestedFor(urlMatching(
"{url}")));
}
Is there anyone here who can help me with this? I tried with Thread.sleep also.Paul Petershagen
03/14/2023, 3:35 AMAwaitility.await().pollDelay(Durations.TWO_SECONDS).untilAsserted(() -> {
wireMockServer.verify(1, getRequestedFor(urlMatching(
String.format("{url}", userId))));
wireMockServer.verify(0, postRequestedFor(urlMatching(
"{url}")));
});
It will wait until the assertions don't throw an exception. You might also want to add an .atMost(...)
, to change the max runtime for the await()
. But if in that time frame the unit under test sends two requests, then that is its behavior, then double check the prod code is doing the right thing.urlMatching
statement if that is right, not sure if you have modified it for this post here.Sheetal Jain
03/14/2023, 6:24 AMurlMatching
. Let me make the changes that you have suggested then I'll let you know.await() statement
to what you have suggested? Like where is the problem.org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a lambda expression in co.tala.atlas.promotions.integration.kafka.consumer.SignUpEventConsumerTest Expected exactly 1 requests matching the following pattern but received 2:
Paul Petershagen
03/14/2023, 6:41 AMSheetal Jain
03/14/2023, 6:45 AMPaul Petershagen
03/14/2023, 6:48 AMSheetal Jain
03/14/2023, 6:48 AMcom.github.tomakehurst.wiremock.client.VerificationException: Expected exactly 1 requests matching the following pattern but received 2:
{
"urlPattern" : "/users/customer/profiles/844424930132106",
"method" : "GET"
}
at com.github.tomakehurst.wiremock.client.WireMock.verifyThat(WireMock.java:538)
at com.github.tomakehurst.wiremock.client.WireMock.verifyThat(WireMock.java:521)
at com.github.tomakehurst.wiremock.WireMockServer.verify(WireMockServer.java:271)
at