Search in sources :

Example 1 with ChangeTestMapping

use of de.dagere.peass.dependency.analysis.data.ChangeTestMapping in project peass by DaGeRe.

the class TestTestDependencies method testParameterChange.

private void testParameterChange(final TestDependencies dependencies, final String parameterizedMethod) {
    HashMap<ChangedEntity, ClazzChangeData> changeTestMap = new HashMap<ChangedEntity, ClazzChangeData>();
    ClazzChangeData classChangeData = new ClazzChangeData(new ChangedEntity("package.ClazzB", "moduleA"), true);
    classChangeData.addChange("ClazzB", parameterizedMethod);
    changeTestMap.put(new ChangedEntity("package.ClazzB", "moduleA"), classChangeData);
    ChangeTestMapping changes = dependencies.getChangeTestMap(changeTestMap);
    Assert.assertEquals(1, changes.getChanges().size());
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) ChangeTestMapping(de.dagere.peass.dependency.analysis.data.ChangeTestMapping) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 2 with ChangeTestMapping

use of de.dagere.peass.dependency.analysis.data.ChangeTestMapping in project peass by DaGeRe.

the class StaticChangeHandler method handleStaticAnalysisChanges.

public VersionStaticSelection handleStaticAnalysisChanges(final String version, final DependencyReadingInput input) throws IOException, JsonGenerationException, JsonMappingException {
    // tells which tests need to be run, and
    final ChangeTestMapping changeTestMap = dependencyManager.getDependencyMap().getChangeTestMap(input.getChanges());
    // because of which change they need to be run
    LOG.debug("Change test mapping (without added tests): " + changeTestMap);
    handleAddedTests(input, changeTestMap);
    if (executionConfig.isCreateDetailDebugFiles())
        Constants.OBJECTMAPPER.writeValue(new File(folders.getDebugFolder(), "changeTestMap_" + version + ".json"), changeTestMap);
    final VersionStaticSelection newVersionStaticSelection = DependencyReaderUtil.createVersionFromChangeMap(input.getChanges(), changeTestMap);
    newVersionStaticSelection.setJdk(dependencyManager.getExecutor().getJDKVersion());
    newVersionStaticSelection.setPredecessor(input.getPredecessor());
    if (executionConfig.isCreateDetailDebugFiles()) {
        Constants.OBJECTMAPPER.writeValue(new File(folders.getDebugFolder(), "versionStaticSelection_" + version + ".json"), newVersionStaticSelection);
    }
    return newVersionStaticSelection;
}
Also used : VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) ChangeTestMapping(de.dagere.peass.dependency.analysis.data.ChangeTestMapping) File(java.io.File)

Example 3 with ChangeTestMapping

use of de.dagere.peass.dependency.analysis.data.ChangeTestMapping in project peass by DaGeRe.

the class TestTestDependencies method testNonParameterChange.

private void testNonParameterChange(final TestDependencies dependencies) {
    HashMap<ChangedEntity, ClazzChangeData> changeTestMap = new HashMap<ChangedEntity, ClazzChangeData>();
    ClazzChangeData classChangeData = new ClazzChangeData(new ChangedEntity("package.ClazzB", "moduleA"), true);
    classChangeData.addChange("ClazzB", "methodB");
    changeTestMap.put(new ChangedEntity("package.ClazzB", "moduleA"), classChangeData);
    ChangeTestMapping changes = dependencies.getChangeTestMap(changeTestMap);
    Assert.assertEquals(1, changes.getChanges().size());
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) ChangeTestMapping(de.dagere.peass.dependency.analysis.data.ChangeTestMapping) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 4 with ChangeTestMapping

use of de.dagere.peass.dependency.analysis.data.ChangeTestMapping in project peass by DaGeRe.

the class TestTestDependencies method testClassLevelChange.

@Test
public void testClassLevelChange() {
    TestDependencies dependencies = buildTestDependencies();
    HashMap<ChangedEntity, ClazzChangeData> changes = new HashMap<ChangedEntity, ClazzChangeData>();
    ClazzChangeData clazzChangeData = new ClazzChangeData(new ChangedEntity("package.ClazzA", "moduleA"), false);
    clazzChangeData.addChange("ClazzA", "methodB");
    changes.put(new ChangedEntity("package.ClazzA", "moduleA"), clazzChangeData);
    ChangeTestMapping changeTestMap = dependencies.getChangeTestMap(changes);
    Set<ChangedEntity> changedClazzes = changeTestMap.getChanges().keySet();
    MatcherAssert.assertThat(changedClazzes, IsIterableContaining.hasItem(new ChangedEntity("package.ClazzA", "moduleA", "methodB")));
    MatcherAssert.assertThat(changeTestMap.getChanges().get(new ChangedEntity("package.ClazzA", "moduleA", "methodB")), IsIterableContaining.hasItem(testEntity));
    MatcherAssert.assertThat(changeTestMap.getChanges().get(new ChangedEntity("package.ClazzA", "moduleA")), IsIterableContaining.hasItem(testEntity));
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) ChangeTestMapping(de.dagere.peass.dependency.analysis.data.ChangeTestMapping) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TestDependencies(de.dagere.peass.dependency.analysis.data.TestDependencies) Test(org.junit.jupiter.api.Test)

Aggregations

ChangeTestMapping (de.dagere.peass.dependency.analysis.data.ChangeTestMapping)4 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)3 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)3 HashMap (java.util.HashMap)3 TestDependencies (de.dagere.peass.dependency.analysis.data.TestDependencies)1 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1