Skip to content

Commit 7416f77

Browse files
authored
docs: add unit test (#95)
* docs: add unit test * docs: linting * docs: update to springwolf version 1.7.0 * docs: improve faq for using springwolf-ui only * docs: re-order homepage feature
1 parent f5edc12 commit 7416f77

13 files changed

+73
-19
lines changed

docs/behind-the-scenes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ They follow the same plugin model.
5151

5252
## Putting it all together
5353

54-
The `AsyncApiService` collects all the channels, schemas and general info and builds the AsyncApi document.
54+
The `AsyncApiService` collects all the channels, schemas and general info and builds the AsyncAPI document.
5555
The controller access this services to serve the document to the UI.

docs/faq.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,45 @@ You can use `springwolf-ui` without any other Springwolf dependency.
1616
`springwolf-ui` will fetch any documentation available at the `springwolf/docs` path.
1717
It must be in `json` format (`yaml` isn't supported).
1818

19-
Either create a custom spring controller to serve the file or [serve static resources with spring](https://spring.io/guides/gs/serving-web-content/) and place your AsyncAPI document into `resources/springwolf/docs` (without file extension).
19+
Either create a custom spring controller to serve the file or [serve static resources with spring](https://spring.io/guides/gs/serving-web-content/) and place AsyncAPI document file called `docs` (without file extension) into the folder `resources/springwolf`.
2020

2121
Note: `springwolf-ui` doesn't support the full AsyncAPI spec.
2222

23+
### Unit test verification
24+
25+
With the AsyncAPI artifact checked into the repository at `src/test/resources/asyncapi.json`,
26+
a unit test can verify that the current code still matches the expected AsyncAPI specification.
27+
Additionally, a diff reveals (un)expected changes.
28+
29+
Example unit test:
30+
31+
```java
32+
@SpringBootTest(
33+
classes = {SpringwolfKafkaExampleApplication.class},
34+
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
35+
class ApiIntegrationTest {
36+
37+
@Autowired
38+
private TestRestTemplate restTemplate;
39+
40+
@Test
41+
void asyncApiResourceArtifactTest() throws IOException {
42+
String url = "/springwolf/docs";
43+
String actual = restTemplate.getForObject(url, String.class);
44+
45+
// writing the actual file can be useful for debugging (remember: gitignore)
46+
Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual);
47+
48+
InputStream s = this.getClass().getResourceAsStream("/asyncapi.json");
49+
String expected = new String(s.readAllBytes(), StandardCharsets.UTF_8).trim();
50+
51+
assertEquals(expected, actual);
52+
}
53+
}
54+
```
55+
56+
For a full example, check the [springwolf-kafka-example ApiIntegrationTest](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/springwolf/examples/kafka/ApiIntegrationTest.java)
57+
2358
## Troubleshooting
2459

2560
### Show `debug` output in the logs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-common-model-converters:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-common-model-converters:1.7.0'
33
}

docs/snippets/_springwolf_common_model_converters_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-common-model-converters</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-generic-binding:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-generic-binding:1.7.0'
33
}

docs/snippets/_springwolf_generic_binding_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-generic-binding</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dependencies {
22
// Provides the documentation API
3-
implementation 'io.github.springwolf:springwolf-kafka:1.4.0'
3+
implementation 'io.github.springwolf:springwolf-kafka:1.7.0'
44

55
// Provides the UI - optional (recommended)
6-
runtimeOnly 'io.github.springwolf:springwolf-ui:1.4.0'
6+
runtimeOnly 'io.github.springwolf:springwolf-ui:1.7.0'
77
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-json-schema:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-json-schema:1.7.0'
33
}

docs/snippets/_springwolf_json_schema_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-json-schema</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:1.7.0'
33
}

0 commit comments

Comments
 (0)