package com.ibtp.kontor.tradingcards.dal;

import com.ibtp.kontor.dal.DatabaseManager;
import com.ibtp.kontor.util.LocalTestDatabase;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.ibtp.kontor.tradingcards.entity.ManufacturerEntity;

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

import java.util.List;

/**
 * Created by tpeetz on 20.01.2015.
 */
public class ManufacturerImplTest {

    @BeforeAll
    public static void setup() {
        DatabaseManager.setDatabase(new LocalTestDatabase());
    }

    @Test
    public void addManufacturer() {
        String manufacturerName = "Manufacturer1";
        ManufacturerImpl manufacturerImpl = new ManufacturerImpl();
        ManufacturerEntity manufacturer = manufacturerImpl.addManufacturer(manufacturerName);
        assertNotNull(manufacturer);
        List<ManufacturerEntity> manufacturerList = manufacturerImpl.findByName(manufacturerName);
        assertTrue(manufacturerList.size() > 0);
    }

    @Test
    public void deleteManufacturer() {
        String manufacturerName = "Manufacturer1";
        ManufacturerImpl manufacturerImpl = new ManufacturerImpl();
        List<ManufacturerEntity> manufacturerList = manufacturerImpl.findByName(manufacturerName);
        assertTrue(manufacturerList.size() > 0);
        manufacturerImpl.delete(manufacturerList.get(0));
        manufacturerList = manufacturerImpl.findByName(manufacturerName);
        assertEquals(0, manufacturerList.size());
    }

    @Test
    public void testManufacturerAddAndDelete() {

    }

    @Test
    public void testManufacturerFindAll() {

    }
}
