Skip to content

Commit 63c5d9f

Browse files
committed
Update dependencies and README.mnd
1 parent 13eb339 commit 63c5d9f

File tree

2 files changed

+78
-25
lines changed

2 files changed

+78
-25
lines changed

README.md

Lines changed: 77 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,86 @@
11
![Diagram](./GraphQLStubbing.gif)
22

3-
# Specmatic UI project for GraphQL demo
4-
5-
## Run the tests
6-
7-
1. Using gradle -
8-
```shell
9-
./gradlew clean test
10-
```
11-
2. Using docker -
12-
- Start Docker Desktop
13-
- Start the graphql service stub using
14-
```shell
15-
docker run -v "$PWD/specmatic.yml:/usr/src/app/specmatic.yml" -v "$PWD/src/test/resources/specmatic/graphql/examples:/usr/src/app/examples" -p 8080:8080 specmatic/specmatic-graphql virtualize --port=8080 --examples=examples
16-
```
17-
- Run the application - `./gradlew bootRun`
18-
- Run the tests -
19-
```shell
20-
docker run --network host -v "$PWD/specmatic.yml:/usr/src/app/specmatic.yml" -v "$PWD/build/reports/specmatic:/usr/src/app/build/reports/specmatic" specmatic/specmatic test --port=8070 --host=host.docker.internal
21-
```
22-
23-
Look at the `ContractTest` class to see how the GraphQL dependency has been stubbed out.
3+
# GraphQL Service Virtualization Using Specmatic GraphQL
4+
5+
* [Specmatic Website](https://specmatic.io)
6+
* [Specmatic Documentation](https://docs.specmatic.io)
7+
8+
This sample project demonstrates how we can practice contract-driven development and contract testing in a REST (Kotlin) API that depends on an external GraphQL domain service. Here, Specmatic is used to stub calls to domain graphQL API service based on its GraphQL specification, and also to contract test the REST API itself based on its own OpenAPI specification.
249

2510
## Start the application
2611

27-
1. Checkout the Order API project from [here](https://github.com/specmatic/specmatic-order-api-java), and start it up using the instructions in it's README.
28-
2. Checkout the BFF project from [here](https://github.com/specmatic/specmatic-order-bff-graphql-java), and start it up using the instructions in it's README.
29-
3. Execute this command:
12+
1. Checkout the BFF project from [here](https://github.com/specmatic/specmatic-order-bff-graphql-java), and start it up using the instructions in it's README.
13+
2. Execute this command:
14+
15+
- On Unix and Windows Powershell:
3016

3117
```shell
3218
./gradlew bootRun
3319
```
20+
21+
- On Windows CMD Prompt:
22+
23+
```shell
24+
gradlew bootRun
25+
```
26+
27+
## Running the contract tests
28+
29+
Look at the [`ContractTest`](./src/test/java/com/example/productsearch/controller/ContractTest.java) class to see how the GraphQL dependency has been stubbed out.
30+
31+
Execute this command to run the contract tests:
32+
33+
- On Unix and Windows Powershell:
34+
35+
```shell
36+
./gradlew test
37+
```
38+
39+
- On Windows CMD Prompt:
40+
41+
```shell
42+
gradlew test
43+
```
44+
45+
### Running the contract tests manually
46+
47+
#### 1. Start the Specmatic GraphQL mock server
48+
49+
- On Unix and Windows Powershell:
50+
51+
```shell
52+
docker run --rm -p 8080:8080 -v "$(pwd)/specmatic.yml:/usr/src/app/specmatic.yml" -v "$(pwd)/src/test/resources/specmatic/graphql/examples:/usr/src/app/examples" specmatic/specmatic-graphql virtualize --port=8080 --examples=examples
53+
```
54+
55+
- On Windows CMD Prompt:
56+
```shell
57+
docker run --rm -p 8080:8080 -v "%cd%/specmatic.yml:/usr/src/app/specmatic.yml" -v "%cd%/src/test/resources/specmatic/graphql/examples:/usr/src/app/examples" specmatic/specmatic-graphql virtualize --port=8080 --examples=examples
58+
```
59+
60+
#### 2. Build and run the BFF service (System Under Test) using Gradle
61+
62+
- On Unix and Windows Powershell:
63+
64+
```shell
65+
./gradlew bootRun
66+
```
67+
68+
- On Windows CMD Prompt:
69+
70+
```shell
71+
gradlew bootRun
72+
```
73+
74+
#### 3. Run the contract tests using Docker
75+
76+
- On Unix and Windows Powershell:
77+
78+
```shell
79+
docker run --rm --network host -v "$(pwd)/specmatic.yml:/usr/src/app/specmatic.yml" -v "$(pwd)/build/reports/specmatic:/usr/src/app/build/reports/specmatic" specmatic/specmatic test --port=8070
80+
```
81+
82+
- On Windows CMD Prompt:
83+
84+
```shell
85+
docker run --rm --network host -v "%cd%/specmatic.yml:/usr/src/app/specmatic.yml" -v "%cd%/build/reports/specmatic:/usr/src/app/build/reports/specmatic" specmatic/specmatic test --port=8070
86+
```

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
specmaticVersion=2.28.1
1+
specmaticVersion=2.29.0
22
specmaticGraphqlVersion=1.5.0

0 commit comments

Comments
 (0)