
com.crawljax.plugins.crawloverview.StateWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crawloverview-plugin Show documentation
Show all versions of crawloverview-plugin Show documentation
Generates an HTML report with a snapshot overview of what is crawled.
package com.crawljax.plugins.crawloverview;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.velocity.VelocityContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.crawljax.core.state.Eventable;
import com.crawljax.core.state.StateFlowGraph;
import com.crawljax.core.state.StateVertex;
import com.crawljax.plugins.crawloverview.model.CandidateElementPosition;
import com.crawljax.plugins.crawloverview.model.State;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
class StateWriter {
private static final Logger LOG = LoggerFactory.getLogger(StateWriter.class);
private static final String COLOR_NEW_STATE = "green";
private static final String COLOR_A_PREVIOUS_STATE = "#00FFFF";
private static final String COLOR_NO_STATE_CHANGE = "orange";
private final OutputBuilder outBuilder;
private final StateFlowGraph sfg;
private final Map visitedStates;
public StateWriter(OutputBuilder outBuilder, StateFlowGraph sfg,
Map visitedStates) {
this.outBuilder = outBuilder;
this.sfg = sfg;
this.visitedStates = visitedStates;
}
void writeHtmlForState(State state) {
LOG.debug("Writing state file for state {}", state.getName());
VelocityContext context = new VelocityContext();
context.put("name", state.getName());
context.put("screenshot", state.getName() + ".jpg");
context.put("elements", getElements(sfg, state));
context.put("fanIn", state.getFanIn());
context.put("fanOut", state.getFanOut());
context.put("url", state.getUrl());
String failedEvents = "-";
if (!state.getFailedEvents().isEmpty()) {
failedEvents = Joiner.on(", ").join(state.getFailedEvents());
}
context.put("failedEvents", failedEvents);
String dom = outBuilder.getDom(state.getName());
dom = StringEscapeUtils.escapeHtml4(dom);
context.put("dom", dom);
// writing
String name = state.getName();
outBuilder.writeState(context, name);
}
private List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy