package de.thpeetz.kontor.tysc.repository;

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

import java.util.List;

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

@SpringBootTest
class PlayerRepositoryTest {

    @Autowired
    private PlayerRepository playerRepository;

    @Test
    void testFindByFirstNameAndLastName() {
        Player existingPlayer = playerRepository.findAll().get(11);
        String firstName = existingPlayer.getFirstName();
        String lastName = existingPlayer.getLastName();
        Player found = playerRepository.findByFirstNameAndLastName(firstName, lastName);
        assertEquals(existingPlayer.getFullName(), found.getFullName());
    }

    @Test
    void testSearch() {
        List<Player> players = playerRepository.search("can");
        assertEquals(1, players.size());
    }
}
