File tree 5 files changed +90
-3
lines changed
openapi-processor-core/src/testInt/resources/tests/server-url
openapi-processor-test/src/main/groovy/io/openapiprocessor/test
5 files changed +90
-3
lines changed Original file line number Diff line number Diff line change 1
1
items :
2
- - outputs/api/Api.java
2
+ - outputs/java/api/Api.java
3
+ - outputs/resources/api.properties
Original file line number Diff line number Diff line change 1
1
package generated .api ;
2
2
3
3
import annotation .Mapping ;
4
- import annotation .Prefix ;
5
4
import generated .support .Generated ;
6
5
7
6
@ Generated (value = "openapi-processor-core" , version = "test" )
8
- @ Prefix ("/foo/bar/v1" )
9
7
public interface Api {
10
8
11
9
@ Mapping ("/foo" )
Original file line number Diff line number Diff line change
1
+ openapi.base.path = /foo/bar/v1
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 https://github.com/openapi-processor/openapi-processor-base
3
+ * PDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ package io.openapiprocessor.test
7
+
8
+ class Expected {
9
+ TestSet testSet
10
+ String packageName
11
+ TestItemsReader reader
12
+
13
+ String path
14
+ Set<String > items
15
+
16
+ Expected (TestSet testSet , String packageName , TestItemsReader reader ) {
17
+ this . testSet = testSet
18
+ this . packageName = packageName
19
+ this . reader = reader
20
+
21
+ def sourcePath = " /tests/${ testSet.name} "
22
+ path = " ${ sourcePath} /${ testSet.expected} "
23
+ items = files (sourcePath, testSet. expected)
24
+ }
25
+
26
+ /**
27
+ * get the expected files (from outputs.yaml) and strips the prefix.
28
+ *
29
+ * @param path the resource path of the test, i.e. /tests/{test-name}
30
+ * @param stripPrefix prefix to strip, i.e. inputs/outputs folder
31
+ * @return the expected files
32
+ */
33
+ private Set<String > files (String path , String stripPrefix ) {
34
+ def items = reader. read (path, testSet. outputs)
35
+
36
+ def wanted = items. items. collect {
37
+ it. substring (stripPrefix. size () + 1 )
38
+ }
39
+
40
+ def result = new TreeSet<String > ()
41
+ result. addAll (wanted)
42
+ result
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 https://github.com/openapi-processor/openapi-processor-base
3
+ * PDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ package io.openapiprocessor.test
7
+
8
+ import com.fasterxml.jackson.databind.DeserializationFeature
9
+ import com.fasterxml.jackson.databind.ObjectMapper
10
+ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
11
+
12
+ class TestItemsReader {
13
+ private Class resourceBase
14
+
15
+ TestItemsReader (Class resourceBase ) {
16
+ this . resourceBase = resourceBase
17
+ }
18
+
19
+ /**
20
+ * read test items yaml
21
+ *
22
+ * @param resource path
23
+ * @param name of test items yaml file
24
+ * @return content of yaml
25
+ */
26
+ TestItems read (String path , String itemsYaml ) {
27
+ def source = getResource (" ${ path} /${ itemsYaml} " )
28
+ if (! source) {
29
+ println " ERROR: missing '${ path} /${ itemsYaml} ' configuration file!"
30
+ }
31
+
32
+ def mapper = createYamlParser ()
33
+ mapper. readValue (source. text, TestItems )
34
+ }
35
+
36
+ InputStream getResource (String path ) {
37
+ resourceBase. getResourceAsStream (path)
38
+ }
39
+
40
+ private static ObjectMapper createYamlParser () {
41
+ new ObjectMapper (new YAMLFactory ()). configure (DeserializationFeature . FAIL_ON_UNKNOWN_PROPERTIES , false )
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments