Untitled
unknown
plain_text
2 years ago
2.6 kB
4
Indexable
package pt.ulisboa.tecnico.socialsoftware.tutor.teacherdashboard.domain import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.boot.test.context.TestConfiguration import pt.ulisboa.tecnico.socialsoftware.tutor.BeanConfiguration import pt.ulisboa.tecnico.socialsoftware.tutor.SpockTest import pt.ulisboa.tecnico.socialsoftware.tutor.question.domain.Question import pt.ulisboa.tecnico.socialsoftware.tutor.question.domain.Course import pt.ulisboa.tecnico.socialsoftware.tutor.user.domain.Teacher import pt.ulisboa.tecnico.socialsoftware.tutor.teacherdashboard.domain.TeacherDashboard import pt.ulisboa.tecnico.socialsoftware.tutor.teacherdashboard.domain.QuestionStats @DataJpaTest class UniqueAnswersTest extends SpockTest { def teacher def teacherDashboard def setup() { createExternalCourseAndExecution() teacher = new Teacher(USER_1_NAME, false) teacherDashboard = new TeacherDashboard(externalCourseExecution, teacher) } def "Creation of two unique question and one not unique"() { given: def course = new Course(COURSE_2_NAME, Course.Type.TECNICO) courseRepository.save(course) Question question = new Question() question.setKey(1) question.setStatus(Question.Status.AVAILABLE) question.setCourse(externalCourse) question.setTitle(QUESTION_1_TITLE) question.setNumberOfAnswers(0) Question question2 = new Question() question2.setKey(2) question2.setStatus(Question.Status.AVAILABLE) question2.setCourse(externalCourse) question2.setTitle(QUESTION_2_TITLE) question2.setNumberOfAnswers(1) Question question3 = new Question() question3.setKey(3) question3.setStatus(Question.Status.AVAILABLE) question3.setCourse(externalCourse) question3.setTitle(QUESTION_2_TITLE) question3.setNumberOfAnswers(3) course.addQuestion(question) course.addQuestion(question2) course.addQuestion(question3) externalCourseExecution.setCourse(course) when: def questionStats = new QuestionStats(externalCourseExecution, teacherDashboard) questionStats.update() then: questionStats.getCourseExecution() == externalCourseExecution questionStats.getAnsweredQuestionUnique() == 2 } @TestConfiguration static class LocalBeanConfiguration extends BeanConfiguration {} }
Editor is loading...