Search in sources :

Example 1 with CommonUserRegistrationDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO in project ArachneCentralAPI by OHDSI.

the class BaseUserController method create.

@ApiOperation("Create new user")
@RequestMapping(value = "/api/v1/admin/users", method = POST)
public CommonUserDTO create(@RequestBody @Valid CommonUserRegistrationDTO dto) throws PasswordValidationException {
    CommonUserDTO result;
    U user = convertRegistrationDTO(dto);
    user.setEmailConfirmed(false);
    user = userService.create(user);
    result = conversionService.convert(user, CommonUserDTO.class);
    return result;
}
Also used : CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CommonUserRegistrationDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO in project ArachneCentralAPI by OHDSI.

the class UserControllerTests method testCreateUser.

@Test
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/registered-user-and-admin.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
public void testCreateUser() throws Exception {
    CommonUserRegistrationDTO inputDTO = getCommonUserRegistrationDTO(PASSWORD);
    MvcResult mvcResult = mvc.perform(post("/api/v1/auth/registration").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(inputDTO)).with(anonymous())).andExpect(OK_STATUS).andReturn();
}
Also used : CommonUserRegistrationDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 3 with CommonUserRegistrationDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO in project ArachneCentralAPI by OHDSI.

the class UserControllerTests method testCreateUserWithBadPassword.

@Test
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/admin-user.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
public void testCreateUserWithBadPassword() throws Exception {
    CommonUserRegistrationDTO inputDTO = getCommonUserRegistrationDTO(BAD_PASSWORD);
    MvcResult mvcResult = mvc.perform(post("/api/v1/auth/registration").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(inputDTO)).with(anonymous())).andExpect(VALIDATION_ERROR_CODE).andExpect(OK_STATUS).andReturn();
}
Also used : CommonUserRegistrationDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 4 with CommonUserRegistrationDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO in project ArachneCentralAPI by OHDSI.

the class UserControllerTests method getCommonUserRegistrationDTO.

private CommonUserRegistrationDTO getCommonUserRegistrationDTO(String password) {
    CommonUserRegistrationDTO inputDTO = new CommonUserRegistrationDTO();
    inputDTO.setEmail(EMAIL);
    inputDTO.setFirstname(FIRST_NAME);
    inputDTO.setLastname(LAST_NAME);
    inputDTO.setMiddlename(MIDDLE_NAME);
    inputDTO.setPassword(password);
    inputDTO.setProfessionalTypeId(PROFESSIONAL_TYPE_ID);
    return inputDTO;
}
Also used : CommonUserRegistrationDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO)

Aggregations

CommonUserRegistrationDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO)3 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)2 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)2 Test (org.junit.Test)2 MvcResult (org.springframework.test.web.servlet.MvcResult)2 CommonUserDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO)1 ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1