Checkpoint: Added ShouldPerformExchange

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-12 14:35:11 +01:00
parent bc8f7407fc
commit 1e1160736d
Signed by: y0rune
GPG Key ID: F204C385F57EB348
2 changed files with 39 additions and 2 deletions

View File

@ -47,10 +47,12 @@ public class ExchangeRepositoryTest{
@Test @Test
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD) @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void shouldReturnMatches() { 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 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 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 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 Commision commision2 = this.commisionRepository.save(new Commision(user2));
final Assignment assignmentUser1 = this.assignmentService.save(new Assignment(group1, commision1)); final Assignment assignmentUser1 = this.assignmentService.save(new Assignment(group1, commision1));

View File

@ -63,4 +63,39 @@ public class ExchangeServiceTest {
final Set<MatchData> uniqList = this.exchangeService.getMatches(); final Set<MatchData> uniqList = this.exchangeService.getMatches();
assertTrue(uniqList.size() == 1); 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);
}
} }