Search in sources :

Example 21 with GroupedFile

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

the class FindCommonLines method executeAction.

@Override
public boolean executeAction() {
    for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
        List<Integer> commonLines = new ArrayList<>(groupedFile.getCoveredLines());
        commonLines.retainAll(groupedFile.getChangedLines());
        groupedFile.setCommonLines(commonLines);
    }
    return !blackboard.getGroupedFiles().stream().allMatch(groupedFile -> groupedFile.getCommonLines().isEmpty());
}
Also used : List(java.util.List) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) BehavioralBlackboard(de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralBlackboard) ArrayList(java.util.ArrayList) GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) ArrayList(java.util.ArrayList)

Example 22 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)

Example 23 with GroupedFile

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

the class GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest method testGroupSingleFileAndTest.

@Test
public void testGroupSingleFileAndTest() {
    var testCase = new ProgrammingExerciseTestCase();
    var gitDiffEntry1 = addGitDiffEntry("test.java", 1, 10);
    var gitDiffEntry2 = addGitDiffEntry("test.java", 12, 6);
    var coverageEntry1 = addCoverageEntry("test.java", 5, 5, testCase);
    var coverageEntry2 = addCoverageEntry("test.java", 15, 2, testCase);
    assertThat(grouper.executeCondition()).isTrue();
    assertThat(grouper.executeAction()).isTrue();
    assertThat(blackboard.getGroupedFiles()).isNotNull().hasSize(1).containsExactly(new GroupedFile("test.java", testCase, Set.of(gitDiffEntry1, gitDiffEntry2), Set.of(coverageEntry1, coverageEntry2)));
}
Also used : GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) ProgrammingExerciseTestCase(de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase) Test(org.junit.jupiter.api.Test)

Example 24 with GroupedFile

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

the class GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest method testGroupTwoFilesSingleTest.

@Test
public void testGroupTwoFilesSingleTest() {
    var testCase = new ProgrammingExerciseTestCase();
    var gitDiffEntry1 = addGitDiffEntry("test.java", 1, 20);
    var gitDiffEntry2 = addGitDiffEntry("test2.java", 1, 20);
    var coverageEntry1 = addCoverageEntry("test.java", 5, 5, testCase);
    var coverageEntry2 = addCoverageEntry("test2.java", 15, 2, testCase);
    assertThat(grouper.executeCondition()).isTrue();
    assertThat(grouper.executeAction()).isTrue();
    assertThat(blackboard.getGroupedFiles()).isNotNull().hasSize(2).containsExactlyInAnyOrder(new GroupedFile("test.java", testCase, Set.of(gitDiffEntry1), Set.of(coverageEntry1)), new GroupedFile("test2.java", testCase, Set.of(gitDiffEntry2), Set.of(coverageEntry2)));
}
Also used : GroupedFile(de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile) ProgrammingExerciseTestCase(de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase) Test(org.junit.jupiter.api.Test)

Example 25 with GroupedFile

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

the class InsertFileContentsTest method initBlackboard.

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

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