Search in sources :

Example 1 with PropertyReadHelper

use of de.dagere.peass.analysis.properties.PropertyReadHelper in project peass by DaGeRe.

the class ReadProperties method detectVersionProperty.

private int detectVersionProperty(final File projectFolder, final File viewFolder, final BufferedWriter csvWriter, final VersionChangeProperties versionProperties, final Entry<String, Changes> versionChanges, final String predecessor, final ExecutionData data) throws IOException, JsonGenerationException, JsonMappingException {
    final File methodFolder = new File(out.getParentFile(), "methods");
    methodFolder.mkdirs();
    final String version = versionChanges.getKey();
    final ChangeProperties changeProperties = new ChangeProperties();
    changeProperties.setCommitText(GitUtils.getCommitText(projectFolder, version));
    changeProperties.setCommitter(GitUtils.getCommitter(projectFolder, version));
    versionProperties.getVersions().put(version, changeProperties);
    int count = 0;
    for (final Entry<String, List<Change>> changes : versionChanges.getValue().getTestcaseChanges().entrySet()) {
        final String testclazz = changes.getKey();
        String module = null;
        for (TestCase test : data.getVersions().get(versionChanges.getKey()).getTests()) {
            if (test.getClazz().equals(testclazz)) {
                module = test.getModule();
            }
        }
        final List<ChangeProperty> properties = new LinkedList<>();
        changeProperties.getProperties().put(testclazz, properties);
        for (final Change testcaseChange : changes.getValue()) {
            ExecutionConfig config = new ExecutionConfig();
            config.setVersion(version);
            config.setVersionOld(predecessor);
            ChangedEntity entity = new ChangedEntity(testclazz, module);
            final PropertyReadHelper reader = new PropertyReadHelper(config, entity, testcaseChange, projectFolder, viewFolder, methodFolder, null);
            final ChangeProperty currentProperty = reader.read();
            // if (currentProperty != null) {
            properties.add(currentProperty);
            Constants.OBJECTMAPPER.writeValue(out, versionProperties);
            writeCSVLine(csvWriter, currentProperty, projectFolder.getName());
            // }
            count++;
        }
    }
    return count;
}
Also used : PropertyReadHelper(de.dagere.peass.analysis.properties.PropertyReadHelper) ChangeProperty(de.dagere.peass.analysis.properties.ChangeProperty) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) Change(de.dagere.peass.analysis.changes.Change) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) LinkedList(java.util.LinkedList) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangeProperties(de.dagere.peass.analysis.properties.ChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) LinkedList(java.util.LinkedList) List(java.util.List) File(java.io.File)

Example 2 with PropertyReadHelper

use of de.dagere.peass.analysis.properties.PropertyReadHelper in project peass by DaGeRe.

the class TestPropertyReadHelper method testNullVersion.

@Test
public void testNullVersion() throws IOException {
    Change changeMock = Mockito.mock(Change.class);
    Mockito.when(changeMock.getMethod()).thenReturn("myTestMethod");
    ExecutionConfig config = new ExecutionConfig();
    config.setVersion("000001");
    File projectFolder = new File("target/current");
    Files.touch(new File(projectFolder, "pom.xml"));
    PropertyReadHelper helper = new PropertyReadHelper(config, new ChangedEntity("Test"), changeMock, projectFolder, null, null, null);
    ChangeProperty emptyProperty = helper.read();
    MatcherAssert.assertThat(emptyProperty, IsNull.notNullValue());
    Assert.assertEquals("myTestMethod", emptyProperty.getMethod());
}
Also used : PropertyReadHelper(de.dagere.peass.analysis.properties.PropertyReadHelper) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ChangeProperty(de.dagere.peass.analysis.properties.ChangeProperty) Change(de.dagere.peass.analysis.changes.Change) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Change (de.dagere.peass.analysis.changes.Change)2 ChangeProperty (de.dagere.peass.analysis.properties.ChangeProperty)2 PropertyReadHelper (de.dagere.peass.analysis.properties.PropertyReadHelper)2 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)2 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)2 File (java.io.File)2 ChangeProperties (de.dagere.peass.analysis.properties.ChangeProperties)1 VersionChangeProperties (de.dagere.peass.analysis.properties.VersionChangeProperties)1 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1