com.github.timm.cucumber.generate.OverriddenCucumberOptionsParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-jvm-parallel-plugin Show documentation
Show all versions of cucumber-jvm-parallel-plugin Show documentation
Plugin for assisting with running Cucumber-JVM features in parallel
package com.github.timm.cucumber.generate;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class OverriddenCucumberOptionsParameters {
private List tags;
private List glue;
private boolean strict;
private List plugins;
private boolean monochrome;
public OverriddenCucumberOptionsParameters setTags(final List tags) {
this.tags = requireNoneBlank(tags, "The parameters 'tags' are missing or invalid");
return this;
}
public OverriddenCucumberOptionsParameters setGlue(final List glue) {
if (glue == null || glue.isEmpty()) {
throw new IllegalArgumentException("The parameters 'glue' are missing or invalid");
}
this.glue = requireNoneBlank(glue, "The parameters 'glue' are invalid");
return this;
}
public OverriddenCucumberOptionsParameters setStrict(final boolean strict) {
this.strict = strict;
return this;
}
public OverriddenCucumberOptionsParameters setPlugins(final List plugins) {
this.plugins = requireNoDuplicateExtensions(plugins);
return this;
}
private static List requireNoDuplicateExtensions(List plugins) {
final Map extension = new HashMap();
for (Plugin plugin : plugins) {
if (plugin.isNoOutput()) {
continue;
}
final Plugin replaced =
extension.put(plugin.getOutputDirectory() + ":" + plugin.getExtension(), plugin);
if (replaced != null) {
throw new IllegalArgumentException("The cucumber plugin '" + plugin
+ "' is writing to the same "
+ "combination of outputDirectory and extension as '"
+ replaced + "'. Use the outputDirectories attribute to "
+ "specify a directory for each plugin");
}
}
return plugins;
}
public OverriddenCucumberOptionsParameters setMonochrome(final boolean monochrome) {
this.monochrome = monochrome;
return this;
}
OverriddenCucumberOptionsParameters overridePlugins(List plugins) {
if (!plugins.isEmpty()) {
setPlugins(plugins);
}
return this;
}
OverriddenCucumberOptionsParameters overrideGlue(List glue) {
if (!glue.isEmpty()) {
setGlue(glue);
}
return this;
}
OverriddenCucumberOptionsParameters overrideTags(List tags) {
if (!tags.isEmpty()) {
setTags(tags);
}
return this;
}
OverriddenCucumberOptionsParameters overrideStrict(Boolean strict) {
if (strict != null) {
this.strict = strict;
}
return this;
}
OverriddenCucumberOptionsParameters overrideMonochrome(Boolean monochrome) {
if (monochrome != null) {
this.monochrome = monochrome;
}
return this;
}
public boolean isStrict() {
return strict;
}
public List getPlugins() {
return plugins;
}
public List getTags() {
return tags;
}
public boolean isMonochrome() {
return monochrome;
}
public List getGlue() {
return glue;
}
private static List requireNoneBlank(List list, String message) {
for (String element : list) {
if (isBlank(element)) {
throw new IllegalArgumentException(message + ": " + list);
}
}
return list;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy