use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class TestMerging method testAlphabetic.
@Test
public void testAlphabetic() {
List<GitCommit> commits = new LinkedList<>();
commits.add(new GitCommit("A", "", "", ""));
commits.add(new GitCommit("C", "", "", ""));
commits.add(new GitCommit("B", "", "", ""));
commits.add(new GitCommit("G", "", "", ""));
commits.add(new GitCommit("E", "", "", ""));
commits.add(new GitCommit("F", "", "", ""));
VersionComparator.setVersions(commits);
StaticTestSelection deps1 = new StaticTestSelection(), deps2 = new StaticTestSelection();
deps1.setInitialversion(new InitialVersion());
deps1.getInitialversion().setVersion("A");
deps1.getVersions().put("C", null);
deps1.getVersions().put("B", null);
deps1.getVersions().put("G", null);
deps2.setInitialversion(new InitialVersion());
deps2.getInitialversion().setVersion("G");
deps2.getVersions().put("E", null);
deps2.getVersions().put("F", null);
StaticTestSelection merged = DependencyReaderUtil.mergeDependencies(deps1, deps2);
System.out.println(merged.getVersions().keySet());
Assert.assertEquals(5, merged.getVersions().size());
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class TestVersionSplitting method testSplitting.
@Test
public void testSplitting() throws IOException {
List<GitCommit> commits = ParallelTestUtil.getCommits();
int count = 3;
int size = commits.size() > 2 * count ? commits.size() / count : 2;
List<StaticTestSelection> dependencies = new LinkedList<>();
for (int chunk = 0; chunk < count; chunk++) {
// Assuming one in three commits should contain a source-change
final int max = Math.min((chunk + 1) * size + 3, commits.size());
readUntilMax(commits, dependencies, chunk, chunk * size, max);
}
StaticTestSelection merged = PartialDependenciesMerger.mergeDependencies(dependencies);
System.out.println(merged.getVersions().keySet());
Assert.assertEquals(7, merged.getVersions().size());
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class TestVersionSplitting method testSplittingNonRunning.
@Test
public void testSplittingNonRunning() throws IOException {
List<GitCommit> commits = ParallelTestUtil.getCommits();
int count = 3;
int size = commits.size() > 2 * count ? commits.size() / count : 2;
for (int i = 1; i < 10; i++) {
for (int j = i + 1; j < 10; j++) {
DummyReader.nonRunning = new HashSet<>(Arrays.asList(String.valueOf(i), String.valueOf(j)));
List<StaticTestSelection> dependencies = new LinkedList<>();
for (int chunk = 0; chunk < count; chunk++) {
// Assuming one in three commits should contain a source-change
final int max = Math.min((chunk + 1) * size + 3, commits.size());
readUntilMax(commits, dependencies, chunk, chunk * size, max);
}
StaticTestSelection merged = PartialDependenciesMerger.mergeDependencies(dependencies);
System.out.println(merged.getVersions().keySet() + " " + merged.getVersions().size());
Assert.assertEquals("Error in " + DummyReader.nonRunning, 7, merged.getVersions().size());
}
}
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class CleaningStarter method getVersionOrder.
private void getVersionOrder() throws IOException, StreamReadException, DatabindException {
StaticTestSelection dependencies = null;
if (dependencyFile != null) {
dependencies = Constants.OBJECTMAPPER.readValue(dependencyFile, StaticTestSelection.class);
VersionComparator.setDependencies(dependencies);
}
if (executionfile != null) {
ExecutionData executionData = Constants.OBJECTMAPPER.readValue(executionfile, ExecutionData.class);
dependencies = new StaticTestSelection(executionData);
VersionComparator.setDependencies(dependencies);
}
if (dependencies == null) {
throw new RuntimeException("Dependencyfile and executionfile not readable - one needs to be defined!");
}
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class DependencyDetectorIT method testClassChange.
@Test
public void testClassChange() throws Exception {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_class");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
changes.put(new ChangedEntity("defaultpackage.NormalDependency", ""), new ClazzChangeData("defaultpackage.NormalDependency", false));
final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(DependencyTestConstants.CURRENT), DependencyTestConstants.NULL_RESULTS_FOLDERS, null, fakeIterator, changeManager, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
final StaticTestSelection dependencies = reader.getDependencies();
System.out.println(dependencies);
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
final TestSet testMe = DependencyDetectorTestUtil.findDependency(dependencies, "defaultpackage.NormalDependency", DependencyTestConstants.VERSION_1);
System.out.println(testMe);
final ChangedEntity change = dependencies.getVersions().get(DependencyTestConstants.VERSION_1).getChangedClazzes().keySet().iterator().next();
Assert.assertEquals("defaultpackage.NormalDependency", change.toString());
Assert.assertEquals("defaultpackage.TestMe#testMe", testMe.getTests().iterator().next().getExecutable());
}
Aggregations