package de.thpeetz.kontor.tysc.repository;

import static org.junit.jupiter.api.Assertions.*;

import java.util.List;

import de.thpeetz.kontor.tysc.data.FieldPosition;
import de.thpeetz.kontor.tysc.data.Player;
import de.thpeetz.kontor.tysc.data.Rooster;
import de.thpeetz.kontor.tysc.data.Team;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class RoosterRepositoryTest {

    @Autowired
    private RoosterRepository roosterRepository;

    @Test
    void testFindByReferences() {
        List<Rooster> roosters = roosterRepository.findAll();
        Rooster existingRooster = roosters.get(4);
        Team team = existingRooster.getTeam();
        Player player = existingRooster.getPlayer();
        FieldPosition position = existingRooster.getPosition();
        int year = existingRooster.getYear();
        Rooster rooster = roosterRepository.findByReferences(player, team, position, year);
        assertNotNull(rooster);
        assertEquals(existingRooster.getId(), rooster.getId());
    }
}
