Skip to content

Commit

Permalink
FIx tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliimak committed Jun 6, 2024
1 parent 06fa545 commit c1eab34
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 148 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>com.simba.googlebigquery.jdbc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@
import liquibase.statement.core.AddColumnStatement;
import liquibase.statement.core.DropColumnStatement;
import liquibase.statement.core.RawSqlStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//
//import static org.junit.jupiter.api.Assertions.assertEquals;
//import static org.junit.jupiter.api.Assertions.assertInstanceOf;

class BigQueryMergeColumnChangeTest {
public class BigQueryMergeColumnChangeTest {

private BigQueryDatabase database;

@BeforeEach
void setUp() {
@Before
public void setUp() {
database = new BigQueryDatabase();
}

@Test
void generateStatements() {
public void generateStatements() {
BigQueryMergeColumnChange change = new BigQueryMergeColumnChange();
change.setTableName("tableName");
change.setColumn1Name("column1Name");
Expand All @@ -34,10 +39,10 @@ void generateStatements() {

SqlStatement[] sqlStatements = change.generateStatements(database);
assertEquals(4, sqlStatements.length);
assertInstanceOf(AddColumnStatement.class, sqlStatements[0]);
assertInstanceOf(RawSqlStatement.class, sqlStatements[1]);
assertInstanceOf(DropColumnStatement.class, sqlStatements[2]);
assertInstanceOf(DropColumnStatement.class, sqlStatements[3]);
assertTrue(sqlStatements[0] instanceof AddColumnStatement);
assertTrue(sqlStatements[1] instanceof RawSqlStatement);
assertTrue(sqlStatements[2] instanceof DropColumnStatement);
assertTrue(sqlStatements[3] instanceof DropColumnStatement);

AddColumnStatement addColumnStatement = (AddColumnStatement) sqlStatements[0];
assertEquals("finalColumnName", addColumnStatement.getColumnName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
package liquibase.ext.bigquery.database;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

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

class BigqueryDatabaseUnitTest {
public class BigqueryDatabaseUnitTest {

private BigQueryDatabase database;

@BeforeEach
void setUp() {
@Before
public void setUp() {
database = new BigQueryDatabase();
}

@Test
void getShortName() {
public void getShortName() {
assertEquals("bigquery", database.getShortName());
}

@Test
void getDefaultDatabaseProductName() {
public void getDefaultDatabaseProductName() {
assertEquals("Google BigQuery", database.getDefaultDatabaseProductName());
}

@Test
void supportsDatabaseChangeLogHistory() {
public void supportsDatabaseChangeLogHistory() {
assertTrue(database.supportsDatabaseChangeLogHistory());
}

@Test
void getCurrentDateTimeFunction() {
public void getCurrentDateTimeFunction() {
assertEquals("CURRENT_DATETIME()", database.getCurrentDateTimeFunction());
}

@Test
void getQuotingStartCharacter() {
public void getQuotingStartCharacter() {
assertEquals("`", database.getQuotingStartCharacter());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class BignumericDataTypeBigQueryTest {
public class BignumericDataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
BignumericDataTypeBigQuery bignumericDataTypeBigQuery = new BignumericDataTypeBigQuery();
DatabaseDataType databaseDataType = bignumericDataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class BoolDataTypeBigQueryTest {
public class BoolDataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
BoolDataTypeBigQuery boolDataTypeBigQuery = new BoolDataTypeBigQuery();
DatabaseDataType databaseDataType = boolDataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class Float64DataTypeBigQueryTest {
public class Float64DataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
Float64DataTypeBigQuery float64DataTypeBigQuery = new Float64DataTypeBigQuery();
DatabaseDataType databaseDataType = float64DataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertEquals;

class GeographyDataTypeBigQueryTest {
public class GeographyDataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
GeographyDataTypeBigQuery datatype = new GeographyDataTypeBigQuery();
DatabaseDataType databaseDataType = datatype.toDatabaseDataType(new BigQueryDatabase());
assertEquals("GEOGRAPHY", databaseDataType.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class Int64DataTypeBigQueryTest {
public class Int64DataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
Int64DataTypeBigQuery int64DataTypeBigQuery = new Int64DataTypeBigQuery();
DatabaseDataType databaseDataType = int64DataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class NumberDataTypeBigQueryTest {
public class NumberDataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
NumericDataTypeBigQuery numberDataTypeBigQuery = new NumericDataTypeBigQuery();
DatabaseDataType databaseDataType = numberDataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@

import liquibase.datatype.DatabaseDataType;
import liquibase.ext.bigquery.database.BigQueryDatabase;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

class StringDataTypeBigQueryTest {
public class StringDataTypeBigQueryTest {

@Test
void toDatabaseDataType() {
public void toDatabaseDataType() {
StringDataTypeBigQuery stringDataTypeBigQuery = new StringDataTypeBigQuery();
DatabaseDataType databaseDataType = stringDataTypeBigQuery.toDatabaseDataType(new BigQueryDatabase());
assertNotNull(databaseDataType);
assertEquals("STRING", databaseDataType.getType());
}

@Test
void objectToSql() {
public void objectToSql() {
StringDataTypeBigQuery stringDataTypeBigQuery = new StringDataTypeBigQuery();
String sql = stringDataTypeBigQuery.objectToSql("TEST", new BigQueryDatabase());
assertEquals("'TEST'", sql);
}

@Test
void objectToSqlNewLineCharacter() {
public void objectToSqlNewLineCharacter() {
StringDataTypeBigQuery stringDataTypeBigQuery = new StringDataTypeBigQuery();
String sql = stringDataTypeBigQuery.objectToSql("TEST\n NEW LINE", new BigQueryDatabase());
assertEquals("'''TEST\n NEW LINE'''", sql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

import liquibase.ext.bigquery.database.BigQueryDatabase;
import liquibase.statement.core.AddColumnStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertEquals;

class BigQueryAddColumnGeneratorTest {
public class BigQueryAddColumnGeneratorTest {

private BigQueryAddColumnGenerator generator;
private BigQueryDatabase database;
private AddColumnStatement statement;

@BeforeEach
void setUp() {
@Before
public void setUp() {
database = new BigQueryDatabase();
generator = new BigQueryAddColumnGenerator();
statement = new AddColumnStatement();
}

@Test
void generateSingleColumnSQL() {
public void generateSingleColumnSQL() {
String sql = generator.generateSingleColumnSQL(statement, database);
assertEquals(" ADD COLUMN null", sql);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
import liquibase.ext.bigquery.database.BigQueryDatabase;
import liquibase.sql.Sql;
import liquibase.statement.core.AddForeignKeyConstraintStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

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

class BigQueryAddForeignKeyConstraintGeneratorTest {
public class BigQueryAddForeignKeyConstraintGeneratorTest {

private BigQueryAddForeignKeyConstraintGenerator generator;
private BigQueryDatabase database;
private AddForeignKeyConstraintStatement statement;

@BeforeEach
void setUp() {
@Before
public void setUp() {
database = new BigQueryDatabase();
generator = new BigQueryAddForeignKeyConstraintGenerator();
statement = new AddForeignKeyConstraintStatement(
Expand All @@ -32,7 +32,7 @@ void setUp() {
}

@Test
void generateSql() {
public void generateSql() {
Sql[] sql = generator.generateSql(statement, database, null);
assertEquals(1, sql.length);
assertEquals(";", sql[0].getEndDelimiter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
import liquibase.ext.bigquery.database.BigQueryDatabase;
import liquibase.sql.Sql;
import liquibase.statement.core.AddPrimaryKeyStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

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

class BigQueryAddPrimaryKeyConstraintGeneratorTest {
public class BigQueryAddPrimaryKeyConstraintGeneratorTest {

private BigQueryAddPrimaryKeyConstraintGenerator generator;
private BigQueryDatabase database;
private AddPrimaryKeyStatement statement;

@BeforeEach
void setUp() {
@Before
public void setUp() {
database = new BigQueryDatabase();
generator = new BigQueryAddPrimaryKeyConstraintGenerator();
statement = new AddPrimaryKeyStatement(
Expand All @@ -28,7 +28,7 @@ void setUp() {
}

@Test
void generateSql() {
public void generateSql() {
Sql[] sql = generator.generateSql(statement, database, null);
assertEquals(1, sql.length);
assertEquals(";", sql[0].getEndDelimiter());
Expand Down
Loading

0 comments on commit c1eab34

Please sign in to comment.