use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class TraceChangeHandler method addAddedTests.
public void addAddedTests(final VersionStaticSelection newVersionInfo, final TestSet testsToRun) {
for (final ChangedEntity testName : newVersionInfo.getChangedClazzes().keySet()) {
ChangedEntity simplyClazz = testName.getSourceContainingClazz();
TestCase potentialTest = new TestCase(simplyClazz.getClazz(), null, testName.getModule());
if (NonIncludedTestRemover.isTestClassIncluded(potentialTest, executionConfig)) {
testsToRun.addTest(potentialTest, null);
}
}
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class DependencyStatisticAnalyzer method getChangeStatistics.
public static DependencyStatistics getChangeStatistics(final File dependenciesFile, final ExecutionData changedTests) throws JAXBException, JsonParseException, JsonMappingException, IOException {
final StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(dependenciesFile, StaticTestSelection.class);
final Map<String, VersionStaticSelection> versions = dependencies.getVersions();
final int startTestCound = dependencies.getInitialversion().getInitialDependencies().size();
final List<TestCase> currentContainedTests = new LinkedList<>();
for (final TestCase dependency : dependencies.getInitialversion().getInitialDependencies().keySet()) {
currentContainedTests.add(dependency);
}
LOG.trace("StartTest: {}", startTestCound);
// final List<TestCase> sometimesChangedTest = new LinkedList<>(); // Nicht nur Vorkommen, auch Anzahl relevant
final DependencyStatistics statistics = new DependencyStatistics();
// final List<TestCase> onlyOnceChangedTests = new LinkedList<>();
statistics.onceChangedTests.addAll(currentContainedTests);
statistics.size = versions.size();
// final int pruningRunTests = 0;
for (final Entry<String, VersionStaticSelection> version : versions.entrySet()) {
final Set<TestCase> currentIterationTests = new HashSet<>();
for (final Map.Entry<ChangedEntity, TestSet> dependency : version.getValue().getChangedClazzes().entrySet()) {
for (final Entry<TestCase, Set<String>> testcase : dependency.getValue().getTestcases().entrySet()) {
final String testclass = testcase.getKey().getClazz();
for (final String method : testcase.getValue()) {
final TestCase testcase2 = new TestCase(testclass, method);
// final String testname = testclass + "." + method;
if (currentContainedTests.contains(testcase2)) {
currentIterationTests.add(testcase2);
} else {
currentContainedTests.add(testcase2);
statistics.onceChangedTests.add(testcase2);
// LOG.info("Neuer Test: " + testname);
}
}
}
}
int currentTraceChangedTests = 0;
if (changedTests != null) {
for (final TestCase currentIterationTest : currentContainedTests) {
if (changedTests.versionContainsTest(version.getKey(), currentIterationTest)) {
currentTraceChangedTests++;
}
}
}
LOG.trace("Version: {} Tests: {} Trace-Changed: {}", version.getKey(), currentIterationTests.size(), currentTraceChangedTests);
statistics.multipleChangedTest.addAll(currentIterationTests);
statistics.onceChangedTests.removeAll(currentIterationTests);
statistics.changedTraceTests += currentTraceChangedTests;
statistics.pruningRunTests += currentIterationTests.size();
statistics.overallRunTests += currentContainedTests.size();
}
return statistics;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class ChangedEntityDeserializer method deserializeKey.
@Override
public ChangedEntity deserializeKey(final String key, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
String value = key;
final ChangedEntity entity;
String method = null;
if (value.contains(ChangedEntity.METHOD_SEPARATOR)) {
method = value.substring(value.indexOf(ChangedEntity.METHOD_SEPARATOR) + 1);
value = value.substring(0, value.indexOf(ChangedEntity.METHOD_SEPARATOR));
}
if (value.contains(ChangedEntity.MODULE_SEPARATOR)) {
final String clazz = value.substring(value.indexOf(ChangedEntity.MODULE_SEPARATOR) + 1);
final String module = value.substring(0, value.indexOf(ChangedEntity.MODULE_SEPARATOR));
entity = new ChangedEntity(clazz, module, method);
} else {
entity = new ChangedEntity(value, "", method);
}
return entity;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class ClazzChangeData method getUniqueChanges.
@JsonIgnore
public Set<ChangedEntity> getUniqueChanges() {
Set<ChangedEntity> entities = new HashSet<>();
for (Map.Entry<String, Set<String>> change : changedMethods.entrySet()) {
String fullQualifiedClassname = getFQN(change.getKey());
if (isOnlyMethodChange) {
for (String method : change.getValue()) {
ChangedEntity entitity = new ChangedEntity(fullQualifiedClassname, containingFile.getModule(), method);
entities.add(entitity);
}
} else {
ChangedEntity entitity = new ChangedEntity(fullQualifiedClassname, containingFile.getModule());
entities.add(entitity);
}
}
return entities;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class ClazzFinder method findClazz.
public static TypeDeclaration<?> findClazz(final ChangedEntity entity, final List<Node> nodes) {
TypeDeclaration<?> declaration = null;
for (final Node node : nodes) {
if (node instanceof TypeDeclaration<?>) {
final TypeDeclaration<?> temp = (TypeDeclaration<?>) node;
final String nameAsString = temp.getNameAsString();
if (nameAsString.equals(entity.getSimpleClazzName())) {
declaration = (ClassOrInterfaceDeclaration) node;
break;
} else {
if (entity.getSimpleClazzName().startsWith(nameAsString + ChangedEntity.CLAZZ_SEPARATOR)) {
ChangedEntity inner = new ChangedEntity(entity.getSimpleClazzName().substring(nameAsString.length() + 1), entity.getModule());
declaration = findClazz(inner, node.getChildNodes());
}
}
}
}
return declaration;
}
Aggregations