package com.ibtp.kontor.tradingcards.dal;

import com.ibtp.kontor.dal.DatabaseManager;
import com.ibtp.kontor.util.LocalTestDatabase;
import com.ibtp.kontor.tradingcards.entity.ManufacturerEntity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

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

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

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

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

    @Test
    public void testManufacturerAddAndDelete() {

    }

    @Test
    public void testManufacturerFindAll() {

    }
}
