Added tests
This commit is contained in:
parent
6ab2ec50dd
commit
b4f51d4382
@ -46,6 +46,7 @@ public class CommisionControllerTest {
|
||||
|
||||
private static final String ADD_COMMISION_ENDPOINT = "/api/v1/commisions/add";
|
||||
private static final String GET_COMMISIONS_ENDPOINT = "/api/v1/commisions/getAllCommisions";
|
||||
private static final String GET_SOMEONE_COMMISIONS_ENDPOINT = "/api/v1/commisions/user";
|
||||
|
||||
private static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(),
|
||||
MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
|
||||
@ -161,6 +162,28 @@ public class CommisionControllerTest {
|
||||
.andExpect(status().is4xxClientError());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetStudentCommisionsListByDeanary() throws Exception {
|
||||
this.checkUsers();
|
||||
|
||||
final String token = this.service.login(TEST_COMMISIONS_DEANERY_EMAIL);
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
||||
mockMvc.perform(get(GET_SOMEONE_COMMISIONS_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
|
||||
.header("Authorization", "Bearer " + token)).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFailStudentCommisionsListByOtherStudent() throws Exception {
|
||||
this.checkUsers();
|
||||
|
||||
final String token = this.service.login(TEST_COMMISIONS_STUDENT_EMAIL);
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
||||
mockMvc.perform(get(GET_SOMEONE_COMMISIONS_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
|
||||
.header("Authorization", "Bearer " + token)).andExpect(status().is4xxClientError());
|
||||
}
|
||||
|
||||
private void checkUsers() {
|
||||
if (CommisionControllerTest.user == null) {
|
||||
CommisionControllerTest.user = new User(null, null, TEST_COMMISIONS_STUDENT_EMAIL, UserRoles.STUDENT);
|
||||
|
Loading…
Reference in New Issue
Block a user