mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Add registration test.
This commit is contained in:
parent
a681cf9b90
commit
6674c607f7
@ -24,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
@JsonAutoDetect(
|
@JsonAutoDetect(
|
||||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||||
@ -47,6 +49,15 @@ public class RestUserRegistration {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RestUserRegistration create(String email, String password, String firstname, String lastname) {
|
||||||
|
final RestUserRegistration result = new RestUserRegistration();
|
||||||
|
result.email = email;
|
||||||
|
result.password = password;
|
||||||
|
result.firstname = firstname;
|
||||||
|
result.lastname = lastname;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,10 @@ import com.wisemapping.config.rest.RestAppConfig;
|
|||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.rest.UserController;
|
import com.wisemapping.rest.UserController;
|
||||||
import com.wisemapping.rest.model.RestUser;
|
import com.wisemapping.rest.model.RestUser;
|
||||||
|
import com.wisemapping.rest.model.RestUserRegistration;
|
||||||
import com.wisemapping.service.UserService;
|
import com.wisemapping.service.UserService;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
@ -37,6 +39,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.createDummyUser;
|
import static com.wisemapping.test.rest.RestHelper.createDummyUser;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||||
@ -71,7 +74,7 @@ public class RestUserControllerTest {
|
|||||||
|
|
||||||
// Check dao ...
|
// Check dao ...
|
||||||
User userBy = userService.getUserBy(result.getEmail());
|
User userBy = userService.getUserBy(result.getEmail());
|
||||||
assertTrue(userBy!=null);
|
assertNotNull(userBy);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,4 +95,24 @@ public class RestUserControllerTest {
|
|||||||
.andDo(print())
|
.andDo(print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled
|
||||||
|
void registerNewUser() throws Exception {
|
||||||
|
final RestUserRegistration user = RestUserRegistration.create("some@example.com", "somepass", "Test", "registation");
|
||||||
|
final String userJson = objectMapper.writeValueAsString(user);
|
||||||
|
|
||||||
|
mockMvc.perform(
|
||||||
|
post("/api/restfull/users/").
|
||||||
|
contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content(userJson))
|
||||||
|
.andExpect(status().isCreated());
|
||||||
|
|
||||||
|
// Check dao ...
|
||||||
|
User userBy = userService.getUserBy(user.getEmail());
|
||||||
|
assertNotNull(userBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user