use of de.tum.in.www1.artemis.domain.lecture.TextUnit in project ArTEMiS by ls1intum.
the class TextUnitIntegrationTest method updateTextUnit_noId_shouldReturnBadRequest.
@Test
@WithMockUser(username = "editor1", roles = "EDITOR")
public void updateTextUnit_noId_shouldReturnBadRequest() throws Exception {
persistTextUnitWithLecture();
TextUnit textUnitFromRequest = request.get("/api/lectures/" + lecture.getId() + "/text-units/" + this.textUnit.getId(), HttpStatus.OK, TextUnit.class);
textUnitFromRequest.setId(null);
request.putWithResponseBody("/api/lectures/" + lecture.getId() + "/text-units", textUnitFromRequest, TextUnit.class, HttpStatus.BAD_REQUEST);
request.get("/api/lectures/" + "2379812738912" + "/text-units/" + this.textUnit.getId(), HttpStatus.CONFLICT, TextUnit.class);
}
use of de.tum.in.www1.artemis.domain.lecture.TextUnit in project ArTEMiS by ls1intum.
the class TextUnitIntegrationTest method getTextUnit_correctId_shouldReturnTextUnit.
@Test
@WithMockUser(username = "editor1", roles = "EDITOR")
public void getTextUnit_correctId_shouldReturnTextUnit() throws Exception {
persistTextUnitWithLecture();
TextUnit textUnitFromRequest = request.get("/api/lectures/" + lecture.getId() + "/text-units/" + this.textUnit.getId(), HttpStatus.OK, TextUnit.class);
assertThat(this.textUnit.getId()).isEqualTo(textUnitFromRequest.getId());
}
use of de.tum.in.www1.artemis.domain.lecture.TextUnit in project ArTEMiS by ls1intum.
the class TextUnitIntegrationTest method createTextUnit_EditorNotInCourse_shouldReturnForbidden.
@Test
@WithMockUser(username = "editor42", roles = "EDITOR")
public void createTextUnit_EditorNotInCourse_shouldReturnForbidden() throws Exception {
request.postWithResponseBody("/api/lectures/" + this.lecture.getId() + "/text-units", textUnit, TextUnit.class, HttpStatus.FORBIDDEN);
request.postWithResponseBody("/api/lectures/" + "2379812738912" + "/text-units", textUnit, TextUnit.class, HttpStatus.BAD_REQUEST);
textUnit.setLecture(new Lecture());
request.postWithResponseBody("/api/lectures/" + this.lecture.getId() + "/text-units", textUnit, TextUnit.class, HttpStatus.CONFLICT);
textUnit.setId(21312321L);
request.postWithResponseBody("/api/lectures/" + this.lecture.getId() + "/text-units", textUnit, TextUnit.class, HttpStatus.BAD_REQUEST);
}
use of de.tum.in.www1.artemis.domain.lecture.TextUnit in project ArTEMiS by ls1intum.
the class TextUnitIntegrationTest method initTestCase.
@BeforeEach
public void initTestCase() throws Exception {
this.database.addUsers(1, 1, 1, 1);
this.lecture = this.database.createCourseWithLecture(true);
this.textUnit = new TextUnit();
this.textUnit.setName("LoremIpsum");
this.textUnit.setContent("This is a Test");
// Add users that are not in the course
userRepository.save(ModelFactory.generateActivatedUser("student42"));
userRepository.save(ModelFactory.generateActivatedUser("tutor42"));
userRepository.save(ModelFactory.generateActivatedUser("editor42"));
userRepository.save(ModelFactory.generateActivatedUser("instructor42"));
}
use of de.tum.in.www1.artemis.domain.lecture.TextUnit in project ArTEMiS by ls1intum.
the class LearningGoalIntegrationTest method creatingLectureUnitsOfLectureTwo.
private void creatingLectureUnitsOfLectureTwo() {
// creating lecture units for lecture one
TextUnit textUnit = new TextUnit();
textUnit.setName("TextUnitOfLectureTwo");
textUnit = textUnitRepository.save(textUnit);
idOfTextUnitOfLectureTwo = textUnit.getId();
Exercise textExercise = exerciseRepository.findById(idOfTextExercise).get();
ExerciseUnit textExerciseUnit = new ExerciseUnit();
textExerciseUnit.setExercise(textExercise);
textExerciseUnit = exerciseUnitRepository.save(textExerciseUnit);
idOfExerciseUnitTextOfLectureTwo = textExerciseUnit.getId();
Exercise modelingExercise = exerciseRepository.findById(idOfModelingExercise).get();
ExerciseUnit modelingExerciseUnit = new ExerciseUnit();
modelingExerciseUnit.setExercise(modelingExercise);
modelingExerciseUnit = exerciseUnitRepository.save(modelingExerciseUnit);
idOfExerciseUnitModelingOfLectureTwo = modelingExerciseUnit.getId();
List<LectureUnit> lectureUnitsOfLectureTwo = List.of(textUnit, textExerciseUnit, modelingExerciseUnit);
Lecture lectureTwo = lectureRepository.findByIdWithPostsAndLectureUnitsAndLearningGoals(idOfLectureTwo).get();
for (LectureUnit lectureUnit : lectureUnitsOfLectureTwo) {
lectureTwo.addLectureUnit(lectureUnit);
}
lectureRepository.save(lectureTwo);
}
Aggregations