From 7fbe18464d293e674fee6ab10352f1f87630ca48 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 13 Mar 2021 17:26:39 +0100 Subject: [PATCH] WIP --- .../consumer/adapter/RemoteUsersServiceConsumerIT.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java b/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java index 9c0e9e4..0eacb8f 100644 --- a/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java +++ b/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java @@ -12,7 +12,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.web.client.RestTemplate; import java.io.IOException; import java.util.Map; @@ -22,15 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@SpringBootTest @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "UsersProvider") public class RemoteUsersServiceConsumerIT { - @Autowired - RemoteUsersServiceConsumer usersService; - - @Pact(consumer="EmailServicesConsumer") public RequestResponsePact getExistingUserByEmail(PactDslWithProvider builder) { return builder @@ -50,6 +47,8 @@ public class RemoteUsersServiceConsumerIT @Test @PactTestFor(pactMethod = "getExistingUserByEmail") public void testGetExistingUserByEmail(MockServer mockServer) { + RestTemplate restTemplate = new RestTemplateBuilder().rootUri(mockServer.getUrl()).build(); + RemoteUsersServiceConsumer usersService = new RemoteUsersServiceConsumer("/path?email={email}", restTemplate); try { Optional result = usersService.getUserByEmail("pact@juplo.de"); -- 2.20.1