use of de.dagere.peass.analysis.changes.Change 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;
}
use of de.dagere.peass.analysis.changes.Change in project peass by DaGeRe.
the class ReadProperties method readVersionProperties.
public static VersionChangeProperties readVersionProperties(final ProjectChanges knowledge, final File versionFile) {
final VersionChangeProperties versionProperties = new VersionChangeProperties();
try {
final VersionChangeProperties allProperties = Constants.OBJECTMAPPER.readValue(versionFile, VersionChangeProperties.class);
for (final Entry<String, Changes> versionChanges : knowledge.getVersionChanges().entrySet()) {
final String version = versionChanges.getKey();
final ChangeProperties allProps = allProperties.getVersions().get(version);
if (allProps != null) {
final ChangeProperties changeProperties = new ChangeProperties();
changeProperties.setCommitText(allProps.getCommitText());
changeProperties.setCommitter(allProps.getCommitText());
versionProperties.getVersions().put(version, changeProperties);
for (final Entry<String, List<Change>> changes : versionChanges.getValue().getTestcaseChanges().entrySet()) {
final String testclazz = changes.getKey();
final List<ChangeProperty> properties = new LinkedList<>();
final List<ChangeProperty> oldTestcaseProperties = allProps.getProperties().get(changes.getKey());
if (oldTestcaseProperties != null) {
changeProperties.getProperties().put(testclazz, properties);
for (final Change change : changes.getValue()) {
for (final ChangeProperty prop : oldTestcaseProperties) {
if (prop.getMethod().equals(change.getMethod())) {
properties.add(prop);
}
}
}
}
}
}
}
} catch (final IOException e) {
e.printStackTrace();
}
return versionProperties;
}
use of de.dagere.peass.analysis.changes.Change in project peass by DaGeRe.
the class GetChangeClasses method main.
public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
final File f = new File("results/merged.json");
final ProjectChanges knowledge = Constants.OBJECTMAPPER.readValue(f, ProjectChanges.class);
final Map<String, DescriptiveStatistics> clazzes = new HashMap<>();
for (final Changes changes : knowledge.getVersionChanges().values()) {
for (final List<Change> change : changes.getTestcaseChanges().values()) {
for (final Change c : change) {
// if (c.getCorrectness() != null && c.getCorrectness().equals("CORRECT")) {
// for (String type : c.getType()) {
// if (type.equals("FUNCTION") || type.equals("BUGFIX") || type.equals("FEATURE")) {
// type = "FUNCTIONALITY";
// }
// if (type.equals("JUNIT")) {
// type = "LIB";
// }
// DescriptiveStatistics clazz = clazzes.get(type);
// if (clazz == null) {
// clazz = new DescriptiveStatistics();
// clazzes.put(type, clazz);
// }
// clazz.addValue(c.getChangePercent());
// }
//
// }
}
}
}
for (final Map.Entry<String, DescriptiveStatistics> clazz : clazzes.entrySet()) {
System.out.println(clazz.getKey() + " " + clazz.getValue().getMean());
}
}
use of de.dagere.peass.analysis.changes.Change 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());
}
use of de.dagere.peass.analysis.changes.Change in project peass by DaGeRe.
the class TestChangeReader method testBasicUsage.
@Test
public void testBasicUsage() throws JAXBException, JsonProcessingException {
ChangeReader reader = new ChangeReader("android-example-correct", new ExecutionData());
ProjectChanges changes = reader.readFile(TestAnalyseFullData.REGULAR_DATA_FOLDER.getParentFile());
System.out.println(Constants.OBJECTMAPPER.writeValueAsString(changes));
List<Change> methodChanges = changes.getVersionChanges().get("946e4318267b56838aa35da0a2a4e5c0528bfe04").getTestcaseChanges().get("com.example.android_example.ExampleUnitTest");
Assert.assertEquals(1, methodChanges.size());
Assert.assertEquals("test_TestMe", methodChanges.get(0).getMethod());
Assert.assertEquals(15087.66, methodChanges.get(0).getOldTime(), 0.1);
}
Aggregations