Skip to content

Commit 0e69c63

Browse files
committed
improved path handling
1 parent 226ec35 commit 0e69c63

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

src/main/groovy/com/github/hauner/openapi/test/ProcessorTestBase.groovy

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ abstract class ProcessorTestBase {
6868
def expectedPath = "${sourcePath}/${packageName}"
6969
def generatedPath = Path.of (folder.root.toString()).resolve (packageName)
7070

71-
def expectedFiles = collectOutputPaths (sourcePath, packageName)
71+
def expectedFiles = collectRelativeOutputPaths (sourcePath, packageName)
7272
.sort ()
7373
def generatedFiles = collectPaths (generatedPath)
7474
.sort ()
@@ -93,9 +93,8 @@ abstract class ProcessorTestBase {
9393

9494
Path root = Files.createDirectory (fs.getPath ("source"))
9595

96-
copy ("/tests/${source}", collectInputPaths ("/tests/${source}"), root)
97-
copy ("/tests/${source}", collectOutputPaths ("/tests/${source}"), root)
98-
96+
copy ("/tests/${source}", collectAbsoluteInputPaths ("/tests/${source}"), root)
97+
copy ("/tests/${source}", collectAbsoluteOutputPaths ("/tests/${source}"), root)
9998

10099
Path api = root.resolve ('openapi.yaml')
101100
Path target = fs.getPath ('target')
@@ -159,13 +158,6 @@ abstract class ProcessorTestBase {
159158
paths.close ()
160159
}
161160

162-
/**
163-
* copy paths resources <=> file system
164-
*/
165-
protected void copy (String source, Path target) {
166-
copy (source, collectResourcePaths (source), target)
167-
}
168-
169161
/**
170162
* copy paths resources <=> file system
171163
*/
@@ -182,7 +174,6 @@ abstract class ProcessorTestBase {
182174
}
183175
}
184176

185-
186177
/**
187178
* collect paths in file system
188179
*/
@@ -205,36 +196,43 @@ abstract class ProcessorTestBase {
205196
/**
206197
* collect input paths
207198
*/
208-
protected List<String> collectInputPaths (String path) {
209-
collectResourcePaths (path, "inputs.yaml")
199+
protected List<String> collectAbsoluteInputPaths (String path) {
200+
collectAbsoluteResourcePaths (path, "inputs.yaml")
210201
}
211202

212203
/**
213204
* collect output paths
214205
*/
215-
protected List<String> collectOutputPaths (String path) {
216-
collectResourcePaths (path, "outputs.yaml")
206+
protected List<String> collectAbsoluteOutputPaths (String path) {
207+
collectAbsoluteResourcePaths (path, "outputs.yaml")
217208
}
218209

219210
/**
220-
* collect output paths, strips path prefix
211+
* collect output paths, relative to packageName
221212
*/
222-
protected List<String> collectOutputPaths (String path, String packageName) {
223-
collectResourcePaths (path, "outputs.yaml").collect {
224-
it.substring ("${path}/${packageName}".size () + 1)
213+
protected List<String> collectRelativeOutputPaths (String path, String packageName) {
214+
collectRelativeResourcePaths (path, "outputs.yaml").collect {
215+
it.substring (packageName.size () + 1)
225216
}
226217
}
227218

228219
/**
229-
* collect full paths from output.yaml in resources
220+
* collect absolute paths from output.yaml in resources
230221
*/
231-
protected List<String> collectResourcePaths (String path, String itemsYaml) {
222+
protected List<String> collectAbsoluteResourcePaths (String path, String itemsYaml) {
223+
collectRelativeResourcePaths (path, itemsYaml).collect {
224+
"${path}/${it}".toString ()
225+
}
226+
}
227+
228+
/**
229+
* collect paths from output.yaml in resources
230+
*/
231+
protected List<String> collectRelativeResourcePaths (String path, String itemsYaml) {
232232
def source = getResource ("${path}/${itemsYaml}").text
233233
def mapper = createYamlParser ()
234234
def sourceItems = mapper.readValue (source, TestItems)
235-
sourceItems.items.collect {
236-
"${path}/${it}".toString ()
237-
}
235+
sourceItems.items
238236
}
239237

240238
/**

0 commit comments

Comments
 (0)