Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
krusche committed Dec 10, 2024
1 parent e8e0c16 commit a5c7dd2
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <p>
* 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
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -294,24 +292,6 @@ public ResponseEntity<Map<String, String>> 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<Set<String>> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FileSubmission> getFileSubmissions(String fileContent) {
List<FileSubmission> fileSubmissions = new ArrayList<>();
FileSubmission fileSubmission = new FileSubmission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit a5c7dd2

Please sign in to comment.