use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class CreateCommonChangeBlocks method executeAction.
@Override
public boolean executeAction() {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
var changeBlocks = new TreeSet<GroupedFile.ChangeBlock>();
Integer previousLine = null;
Integer startLine = null;
int lineCount = 0;
for (Integer currentLine : groupedFile.getCommonLines()) {
if (startLine == null) {
startLine = currentLine;
}
// Check if this is a new change block
if (previousLine != null && currentLine - 1 > previousLine) {
changeBlocks.add(new GroupedFile.ChangeBlock(IntStream.range(startLine, startLine + lineCount).boxed().toList()));
lineCount = 0;
startLine = currentLine;
}
lineCount++;
previousLine = currentLine;
}
// Add the last change block if any existA
if (startLine != null) {
changeBlocks.add(new GroupedFile.ChangeBlock(IntStream.range(startLine, startLine + lineCount).boxed().toList()));
}
if (!changeBlocks.equals(groupedFile.getCommonChanges())) {
groupedFile.setCommonChanges(changeBlocks);
didChanges = true;
}
}
return didChanges;
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class ExtractCoveredLinesTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
BehavioralBlackboard blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
coverageReportEntries = new HashSet<>();
groupedFile = new GroupedFile("test.java", null, null, coverageReportEntries);
groupedFiles.add(groupedFile);
extractCoveredLines = new ExtractCoveredLines(blackboard);
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class FindCommonLinesTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
BehavioralBlackboard blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
groupedFile = new GroupedFile("test.java", null, null, null);
groupedFiles.add(groupedFile);
findCommonLines = new FindCommonLines(blackboard);
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest method testGroupSingleFileTwoTests.
@Test
public void testGroupSingleFileTwoTests() {
var testCase1 = new ProgrammingExerciseTestCase();
var testCase2 = new ProgrammingExerciseTestCase();
var gitDiffEntry = addGitDiffEntry("test.java", 1, 20);
var coverageEntry1 = addCoverageEntry("test.java", 5, 5, testCase1);
var coverageEntry2 = addCoverageEntry("test.java", 15, 2, testCase2);
assertThat(grouper.executeCondition()).isTrue();
assertThat(grouper.executeAction()).isTrue();
assertThat(blackboard.getGroupedFiles()).isNotNull().hasSize(2).containsExactlyInAnyOrder(new GroupedFile("test.java", testCase1, Set.of(gitDiffEntry), Set.of(coverageEntry1)), new GroupedFile("test.java", testCase2, Set.of(gitDiffEntry), Set.of(coverageEntry2)));
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class ExtractChangedLinesTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
BehavioralBlackboard blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
gitDiffEntries = new HashSet<>();
groupedFile = new GroupedFile("test.java", null, gitDiffEntries, null);
groupedFiles.add(groupedFile);
extractChangedLines = new ExtractChangedLines(blackboard);
}
Aggregations