diff --git a/restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java index 02b7f7d..1b89a32 100644 --- a/restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/ExchangeControllerTest.java @@ -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()); } }