package de.thpeetz.kontor.tysc.repository;

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

import java.util.List;

import de.thpeetz.kontor.tysc.data.CardSet;
import de.thpeetz.kontor.tysc.data.Vendor;
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 CardSetRepositoryTest {

    @Autowired
    private CardSetRepository cardSetRepository;

    @Autowired
    private VendorRepository vendorRepository;

    @Test
    void testFindByName() {
        List<CardSet> cardSets = cardSetRepository.findByName(TestConstants.CARDSET_MYSTIQUE_NAME);
        assertEquals(1, cardSets.size());
    }

    @Test
    void testFindByNameAndVendor() {
        Vendor fleer = vendorRepository.findByName(TestConstants.VENDOR_FLEER);
        assertNotNull(fleer);
        CardSet cardSet = cardSetRepository.findByNameAndVendor(TestConstants.CARDSET_MYSTIQUE_NAME, fleer);
        assertNotNull(cardSet);
    }

    @Test
    void testSearch() {
        List<CardSet> cardSets = cardSetRepository.search("SP");
        assertEquals(3, cardSets.size());
    }
}
