Search in sources :

Example 26 with GroupedFile

use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.

the class CombineChangeBlocksTest 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);
    combineChangeBlocks = new CombineChangeBlocks(blackboard);
}
Also used : BehavioralBlackboard(de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralBlackboard) CombineChangeBlocks(de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CombineChangeBlocks) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) ArrayList(java.util.ArrayList) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 27 with GroupedFile

use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.

the class CreateCommonChangeBlocksTest 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);
    createCommonChangeBlocks = new CreateCommonChangeBlocks(blackboard);
}
Also used : BehavioralBlackboard(de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralBlackboard) CreateCommonChangeBlocks(de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CreateCommonChangeBlocks) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) ArrayList(java.util.ArrayList) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 28 with GroupedFile

use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.

the class CreateSolutionEntriesTest method initBlackboard.

@BeforeEach
public void initBlackboard() {
    blackboard = new BehavioralBlackboard(null, null, null);
    var groupedFiles = new ArrayList<GroupedFile>();
    blackboard.setGroupedFiles(groupedFiles);
    groupedFile = new GroupedFile("test.java", new ProgrammingExerciseTestCase(), null, null);
    groupedFiles.add(groupedFile);
    createSolutionEntries = new CreateSolutionEntries(blackboard);
}
Also used : BehavioralBlackboard(de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralBlackboard) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) CreateSolutionEntries(de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CreateSolutionEntries) ArrayList(java.util.ArrayList) ProgrammingExerciseTestCase(de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 29 with GroupedFile

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;
}
Also used : TreeSet(java.util.TreeSet) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile)

Example 30 with GroupedFile

use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.

the class InsertFileContents method executeAction.

@Override
public boolean executeAction() throws BehavioralSolutionEntryGenerationException {
    for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
        var fileContent = blackboard.getSolutionRepoFiles().get(groupedFile.getFilePath());
        if (fileContent == null) {
            throw new BehavioralSolutionEntryGenerationException(String.format("Unable to find file '%s' in the solution repo despite it being referenced in the git-diff and coverage", groupedFile.getFilePath()));
        }
        groupedFile.setFileContent(fileContent);
    }
    return !blackboard.getGroupedFiles().isEmpty();
}
Also used : GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) BehavioralSolutionEntryGenerationException(de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralSolutionEntryGenerationException)

Aggregations

GroupedFile (de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile)32 ArrayList (java.util.ArrayList)20 BehavioralBlackboard (de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralBlackboard)16 BeforeEach (org.junit.jupiter.api.BeforeEach)14 ProgrammingExerciseTestCase (de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase)8 TreeSet (java.util.TreeSet)6 Test (org.junit.jupiter.api.Test)6 BehavioralSolutionEntryGenerationException (de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralSolutionEntryGenerationException)2 ChangeBlock (de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile.ChangeBlock)2 CombineChangeBlocks (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CombineChangeBlocks)2 CreateCommonChangeBlocks (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CreateCommonChangeBlocks)2 CreateSolutionEntries (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.CreateSolutionEntries)2 ExtractChangedLines (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.ExtractChangedLines)2 ExtractCoveredLines (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.ExtractCoveredLines)2 FindCommonLines (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.FindCommonLines)2 InsertFileContents (de.tum.in.www1.artemis.service.hestia.behavioral.knowledgesource.InsertFileContents)2 List (java.util.List)2