mirror of
https://codeberg.org/beerbrawl/beerbrawl.git
synced 2024-09-23 05:40:51 +02:00
Merge branch 'fix/date-rounded-up-by-jpa-causing-inconsistent-date-comparison' into 'development'
Quick fix for jpa rounding (up) dates See merge request 2024ss-se-pr-group/24ss-se-pr-qse-11!85
This commit is contained in:
commit
1cbe2c5a91
|
@ -7,6 +7,7 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TeamRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -15,8 +16,6 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
@ -64,10 +63,10 @@ public class TestDataGenerator {
|
|||
LOGGER.debug("generating TEST_TOURNAMENT tournament");
|
||||
|
||||
final var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(7), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(7), 64L,
|
||||
"TEST_TOURNAMENT_DESCRIPTION", userRepository.findByUsername(TEST_USER));
|
||||
final var tournament2 = new Tournament(
|
||||
"TEST_TOURNAMENT2", currentUtcTime().plusDays(7), 32L,
|
||||
"TEST_TOURNAMENT2", BeerDateTime.nowUtc().plusDays(7), 32L,
|
||||
"TEST_TOURNAMENT2_DESCRIPTION", userRepository.findByUsername(TEST_USER));
|
||||
|
||||
tournamentRepository.saveAllAndFlush(List.of(tournament, tournament2));
|
||||
|
@ -89,8 +88,4 @@ public class TestDataGenerator {
|
|||
generateTestUser();
|
||||
generateTestTournaments();
|
||||
}
|
||||
|
||||
private static LocalDateTime currentUtcTime() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import at.ac.tuwien.sepr.groupphase.backend.entity.Tournament;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.exception.UserAlreadyExistsException;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.UserService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
|
@ -31,8 +32,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -154,7 +153,7 @@ public class UserEndpoint {
|
|||
//Todo: Move filtering to tournamentService?
|
||||
var tournamentNames = tournaments.stream().map(Tournament::getName).toList();
|
||||
Predicate<Tournament> isPast = t -> t.getRegistrationEnd()
|
||||
.isBefore(LocalDateTime.now(ZoneOffset.UTC));
|
||||
.isBefore(BeerDateTime.nowUtc());
|
||||
|
||||
Map<Boolean, Long> counts = tournaments.stream()
|
||||
.collect(Collectors.partitioningBy(isPast, Collectors.counting()));
|
||||
|
|
|
@ -12,7 +12,6 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -21,6 +20,8 @@ import java.util.UUID;
|
|||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
/**
|
||||
* The tournament entity.
|
||||
* Owns the relation with teams for consistency reasons.
|
||||
|
@ -69,7 +70,7 @@ public class Tournament {
|
|||
public Tournament(String name, LocalDateTime registrationEnd, Long maxParticipants, String description,
|
||||
ApplicationUser organizer) {
|
||||
this.name = name;
|
||||
if (registrationEnd.isBefore(LocalDateTime.now(ZoneOffset.UTC))) {
|
||||
if (registrationEnd.isBefore(BeerDateTime.nowUtc())) {
|
||||
throw new IllegalArgumentException("Registration end must be in the future");
|
||||
}
|
||||
this.registrationEnd = registrationEnd;
|
||||
|
@ -119,7 +120,7 @@ public class Tournament {
|
|||
* @return Result enum
|
||||
*/
|
||||
public SignupTeamResult signupTeam(Team team) {
|
||||
if (registrationEnd.isBefore(LocalDateTime.now(ZoneOffset.UTC))) {
|
||||
if (registrationEnd.isBefore(BeerDateTime.nowUtc())) {
|
||||
return SignupTeamResult.REGISTRATION_CLOSED;
|
||||
}
|
||||
if (teams.size() >= maxParticipants) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentKoPhaseService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentQualificationService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.models.QualificationTeamScoreModel;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -23,8 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -262,13 +261,9 @@ public class TournamentKoPhaseServiceImpl implements TournamentKoPhaseService {
|
|||
// and only set `startTime` it if it has. See also #40.
|
||||
|
||||
LOG.debug("Starting KO-match {}", nextStanding.getId());
|
||||
nextStanding.setStartTime(currentUtcTime());
|
||||
nextStanding.setStartTime(BeerDateTime.nowUtc());
|
||||
}
|
||||
|
||||
this.koStandingsRepository.saveAllAndFlush(matches);
|
||||
}
|
||||
|
||||
private static LocalDateTime currentUtcTime() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.QualificationParticipatio
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.TeamRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.models.QualificationTeamScoreModel;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentQualificationService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -23,8 +24,6 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -42,35 +41,40 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
private final QualificationParticipationRepository qualificationParticipationRepository;
|
||||
|
||||
@Override
|
||||
/*
|
||||
* @Transactional is necessary, as the qualificationMatches are not persisted in one go.
|
||||
* By default, a transaction is opened for each repository.saveAndFlush().
|
||||
*/
|
||||
@Transactional
|
||||
public List<QualificationMatch> generateQualificationMatchesForTournament(
|
||||
Long tournamentId, String currentUserName
|
||||
) throws PreconditionFailedException, AccessDeniedException, NotFoundException {
|
||||
Long tournamentId, String currentUserName)
|
||||
throws PreconditionFailedException, AccessDeniedException, NotFoundException {
|
||||
LOG.debug("Create qualifying matches for tournament with id {}", tournamentId);
|
||||
|
||||
var tournamentOrganizer = tournamentRepository
|
||||
.findById(tournamentId)
|
||||
.orElseThrow(NotFoundException::new)
|
||||
.getOrganizer();
|
||||
.findById(tournamentId)
|
||||
.orElseThrow(NotFoundException::new)
|
||||
.getOrganizer();
|
||||
|
||||
if (tournamentOrganizer == null || !tournamentOrganizer.getUsername().equals(currentUserName)) {
|
||||
LOG.debug(
|
||||
"Couldn't create qualifying matches for tournament with id {}, because the user who started the process isn't the same as the creator of the tournament.",
|
||||
tournamentId);
|
||||
"Couldn't create qualifying matches for tournament with id {}, because the user who started the process isn't the same as the creator of the tournament.",
|
||||
tournamentId);
|
||||
throw new AccessDeniedException("Current user isn't organizer of tournament.");
|
||||
}
|
||||
|
||||
var teams = teamRepository.findAllByTournamentId(tournamentId);
|
||||
if (teams.size() < 16) {
|
||||
LOG.debug(
|
||||
"Couldn't create qualifying matches for tournament with id {}, because there were less than 16 teams assigned to the tournament.",
|
||||
tournamentId);
|
||||
"Couldn't create qualifying matches for tournament with id {}, because there were less than 16 teams assigned to the tournament.",
|
||||
tournamentId);
|
||||
throw new PreconditionFailedException("Not enough teams in specified tournament.");
|
||||
}
|
||||
|
||||
if (teams.stream().anyMatch(t -> qualificationParticipationRepository.existsByTeamId(t.getId()))) {
|
||||
LOG.debug(
|
||||
"Couldn't create qualifying matches for tournament with id {}, because there were already qualification matches assigned.",
|
||||
tournamentId);
|
||||
"Couldn't create qualifying matches for tournament with id {}, because there were already qualification matches assigned.",
|
||||
tournamentId);
|
||||
throw new PreconditionFailedException("Qualification matches already created for tournament.");
|
||||
}
|
||||
|
||||
|
@ -100,7 +104,6 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
return qualificationRepository.getAllByIdIn(matches.stream().map(Match::getId).toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<QualificationMatch> getQualificationMatchesForTournament(Long tournamentId) {
|
||||
LOG.debug("Get qualification matches for tournament with id {}", tournamentId);
|
||||
|
@ -110,15 +113,14 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
|
||||
@Override
|
||||
public QualificationMatch updateQualificationMatch(
|
||||
Long tournamentId,
|
||||
Long matchId,
|
||||
TournamentUpdateQualificationMatchDto updateDto
|
||||
) {
|
||||
Long tournamentId,
|
||||
Long matchId,
|
||||
TournamentUpdateQualificationMatchDto updateDto) {
|
||||
LOG.debug("Updating qualification match {} in tournament {} with {}",
|
||||
matchId, tournamentId, updateDto);
|
||||
matchId, tournamentId, updateDto);
|
||||
|
||||
var match = this.qualificationRepository.findById(matchId)
|
||||
.orElseThrow(() -> new NotFoundException("Match not found"));
|
||||
.orElseThrow(() -> new NotFoundException("Match not found"));
|
||||
|
||||
if (!Objects.equals(match.getTournament().getId(), tournamentId)) {
|
||||
throw new NotFoundException("Match not found");
|
||||
|
@ -138,20 +140,18 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
|
||||
// Ensure we return an up-to-date object in any case
|
||||
return this.qualificationRepository.findById(matchId)
|
||||
.orElseThrow(() -> new NotFoundException("Match not found"));
|
||||
.orElseThrow(() -> new NotFoundException("Match not found"));
|
||||
}
|
||||
|
||||
private void updateQualificationMatchDrinksStatus(
|
||||
QualificationMatch match,
|
||||
TournamentUpdateQualificationMatchDto.DrinksPickupDto updateDto
|
||||
) {
|
||||
QualificationMatch match,
|
||||
TournamentUpdateQualificationMatchDto.DrinksPickupDto updateDto) {
|
||||
final var participation = match.getParticipations()
|
||||
.stream().filter(p -> p.getTeam().getId() == updateDto.teamId())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new PreconditionFailedException(
|
||||
"Team %d is not a participant of qualification match %d"
|
||||
.formatted(updateDto.teamId(), match.getId())
|
||||
));
|
||||
.stream().filter(p -> p.getTeam().getId() == updateDto.teamId())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new PreconditionFailedException(
|
||||
"Team %d is not a participant of qualification match %d"
|
||||
.formatted(updateDto.teamId(), match.getId())));
|
||||
|
||||
if (participation.isDrinksCollected()) {
|
||||
throw new TeamMatchDrinksAlreadyPickedUpException(match.getId(), participation.getTeam().getId());
|
||||
|
@ -172,38 +172,36 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
}
|
||||
|
||||
private void updateQualificationMatchResults(
|
||||
QualificationMatch match,
|
||||
TournamentUpdateQualificationMatchDto.ScoreUpdateDto updateDto
|
||||
) {
|
||||
QualificationMatch match,
|
||||
TournamentUpdateQualificationMatchDto.ScoreUpdateDto updateDto) {
|
||||
if (match.getStartTime() == null
|
||||
|| match.getStartTime().isAfter(currentUtcTime())
|
||||
) {
|
||||
|| match.getStartTime().isAfter(BeerDateTime.nowUtc())) {
|
||||
throw new PreconditionFailedException("Match has not started yet");
|
||||
}
|
||||
|
||||
// Check if both teams are ready
|
||||
final var allParticipants = this.qualificationParticipationRepository
|
||||
.findAllByQualificationMatchId(match.getId());
|
||||
.findAllByQualificationMatchId(match.getId());
|
||||
|
||||
if (allParticipants.size() != 2
|
||||
|| !allParticipants.stream().allMatch(p -> p.getTeam().getCheckedIn())) {
|
||||
|| !allParticipants.stream().allMatch(p -> p.getTeam().getCheckedIn())) {
|
||||
throw new PreconditionFailedException("Both teams must be ready to update match results");
|
||||
}
|
||||
|
||||
if (updateDto.winnerTeamId() != null) {
|
||||
final var team = this.teamRepository.findById(updateDto.winnerTeamId())
|
||||
.orElseThrow(() -> new NotFoundException("Winner team not found"));
|
||||
.orElseThrow(() -> new NotFoundException("Winner team not found"));
|
||||
|
||||
// Check if team actually participates in that match
|
||||
final var participation = this.qualificationParticipationRepository
|
||||
.findByTeamIdAndQualificationMatchId(team.getId(), match.getId())
|
||||
.orElseThrow(() -> new NotFoundException("Winner team participation not found"));
|
||||
.findByTeamIdAndQualificationMatchId(team.getId(), match.getId())
|
||||
.orElseThrow(() -> new NotFoundException("Winner team participation not found"));
|
||||
|
||||
match.setWinner(participation);
|
||||
match.setWinnerPoints(updateDto.winnerPoints());
|
||||
}
|
||||
|
||||
match.setEndTime(currentUtcTime());
|
||||
match.setEndTime(BeerDateTime.nowUtc());
|
||||
this.qualificationRepository.saveAndFlush(match);
|
||||
}
|
||||
|
||||
|
@ -216,9 +214,9 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
*/
|
||||
private void tryStartQualificationMatchByTeam(long teamId) {
|
||||
var matches = this.qualificationParticipationRepository
|
||||
.findByTeamId(teamId)
|
||||
.stream().map(QualificationParticipation::getQualificationMatch)
|
||||
.toList();
|
||||
.findByTeamId(teamId)
|
||||
.stream().map(QualificationParticipation::getQualificationMatch)
|
||||
.toList();
|
||||
|
||||
for (var match : matches) {
|
||||
if (match.getStartTime() != null) {
|
||||
|
@ -226,11 +224,11 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
}
|
||||
|
||||
final var participants = this.qualificationParticipationRepository
|
||||
.findAllByQualificationMatchId(match.getId());
|
||||
.findAllByQualificationMatchId(match.getId());
|
||||
|
||||
if (participants.size() != 2) {
|
||||
LOG.warn("Found qualification match with {} participants, expected 2?",
|
||||
participants.size());
|
||||
participants.size());
|
||||
LOG.warn("Refusing to try to start qualification match");
|
||||
return;
|
||||
}
|
||||
|
@ -243,7 +241,7 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
|
||||
if (participants.stream().allMatch(Participation::isDrinksCollected)) {
|
||||
LOG.debug("Starting qualification match {}", match.getId());
|
||||
match.setStartTime(currentUtcTime());
|
||||
match.setStartTime(BeerDateTime.nowUtc());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,9 +253,9 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
public List<QualificationTeamScoreModel> getTournamentQualificationScoreTable(Long tournamentId) {
|
||||
LOG.debug("Get qualification score table for tournament with id {}", tournamentId);
|
||||
|
||||
//check that the tournament exists
|
||||
// check that the tournament exists
|
||||
tournamentRepository.findById(tournamentId)
|
||||
.orElseThrow(() -> new NotFoundException("Tournament not found"));
|
||||
.orElseThrow(() -> new NotFoundException("Tournament not found"));
|
||||
|
||||
var teams = teamRepository.findAllByTournamentId(tournamentId);
|
||||
var matches = qualificationRepository.findAllByTournamentId(tournamentId);
|
||||
|
@ -265,11 +263,9 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
return calculateScores(teams, matches);
|
||||
}
|
||||
|
||||
|
||||
private static List<QualificationTeamScoreModel> calculateScores(
|
||||
List<Team> teams,
|
||||
List<QualificationMatch> matches
|
||||
) {
|
||||
List<Team> teams,
|
||||
List<QualificationMatch> matches) {
|
||||
Map<Long, QualificationTeamScoreModel> scoreEntryMap = new java.util.HashMap<>(Map.of());
|
||||
for (var team : teams) {
|
||||
var current = QualificationTeamScoreModel.empty(team);
|
||||
|
@ -289,7 +285,6 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
|
||||
var scoreEntries = new ArrayList<>(scoreEntryMap.values().stream().toList());
|
||||
|
||||
|
||||
// sort by wins, then points, and then just by their name
|
||||
scoreEntries.sort((a, b) -> {
|
||||
if (a.getWins().equals(b.getWins())) {
|
||||
|
@ -305,9 +300,8 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
QualificationTeamScoreModel lastEntry = null;
|
||||
for (var entry : scoreEntries) {
|
||||
if (lastEntry != null
|
||||
&& lastEntry.getWins().equals(entry.getWins())
|
||||
&& lastEntry.getPoints().equals(entry.getPoints())
|
||||
) {
|
||||
&& lastEntry.getWins().equals(entry.getWins())
|
||||
&& lastEntry.getPoints().equals(entry.getPoints())) {
|
||||
entry.setPosition(lastEntry.getPosition());
|
||||
} else {
|
||||
entry.setPosition(currentPosition);
|
||||
|
@ -318,8 +312,4 @@ public class TournamentQualificationServiceImpl implements TournamentQualificati
|
|||
|
||||
return scoreEntries;
|
||||
}
|
||||
|
||||
private static LocalDateTime currentUtcTime() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package at.ac.tuwien.sepr.groupphase.backend.util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class BeerDateTime {
|
||||
public static LocalDateTime nowUtc() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC).truncatedTo(ChronoUnit.MILLIS);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentQualificationService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import net.bytebuddy.dynamic.scaffold.MethodGraph;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -60,13 +61,9 @@ public class TestData {
|
|||
}
|
||||
};
|
||||
|
||||
protected static LocalDateTime currentUtcTime() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
protected Tournament generateTournamentWithQualificationMatches() {
|
||||
var tournament = new Tournament(
|
||||
"testname", currentUtcTime().plusDays(1), 64L, "testdescription",
|
||||
"testname", BeerDateTime.nowUtc().plusDays(1), 64L, "testdescription",
|
||||
userRepository.findByUsername(TEST_USER));
|
||||
tournamentService.create(tournament, TEST_USER);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.BeerPongTableRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.security.JwtTokenizer;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
@Test
|
||||
public void getSingleBeerPongTableById() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament("TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64l, null,
|
||||
var tournament = new Tournament("TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64l, null,
|
||||
null);
|
||||
|
||||
tournament = tournamentService.create(tournament, TestDataGenerator.TEST_USER);
|
||||
|
@ -105,7 +106,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
userRepository.save(user);
|
||||
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", user
|
||||
);
|
||||
tournament = tournamentService.create(tournament, user.getUsername());
|
||||
|
@ -141,7 +142,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
userRepository.save(user);
|
||||
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", user
|
||||
);
|
||||
tournament = tournamentService.create(tournament, user.getUsername());
|
||||
|
@ -183,7 +184,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
@Test
|
||||
public void updateBeerPongTableForExistingTournamentThatWasCreatedByTheCurrentUser() throws Exception {
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -218,7 +219,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
@Test
|
||||
public void updateBeerPongTableForExistingTournamentThatWasntCreatedByTheCurrentUser() throws Exception {
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -267,7 +268,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
userRepository.save(user);
|
||||
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", user
|
||||
);
|
||||
tournament = tournamentService.create(tournament, user.getUsername());
|
||||
|
@ -294,7 +295,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
userRepository.save(user);
|
||||
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", user
|
||||
);
|
||||
tournament = tournamentService.create(tournament, user.getUsername());
|
||||
|
@ -332,7 +333,7 @@ public class BeerPongTableEndpointTest extends TestData {
|
|||
userRepository.save(user);
|
||||
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", user
|
||||
);
|
||||
tournament = tournamentService.create(tournament, user.getUsername());
|
||||
|
|
|
@ -34,6 +34,8 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TeamRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.security.JwtTokenizer;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import static org.assertj.core.api.Assertions.as;
|
||||
|
@ -104,7 +106,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
|
||||
@Test
|
||||
public void successfullyCreateNewTournament() throws Exception {
|
||||
var registrationEnd = currentUtcTime().plusDays(1).withSecond(0).withNano(0);
|
||||
var registrationEnd = BeerDateTime.nowUtc().plusDays(1).withSecond(0).withNano(0);
|
||||
CreateTournamentDto data = new CreateTournamentDto()
|
||||
.setName("TOURNAMENT 1")
|
||||
.setRegistrationEnd(registrationEnd)
|
||||
|
@ -133,7 +135,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void createNewTournamentWithValidationErrorsFor_Name_RegistrationEnd_And_MaxParticipants() throws Exception {
|
||||
CreateTournamentDto data = new CreateTournamentDto()
|
||||
.setName(null)
|
||||
.setRegistrationEnd(currentUtcTime().minusDays(1))
|
||||
.setRegistrationEnd(BeerDateTime.nowUtc().minusDays(1))
|
||||
.setMaxParticipants(0L);
|
||||
var mvcResult = this.mockMvc.perform(post(TOURNAMENT_BASE_URI)
|
||||
.header(securityProperties.getAuthHeader(), jwtTokenizer.getAuthToken(TEST_USER, TEST_USER_ROLES))
|
||||
|
@ -214,7 +216,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void generateQualificationMatchesForTournamentWithEnoughTeams() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TOURNAMENT_WITHOUT_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
"TOURNAMENT_WITHOUT_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
|
||||
|
@ -261,7 +263,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void generateQualificationMatchesForTournamentWithoutEnoughTeams() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TOURNAMENT_WITHOUT_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
"TOURNAMENT_WITHOUT_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournamentRepository.saveAndFlush(tournament);
|
||||
|
@ -285,7 +287,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void generateQualificationMatchesForTournamentFromAnotherOrganizerWhenItIsntAllowed() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TOURNAMENT_WITHOUT_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
"TOURNAMENT_WITHOUT_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournamentRepository.saveAndFlush(tournament);
|
||||
|
@ -321,7 +323,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
// Setup: Create a tournament to delete
|
||||
var tournament = new Tournament(
|
||||
"TOURNAMENT_TO_DELETE",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -347,7 +349,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
// Setup: Create a tournament to delete
|
||||
var tournament = new Tournament(
|
||||
"TOURNAMENT_TO_DELETE",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -394,7 +396,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
newUser
|
||||
|
@ -415,7 +417,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
//given
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -436,14 +438,14 @@ public class TournamentEndpointTest extends TestData {
|
|||
//given
|
||||
var tournament1 = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
);
|
||||
var tournament2 = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -470,7 +472,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
// setup
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -512,7 +514,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
// setup
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -617,7 +619,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
newUser
|
||||
|
@ -638,7 +640,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
//given
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -659,14 +661,14 @@ public class TournamentEndpointTest extends TestData {
|
|||
//given
|
||||
var tournament1 = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
);
|
||||
var tournament2 = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -693,7 +695,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
//given
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -724,7 +726,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void getTournamentOverviewWithMatches_OnePlayedEach() throws Exception{
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -744,11 +746,11 @@ public class TournamentEndpointTest extends TestData {
|
|||
qualif1.setQualificationMatch(match1);
|
||||
qualif2.setQualificationMatch(match1);
|
||||
var match2 = new QualificationMatch(tournament);
|
||||
match2.setStartTime(currentUtcTime().minusDays(7));
|
||||
match2.setEndTime(currentUtcTime().minusDays(1));
|
||||
match2.setStartTime(BeerDateTime.nowUtc().minusDays(7));
|
||||
match2.setEndTime(BeerDateTime.nowUtc().minusDays(1));
|
||||
var match3 = new KoStanding(tournament, null, team1);
|
||||
match3.setStartTime(currentUtcTime().minusDays(7));
|
||||
match3.setEndTime(currentUtcTime().minusDays(1));
|
||||
match3.setStartTime(BeerDateTime.nowUtc().minusDays(7));
|
||||
match3.setEndTime(BeerDateTime.nowUtc().minusDays(1));
|
||||
|
||||
var table = new BeerPongTable("Table", tournament);
|
||||
tournament.getTables().add(table);
|
||||
|
@ -790,7 +792,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void getTournamentOverview_DifferentOrganizer() throws Exception{
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -812,7 +814,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
public void getTournamentOverview_NonExistentTournament() throws Exception{
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
@ -836,7 +838,7 @@ public class TournamentEndpointTest extends TestData {
|
|||
var userid = userRepository.findByUsername(TEST_USER).getId();
|
||||
var tournament = tournamentRepository.findAllByOrganizerIdOrderByNameAsc(userid).getFirst();
|
||||
var updatesDto = new TournamentUpdateDto(
|
||||
"Updated", currentUtcTime().plusMinutes(1), 22L, "Updated description"
|
||||
"Updated", BeerDateTime.nowUtc().plusMinutes(1), 22L, "Updated description"
|
||||
);
|
||||
|
||||
this.mockMvc.perform(
|
||||
|
|
|
@ -17,6 +17,8 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.security.JwtTokenizer;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.impl.TournamentQualificationServiceImpl;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -74,7 +76,7 @@ public class TournamentQualificationEndpointTest extends TestData {
|
|||
// setup
|
||||
var tournament = new Tournament(
|
||||
"Tournament 1",
|
||||
currentUtcTime().plusDays(1),
|
||||
BeerDateTime.nowUtc().plusDays(1),
|
||||
64L,
|
||||
"new Tournament",
|
||||
userRepository.findByUsername(TestDataGenerator.TEST_USER)
|
||||
|
|
|
@ -26,6 +26,7 @@ import at.ac.tuwien.sepr.groupphase.backend.exception.NotFoundException;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.BeerPongTableRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.BeerPongTableService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@ActiveProfiles("test")
|
||||
|
@ -44,7 +45,7 @@ public class BeerPongTableServiceTest extends TestData {
|
|||
public void getSingleBeerPongTableById() {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -72,7 +73,7 @@ public class BeerPongTableServiceTest extends TestData {
|
|||
public void createNewBeerPongTableForExistingTournamentThatWasCreatedByTheCurrentUser() {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -93,7 +94,7 @@ public class BeerPongTableServiceTest extends TestData {
|
|||
public void createNewBeerPongTableForExistingTournamentThatWasntCreatedByTheCurrentUser() {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -119,7 +120,7 @@ public class BeerPongTableServiceTest extends TestData {
|
|||
public void updateBeerPongTableForExistingTournamentThatWasCreatedByTheCurrentUser() {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
@ -143,7 +144,7 @@ public class BeerPongTableServiceTest extends TestData {
|
|||
public void updateBeerPongTableForExistingTournamentThatWasntCreatedByTheCurrentUser() {
|
||||
// setup
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TEST_USER);
|
||||
|
|
|
@ -13,6 +13,8 @@ import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentQualificationService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
@ -44,7 +46,7 @@ public class TournamentQualificationServiceTest extends TestData {
|
|||
|
||||
@Test
|
||||
public void generateQualificationMatchesForTournamentWithEnoughTeams() throws Exception {
|
||||
var tournament = new Tournament("TOURNAMENT_WITH_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
var tournament = new Tournament("TOURNAMENT_WITH_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription",
|
||||
userRepository.findByUsername(TEST_USER));
|
||||
|
||||
|
@ -82,7 +84,7 @@ public class TournamentQualificationServiceTest extends TestData {
|
|||
@Test
|
||||
public void generateQualificationMatchesForTournamentWithoutEnoughTeams() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament("TOURNAMENT_WITHOUT_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
var tournament = new Tournament("TOURNAMENT_WITHOUT_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription",
|
||||
userRepository.findByUsername(TEST_USER));
|
||||
|
||||
|
@ -95,7 +97,7 @@ public class TournamentQualificationServiceTest extends TestData {
|
|||
@Test
|
||||
public void generateQualificationMatchesForTournamentFromAnotherOrganizerWhenItIsntAllowed() throws Exception {
|
||||
// setup
|
||||
var tournament = new Tournament("TOURNAMENT_WITHOUT_TEAMS", currentUtcTime().plusDays(1), 64L,
|
||||
var tournament = new Tournament("TOURNAMENT_WITHOUT_TEAMS", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription",
|
||||
userRepository.findByUsername(TEST_USER));
|
||||
|
||||
|
@ -177,6 +179,6 @@ public class TournamentQualificationServiceTest extends TestData {
|
|||
final var m = this.qualificationMatchRepository.findById(match.getId());
|
||||
assertTrue(m.isPresent());
|
||||
assertNotNull(m.get().getStartTime());
|
||||
assertTrue(m.get().getStartTime().isBefore(currentUtcTime()));
|
||||
assertTrue(m.get().getStartTime().isBefore(BeerDateTime.nowUtc()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentUpdateDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.util.BeerDateTime;
|
||||
import jakarta.validation.ValidationException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -39,7 +40,7 @@ public class TournamentServiceTest extends TestData {
|
|||
@Test
|
||||
public void createNewTournamentWithTestUserAsOrganizer() {
|
||||
var tournament = new Tournament(
|
||||
"TEST_TOURNAMENT", currentUtcTime().plusDays(1), 64L,
|
||||
"TEST_TOURNAMENT", BeerDateTime.nowUtc().plusDays(1), 64L,
|
||||
"testdescription", userRepository.findByUsername(TEST_USER)
|
||||
);
|
||||
tournament = tournamentService.create(tournament, TestDataGenerator.TEST_USER);
|
||||
|
@ -70,7 +71,7 @@ public class TournamentServiceTest extends TestData {
|
|||
@Test
|
||||
public void editTournament_ValidUpdate() {
|
||||
var tournament = new Tournament(
|
||||
"testname", currentUtcTime().plusMinutes(2), 32L, "testdescription",
|
||||
"testname", BeerDateTime.nowUtc().plusMinutes(2), 32L, "testdescription",
|
||||
userRepository.findByUsername(TEST_USER));
|
||||
tournamentRepository.saveAndFlush(tournament);
|
||||
|
||||
|
|
Loading…
Reference in a new issue