io.cucumber.core.options.FeatureWithLinesOrRerunPath Maven / Gradle / Ivy
package io.cucumber.core.options;
import io.cucumber.core.feature.FeatureWithLines;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.Optional;
/**
* Identifies either:
*
*
* a single rerun file,
*
*
* a directory of containing exclusively rerun files,
*
*
* a directory containing feature files,
*
*
* a specific feature,
*
*
* or specific scenarios and examples (pickles) in a feature
*
*
*
* The syntax is either a {@link FeatureWithLines} or an {@code @} followed by a
* {@link RerunPath}.
*/
class FeatureWithLinesOrRerunPath {
private final FeatureWithLines featureWithLines;
private final Collection featuresWithLinesToRerun;
FeatureWithLinesOrRerunPath(
FeatureWithLines featureWithLines, Collection featuresWithLinesToRerun
) {
this.featureWithLines = featureWithLines;
this.featuresWithLinesToRerun = featuresWithLinesToRerun;
}
static FeatureWithLinesOrRerunPath parse(String arg) {
if (arg.startsWith("@")) {
Path rerunFileOrDirectory = Paths.get(arg.substring(1));
return new FeatureWithLinesOrRerunPath(null, RerunPath.parse(rerunFileOrDirectory));
} else {
return new FeatureWithLinesOrRerunPath(FeatureWithLines.parse(arg), null);
}
}
Optional> getFeaturesToRerun() {
return Optional.ofNullable(featuresWithLinesToRerun);
}
Optional getFeatureWithLines() {
return Optional.ofNullable(featureWithLines);
}
}