package liquibase.ext;

import liquibase.database.Database;
import liquibase.database.structure.type.DataType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertEquals;

@RunWith(MockitoJUnitRunner.class)
public class CustomOracleTypeConverterTest {

    private final CustomOracleTypeConverter converter = new CustomOracleTypeConverter();

    @Mock
    private Database database;

    @Test
    public void testGetDataTypeForVarChar2() throws Exception {
        DataType type = converter.getDataType("VARCHAR2", false, "VARCHAR2", null, null);
        assertEquals("CHAR", type.getUnit());
    }

    @Test
    public void testGetDataTypeForCharacterWithPrecision() throws Exception {
        DataType type = converter.getDataType("CHARACTER(255)", null, "CHARACTER", "255", null);
        assertEquals("CHAR", type.getUnit());
        assertEquals("255", type.getFirstParameter());
    }


    @Test
    public void testGetPriority() throws Exception {
        assertEquals(Priority.PRIORITY_OVERRIDE, converter.getPriority());
    }

}
