Skip to content

Commit

Permalink
Fixed instructions for starting the stub server and Kafka mock
Browse files Browse the repository at this point in the history
Fixed instructions for starting the stub server and Kafka mock
  • Loading branch information
nashjain authored Jul 30, 2024
1 parent eb80184 commit 524eca1
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,41 @@ A typical web application might look like this. We can use Specmatic to practice
2. Specmatic
3. Specmatic Beta extension (for mocking Kafka)
4. Karate

## Run Tests
This will start the specmatic stub server for domain api and kafka mock using the information in specmatic.json and run contract tests using Specmatic and API Tests using karate.
```shell
./gradlew test
```

# Break down each components and understand what is happening

## Start BFF Server
This will start the springboot BFF server
### Start the dependent components
1. Download Specmatic Jar from [github](https://github.com/znsio/specmatic/releases)

2. Start domain api stub server
```shell
./gradlew bootRun
java -jar specmatic.jar stub --port=8090
```
_*Note:* When running this command you might get an error:_

3. Start Kafka stub server
```shell
Could not find in. specmatic: specmatic-kafka:0.xx.yy.
java -jar lib/specmatic-kafka-0.22.5-TRIAL-all.jar --specification=.specmatic/repos/specmatic-order-contracts/io/specmatic/examples/store/asyncapi/kafka.yaml
```
You would have got this error because you don't have access to Specmatic Kafka. To fix this issue, reach out to us at [email protected] and we'll add you to our beta program and provide you access.

Access find orders api at http://localhost:8080/findAvailableProducts
_*Note:* Unless domain api service is running on port 9000, above requests will fail. Move to next section for solution!_
## Start BFF Server
This will start the springboot BFF server
```shell
./gradlew bootRun
```

### Start BFF Server with Domain API Stub
1. Download Specmatic Jar from [github](https://github.com/znsio/specmatic/releases)
## Test if everything is working

2. Start domain api stub server
```shell
java -jar specmatic.jar stub
curl -H "pageSize: 10" "http://localhost:8080/findAvailableProducts"
```
Access find orders api again at http://localhost:8080/findAvailableProducts with result like

You result should look like:
```json
[{"id":698,"name":"NUBYR","type":"book","inventory":278}]
```

## Run Tests
This will start the specmatic stub server for domain api using the information in specmatic.json and run the karate tests that expects the domain api at port 9000.
```shell
./gradlew test
```

0 comments on commit 524eca1

Please sign in to comment.