use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock in project ArTEMiS by ls1intum.
the class CombineChangeBlocksTest method testCombineManyIntoOne2.
@Test
public void testCombineManyIntoOne2() throws BehavioralSolutionEntryGenerationException {
var changeBlocks = new ChangeBlock[] { new ChangeBlock(List.of(1, 2, 3)), new ChangeBlock(List.of(3, 4, 5)), new ChangeBlock(List.of(4, 5, 6)), new ChangeBlock(List.of(7, 8, 9)) };
groupedFile.setCommonChanges(List.of(changeBlocks));
assertThat(combineChangeBlocks.executeCondition()).isTrue();
assertThat(combineChangeBlocks.executeAction()).isTrue();
assertThat(groupedFile.getCommonChanges()).containsExactly(new ChangeBlock(List.of(1, 2, 3, 4, 5, 6, 7, 8, 9)));
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock in project Artemis by ls1intum.
the class CombineChangeBlocksTest method testCombineManyIntoOne1.
@Test
public void testCombineManyIntoOne1() throws BehavioralSolutionEntryGenerationException {
var changeBlocks = new ChangeBlock[] { new ChangeBlock(List.of(2)), new ChangeBlock(List.of(3)), new ChangeBlock(List.of(4)), new ChangeBlock(List.of(5)) };
groupedFile.setCommonChanges(List.of(changeBlocks));
assertThat(combineChangeBlocks.executeCondition()).isTrue();
assertThat(combineChangeBlocks.executeAction()).isTrue();
assertThat(groupedFile.getCommonChanges()).containsExactly(new ChangeBlock(List.of(2, 3, 4, 5)));
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock in project Artemis by ls1intum.
the class CombineChangeBlocksTest method testOneCombination2.
@Test
public void testOneCombination2() throws BehavioralSolutionEntryGenerationException {
var changeBlocks = new ChangeBlock[] { new ChangeBlock(List.of(1, 2, 3, 4)), new ChangeBlock(List.of(3, 4, 5, 6, 7, 8)) };
groupedFile.setCommonChanges(List.of(changeBlocks));
assertThat(combineChangeBlocks.executeCondition()).isTrue();
assertThat(combineChangeBlocks.executeAction()).isTrue();
assertThat(groupedFile.getCommonChanges()).containsExactly(new ChangeBlock(List.of(1, 2, 3, 4, 5, 6, 7, 8)));
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock in project Artemis by ls1intum.
the class AddUncoveredLinesAsPotentialCodeBlocks method executeAction.
@Override
public boolean executeAction() {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
var newChangeBlocks = new TreeSet<ChangeBlock>();
for (ChangeBlock commonChange : groupedFile.getCommonChanges()) {
var firstLine = commonChange.getLines().first();
var potentialPrefix = getPotentialPrefix(firstLine, groupedFile.getFileContent());
if (potentialPrefix != null) {
newChangeBlocks.add(potentialPrefix);
}
var lastLine = commonChange.getLines().last();
var potentialPostfix = getPotentialPostfix(lastLine, groupedFile.getFileContent());
if (potentialPostfix != null) {
newChangeBlocks.add(potentialPostfix);
}
}
if (!newChangeBlocks.isEmpty()) {
groupedFile.getCommonChanges().addAll(newChangeBlocks);
didChanges = true;
}
}
return didChanges;
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock in project Artemis by ls1intum.
the class CreateSolutionEntries method executeAction.
@Override
public boolean executeAction() {
var solutionEntries = new ArrayList<ProgrammingExerciseSolutionEntry>();
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
for (GroupedFile.ChangeBlock changeBlock : groupedFile.getCommonChanges()) {
if (!changeBlock.isPotential()) {
solutionEntries.add(createSolutionEntry(groupedFile, changeBlock));
}
}
}
if (solutionEntries.equals(blackboard.getSolutionEntries())) {
return false;
}
blackboard.setSolutionEntries(solutionEntries);
return !blackboard.getSolutionEntries().isEmpty();
}
Aggregations