From: Kai Moritz Date: Sat, 13 Mar 2021 16:26:39 +0000 (+0100) Subject: WIP X-Git-Tag: wip-consumer~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=7fbe18464d293e674fee6ab10352f1f87630ca48;p=demos%2Fpact WIP --- 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");