Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request sequence not found #125

Open
florinmoc-git opened this issue May 26, 2022 · 1 comment
Open

Request sequence not found #125

florinmoc-git opened this issue May 26, 2022 · 1 comment

Comments

@florinmoc-git
Copy link

florinmoc-git commented May 26, 2022

Describe the issue
The expectations are not met. The request is returned instead of a comparison of the two paths.

What you are trying to do
I have a test where I expect 'authenticate' to be called before 'orders' (I'm using JUnit 4). Here's the code:

mockServer.verify(
    request().withPath("/users/v2/authenticate"),
    request().withPath("/data/v1/orders")
);

MockServer version
5.13.2

To Reproduce
Steps to reproduce the issue:

  1. How you are running MockServer (i.e maven plugin, docker, etc)
    In a JUnit 4 test:
@BeforeClass
public static void startMockServer() {
    ConfigurationProperties.initializationClass(ExpectationInitializer.class.getName());
    ConfigurationProperties.logLevel("WARN");
    mockServer = ClientAndServer.startClientAndServer(9001);
}
  1. Code you used to create expectations
@Override
public Expectation[] initializeExpectations() {
    return new Expectation[]{
            new Expectation(
                    request()
                            .withMethod("POST")
                            .withPath("/users/v2/authenticate")
            )
                    .thenRespond(
                    response()
                            .withStatusCode(200)
                            .withBody(json("{\n" +
                                    "  \"ImpersonationToken\": \"string\",\n" +
                                    "  \"KeepAliveTimeout\": \"string\",\n" +
                                    "  \"User\": {\n" +
                                    "    \"Language\": \"string\",\n" +
                                    "    \"Institution\": \"string\",\n" +
                                    "    \"Permissions\": {\n" +
                                    "      \"ImportSlides\": true,\n" +
                                    "      \"SaveAnnotations\": true,\n" +
                                    "      \"SaveOwnAnnotations\": true,\n" +
                                    "      \"ModifySystemConfiguration\": true,\n" +
                                    "      \"UseLisDataApi\": true,\n" +
                                    "      \"ExportImages\": true\n" +
                                    "    },\n" +
                                    "    \"Id\": \"00000000-0000-0000-0000-000000000000\",\n" +
                                    "    \"Login\": \"string\",\n" +
                                    "    \"Domain\": \"string\",\n" +
                                    "    \"FullName\": \"string\",\n" +
                                    "    \"RawName\": \"string\"\n" +
                                    "  },\n" +
                                    "  \"UrlAccessString\": \"string\"\n" +
                                    "}"))
            ),
            new Expectation(
                    request()
                            .withMethod("POST")
                            .withPath("/data/v1/orders")
            )
                    .thenRespond(
                    response()
                            .withStatusCode(200)
            )
    };
}
  1. What error you saw
    Intermittently I get this error:
junit.framework.AssertionFailedError: Request sequence not found, expected:<[ {
  "path" : "/users/v2/authenticate"
}, {
  "path" : "/data/v1/orders"
} ]> but was:<{
  "body" : {
    "contentType" : "application/json",
    "type" : "JSON",
    "json" : {
      "Login" : "ServerAccount",
      "Password" : "Password"
    },
    "rawBytes" : "eyJMb2dpbiI6IlNDSFNlcnZlckFjY591bnQiLCJQYXNzd29yZCI6IlNlY3RyYVBBQ1M0dSJ9"
  },
  "headers" : {
    "Authorization" : [ "Basic U0NIU9VydmVyQWNjb3VudDpTZWN0cmFQQUNTNHU=" ],
    "content-length" : [ "54" ],
    "Accept" : [ "application/json" ],
    "Connection" : [ "Keep-Alive" ],
    "User-Agent" : [ "Apache-HttpClient/4.5.4 (Java/11.0.14.1)" ],
    "Host" : [ "localhost:9001" ],
    "Accept-Encoding" : [ "gzip,deflate" ],
    "Content-Type" : [ "application/json" ]
  },
  "keepAlive" : true,
  "method" : "POST",
  "path" : "/users/v2/authenticate",
  "secure" : false
}>

Expected behaviour
To show that the calls were made in the right order

MockServer Log

at org.mockserver.client.MockServerClient.verify(MockServerClient.java:864)
at org.mockserver.client.MockServerClient.verify(MockServerClient.java:822)
@jamesdbloom
Copy link
Collaborator

How do you know that the code being test isn't sometimes not sending the second request? Also I don't understand the description:

The expectations are not met. The request is returned instead of a comparison of the two paths.

I guess the only issue you'ree concerned about is that you think MockServer is not verifying it has received both requests in the specified order when you feel it has?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants