Skip to content

Commit

Permalink
docs: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Sep 6, 2024
1 parent 10fbf53 commit d0f8419
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
34 changes: 34 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,40 @@ Either create a custom spring controller to serve the file or [serve static reso

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

### Unit test verification

With the AsyncApi artifact (i.e. at `src/test/resources/asyncapi.json) checked into the repository,

Check failure on line 25 in docs/faq.md

View workflow job for this annotation

GitHub Actions / Build

[vale] reported by reviewdog 🐶 [Microsoft.Foreign] Use 'that is' instead of 'i.e.'. Raw Output: {"message": "[Microsoft.Foreign] Use 'that is' instead of 'i.e.'.", "location": {"path": "docs/faq.md", "range": {"start": {"line": 25, "column": 29}}}, "severity": "ERROR"}
a unit test can verify that the current code still matches the expected AsyncApi specification.
Additionally, a diff reveals (un)expected changes.

Example unit test:
```java
@SpringBootTest(
classes = {SpringwolfKafkaExampleApplication.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ApiIntegrationTest {

@Autowired
private TestRestTemplate restTemplate;

@Test
void asyncApiResourceArtifactTest() throws IOException {
String url = "/springwolf/docs";
String actual = restTemplate.getForObject(url, String.class);

// writing the actual file can be useful for debugging (remember: gitignore)
Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual);

InputStream s = this.getClass().getResourceAsStream("/asyncapi.json");
String expected = new String(s.readAllBytes(), StandardCharsets.UTF_8).trim();

assertEquals(expected, actual);
}
}
```

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)

## Troubleshooting

### Show `debug` output in the logs
Expand Down
27 changes: 23 additions & 4 deletions src/components/HomepageFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const FeatureList = [
title: 'Effortless API documentation',
description: (
<>
Springwolf uses metadata already provided in the code
Springwolf uses metadata already provided in the code
to automatically create documentation.
</>
),
Expand All @@ -26,15 +26,17 @@ const FeatureList = [
title: 'Powered by AsyncAPI v3',
description: (
<>
The generated documentation is compliant with the <Link to='https://www.asyncapi.com/'>AsyncAPI specification</Link>.
The generated documentation is compliant with the
<Link to='https://www.asyncapi.com/'>AsyncAPI specification</Link>.
</>
),
},
{
title: 'Optional web-ui',
description: (
<>
Single dependency ui for API testing including event publishing.
Single dependency for API testing including event publishing
(<Link to={'https://demo.springwolf.dev'}>demo</Link>).
</>
),
},
Expand All @@ -50,7 +52,24 @@ const FeatureList = [
title: 'Integrate',
description: (
<>
Generate documentation in your CI/CD pipeline and publish to tools like <Link to="https://backstage.io">Backstage</Link>.
Generate documentation in your CI/CD pipeline and publish to tools like
<Link to="https://backstage.io">Backstage</Link>.
</>
),
},
{
title: 'Verify',
description: (
<>
Use an unit test to check for (un)expected changes.
</>
),
},
{
title: 'Participate',
description: (
<>
Something missing? Features requests and contributions are welcome.
</>
),
},
Expand Down

0 comments on commit d0f8419

Please sign in to comment.