use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class GitUtils method getChangedLines.
public static int getChangedLines(final File projectFolder, final String version, final List<ChangedEntity> entities, ExecutionConfig config) {
try {
final File folderTemp = new File(FilenameUtils.normalize(projectFolder.getAbsolutePath()));
final String command = "git diff --stat=250 " + version + ".." + version + "~1";
final Process process = Runtime.getRuntime().exec(command, new String[0], folderTemp);
final String output = StreamGobbler.getFullProcess(process, false);
int size = 0;
final String[] lines = output.split("\n");
// Skip last line - therefore - 1
for (int index = 0; index < lines.length - 1; index++) {
final String line = lines[index].trim().replaceAll("\\s{2,}", " ");
System.out.println(line);
final String[] parts = line.split("\\|");
final String clazz = parts[0].replaceAll(" ", "");
final String number = parts[1];
final String countString = number.split(" ")[1];
if (!countString.equals("Bin")) {
final int count = Integer.parseInt(countString);
String clazzName = getClazz(clazz, config);
if (clazzName != null) {
final ChangedEntity changedEntity = new ChangedEntity(clazzName, "");
if (entities.contains(changedEntity)) {
size += count;
}
}
}
}
return size;
} catch (final IOException e) {
e.printStackTrace();
}
return -1;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class DependencyReaderUtil method addNewTestcases.
static void addNewTestcases(final VersionStaticSelection newVersionInfo, final Map<ChangedEntity, Set<TestCase>> newTestcases) {
for (final Map.Entry<ChangedEntity, Set<TestCase>> newTestcase : newTestcases.entrySet()) {
final ChangedEntity changedClazz = newTestcase.getKey();
TestSet testsetForChange = null;
for (final Entry<ChangedEntity, TestSet> dependency : newVersionInfo.getChangedClazzes().entrySet()) {
ChangedEntity dependencyChangedClazz = dependency.getKey();
if (dependencyChangedClazz.equals(changedClazz)) {
testsetForChange = dependency.getValue();
}
}
if (testsetForChange == null) {
testsetForChange = new TestSet();
newVersionInfo.getChangedClazzes().put(changedClazz, testsetForChange);
}
for (final TestCase testcase : newTestcase.getValue()) {
testsetForChange.addTest(testcase.onlyClazz(), testcase.getMethod());
}
}
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class InitialVersionReader method addVersionTestDependencies.
private void addVersionTestDependencies(final VersionStaticSelection version) {
for (final Entry<ChangedEntity, TestSet> dependency : version.getChangedClazzes().entrySet()) {
final ChangedEntity callee = dependency.getKey();
for (final Entry<TestCase, Set<String>> testcase : dependency.getValue().getTestcases().entrySet()) {
for (final String testMethod : testcase.getValue()) {
final Map<ChangedEntity, Set<String>> calledClasses = new HashMap<>();
final Set<String> methods = new HashSet<>();
methods.add(callee.getMethod());
calledClasses.put(new ChangedEntity(callee.getClazz(), callee.getModule()), methods);
final TestCase testClazz = testcase.getKey();
TestCase test = new TestCase(testClazz.getClazz(), testMethod, testClazz.getModule());
dependencyManager.addDependencies(test, calledClasses);
}
}
}
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class InitialVersionReader method addDependencies.
private void addDependencies(final TestCase testClassName, final ChangedEntity dependentClass) {
final Map<ChangedEntity, Set<String>> testDependencies = dependencyMap.getOrAddDependenciesForTest(testClassName);
final ChangedEntity dependencyEntity = new ChangedEntity(dependentClass.getClazz(), dependentClass.getModule());
Set<String> methods = testDependencies.get(dependencyEntity);
if (methods == null) {
methods = new HashSet<>();
testDependencies.put(dependencyEntity, methods);
}
String method = dependentClass.getMethod() + dependentClass.getParameterString();
methods.add(method);
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class InitialVersionReader method fillInitialTestDependencies.
private void fillInitialTestDependencies() {
for (final Entry<TestCase, InitialDependency> dependency : dependencyResult.getInitialversion().getInitialDependencies().entrySet()) {
for (final ChangedEntity dependentClass : dependency.getValue().getEntities()) {
TestCase testClassName = dependency.getKey();
addDependencies(testClassName, dependentClass);
}
}
}
Aggregations