Package liquibase.ext.hibernate.snapshot

Source Code of liquibase.ext.hibernate.snapshot.ColumnSnapshotGeneratorTest

package liquibase.ext.hibernate.snapshot;

import liquibase.exception.DatabaseException;
import liquibase.structure.core.DataType;
import org.junit.Test;

import java.sql.Types;

import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.assertNull;

public class ColumnSnapshotGeneratorTest {

    @Test
    public void toDataType() throws DatabaseException {
        ColumnSnapshotGenerator columnSnapshotGenerator = new ColumnSnapshotGenerator();
        DataType varchar = columnSnapshotGenerator.toDataType("varchar(255)", Types.VARCHAR);
        assertEquals("varchar", varchar.getTypeName());
        assertEquals(255, varchar.getColumnSize().intValue());
        assertEquals(Types.VARCHAR, varchar.getDataTypeId().intValue());
        assertNull(varchar.getColumnSizeUnit());

        DataType intType = columnSnapshotGenerator.toDataType("integer", Types.INTEGER);
        assertEquals("integer", intType.getTypeName());

        DataType varcharChar = columnSnapshotGenerator.toDataType("varchar2(30 char)", Types.INTEGER);
        assertEquals("varchar2", varcharChar.getTypeName());
        assertEquals(30, varcharChar.getColumnSize().intValue());
        assertEquals(DataType.ColumnSizeUnit.CHAR, varcharChar.getColumnSizeUnit());

    }
}
TOP

Related Classes of liquibase.ext.hibernate.snapshot.ColumnSnapshotGeneratorTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.