Tested in big data set

This commit is contained in:
Filip Izydorczyk 2021-01-03 17:57:32 +01:00
parent 95cc34c676
commit 44f8c610d9
3 changed files with 20 additions and 9 deletions

View File

@ -89,13 +89,13 @@ public class AssignmentService {
final Groups group = a.getGroup(); final Groups group = a.getGroup();
if (group.getCapacity() > group.getRegisteredStudents().size()) { if (group.getCapacity() > group.getRegisteredStudents().size()) {
e.claimGroup(group); e.claimGroup(group);
this.userService.save(e);
accepted.add(group); accepted.add(group);
} else { } else {
removed.add(group); removed.add(group);
} }
}); });
} }
this.userService.save(e);
this.emailService.sendAcceptationResult(e, new EmailAcceptedData(accepted, removed)); this.emailService.sendAcceptationResult(e, new EmailAcceptedData(accepted, removed));
}); });
} }

View File

@ -154,6 +154,10 @@ public class UserService {
return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0; return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0;
} }
public void saveAll(List<User> users) {
this.repo.saveAll(users);
}
/** /**
* get students sorted by their ranking * get students sorted by their ranking
* *

View File

@ -9,6 +9,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@ -21,6 +22,7 @@ import com.plannaplan.entities.User;
import com.plannaplan.types.UserRoles; import com.plannaplan.types.UserRoles;
import com.plannaplan.types.WeekDay; import com.plannaplan.types.WeekDay;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -66,23 +68,28 @@ public class AssignmentServiceTest {
} }
@Test @Test
@Ignore
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD) @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void shouldPerformAcceptAlgorythm() { public void shouldPerformAcceptAlgorythm() {
final Random generator = new Random(); final Random generator = new Random();
IntStream.range(0, 1700).forEach(i -> { final List<Groups> groups = new ArrayList<>();
this.userService.save(new User(null, null,
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
UserRoles.STUDENT, generator.nextInt(400) + 100));
});
IntStream.range(0, 418).forEach(i -> { IntStream.range(0, 418).forEach(i -> {
this.groupService.save(new Groups(generator.nextInt(80) + 20, null, null, groups.add(this.groupService.save(new Groups(generator.nextInt(80) + 20, null, null,
generator.nextInt(9) * 30 + 9 * 30, WeekDay.getDay(generator.nextInt(5)), null)); generator.nextInt(9) * 30 + 9 * 30, WeekDay.getDay(generator.nextInt(5)), null)));
}); });
IntStream.range(0, 1700).forEach(i -> {
final User user = this.userService.save(new User(null, null,
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
UserRoles.STUDENT, generator.nextInt(400) + 100));
final Commision com = this.comServie.save(new Commision(user));
IntStream.range(0, 5).forEach(j -> {
this.service.save(new Assignment(groups.get(generator.nextInt(groups.size())), com));
});
});
this.service.callAcceptAlgorythm(); this.service.callAcceptAlgorythm();
System.out.println("-X_-x-x-x-_X-x-x-x-X_-x-x-x-");
} }
/** /**