io.openapiprocessor.test.TestItems.groovy Maven / Gradle / Ivy
/*
* Copyright 2020 https://github.com/openapi-processor/openapi-processor-base
* PDX-License-Identifier: Apache-2.0
*/
package io.openapiprocessor.test
/**
* input.yaml / output.yaml items.
*/
class TestItems {
private List items
TestItems() {
}
private TestItems(List items) {
this.items = items
}
List getItems() {
return items
}
void setItems(List items) {
this.items = items
}
/** convert to absolute paths */
List addPrefix(String path) {
items.collect {
"${path}/${it}".toString ()
}
}
TestItems resolvePlaceholder(String replacement) {
def results = new TreeSet ()
items.each {
results.add(resolveModel(it, replacement))
}
return new TestItems(results as List)
}
private static String resolveModel(String path, String replacement) {
return path.replaceFirst("", replacement)
}
}