diff --git a/buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java b/buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java index 1f3640f..20cc593 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/repositories/ExchangeRepositoryTest.java @@ -47,10 +47,12 @@ public class ExchangeRepositoryTest{ @Test @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD) public void shouldReturnMatches() { - final User user1 = this.userService.save(new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT , 451)); + final User user1 = this.userService.save( + new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT, 451)); final Groups group1 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.MONDAY, null)); final Commision commision1 = this.commisionRepository.save(new Commision(user1)); - final User user2 = this.userService.save(new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT , 451)); + final User user2 = this.userService.save( + new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT, 451)); final Groups group2 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.MONDAY, null)); final Commision commision2 = this.commisionRepository.save(new Commision(user2)); final Assignment assignmentUser1 = this.assignmentService.save(new Assignment(group1, commision1)); diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java index 2ac8b4d..66395a8 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/services/ExchangeServiceTest.java @@ -63,4 +63,39 @@ public class ExchangeServiceTest { final Set uniqList = this.exchangeService.getMatches(); assertTrue(uniqList.size() == 1); } + + @Test + @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD) + public void shouldPerformExchange() { + final User user1 = this.userService.save(new User(null, null, "1shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT , 451)); + final Groups group1 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.MONDAY, null)); + final Commision commision1 = this.commisionRepository.save(new Commision(user1)); + + final User user2 = this.userService.save(new User(null, null, "2shouldReturnMatches@ExchangeRepository.test", "123455", UserRoles.STUDENT , 452)); + final Groups group2 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.THURSDAY, null)); + final Commision commision2 = this.commisionRepository.save(new Commision(user2)); + + final User user3 = this.userService.save(new User(null, null, "3shouldReturnMatches@ExchangeRepository.test", "123456", UserRoles.STUDENT , 453)); + final Groups group3 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.WEDNESDAY, null)); + final Commision commision3 = this.commisionRepository.save(new Commision(user3)); + + final User user4 = this.userService.save(new User(null, null, "2shouldReturnMatches@ExchangeRepository.test", "123457", UserRoles.STUDENT , 455)); + final Groups group4 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.FRIDAY, null)); + final Commision commision4 = this.commisionRepository.save(new Commision(user4)); + + final Assignment assignmentUser1 = this.assignmentService.save(new Assignment(group1, commision1)); + final Assignment assignmentUser2 = this.assignmentService.save(new Assignment(group2, commision2)); + final Assignment assignmentUser3 = this.assignmentService.save(new Assignment(group2, commision3)); + final Assignment assignmentUser4 = this.assignmentService.save(new Assignment(group4, commision4)); + + this.assignmentService.callAcceptAlgorythm(); + + this.exchangeService.save(new Exchange(assignmentUser1, group2)); + this.exchangeService.save(new Exchange(assignmentUser2, group1)); + this.exchangeService.save(new Exchange(assignmentUser3, group1)); + this.exchangeService.save(new Exchange(assignmentUser4, group3)); + + this.exchangeService.performExchange(); + assertTrue(false); + } }