Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Fix cases of ignored return values #8575

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public AnswerPost updateAnswerPost(Long courseId, Long answerPostId, AnswerPost
}
AnswerPost existingAnswerPost = this.findById(answerPostId);
final Course course = courseRepository.findByIdElseThrow(courseId);
authorizationCheckService.isAtLeastStudentInCourse(course, user);
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, user);
parseUserMentions(course, answerPost.getContent());

AnswerPost updatedAnswerPost;

// determine if the update operation is to mark the answer post as resolving the original post
if (existingAnswerPost.doesResolvePost() != answerPost.doesResolvePost()) {
if (!Objects.equals(existingAnswerPost.doesResolvePost(), answerPost.doesResolvePost())) {
// check if requesting user is allowed to mark this answer post as resolving, i.e. if user is author or original post or at least tutor
mayMarkAnswerPostAsResolvingElseThrow(existingAnswerPost, user, course);
existingAnswerPost.setResolvesPost(answerPost.doesResolvePost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ private Set<User> findUsersByRegistrationNumbers(Set<String> registrationNumbers

private Set<User> findUsersByLogins(Set<String> logins, String groupName) {
return new HashSet<>(userRepository.findAllWithGroupsByIsDeletedIsFalseAndGroupsContainsAndLoginIn(groupName, logins));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ public ResponseEntity<Void> deleteChannel(@PathVariable Long courseId, @PathVari
var requestingUser = userRepository.getUserWithGroupsAndAuthorities();
channelAuthorizationService.isAllowedToDeleteChannel(channel, requestingUser);

tutorialGroupChannelManagementService.getTutorialGroupBelongingToChannel(channel).ifPresentOrElse(tutorialGroup -> {
tutorialGroupChannelManagementService.getTutorialGroupBelongingToChannel(channel).ifPresent(tutorialGroup -> {
throw new BadRequestAlertException("The channel belongs to tutorial group " + tutorialGroup.getTitle(), CHANNEL_ENTITY_NAME, "channel.tutorialGroup.mismatch");
}, Optional::empty);
});

var usersToNotify = conversationParticipantRepository.findConversationParticipantsByConversationId(channel.getId()).stream().map(ConversationParticipant::getUser)
.collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ void getConversationsOfUser_onlyCourseWideChannelsIfMessagingDisabled() throws E
setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.COMMUNICATION_ONLY);
List<ConversationDTO> channels = request.getList("/api/courses/" + exampleCourseId + "/conversations", HttpStatus.OK, ConversationDTO.class);

channels.forEach(conv -> assertThat(conv instanceof ChannelDTO ch && ch.getIsCourseWide()));
assertThat(channels).allSatisfy(ch -> {
assertThat(ch).isInstanceOf(ChannelDTO.class);
assertThat(((ChannelDTO) ch).getIsCourseWide()).isTrue();
});

// cleanup
conversationMessageRepository.deleteById(post.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void updateAttendanceCount_asTutor_shouldUpdateAttendanceCount() throws Exceptio

// when
request.patchWithResponseBody(getSessionsPathOfTutorialGroup(exampleTutorialGroupId, session.getId()) + "/attendance-count", null, TutorialGroupSession.class,
HttpStatus.OK).getId();
HttpStatus.OK);
updatedSession = tutorialGroupSessionRepository.findByIdElseThrow(updatedSessionId);
assertThat(updatedSession.getAttendanceCount()).isNull();

Expand Down
Loading