use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class QuizExerciseResourceIntTest method createQuizExercise.
@Test
@Transactional
public void createQuizExercise() throws Exception {
int databaseSizeBeforeCreate = quizExerciseRepository.findAll().size();
// Create the QuizExercise
restQuizExerciseMockMvc.perform(post("/api/quiz-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(quizExercise))).andExpect(status().isCreated());
// Validate the QuizExercise in the database
List<QuizExercise> quizExerciseList = quizExerciseRepository.findAll();
assertThat(quizExerciseList).hasSize(databaseSizeBeforeCreate + 1);
QuizExercise testQuizExercise = quizExerciseList.get(quizExerciseList.size() - 1);
assertThat(testQuizExercise.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testQuizExercise.getExplanation()).isEqualTo(DEFAULT_EXPLANATION);
assertThat(testQuizExercise.isRandomizeQuestionOrder()).isEqualTo(DEFAULT_RANDOMIZE_QUESTION_ORDER);
assertThat(testQuizExercise.getAllowedNumberOfAttempts()).isEqualTo(DEFAULT_ALLOWED_NUMBER_OF_ATTEMPTS);
assertThat(testQuizExercise.isIsVisibleBeforeStart()).isEqualTo(DEFAULT_IS_VISIBLE_BEFORE_START);
assertThat(testQuizExercise.isIsOpenForPractice()).isEqualTo(DEFAULT_IS_OPEN_FOR_PRACTICE);
assertThat(testQuizExercise.isIsPlannedToStart()).isEqualTo(DEFAULT_IS_PLANNED_TO_START);
assertThat(testQuizExercise.getDuration()).isEqualTo(DEFAULT_DURATION);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class QuizSubmissionResourceIntTest method createQuizSubmission.
@Test
@Transactional
public void createQuizSubmission() throws Exception {
int databaseSizeBeforeCreate = quizSubmissionRepository.findAll().size();
// Create the QuizSubmission
restQuizSubmissionMockMvc.perform(post("/api/quiz-submissions").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(quizSubmission))).andExpect(status().isCreated());
// Validate the QuizSubmission in the database
List<QuizSubmission> quizSubmissionList = quizSubmissionRepository.findAll();
assertThat(quizSubmissionList).hasSize(databaseSizeBeforeCreate + 1);
QuizSubmission testQuizSubmission = quizSubmissionList.get(quizSubmissionList.size() - 1);
assertThat(testQuizSubmission.getScoreInPoints()).isEqualTo(DEFAULT_SCORE_IN_POINTS);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class ResultResourceIntTest method createResult.
@Test
@Transactional
public void createResult() throws Exception {
int databaseSizeBeforeCreate = resultRepository.findAll().size();
// Create the Result
restResultMockMvc.perform(post("/api/results").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(result))).andExpect(status().isCreated());
// Validate the Result in the database
List<Result> resultList = resultRepository.findAll();
assertThat(resultList).hasSize(databaseSizeBeforeCreate + 1);
Result testResult = resultList.get(resultList.size() - 1);
assertThat(testResult.getResultString()).isEqualTo(DEFAULT_RESULT_STRING);
assertThat(testResult.getCompletionDate()).isEqualTo(DEFAULT_COMPLETION_DATE);
assertThat(testResult.isSuccessful()).isEqualTo(DEFAULT_SUCCESSFUL);
assertThat(testResult.isBuildArtifact()).isEqualTo(DEFAULT_BUILD_ARTIFACT);
assertThat(testResult.getScore()).isEqualTo(DEFAULT_SCORE);
assertThat(testResult.isRated()).isEqualTo(DEFAULT_RATED);
assertThat(testResult.getHasFeedback()).isEqualTo(DEFAULT_HAS_FEEDBACK);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class UserResourceIntTest method createUserWithExistingEmail.
@Test
@Transactional
public void createUserWithExistingEmail() throws Exception {
// Initialize the database
userRepository.saveAndFlush(user);
int databaseSizeBeforeCreate = userRepository.findAll().size();
Set<String> authorities = new HashSet<>();
authorities.add(AuthoritiesConstants.USER);
ManagedUserVM managedUserVM = new ManagedUserVM(null, "anotherlogin", DEFAULT_PASSWORD, DEFAULT_FIRSTNAME, DEFAULT_LASTNAME, // this email should already be used
DEFAULT_EMAIL, true, DEFAULT_IMAGEURL, DEFAULT_LANGKEY, null, null, null, null, authorities, new ArrayList<String>());
// Create the User
restUserMockMvc.perform(post("/api/users").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedUserVM))).andExpect(status().isBadRequest());
// Validate the User in the database
List<User> userList = userRepository.findAll();
assertThat(userList).hasSize(databaseSizeBeforeCreate);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class FeedbackResource method createFeedback.
/**
* POST /feedbacks : Create a new feedback.
*
* @param feedback the feedback to create
* @return the ResponseEntity with status 201 (Created) and with body the new feedback, or with status 400 (Bad Request) if the feedback has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/feedbacks")
@Timed
public ResponseEntity<Feedback> createFeedback(@RequestBody Feedback feedback) throws URISyntaxException {
log.debug("REST request to save Feedback : {}", feedback);
if (feedback.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new feedback cannot already have an ID")).body(null);
}
Feedback savedFeedback = feedbackService.save(feedback);
return ResponseEntity.created(new URI("/api/feedbacks/" + savedFeedback.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, savedFeedback.getId().toString())).body(savedFeedback);
}
Aggregations