use of de.dagere.peass.analysis.groups.TestcaseClass in project peass by DaGeRe.
the class ClassifyByRules method classifyProject.
private void classifyProject(final Set<String> allFeatures, final String project) throws IOException, JsonParseException, JsonMappingException {
final RepoFolders repos = new RepoFolders();
final File learnFile = new File(repos.getClassificationFolder(), project + ".json");
final File learnPropertyFile = repos.getProjectPropertyFile(project);
final Classification learn = Constants.OBJECTMAPPER.readValue(learnFile, Classification.class);
final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(learnPropertyFile, VersionChangeProperties.class);
final File methodFileFolder = new File(learnPropertyFile.getParentFile(), "methods");
try (BufferedWriter csvWriter = new BufferedWriter(new FileWriter(new File(project + ".csv")))) {
for (final Entry<String, ChangeProperties> version : changes.getVersions().entrySet()) {
final File versionFolder = new File(methodFileFolder, version.getKey());
for (final Entry<String, List<ChangeProperty>> testcase : version.getValue().getProperties().entrySet()) {
for (final ChangeProperty property : testcase.getValue()) {
final VersionClass versionClass = learn.getVersions().get(version.getKey());
final ChangedEntity entity = new ChangedEntity(testcase.getKey(), "", property.getMethod());
final TestcaseClass testcaseClass = versionClass.getTestcases().get(entity);
final GuessDecider guesser = new GuessDecider(versionFolder);
final Set<String> types = testcaseClass.getTypes();
writeFeatures(allFeatures, csvWriter, property, guesser);
writeType(csvWriter, types);
csvWriter.write("\n");
csvWriter.flush();
}
}
}
}
}
use of de.dagere.peass.analysis.groups.TestcaseClass in project peass by DaGeRe.
the class FindWrong method main.
public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
final File executeCommands = new File("execute-wrong.sh");
final PrintStream goal = new PrintStream(new FileOutputStream(executeCommands));
final File folder = new File("/home/reichelt/daten3/diss/repos/properties/classification");
int index = 0;
for (final File project : folder.listFiles()) {
if (project.getName().endsWith(".json")) {
final String projectName = project.getName().substring(0, project.getName().indexOf('.'));
final String url = Constants.defaultUrls.get(projectName);
RunCommandWriter writer = new RunCommandWriterSlurm(goal, "wrong_rerun", projectName, url);
if (url != null) {
final Classification data = Constants.OBJECTMAPPER.readValue(project, Classification.class);
for (final Map.Entry<String, VersionClass> version : data.getVersions().entrySet()) {
for (final Map.Entry<ChangedEntity, TestcaseClass> method : version.getValue().getTestcases().entrySet()) {
if (method.getValue().getTypes().contains("WRONG") || method.getValue().getTypes().contains("WRONGTEST")) {
// System.out.println(version.getKey() + " " + method.getKey());
writer.createSingleMethodCommand(index, version.getKey(), method.getKey().toString());
index++;
}
}
}
} else {
System.err.println("Missing url: " + projectName);
}
}
}
}
use of de.dagere.peass.analysis.groups.TestcaseClass in project peass by DaGeRe.
the class GuessClassificationsByRules method guessVersion.
private void guessVersion(final Classification manual, final Entry<String, ChangeProperties> version) throws IOException {
File versionFolder = new File(methodFileFolder, version.getKey());
for (Entry<String, List<ChangeProperty>> testcase : version.getValue().getProperties().entrySet()) {
GuessDecider guesser = new GuessDecider(versionFolder);
for (ChangeProperty property : testcase.getValue()) {
all++;
if (version.getKey().equals("4ed6e923cb2033272fcb993978d69e325990a5aa")) {
System.err.println();
}
Guess guess = guesser.guess(property.getAffectedMethods());
testStructuralChanges(guesser, property, guess);
if (guess != null) {
VersionClass versionClass = manual.getVersions().get(version.getKey());
if (versionClass != null) {
ChangedEntity entity = new ChangedEntity(testcase.getKey(), "", property.getMethod());
TestcaseClass testcaseClass = versionClass.getTestcases().get(entity);
if (testcaseClass != null) {
checkCorrectness(guess, testcaseClass, version.getKey(), entity);
} else {
LOG.error("In version {}, Testcase {} is missing - changes not consistent with properties!", version.getKey(), testcase);
}
} else {
LOG.error("Version {} is missing - changes not consistent with properties!", version.getKey());
}
}
}
}
}
Aggregations