use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class AccountResourceIntTest method testSaveAccount.
@Test
@Transactional
@WithMockUser("save-account")
public void testSaveAccount() throws Exception {
User user = new User();
user.setLogin("save-account");
user.setEmail("save-account@example.com");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
userRepository.saveAndFlush(user);
UserDTO userDTO = new UserDTO(// id
null, // login
"not-used", // firstName
"firstname", // lastName
"lastname", // email
"save-account@example.com", // activated
false, // imageUrl
"http://placehold.it/50x50", // langKey
Constants.DEFAULT_LANGUAGE, // createdBy
null, // createdDate
null, // lastModifiedBy
null, // lastModifiedDate
null, new HashSet<>(Collections.singletonList(AuthoritiesConstants.ADMIN)), new ArrayList<String>());
restMvc.perform(post("/api/account").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(userDTO))).andExpect(status().isOk());
User updatedUser = userRepository.findOneByLogin(user.getLogin()).orElse(null);
assertThat(updatedUser.getFirstName()).isEqualTo(userDTO.getFirstName());
assertThat(updatedUser.getLastName()).isEqualTo(userDTO.getLastName());
assertThat(updatedUser.getEmail()).isEqualTo(userDTO.getEmail());
assertThat(updatedUser.getLangKey()).isEqualTo(userDTO.getLangKey());
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
assertThat(updatedUser.getImageUrl()).isEqualTo(userDTO.getImageUrl());
assertThat(updatedUser.getActivated()).isEqualTo(true);
assertThat(updatedUser.getAuthorities()).isEmpty();
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class CourseResourceIntTest method createCourse.
@Test
@Transactional
public void createCourse() throws Exception {
int databaseSizeBeforeCreate = courseRepository.findAll().size();
// Create the Course
restCourseMockMvc.perform(post("/api/courses").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(course))).andExpect(status().isCreated());
// Validate the Course in the database
List<Course> courseList = courseRepository.findAll();
assertThat(courseList).hasSize(databaseSizeBeforeCreate + 1);
Course testCourse = courseList.get(courseList.size() - 1);
assertThat(testCourse.getTitle()).isEqualTo(DEFAULT_TITLE);
assertThat(testCourse.getStudentGroupName()).isEqualTo(DEFAULT_STUDENT_GROUP_NAME);
assertThat(testCourse.getTeachingAssistantGroupName()).isEqualTo(DEFAULT_TEACHING_ASSISTANT_GROUP_NAME);
assertThat(testCourse.getInstructorGroupName()).isEqualTo(DEFAULT_INSTRUCTOR_GROUP_NAME);
assertThat(testCourse.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testCourse.getEndDate()).isEqualTo(DEFAULT_END_DATE);
assertThat(testCourse.isOnlineCourse()).isEqualTo(DEFAULT_ONLINE_COURSE);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class FeedbackResourceIntTest method createFeedback.
@Test
@Transactional
public void createFeedback() throws Exception {
int databaseSizeBeforeCreate = feedbackRepository.findAll().size();
// Create the Feedback
restFeedbackMockMvc.perform(post("/api/feedbacks").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(feedback))).andExpect(status().isCreated());
// Validate the Feedback in the database
List<Feedback> feedbackList = feedbackRepository.findAll();
assertThat(feedbackList).hasSize(databaseSizeBeforeCreate + 1);
Feedback testFeedback = feedbackList.get(feedbackList.size() - 1);
assertThat(testFeedback.getText()).isEqualTo(DEFAULT_TEXT);
assertThat(testFeedback.getDetailText()).isEqualTo(DEFAULT_DETAIL_TEXT);
assertThat(testFeedback.isPositive()).isEqualTo(DEFAULT_POSITIVE);
assertThat(testFeedback.getType()).isEqualTo(DEFAULT_TYPE);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class LtiUserIdResourceIntTest method createLtiUserId.
@Test
@Transactional
public void createLtiUserId() throws Exception {
int databaseSizeBeforeCreate = ltiUserIdRepository.findAll().size();
// Create the LtiUserId
restLtiUserIdMockMvc.perform(post("/api/lti-user-ids").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(ltiUserId))).andExpect(status().isCreated());
// Validate the LtiUserId in the database
List<LtiUserId> ltiUserIdList = ltiUserIdRepository.findAll();
assertThat(ltiUserIdList).hasSize(databaseSizeBeforeCreate + 1);
LtiUserId testLtiUserId = ltiUserIdList.get(ltiUserIdList.size() - 1);
assertThat(testLtiUserId.getLtiUserId()).isEqualTo(DEFAULT_LTI_USER_ID);
}
use of de.tum.in.www1.artemis.domain.metis.Post in project ArTEMiS by ls1intum.
the class ModelingExerciseResourceIntTest method createModelingExercise.
@Test
@Transactional
public void createModelingExercise() throws Exception {
int databaseSizeBeforeCreate = modelingExerciseRepository.findAll().size();
// Create the ModelingExercise
restModelingExerciseMockMvc.perform(post("/api/modeling-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(modelingExercise))).andExpect(status().isCreated());
// Validate the ModelingExercise in the database
List<ModelingExercise> modelingExerciseList = modelingExerciseRepository.findAll();
assertThat(modelingExerciseList).hasSize(databaseSizeBeforeCreate + 1);
ModelingExercise testModelingExercise = modelingExerciseList.get(modelingExerciseList.size() - 1);
assertThat(testModelingExercise.getBaseFilePath()).isEqualTo(DEFAULT_BASE_FILE_PATH);
}
Aggregations