-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor & update/clear feedback not owner
- Loading branch information
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ public void createFeedbackFormForbidden() { | |
@Test | ||
@TestSecurity(user = "Prof", roles = { UserRole.PROF}) | ||
@JwtSecurity(claims = { @Claim(key = "email", value = "[email protected]") }) | ||
public void getFeedbackForm() { | ||
public void getFeedbackFormWithoutResult() { | ||
//create & get courses + ids | ||
List<Course> courses = createCourse(); | ||
String courseId = courses.getFirst().getId().toString(); | ||
|
@@ -159,6 +159,26 @@ public void clearResults() { | |
feedbackFormService.clearFeedbackFormResults(courses.get(0).id.toString(), feedbackForm.id.toString()); | ||
FeedbackForm feedbackFormCleared = feedbackFormService.getFeedbackForm(courses.get(0).id.toString(), formId, true); | ||
Assertions.assertEquals(0, feedbackFormCleared.questions.get(0).results.size()); | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "Prof", roles = { UserRole.PROF}) | ||
@JwtSecurity(claims = { @Claim(key = "sub", value = "111111111111111111111111") }) | ||
public void clearResultsNotOwner() { | ||
//create & get courses + ids | ||
List<Course> courses = createCourse(); | ||
String courseId = courses.getFirst().getId().toString(); | ||
String formId = courses.getFirst().getFeedbackForms().get(0).getId().toString(); | ||
String questionId = courses.getFirst().feedbackForms.get(0).questions.get(0).getId().toString(); | ||
// add a result & get feedback forms | ||
addResult(courseId, formId, questionId); | ||
FeedbackForm feedbackForm = feedbackFormService.getFeedbackForm(courses.get(0).id.toString(), formId, true); | ||
|
||
// Todo Assert that results were not cleared (not owner) | ||
Assertions.assertEquals(1, feedbackForm.questions.get(0).results.size()); | ||
feedbackFormService.clearFeedbackFormResults(courses.get(0).id.toString(), feedbackForm.id.toString()); | ||
FeedbackForm feedbackFormCleared = feedbackFormService.getFeedbackForm(courses.get(0).id.toString(), formId, true); | ||
Assertions.assertEquals(0, feedbackFormCleared.questions.get(0).results.size()); | ||
} | ||
|
||
@Test | ||
|
@@ -198,6 +218,25 @@ public void updateFeedbackForm() { | |
Assertions.assertEquals(0, updatedFeedbackForms.get(0).questions.size()); | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "Prof", roles = { UserRole.PROF}) | ||
@JwtSecurity(claims = { @Claim(key = "sub", value = "111111111111111111111111") }) | ||
public void updateFeedbackFormNotOwner() { | ||
//create & get courses + ids | ||
List<Course> courses = createCourse(); | ||
String courseId = courses.getFirst().getId().toString(); | ||
String formId = courses.getFirst().getFeedbackForms().get(0).getId().toString(); | ||
|
||
// update the feedback form name, description and questions | ||
FeedbackForm feedbackFormUpdate = new FeedbackForm(courses.get(0).id, "nameUpdate", "descriptionUpdate", List.of(), FormStatus.NOT_STARTED); | ||
feedbackFormService.updateFeedbackForm(courseId, formId, feedbackFormUpdate); | ||
|
||
// Todo Assert that results were not cleared (not owner) | ||
List<FeedbackForm> updatedFeedbackForms = feedbackFormService.getFeedbackForms(courses.get(0).id.toString()); | ||
Assertions.assertEquals("nameUpdate", updatedFeedbackForms.get(0).name); | ||
Assertions.assertEquals("descriptionUpdate", updatedFeedbackForms.get(0).description); | ||
Assertions.assertEquals(0, updatedFeedbackForms.get(0).questions.size()); | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "Student", roles = { UserRole.STUDENT}) | ||
|
@@ -256,6 +295,9 @@ private void addResult(String courseId, String formId, String questionId) { | |
} | ||
} | ||
|
||
@Test | ||
@TestSecurity(user = "Prof", roles = { UserRole.PROF}) | ||
@JwtSecurity(claims = { @Claim(key = "email", value = "[email protected]") }) | ||
private List<Course> createCourse() { | ||
// create a course via the json api | ||
ApiCourse apiCourse = new ApiCourse( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters