|
25 | 25 | import java.util.HashMap;
|
26 | 26 | import java.util.HashSet;
|
27 | 27 | import java.util.List;
|
| 28 | +import java.util.Map; |
28 | 29 |
|
29 | 30 | public class WiremockTests {
|
30 | 31 | @Rule
|
@@ -458,4 +459,52 @@ public void octothorpeInUrlQuery() throws Exception {
|
458 | 459 |
|
459 | 460 | wireMockRule.verify(1, getRequestedFor(urlEqualTo("/api/v1/app/app1/msg?tag=test%23test")));
|
460 | 461 | }
|
| 462 | + |
| 463 | + @Test |
| 464 | + public void headersInTransformationParamsNotOverwritten() throws Exception { |
| 465 | + Svix svx = testClient(); |
| 466 | + wireMockRule.stubFor( |
| 467 | + WireMock.post(urlEqualTo("/api/v1/app/app1/msg")) |
| 468 | + .willReturn(WireMock.ok().withBodyFile("MessageOut.json"))); |
| 469 | + |
| 470 | + String jsonPayload = "{\"key\":\"val\",\"key1\":[\"list\"]}"; |
| 471 | + MessageIn msg = new MessageIn().payload(jsonPayload).eventType("event.type").transformationsParams(Map.of("headers",Map.of( "header-key","header-val"))); |
| 472 | + svx.getMessage().create("app1", msg); |
| 473 | + |
| 474 | + // file in java/lib/src/test/resources/__files/ExpectedMsgCreateBodyWithHeaders.json |
| 475 | + String expectedBody = |
| 476 | + wireMockRule |
| 477 | + .getOptions() |
| 478 | + .filesRoot() |
| 479 | + .getTextFileNamed("__files/ExpectedMsgCreateBodyWithHeaders.json") |
| 480 | + .readContentsAsString(); |
| 481 | + wireMockRule.verify( |
| 482 | + 1, |
| 483 | + postRequestedFor(urlEqualTo("/api/v1/app/app1/msg")) |
| 484 | + .withRequestBody(equalTo(expectedBody))); |
| 485 | + } |
| 486 | + @Test |
| 487 | + public void jsonEncodedMessageIn() throws Exception { |
| 488 | + Svix svx = testClient(); |
| 489 | + wireMockRule.stubFor( |
| 490 | + WireMock.post(urlEqualTo("/api/v1/app/app1/msg")) |
| 491 | + .willReturn(WireMock.ok().withBodyFile("MessageOut.json"))); |
| 492 | + |
| 493 | + String jsonPayload = "{\"key\":\"val\",\"key1\":[\"list\"]}"; |
| 494 | + MessageIn msg = new MessageIn().payload(jsonPayload).eventType("event.type"); |
| 495 | + svx.getMessage().create("app1", msg); |
| 496 | + |
| 497 | + // file in java/lib/src/test/resources/__files/ExpectedMsgCreateBody2.json |
| 498 | + String expectedBody = |
| 499 | + wireMockRule |
| 500 | + .getOptions() |
| 501 | + .filesRoot() |
| 502 | + .getTextFileNamed("__files/ExpectedMsgCreateBody2.json") |
| 503 | + .readContentsAsString(); |
| 504 | + wireMockRule.verify( |
| 505 | + 1, |
| 506 | + postRequestedFor(urlEqualTo("/api/v1/app/app1/msg")) |
| 507 | + .withRequestBody(equalTo(expectedBody))); |
| 508 | + } |
| 509 | + |
461 | 510 | }
|
0 commit comments