From 6fe72465b9fd4431b5ed6a3cc63d3842f4d8e519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sun, 10 Jan 2021 14:24:39 +0100 Subject: [PATCH] Checkpoint: All test good :3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../controllers/ExchangeControllerTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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()); } }