|
|
|
@ -58,7 +58,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
public void shouldFailedAddingCommisionDueToNoArgs() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT).header("Authorization", "Bearer " + token))
|
|
|
|
@ -69,7 +69,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
public void shouldReturnOkAddingCommision() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT).header("Authorization", "Bearer " + token)
|
|
|
|
@ -86,7 +86,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
public void shouldReturnOkGettingAllCommisions() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(get(GET_COMMISIONS_ENDPOINT).header("Authorization", "Bearer " + token))
|
|
|
|
@ -97,7 +97,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
public void shouldAddCommisionWithSelfIdPrivided() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
|
|
|
|
@ -110,7 +110,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.otherUser.getId().toString())
|
|
|
|
@ -122,7 +122,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
public void shouldFailCommisionAsDeanaryWithNoId() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_DEANERY_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT).header("Authorization", "Bearer " + token)
|
|
|
|
@ -132,7 +132,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void shouldFailCommisionWithSelfIdPrividedAsDeanary() throws Exception {
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_DEANERY_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.asker.getId().toString())
|
|
|
|
@ -145,7 +145,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_DEANERY_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.otherUser.getId().toString())
|
|
|
|
@ -158,7 +158,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_DEANERY_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.otherAsker.getId().toString())
|
|
|
|
@ -171,7 +171,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_DEANERY_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(get(GET_SOMEONE_COMMISIONS_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
|
|
|
|
@ -181,9 +181,9 @@ public class CommisionControllerTest extends AbstractControllerTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void shouldFailStudentCommisionsListByOtherStudent() throws Exception {
|
|
|
|
|
this.checkUsers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
|
|
|
|
|
final String token = this.service.login(user);
|
|
|
|
|
final String token = this.service.login(user).getToken();
|
|
|
|
|
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
|
|
|
|
mockMvc.perform(get(GET_SOMEONE_COMMISIONS_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
|
|
|
|
|