WIP
authorKai Moritz <kai@juplo.de>
Sat, 13 Mar 2021 16:26:39 +0000 (17:26 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 13 Mar 2021 16:26:39 +0000 (17:26 +0100)
consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java

index 9c0e9e4..0eacb8f 100644 (file)
@@ -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<User> result = usersService.getUserByEmail("pact@juplo.de");