nl.hsac.fitnesse.slimcoverage.SlimScenarioUsagePer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hsac-fitnesse-plugin Show documentation
Show all versions of hsac-fitnesse-plugin Show documentation
Plugin to add features to a FitNesse installation
package nl.hsac.fitnesse.slimcoverage;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class SlimScenarioUsagePer {
private final String groupName;
private final Map usage = new LinkedHashMap();
private final List overriddenScenarios = new ArrayList();
public SlimScenarioUsagePer(String groupName) {
this.groupName = groupName;
}
public void addDefinition(String scenarioName) {
if (usage.containsKey(scenarioName)) {
overriddenScenarios.add(scenarioName);
} else {
addUsage(scenarioName, 0);
}
}
public void addUsage(String scenarioName) {
addUsage(scenarioName, 1);
}
public void addUsage(String scenarioName, Integer valueToAdd) {
AtomicInteger currentValue = usage.get(scenarioName);
if (currentValue == null) {
currentValue = new AtomicInteger(0);
usage.put(scenarioName, currentValue);
}
currentValue.getAndAdd(valueToAdd);
}
public Map getUsage() {
Map result = new LinkedHashMap();
for (Map.Entry entry : usage.entrySet()) {
result.put(entry.getKey(), entry.getValue().intValue());
}
return result;
}
public List getOverriddenScenarios() {
return overriddenScenarios;
}
public String toString() {
return groupName + ": " + usage;
}
public String getGroupName() {
return groupName;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy