@@ -17,105 +17,7 @@ link:{oap-central}[image:{badge-central}[]]
1717
1818== openapi-processor-test
1919
20- this contains re-usable code and data for testing openapi-processors.
21-
22- === test code/data
23-
24- A test case does an end-to-end test of an openapi-processor.
25-
26- `resources/tests` contains the input files of a number of tests. The name of the folder is the name
27- of the test case.
28-
29- A test case contains an `openapi.yaml` and a `mapping.yaml` file in the `inputs` folder. An
30- `inputs.yaml` sibling file of the `inputs` folder list the files in the folder.
31-
32- To provide the expected output of the test case a consumer of oap-test creates a
33- `resources/tests/<integration test name>` folder in its *own* resources. Inside it a `generated` folder
34- and a `generated.yaml` with the list of expected files in the corresponding folder.
35-
36- A test case can contain both inputs and outputs. So it is easy to create additional tests without
37- touching oap-test.
38-
39- To run the test cases a consumer creates an `@RunWith(Parameterized)` junit test which extends
40- `com.github.hauner.openapi.test.ProcessorTestBase`. The `@Parameterized` method provides the list of
41- test cases to run.
42-
43- ==== example
44-
45- the inputs:
46-
47- resources/tests/my-test
48- +--- inputs.yaml
49- \--- inputs
50- +--- mapping.yaml
51- \--- openapi.yaml
52-
53- the expected files:
54-
55- resources/tests/my-test
56- +--- generated.yaml
57- \--- generated
58- +--- api
59- | \--- EndpointApi.java
60- \--- model
61- \--- Foo.java
62-
63- the `inputs.yaml` and `generated.yaml` use the same simple format:
64-
65- items:
66- - inputs/openapi.yaml
67- - inputs/mapping.yaml
68-
69- or
70-
71- items:
72- - generated/api/EndpointApi.java
73- - generated/model/Foo.java
74-
75-
76- Extending `com.github.hauner.openapi.test.ProcessorTestBase` looks like this (using groovy):
77-
78- [source,groovy]
79- ----
80- import com.github.hauner.openapi.test.ProcessorTestBase
81- import com.github.hauner.openapi.test.TestSet
82-
83- @RunWith(Parameterized)
84- class ProcessorEndToEndTest extends ProcessorTestBase {
85-
86- static def ALL = [
87- 'test-case', // this is the folder name in resources/tests
88- // ... more tests
89- ]
90-
91-
92- @Parameterized.Parameters(name = "{0}")
93- static Collection<TestSet> sources () {
94- def swagger = ALL.collect {
95- new TestSet (name: it, processor: new Processor(), parser: ParserType.SWAGGER.name ())
96- }
97-
98- def openapi4j = ALL.collect {
99- new TestSet (name: it, processor: new Processor(), parser: ParserType.OPENAPI4J.name ())
100- }
101-
102- swagger + openapi4j
103- }
104-
105- ProcessorEndToEndTest (TestSet testSet) {
106- super (testSet)
107- }
108-
109- @Test
110- void "native - processor creates expected files for api set "() {
111- runOnNativeFileSystem ()
112- }
113-
114- }
115- ----
116-
117- See link:{oap-core}[openapi-processor-core] and link:{oap-spring}[openapi-processor-spring] for
118- working examples.
20+ this contains re-usable code for running integration test of an openapi-processor-x.
11921
12022== documentation
12123
0 commit comments