Skip to content

Commit

Permalink
Merge branch 'develop' into chore/wrong-assertJ-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Strohgelaender authored May 11, 2024
2 parents 2822d79 + f74d5c5 commit b59ab0e
Show file tree
Hide file tree
Showing 38 changed files with 200 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "🐛 Bug report"
name: "🐛 Bug Report"
description: Something on Artemis is not working as expected? Create a report to help us improve.
labels: [bug]
body:
Expand All @@ -8,7 +8,7 @@ body:
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
description: A clear and concise description of what the bug is.
placeholder: What happened? Also tell us, what did you expect to happen?
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-proposal--developer-.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Feature Proposal (Developer)
name: 📝 Feature Proposal (Developer)
about: Software Engineering Process for a new feature
title: "[Feature Proposal]"
labels: feature-proposal
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: "🚀 Feature request"
name: "🚀 Feature Request"
description: Suggest an idea for this project
labels: [feature]
body:
- type: markdown
attributes:
value: |
Thanks for suggesting new features or pointing our missing functionality.
Thanks for suggesting new features or pointing our missing functionality.
Please describe your request in detail so we can understand your ideas. Feel free to upload additional material such as mockups, diagrams, or sketches
- type: textarea
attributes:
Expand Down
13 changes: 13 additions & 0 deletions .idea/runConfigurations/Artemis__Server__Jenkins___LocalVC_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ jacocoTestCoverageVerification {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
// TODO: in the future the following value should become higher than 0.92
minimum = 0.899
minimum = 0.898
}
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
// TODO: in the future the following value should become less than 10
maximum = 27
maximum = 28
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ module.exports = {
coverageThreshold: {
global: {
// TODO: in the future, the following values should increase to at least 90%
statements: 87.3,
branches: 73.9,
functions: 81.79,
lines: 87.4,
statements: 87.38,
branches: 73.88,
functions: 81.80,
lines: 87.46,
},
},
coverageReporters: ['clover', 'json', 'lcov', 'text-summary'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CustomLti13Configurer extends Lti13Configurer {
private static final String LOGIN_INITIATION_PATH = "/initiate-login";

/** Base path for LTI 1.3 API endpoints. */
public static final String LTI13_BASE_PATH = "/api/public/lti13";
public static final String LTI13_BASE_PATH = "api/public/lti13";

/** Full path for LTI 1.3 login. */
public static final String LTI13_LOGIN_PATH = LTI13_BASE_PATH + LOGIN_PATH;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void configure(HttpSecurity http) {
// https://www.imsglobal.org/spec/security/v1p0/#step-3-authentication-response
OAuth2LoginAuthenticationFilter defaultLoginFilter = configureLoginFilter(clientRegistrationRepository(http), oidcLaunchFlowAuthenticationProvider,
authorizationRequestRepository);
http.addFilterAfter(new Lti13LaunchFilter(defaultLoginFilter, LTI13_BASE_PATH + LOGIN_PATH, lti13Service(http)), AbstractPreAuthenticatedProcessingFilter.class);
http.addFilterAfter(new Lti13LaunchFilter(defaultLoginFilter, "/" + LTI13_LOGIN_PATH, lti13Service(http)), AbstractPreAuthenticatedProcessingFilter.class);
}

protected Lti13Service lti13Service(HttpSecurity http) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ public InputStream convertModel(String model) {
request.setModel(model);

var response = restTemplate.postForEntity(apollonConversionUrl + "/pdf", request, Resource.class);
assert response.getBody() != null;
return response.getBody().getInputStream();
if (response.getBody() != null) {
return response.getBody().getInputStream();
}
}
catch (HttpClientErrorException ex) {
log.error("Error while calling Remote Service: {}", ex.getMessage());
}
catch (IOException ex) {
log.error(ex.getMessage());
log.error(ex.getMessage(), ex);
}
return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private void sendToConversationMembershipChannel(MetisCrudAction metisCrudAction
public Page<User> searchMembersOfConversation(Course course, Conversation conversation, Pageable pageable, String searchTerm,
Optional<ConversationMemberSearchFilters> filter) {
if (filter.isEmpty()) {
if (conversation instanceof Channel && ((Channel) conversation).getIsCourseWide()) {
if (conversation instanceof Channel channel && channel.getIsCourseWide()) {
return userRepository.searchAllByLoginOrNameInCourse(pageable, searchTerm, course.getId());
}
return userRepository.searchAllByLoginOrNameInConversation(pageable, searchTerm, conversation.getId());
Expand All @@ -389,13 +389,15 @@ public Page<User> searchMembersOfConversation(Course course, Conversation conver
}
case STUDENT -> groups.add(course.getStudentGroupName());
case CHANNEL_MODERATOR -> {
assert conversation instanceof Channel : "The filter CHANNEL_MODERATOR is only allowed for channels!";
if (!(conversation instanceof Channel)) {
throw new IllegalArgumentException("The filter CHANNEL_MODERATOR is only allowed for channels!");
}
return userRepository.searchChannelModeratorsByLoginOrNameInConversation(pageable, searchTerm, conversation.getId());
}
default -> throw new IllegalArgumentException("The filter is not supported.");
}

if (conversation instanceof Channel && ((Channel) conversation).getIsCourseWide()) {
if (conversation instanceof Channel channel && channel.getIsCourseWide()) {
return userRepository.searchAllByLoginOrNameInGroups(pageable, searchTerm, groups);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ public Set<TutorialGroupRegistrationImportDTO> importRegistrations(Course course
// === Step 3: Register all found users to their respective tutorial groups ===
Map<TutorialGroup, Set<User>> tutorialGroupToRegisteredUsers = new HashMap<>();
for (var registrationUserPair : uniqueRegistrationsWithMatchingUsers.entrySet()) {
assert registrationUserPair.getKey().title() != null;
var tutorialGroup = tutorialGroupTitleToTutorialGroup.get(registrationUserPair.getKey().title().trim());
String title = Objects.requireNonNull(registrationUserPair.getKey().title());
var tutorialGroup = tutorialGroupTitleToTutorialGroup.get(title.trim());
var user = registrationUserPair.getValue();
tutorialGroupToRegisteredUsers.computeIfAbsent(tutorialGroup, key -> new HashSet<>()).add(user);
}
Expand Down Expand Up @@ -456,7 +456,9 @@ private Map<TutorialGroupRegistrationImportDTO, User> filterOutWithoutMatchingUs

private static Optional<User> getMatchingUser(Set<User> users, TutorialGroupRegistrationImportDTO registration) {
return users.stream().filter(user -> {
assert registration.student() != null; // should be the case as we filtered out all registrations without a student
if (registration.student() == null) {
return false;
}
boolean hasRegistrationNumber = StringUtils.hasText(registration.student().registrationNumber());
boolean hasLogin = StringUtils.hasText(registration.student().login());

Expand All @@ -475,7 +477,9 @@ private Set<User> tryToFindMatchingUsers(Course course, Set<TutorialGroupRegistr
var loginsToSearchFor = new HashSet<String>();

for (var registration : registrations) {
assert registration.student() != null; // should be the case as we filtered out all registrations without a student in the calling method
if (registration.student() == null) {
continue; // should not be the case as we filtered out all registrations without a student in the calling method
}
boolean hasRegistrationNumber = StringUtils.hasText(registration.student().registrationNumber());
boolean hasLogin = StringUtils.hasText(registration.student().login());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public AeolusTemplateResource(AeolusTemplateService aeolusTemplateService, Build
* @param testCoverage Whether the test coverage template should be used
* @return The requested file, or 404 if the file doesn't exist
*/
@GetMapping({ "templates/{language}/{projectType}", "/templates/{language}" })
@GetMapping({ "templates/{language}/{projectType}", "templates/{language}" })
@EnforceAtLeastEditor
public ResponseEntity<String> getAeolusTemplate(@PathVariable ProgrammingLanguage language, @PathVariable Optional<ProjectType> projectType,
@RequestParam(value = "staticAnalysis", defaultValue = "false") boolean staticAnalysis,
Expand All @@ -91,7 +91,7 @@ public ResponseEntity<String> getAeolusTemplate(@PathVariable ProgrammingLanguag
* @param testCoverage Whether the test coverage template should be used
* @return The requested file, or 404 if the file doesn't exist
*/
@GetMapping({ "templateScripts/{language}/{projectType}", "/templateScripts/{language}" })
@GetMapping({ "templateScripts/{language}/{projectType}", "templateScripts/{language}" })
@EnforceAtLeastEditor
public ResponseEntity<String> getAeolusTemplateScript(@PathVariable ProgrammingLanguage language, @PathVariable Optional<ProjectType> projectType,
@RequestParam(value = "staticAnalysis", defaultValue = "false") boolean staticAnalysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public ResponseEntity<ApollonDiagram> updateApollonDiagram(@RequestBody ApollonD
* @param diagramId the id of the diagram
* @return the ResponseEntity with status 200 (OK) and with body the title of the diagram or 404 Not Found if no diagram with that id exists
*/
@GetMapping(value = "/apollon-diagrams/{diagramId}/title")
@GetMapping("apollon-diagrams/{diagramId}/title")
@EnforceAtLeastStudent
public ResponseEntity<String> getDiagramTitle(@PathVariable Long diagramId) {
final var title = apollonDiagramRepository.getDiagramTitle(diagramId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public ResponseEntity<Competency> createCompetency(@PathVariable long courseId,
* @return the ResponseEntity with status 201 (Created) and body the created competencies
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/courses/{courseId}/competencies/bulk")
@PostMapping("courses/{courseId}/competencies/bulk")
@EnforceAtLeastInstructor
public ResponseEntity<List<Competency>> createCompetencies(@PathVariable Long courseId, @RequestBody List<Competency> competencies) throws URISyntaxException {
log.debug("REST request to create Competencies : {}", competencies);
Expand Down Expand Up @@ -316,7 +316,7 @@ public ResponseEntity<Competency> importCompetency(@PathVariable long courseId,
* @return the ResponseEntity with status 201 (Created) and with body containing the imported competencies
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/courses/{courseId}/competencies/import/bulk")
@PostMapping("courses/{courseId}/competencies/import/bulk")
@EnforceAtLeastEditor
public ResponseEntity<List<CompetencyWithTailRelationDTO>> importCompetencies(@PathVariable long courseId, @RequestBody List<Competency> competenciesToImport,
@RequestParam(defaultValue = "false") boolean importRelations) throws URISyntaxException {
Expand Down Expand Up @@ -349,7 +349,7 @@ public ResponseEntity<List<CompetencyWithTailRelationDTO>> importCompetencies(@P
* @return the ResponseEntity with status 201 (Created) and with body containing the imported competencies (and relations)
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/courses/{courseId}/competencies/import-all/{sourceCourseId}")
@PostMapping("courses/{courseId}/competencies/import-all/{sourceCourseId}")
@EnforceAtLeastInstructor
public ResponseEntity<List<CompetencyWithTailRelationDTO>> importAllCompetenciesFromCourse(@PathVariable long courseId, @PathVariable long sourceCourseId,
@RequestParam(defaultValue = "false") boolean importRelations) throws URISyntaxException {
Expand Down Expand Up @@ -385,7 +385,7 @@ public ResponseEntity<List<CompetencyWithTailRelationDTO>> importAllCompetencies
* @return the ResponseEntity with status 201 (Created) and with body containing the imported competencies
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/courses/{courseId}/competencies/import-standardized")
@PostMapping("courses/{courseId}/competencies/import-standardized")
@EnforceAtLeastEditorInCourse
public ResponseEntity<List<CompetencyImportResponseDTO>> importStandardizedCompetencies(@PathVariable long courseId, @RequestBody List<Long> competencyIdsToImport)
throws URISyntaxException {
Expand Down Expand Up @@ -612,7 +612,7 @@ public ResponseEntity<Void> removePrerequisite(@PathVariable long competencyId,
* @param courseDescription the text description of the course
* @return the ResponseEntity with status 200 (OK) and body the genrated competencies
*/
@PostMapping("/courses/{courseId}/competencies/generate-from-description")
@PostMapping("courses/{courseId}/competencies/generate-from-description")
@EnforceAtLeastEditor
public ResponseEntity<List<Competency>> generateCompetenciesFromCourseDescription(@PathVariable Long courseId, @RequestBody String courseDescription) {
var irisService = irisCompetencyGenerationSessionService.orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public ResponseEntity<SearchResultPageDTO<Lecture>> getAllLecturesOnPage(SearchT
* @param courseId the courseId of the course for which all lectures should be returned
* @return the ResponseEntity with status 200 (OK) and the list of lectures in body
*/
@GetMapping(value = "/courses/{courseId}/lectures")
@GetMapping("courses/{courseId}/lectures")
@EnforceAtLeastEditor
public ResponseEntity<Set<Lecture>> getLecturesForCourse(@PathVariable Long courseId, @RequestParam(required = false, defaultValue = "false") boolean withLectureUnits) {
log.debug("REST request to get all Lectures for the course with id : {}", courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private ResponseEntity<ModelingSubmission> handleModelingSubmission(Long exercis
@ResponseStatus(HttpStatus.OK)
@ApiResponses({ @ApiResponse(code = 200, message = GET_200_SUBMISSIONS_REASON, response = ModelingSubmission.class, responseContainer = "List"),
@ApiResponse(code = 403, message = ErrorConstants.REQ_403_REASON), @ApiResponse(code = 404, message = ErrorConstants.REQ_404_REASON), })
@GetMapping(value = "/exercises/{exerciseId}/modeling-submissions")
@GetMapping("exercises/{exerciseId}/modeling-submissions")
@EnforceAtLeastTutor
public ResponseEntity<List<Submission>> getAllModelingSubmissions(@PathVariable Long exerciseId, @RequestParam(defaultValue = "false") boolean submittedOnly,
@RequestParam(defaultValue = "false") boolean assessedByTutor, @RequestParam(value = "correction-round", defaultValue = "0") int correctionRound) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public ResponseEntity<ModelingSubmission> getModelingSubmission(@PathVariable Lo
* @param correctionRound correctionRound for which submissions without a result should be returned
* @return the ResponseEntity with status 200 (OK) and a modeling submission without assessment in body
*/
@GetMapping(value = "/exercises/{exerciseId}/modeling-submission-without-assessment")
@GetMapping("exercises/{exerciseId}/modeling-submission-without-assessment")
@EnforceAtLeastTutor
public ResponseEntity<ModelingSubmission> getModelingSubmissionWithoutAssessment(@PathVariable Long exerciseId,
@RequestParam(value = "lock", defaultValue = "false") boolean lockSubmission, @RequestParam(value = "correction-round", defaultValue = "0") int correctionRound) {
Expand Down
Loading

0 comments on commit b59ab0e

Please sign in to comment.