use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUploadFile.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-after-updating-description.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-description.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/study/studies-files.xml", assertionMode = NON_STRICT) })
public void testUploadFile() throws Exception {
String path = this.getClass().getResource("/test.jpg").getPath();
FileInputStream fileInputStream = new FileInputStream(path);
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.jpg", "image/jpeg", fileInputStream);
mvc.perform(fileUpload("/api/v1/study-management/studies/" + STUDY_ID + "/upload").file(multipartFile).param("label", "labelUploadedFile").param("file", path).contentType(MULTIPART_FORM_DATA)).andExpect(NO_ERROR_CODE);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyDescription.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-description.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyDescription() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setDescription(UPDATED_DESCRIPTION);
StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_JSON_OBJECT, null);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisHelperTest method createSubmission.
@Test
@WithUserDetails("admin@odysseusinc.com")
public void createSubmission() throws Exception {
DataSource dataSource = prepareDataSource();
when(dataSourceService.getByIdUnsecured(1L)).thenReturn(dataSource);
IUser user = prepareUser();
Study study = prepareStudy(user);
Analysis analysis = prepareAnalysis(user, study);
List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, Collections.<Long>singletonList(1L), user, analysis);
try {
assertThat(submissions, is(not(empty())));
assertThat(submissions, contains(hasProperty("status", notNullValue())));
assertThat(submissions, contains(hasProperty("submissionGroup", notNullValue())));
} finally {
cleanup(submissions, analysis, study);
}
}
use of org.springframework.security.test.context.support.WithUserDetails in project tutorials by eugenp.
the class TestWithUserDetails method whenJohn_callLoadUserDetail_thenOK.
@Test
@WithUserDetails(value = "john", userDetailsServiceBeanName = "userDetailService")
public void whenJohn_callLoadUserDetail_thenOK() {
CustomUser user = userService.loadUserDetail("jane");
assertEquals("jane", user.getNickName());
}
use of org.springframework.security.test.context.support.WithUserDetails in project tutorials by eugenp.
the class TestWithUserDetails method givenJane_callSecuredLoadUserDetailWithJane_thenOK.
@Test
@WithUserDetails(value = "jane", userDetailsServiceBeanName = "userDetailService")
public void givenJane_callSecuredLoadUserDetailWithJane_thenOK() {
CustomUser user = userService.securedLoadUserDetail("jane");
assertEquals("jane", user.getNickName());
assertEquals("jane", user.getUsername());
}
Aggregations