From 85861ffd8e9f84ad733b1e9b9a709460113eb120 Mon Sep 17 00:00:00 2001 From: Ryan Bergman Date: Thu, 26 Oct 2023 07:56:30 -0500 Subject: [PATCH] invocation matching not taking verb into account correctly --- unirest-mocks/src/main/java/kong/unirest/core/Routes.java | 2 +- unirest-mocks/src/test/java/kong/tests/AssertTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/unirest-mocks/src/main/java/kong/unirest/core/Routes.java b/unirest-mocks/src/main/java/kong/unirest/core/Routes.java index cfd853d9..c03d30ec 100644 --- a/unirest-mocks/src/main/java/kong/unirest/core/Routes.java +++ b/unirest-mocks/src/main/java/kong/unirest/core/Routes.java @@ -54,7 +54,7 @@ Expectation newExpectation() { boolean matches(HttpRequest request) { Path p = new Path(request.getUrl()); return this.method.equals(request.getHttpMethod()) - && this.path == null || this.path.equalsIgnoreCase(p.baseUrl()); + && (this.path == null || this.path.equalsIgnoreCase(p.baseUrl())); } RawResponse exchange(HttpRequest request, Config config) { diff --git a/unirest-mocks/src/test/java/kong/tests/AssertTest.java b/unirest-mocks/src/test/java/kong/tests/AssertTest.java index c58814d6..b1411c25 100644 --- a/unirest-mocks/src/test/java/kong/tests/AssertTest.java +++ b/unirest-mocks/src/test/java/kong/tests/AssertTest.java @@ -250,6 +250,12 @@ void returnAMockResponseObjectWithoutStuff() { assertEquals(List.of(), response.getHeaders().get("cool")); } + @Test + void verbsAreImportant() { + client.expect(GET, path).thenReturn("hi"); + assertNotEquals("hi", Unirest.post(path).asString().getBody()); + } + private static class BodyBuddy implements Supplier{ String body; @Override