org.sahagin.share.runresults.LineScreenCapture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sahagin Show documentation
Show all versions of sahagin Show documentation
Sahagin makes your Selenium script more readable and maintainable.
package org.sahagin.share.runresults;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sahagin.share.yaml.YamlUtils;
import org.sahagin.share.yaml.YamlConvertException;
import org.sahagin.share.yaml.YamlConvertible;
public class LineScreenCapture implements YamlConvertible {
// should use absolute path
private File path;
// head element means stack top
private List stackLines = new ArrayList(16);
public File getPath() {
return path;
}
public void setPath(File path) {
this.path = path;
}
public List getStackLines() {
return stackLines;
}
public void addStackLine(StackLine stackLine) {
stackLines.add(stackLine);
}
public void addAllStackLines(List stackLines) {
for (StackLine stackLine : stackLines) {
addStackLine(stackLine);
}
}
// check if stack line for this instance matches targetStackLines
public boolean matchesStackLines(List targetStackLines) {
if (targetStackLines.size() != getStackLines().size()) {
return false;
}
for (int i = 0; i < targetStackLines.size(); i++) {
StackLine targetLine = targetStackLines.get(i);
StackLine line = getStackLines().get(i);
if (!targetLine.getMethod().getKey().equals(line.getMethod().getKey())) {
return false;
}
if (targetLine.getCodeBodyIndex() != line.getCodeBodyIndex()) {
return false;
}
}
return true;
}
@Override
public Map toYamlObject() {
Map result = new HashMap(2);
result.put("path", path.getPath());
result.put("stackLines", YamlUtils.toYamlObjectList(stackLines));
return result;
}
@Override
public void fromYamlObject(Map yamlObject)
throws YamlConvertException {
path = new File(YamlUtils.getStrValue(yamlObject, "path"));
List