Reapaired tetst

This commit is contained in:
Filip Izydorczyk 2021-01-14 14:46:45 +01:00
parent 334129cb70
commit 423c6667a9

View File

@ -15,6 +15,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.nio.charset.Charset; import java.nio.charset.Charset;
import com.plannaplan.entities.User; import com.plannaplan.entities.User;
import com.plannaplan.services.ConfiguratorService;
import com.plannaplan.services.UserService; import com.plannaplan.services.UserService;
import com.plannaplan.types.UserRoles; import com.plannaplan.types.UserRoles;
@ -67,14 +68,14 @@ public class CommisionControllerTest extends AbstractControllerTest {
} }
@Test @Test
public void shouldReturnOkAddingCommision() throws Exception { public void shouldFailAddingCommisionDueToWrongTour() throws Exception {
this.checkUsers(); this.checkUsers();
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null); final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
final String token = this.service.login(user).getToken(); final String token = this.service.login(user).getToken();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
mockMvc.perform(post(ADD_COMMISION_ENDPOINT).header("Authorization", "Bearer " + token) mockMvc.perform(post(ADD_COMMISION_ENDPOINT).header("Authorization", "Bearer " + token)
.contentType(APPLICATION_JSON_UTF8).content("[]")).andExpect(status().isOk()); .contentType(APPLICATION_JSON_UTF8).content("[]")).andExpect(status().is4xxClientError());
} }
@Test @Test
@ -95,15 +96,16 @@ public class CommisionControllerTest extends AbstractControllerTest {
} }
@Test @Test
public void shouldAddCommisionWithSelfIdPrivided() throws Exception { public void shouldFailAddingCommisionWithSelfIdPrividedDueToWrongTour() throws Exception {
this.checkUsers(); this.checkUsers();
final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null); final User user = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
final String token = this.service.login(user).getToken(); final String token = this.service.login(user).getToken();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString()) mockMvc.perform(post(ADD_COMMISION_ENDPOINT + "/" + CommisionControllerTest.user.getId().toString())
.header("Authorization", "Bearer " + token).contentType(APPLICATION_JSON_UTF8).content("[]")) .header("Authorization", "Bearer " + token).contentType(APPLICATION_JSON_UTF8).content("[]"))
.andExpect(status().isOk()); .andExpect(status().is4xxClientError());
} }
@Test @Test