package de.thpeetz.kontor.tysc.repository;

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

import java.util.List;

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;

import de.thpeetz.kontor.tysc.TestConstants;

@SpringBootTest
class TeamRepositoryTest {

    @Autowired
    private TeamRepository teamRepository;

    @Test
    void testFindByName() {
        Team team = teamRepository.findByName(TestConstants.DOLPHINS_NAME);
        assertEquals(TestConstants.DOLPHINS_SHORT, team.getShortName());
    }

    @Test
    void testFindByNameIgnoreCase() {
        List<Team> teams = teamRepository.findByNameIgnoreCase(TestConstants.DOLPHINS_NAME.toLowerCase());
        assertEquals(1, teams.size());
        assertEquals(TestConstants.DOLPHINS_SHORT, teams.get(0).getShortName());
    }

    @Test
    void testSearch() {
        List<Team> teams = teamRepository.search("dol");
        assertEquals(1, teams.size());
    }
}
