Checkpoint: All test good :3

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-10 14:24:39 +01:00
parent 00f639ad55
commit 6fe72465b9
Signed by: y0rune
GPG Key ID: F204C385F57EB348

View File

@ -277,9 +277,19 @@ public class ExchangeControllerTest extends AbstractControllerTest {
@Test
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void shouldFailPostDueToGroupAlreadyAccepted(){
final User user = this.userService.save(new User(null, null,
"shouldFailPostDueToGroupAlreadyAccepted@ExchangeController.test", UserRoles.STUDENT));
assertTrue(false);
public void shouldFailPostDueToGroupAlreadyAccepted() throws Exception{
final User user = this.userService.save(new User(null, null, "shouldFailPostDueToGroupAlreadyAccepted@ExchangeController.test", "11111", UserRoles.STUDENT, 320));
final String token = this.userService.login(user).getToken();
final Groups group = this.groupService.save(new Groups(215, "A2-2", null, 520, WeekDay.TUESDAY, null));
final Groups group2 = this.groupService.save(new Groups(216, "A2-3", null, 530, WeekDay.MONDAY, null));
final Commision commision = this.commisionService.save(new Commision(user));
final Assignment assignment = this.assignmentService.save(new Assignment(group, commision));
this.assignmentService.save(new Assignment(group2, commision));
this.assignmentService.callAcceptAlgorythm();
this.exchangeService.save(new Exchange(assignment, group2));
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
mockMvc.perform(post(EXCHANGE_ENDPOINT).header("Authorization", "Bearer " +
token).contentType(APPLICATION_JSON_UTF8).content("{\"assignment\": "+ assignment.getId() +", \"group\": "+ group2.getId() +" }")).andExpect(status().isBadRequest());
}
}