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;
}
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());
}
Aggregations