org.jbehave.web.selenium.SauceContextOutput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbehave-web-selenium Show documentation
Show all versions of jbehave-web-selenium Show documentation
Selenium and WebDriver API bindings for JBehave
The newest version!
package org.jbehave.web.selenium;
import com.thoughtworks.xstream.XStream;
import org.jbehave.core.model.Story;
import org.jbehave.core.reporters.CrossReference;
import org.jbehave.core.reporters.FilePrintStreamFactory;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporter;
import org.jbehave.core.reporters.StoryReporterBuilder;
import java.util.Map;
/**
* A {@link Format} that uses {@link SauceContextStoryReporter}.
*/
public class SauceContextOutput extends Format {
private final WebDriverProvider webDriverProvider;
private final SeleniumContext seleniumContext;
private final java.util.Map storyToSauceUrlMap;
public SauceContextOutput(WebDriverProvider webDriverProvider, SeleniumContext seleniumContext, java.util.Map storyToSauceUrlMap) {
super("SAUCE_CONTEXT");
this.webDriverProvider = webDriverProvider;
this.seleniumContext = seleniumContext;
this.storyToSauceUrlMap = storyToSauceUrlMap;
}
@Override
public StoryReporter createStoryReporter(FilePrintStreamFactory filePrintStreamFactory,
StoryReporterBuilder storyReporterBuilder) {
return new SauceContextStoryReporter(webDriverProvider, seleniumContext, storyToSauceUrlMap);
}
public static class SauceLabsXRefRoot extends CrossReference.XRefRoot {
protected final transient Map storyToSauceUrlMap;
public SauceLabsXRefRoot(java.util.Map storyToSauceUrlMap) {
this.storyToSauceUrlMap = storyToSauceUrlMap;
}
protected CrossReference.XRefStory createXRefStory(StoryReporterBuilder storyReporterBuilder, Story story, boolean passed, boolean pending) {
return new SauceLabsXRefStory(story, storyReporterBuilder, passed, pending, storyToSauceUrlMap.get(story.getPath()));
}
}
public static class SauceLabsXRefStory extends CrossReference.XRefStory {
private String sauceLabsUrl;
public SauceLabsXRefStory(Story story, StoryReporterBuilder storyReporterBuilder, boolean passed, boolean pending, String sauceLabsUrl) {
this.sauceLabsUrl = sauceLabsUrl;
}
}
public static class SauceLabsCrossReference extends CrossReference {
protected final transient Map storyToSauceUrlMap;
public SauceLabsCrossReference(Map storyToSauceUrlMap) {
this.storyToSauceUrlMap = storyToSauceUrlMap;
}
@Override
protected XRefRoot newXRefRoot() {
return new SauceContextOutput.SauceLabsXRefRoot(storyToSauceUrlMap);
}
@Override
protected void aliasForXRefRoot(XStream xstream) {
xstream.alias("xref", SauceContextOutput.SauceLabsXRefRoot.class);
}
@Override
protected void aliasForXRefStory(XStream xstream) {
xstream.alias("story", SauceContextOutput.SauceLabsXRefStory.class);
}
}
}