From a5c7dd2102a433c0566747aaa7c17f9d27555ef8 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Tue, 10 Dec 2024 20:34:36 +0100 Subject: [PATCH] remove unused code --- .../web/ProgrammingExerciseResource.java | 24 ------------------- ...grammingExerciseParticipationResource.java | 20 ---------------- .../programming/programming-exercise.model.ts | 5 ---- .../RepositoryIntegrationTest.java | 7 ------ ...gramming-exercise-detail.component.spec.ts | 1 - .../programming-exercise.service.spec.ts | 2 -- 6 files changed, 59 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java index e5317547f8d1..9d472c2cfbf1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java @@ -853,30 +853,6 @@ public ModelAndView redirectGetTemplateRepositoryFiles(@PathVariable Long exerci return new ModelAndView("forward:/api/repository/" + participation.getId() + "/files-content"); } - /** - * GET programming-exercises/:exerciseId/solution-file-names - *

- * Returns the solution repository file names for a given programming exercise. - * Note: This endpoint redirects the request to the ProgrammingExerciseParticipationService. This is required if - * the solution participation id is not known for the client. - * - * @param exerciseId the exercise for which the solution repository files should be retrieved - * @return a redirect to the endpoint returning the files with content - */ - @GetMapping("programming-exercises/{exerciseId}/file-names") - @EnforceAtLeastTutor - @FeatureToggle(Feature.ProgrammingExercises) - public ModelAndView redirectGetSolutionRepositoryFilesWithoutContent(@PathVariable Long exerciseId) { - log.debug("REST request to get latest solution repository file names for ProgrammingExercise with id : {}", exerciseId); - ProgrammingExercise exercise = programmingExerciseRepository.findByIdElseThrow(exerciseId); - authCheckService.checkHasAtLeastRoleForExerciseElseThrow(Role.TEACHING_ASSISTANT, exercise, null); - - var participation = solutionProgrammingExerciseParticipationRepository.findByProgrammingExerciseIdElseThrow(exerciseId); - - // TODO: We want to get rid of ModelAndView and use ResponseEntity instead. Define an appropriate service method and then call it here and in the referenced endpoint. - return new ModelAndView("forward:/api/repository/" + participation.getId() + "/file-names"); - } - /** * GET programming-exercises/:exerciseId/build-log-statistics *

diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/web/repository/RepositoryProgrammingExerciseParticipationResource.java b/src/main/java/de/tum/cit/aet/artemis/programming/web/repository/RepositoryProgrammingExerciseParticipationResource.java index 6cb9df0b10ee..28515ba970bb 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/web/repository/RepositoryProgrammingExerciseParticipationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/web/repository/RepositoryProgrammingExerciseParticipationResource.java @@ -7,8 +7,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; import jakarta.servlet.http.HttpServletRequest; @@ -294,24 +292,6 @@ public ResponseEntity> getFilesWithContent(@PathVariable Lon }); } - /** - * GET /repository/{participationId}/file-names: Gets the file names of the repository - * - * @param participationId participation of the student/template/solution - * @return the ResponseEntity with status 200 (OK) and a set of file names - */ - @GetMapping(value = "repository/{participationId}/file-names", produces = MediaType.APPLICATION_JSON_VALUE) - @EnforceAtLeastTutor - public ResponseEntity> getFileNames(@PathVariable Long participationId) { - return super.executeAndCheckForExceptions(() -> { - Repository repository = getRepository(participationId, RepositoryActionType.READ, true); - var nonFolderFileNames = super.repositoryService.getFiles(repository).entrySet().stream().filter(mapEntry -> mapEntry.getValue().equals(FileType.FILE)) - .map(Map.Entry::getKey).collect(Collectors.toSet()); - - return new ResponseEntity<>(nonFolderFileNames, HttpStatus.OK); - }); - } - @Override @PostMapping(value = "repository/{participationId}/file", produces = MediaType.APPLICATION_JSON_VALUE) @FeatureToggle(Feature.ProgrammingExercises) diff --git a/src/main/webapp/app/entities/programming/programming-exercise.model.ts b/src/main/webapp/app/entities/programming/programming-exercise.model.ts index b8eab6807c3c..86c60beecac2 100644 --- a/src/main/webapp/app/entities/programming/programming-exercise.model.ts +++ b/src/main/webapp/app/entities/programming/programming-exercise.model.ts @@ -71,11 +71,6 @@ export class ProgrammingExercise extends Exercise { public projectType?: ProjectType; - // helper attributes - - // this attribute is used to display the covered lines ratio - public coveredLinesRatio?: number; - /** * This attribute is used to generate a programming exercise with no connection to the VCS and CI. * This functionality is only for testing purposes. diff --git a/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java index 64307de24282..1fc69fb5eedb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java @@ -1201,13 +1201,6 @@ void testLockStudentRepository_beforeStateRepoConfigured() { assertThat(logsList.getFirst().getArgumentArray()).containsExactly(participation.getId()); } - @Test - @WithMockUser(username = TEST_PREFIX + "tutor1", roles = "TA") - void testGetSolutionFileNames() throws Exception { - var fileNames = request.get(studentRepoBaseUrl + participation.getId() + "/file-names", HttpStatus.OK, String[].class); - assertThat(fileNames).containsExactly("currentFileName"); - } - private List getFileSubmissions(String fileContent) { List fileSubmissions = new ArrayList<>(); FileSubmission fileSubmission = new FileSubmission(); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts index 32ab0cfbe768..f6ba60839644 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts @@ -164,7 +164,6 @@ describe('ProgrammingExerciseDetailComponent', () => { tick(); expect(loadDiffSpy).toHaveBeenCalledOnce(); expect(gitDiffReportStub).toHaveBeenCalledOnce(); - expect(comp.programmingExercise.coveredLinesRatio).toBe(0.5); })); describe('onInit for course exercise', () => { diff --git a/src/test/javascript/spec/service/programming-exercise.service.spec.ts b/src/test/javascript/spec/service/programming-exercise.service.spec.ts index 0b4d81803d09..6473ce25204c 100644 --- a/src/test/javascript/spec/service/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise.service.spec.ts @@ -426,8 +426,6 @@ describe('ProgrammingExercise Service', () => { { uri: 'plagiarism-result', method: 'getLatestPlagiarismResult' }, { uri: 'test-case-state', method: 'getProgrammingExerciseTestCaseState' }, { uri: 'diff-report', method: 'getDiffReport' }, - { uri: 'file-names', method: 'getSolutionFileNames' }, - { uri: 'test-cases', method: 'getAllTestCases' }, { uri: 'build-log-statistics', method: 'getBuildLogStatistics' }, ])('should call correct exercise endpoint', (test) => fakeAsync(() => {