Skip to content

Commit ae6541c

Browse files
committed
polish
1 parent 0fec7ae commit ae6541c

3 files changed

Lines changed: 13 additions & 28 deletions

File tree

pact-feign-consumer/src/main/java/com/example/demo/AddressClient.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
import org.springframework.hateoas.Resource;
55
import org.springframework.hateoas.Resources;
66
import org.springframework.web.bind.annotation.PathVariable;
7-
import org.springframework.web.bind.annotation.RequestBody;
87
import org.springframework.web.bind.annotation.RequestMapping;
98
import org.springframework.web.bind.annotation.RequestMethod;
109

1110
@FeignClient(value = "addresses", path = "/addresses")
1211
public interface AddressClient {
1312

14-
@RequestMapping(method = RequestMethod.GET, path = "/")
15-
Resources<Address> getAddresses();
13+
@RequestMapping(method = RequestMethod.GET, path = "/")
14+
Resources<Address> getAddresses();
1615

17-
@RequestMapping(method = RequestMethod.GET, path = "/{id}")
18-
Resource<Address> getAddress(@PathVariable("id") long id);
19-
20-
@RequestMapping(method = RequestMethod.PUT, consumes = "text/uri-list", path="/{addressId}/customer")
21-
Resource<Address> associateWithCustomer(@PathVariable("addressId") long addressId, @RequestBody String customerUri);
22-
23-
@RequestMapping(method = RequestMethod.GET, path="/{addressId}/customer")
24-
Resource<Customer> getCustomer(@PathVariable("addressId") long addressId);
16+
@RequestMapping(method = RequestMethod.GET, path = "/{id}")
17+
Resource<Address> getAddress(@PathVariable("id") long id);
2518

2619
}

pact-feign-consumer/src/test/java/com/example/demo/ConsumerPactVerificationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@RunWith(SpringRunner.class)
2121
@SpringBootTest(properties = {
22-
// overriding producer address
22+
// overriding provider address
2323
"addresses.ribbon.listOfServers: localhost:8888"
2424
})
2525
public class ConsumerPactVerificationTest {
@@ -30,10 +30,10 @@ public class ConsumerPactVerificationTest {
3030
@Autowired
3131
private AddressClient addressClient;
3232

33-
@Pact(state = "address-collection", provider = "customerServiceProvider", consumer = "addressClient")
33+
@Pact(state = "a collection of 2 addresses", provider = "customerServiceProvider", consumer = "addressClient")
3434
public RequestResponsePact createAddressCollectionResourcePact(PactDslWithProvider builder) {
3535
return builder
36-
.given("address-collection")
36+
.given("a collection of 2 addresses")
3737
.uponReceiving("a request to the address collection resource")
3838
.path("/addresses/")
3939
.method("GET")
@@ -94,10 +94,10 @@ public RequestResponsePact createAddressCollectionResourcePact(PactDslWithProvid
9494
.toPact();
9595
}
9696

97-
@Pact(state = "single-address", provider = "customerServiceProvider", consumer = "addressClient")
97+
@Pact(state = "a single address", provider = "customerServiceProvider", consumer = "addressClient")
9898
public RequestResponsePact createAddressResourcePact(PactDslWithProvider builder) {
9999
return builder
100-
.given("single-address")
100+
.given("a single address")
101101
.uponReceiving("a request to the address resource")
102102
.path("/addresses/1")
103103
.method("GET")
@@ -122,14 +122,14 @@ public RequestResponsePact createAddressResourcePact(PactDslWithProvider builder
122122

123123
@Test
124124
@PactVerification(fragment = "createAddressCollectionResourcePact")
125-
public void addressCollectionResourcePact() {
125+
public void verifyAddressCollectionPact() {
126126
Resources<Address> addresses = addressClient.getAddresses();
127127
assertThat(addresses).hasSize(2);
128128
}
129129

130130
@Test
131131
@PactVerification(fragment = "createAddressResourcePact")
132-
public void addressResourcePact() {
132+
public void verifyAddressPact() {
133133
Resource<Address> address = addressClient.getAddress(1L);
134134
assertThat(address).isNotNull();
135135
}

pact-spring-data-rest-provider/src/test/java/com/example/demo/ProviderPactVerificationTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@
77
import au.com.dius.pact.provider.junit.target.HttpTarget;
88
import au.com.dius.pact.provider.junit.target.Target;
99
import au.com.dius.pact.provider.junit.target.TestTarget;
10-
import com.example.framework.DatabaseState;
1110
import com.example.framework.DatabaseStateHolder;
1211
import com.example.framework.SpringBootStarter;
1312
import org.junit.ClassRule;
1413
import org.junit.runner.RunWith;
15-
import org.springframework.boot.test.context.SpringBootTest;
16-
import org.springframework.context.ConfigurableApplicationContext;
17-
18-
import java.util.ArrayList;
19-
import java.util.List;
20-
import java.util.Map;
2114

2215
@RunWith(PactRunner.class)
2316
@Provider("customerServiceProvider")
@@ -32,18 +25,17 @@ public class ProviderPactVerificationTest {
3225
.withDatabaseState("address-collection", "/initial-schema.sql", "/address-collection.sql")
3326
.build();
3427

35-
@State("single-address")
28+
@State("a single address")
3629
public void toSingleAddressState() {
3730
DatabaseStateHolder.setCurrentDatabaseState("single-address");
3831
}
3932

40-
@State("address-collection")
33+
@State("a collection of 2 addresses")
4134
public void toAddressCollectionState() {
4235
DatabaseStateHolder.setCurrentDatabaseState("address-collection");
4336
}
4437

4538
@TestTarget
4639
public final Target target = new HttpTarget(8080);
4740

48-
4941
}

0 commit comments

Comments
 (0)