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;
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
@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");