use of de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralSolutionEntryGenerationException in project ArTEMiS by ls1intum.
the class ProgrammingExerciseSolutionEntryResource method createBehavioralSolutionEntries.
/**
* POST programming-exercises/:exerciseId/behavioral-solution-entries : Create the behavioral solution entries for a programming exercise
*
* @param exerciseId of the exercise
* @return the {@link ResponseEntity} with status {@code 200} and with body the created solution entries,
*/
@PostMapping("programming-exercises/{exerciseId}/behavioral-solution-entries")
@PreAuthorize("hasRole('EDITOR')")
public ResponseEntity<List<ProgrammingExerciseSolutionEntry>> createBehavioralSolutionEntries(@PathVariable Long exerciseId) {
log.debug("REST request to create behavioral solution entries");
ProgrammingExercise exercise = programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(exerciseId);
authCheckService.checkHasAtLeastRoleForExerciseElseThrow(Role.EDITOR, exercise, null);
try {
var solutionEntries = behavioralTestCaseService.generateBehavioralSolutionEntries(exercise);
return ResponseEntity.ok(solutionEntries);
} catch (BehavioralSolutionEntryGenerationException e) {
log.error("Unable to create behavioral solution entries", e);
throw new InternalServerErrorException(e.getMessage());
}
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralSolutionEntryGenerationException 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.BehavioralSolutionEntryGenerationException in project Artemis by ls1intum.
the class ProgrammingExerciseSolutionEntryResource method createBehavioralSolutionEntries.
/**
* POST programming-exercises/:exerciseId/behavioral-solution-entries : Create the behavioral solution entries for a programming exercise
*
* @param exerciseId of the exercise
* @return the {@link ResponseEntity} with status {@code 200} and with body the created solution entries,
*/
@PostMapping("programming-exercises/{exerciseId}/behavioral-solution-entries")
@PreAuthorize("hasRole('EDITOR')")
public ResponseEntity<List<ProgrammingExerciseSolutionEntry>> createBehavioralSolutionEntries(@PathVariable Long exerciseId) {
log.debug("REST request to create behavioral solution entries");
ProgrammingExercise exercise = programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(exerciseId);
authCheckService.checkHasAtLeastRoleForExerciseElseThrow(Role.EDITOR, exercise, null);
try {
var solutionEntries = behavioralTestCaseService.generateBehavioralSolutionEntries(exercise);
return ResponseEntity.ok(solutionEntries);
} catch (BehavioralSolutionEntryGenerationException e) {
log.error("Unable to create behavioral solution entries", e);
throw new InternalServerErrorException(e.getMessage());
}
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.BehavioralSolutionEntryGenerationException 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.BehavioralSolutionEntryGenerationException 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)));
}
Aggregations