Skip to content

Commit

Permalink
chore: restore Oleh changes; move tests to java + add slf4j api
Browse files Browse the repository at this point in the history
  • Loading branch information
filipelautert committed Sep 6, 2024
1 parent e5bc589 commit 925aa2c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 119 deletions.
130 changes: 43 additions & 87 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-parent-pom</artifactId>
<version>0.4.5</version> <!-- Replace with the desired version -->
</parent>

<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-databricks</artifactId>
<version>1.4.0-SNAPSHOT</version>
Expand Down Expand Up @@ -36,10 +42,10 @@
</developers>

<scm>
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/liquibase/liquibase-databricks.git</url>
<tag>HEAD</tag>
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/liquibase/liquibase-databricks.git</url>
<tag>HEAD</tag>
</scm>

<properties>
Expand All @@ -56,11 +62,10 @@
<sonar.scm.provider>git</sonar.scm.provider>
<sonar.qualitygate.wait>true</sonar.qualitygate.wait>
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/groovy</sonar.tests>

<groovy.version>2.4.21</groovy.version>
<dependency.spock.version>1.3-groovy-2.4</dependency.spock.version>

<sonar.tests>src/test</sonar.tests>
<liquibase-test-harness.version>1.0.10</liquibase-test-harness.version>
<junit.version>5.11.0</junit.version>
<junit-platform.version>1.11.0</junit-platform.version>
<jacoco.fileset.directory>target</jacoco.fileset.directory>
</properties>

Expand All @@ -71,65 +76,54 @@
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-commercial</artifactId>
<version>${liquibase.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>databricks-jdbc</artifactId>
<version>2.6.40</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-test-harness</artifactId>
<version>1.0.9</version>
<scope>test</scope>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>${junit-platform.version}</version>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.3</version>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>databricks-jdbc</artifactId>
<version>2.6.38</version>
<scope>test</scope>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<scope>test</scope>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
</exclusion>
</exclusions>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>${dependency.spock.version}</version>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>${jsonassert.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>databricks-jdbc</artifactId>
<version>2.6.38</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -157,15 +151,6 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reportFormat>plain</reportFormat>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand Down Expand Up @@ -197,35 +182,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -245,7 +201,7 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.11.0.3922</version>
<version>4.0.0.4121</version>
</plugin>

<plugin>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package liquibase.ext.databricks;

import liquibase.harness.AdvancedHarnessSuite;

public class AdvancedExtensionHarnessTestSuite extends AdvancedHarnessSuite {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package liquibase.ext.databricks;

import liquibase.harness.BaseHarnessSuite;

public class ContributedExtensionHarnessTestSuite extends BaseHarnessSuite {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package liquibase.ext.databricks;

import liquibase.harness.FoundationalHarnessSuite;

public class FoundationalExtensionHarnessTestSuite extends FoundationalHarnessSuite {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
import liquibase.statement.core.AddPrimaryKeyStatement;
import liquibase.statement.core.RawParameterizedSqlStatement;
import liquibase.statement.core.SetNullableStatement;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

public class AddLookupTableChangeDatabricksTest {
class AddLookupTableChangeDatabricksTest {

private DatabricksDatabase database;

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

@Test
public void getConstraintName() {
void getConstraintName() {
AddLookupTableChangeDatabricks change = new AddLookupTableChangeDatabricks();
change.setConstraintName("testConstraint");

Expand All @@ -30,7 +31,7 @@ public void getConstraintName() {
}

@Test
public void getConstraintNameGenerated() {
void getConstraintNameGenerated() {
AddLookupTableChangeDatabricks changeNoName = new AddLookupTableChangeDatabricks();
changeNoName.setExistingTableName("existingTable");
changeNoName.setNewTableName("newTable");
Expand All @@ -40,13 +41,13 @@ public void getConstraintNameGenerated() {
}

@Test
public void supports() {
void supports() {
AddLookupTableChangeDatabricks change = new AddLookupTableChangeDatabricks();
assertTrue(change.supports(database));
}

@Test
public void generateStatements() {
void generateStatements() {
AddLookupTableChangeDatabricks change = new AddLookupTableChangeDatabricks();
change.setExistingTableName("oldTable");
change.setExistingColumnName("oldColumn");
Expand All @@ -58,14 +59,10 @@ public void generateStatements() {
assertEquals(4, sqlStatements.length);
assertInstanceOf(RawParameterizedSqlStatement.class, sqlStatements[0]);
assertEquals("CREATE TABLE newTable USING delta TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported', 'delta.columnMapping.mode' = 'name')" +
" AS SELECT DISTINCT oldColumn AS newColumn FROM oldTable WHERE oldColumn IS NOT NULL",
" AS SELECT DISTINCT oldColumn AS newColumn FROM oldTable WHERE oldColumn IS NOT NULL",
((RawParameterizedSqlStatement) sqlStatements[0]).getSql() );
assertInstanceOf(SetNullableStatement.class, sqlStatements[1]);
assertInstanceOf(AddPrimaryKeyStatement.class, sqlStatements[2]);
assertInstanceOf(AddForeignKeyConstraintStatement.class, sqlStatements[3]);
}

private void assertInstanceOf(Class clazz, Object object) {
assertTrue(object.getClass().isAssignableFrom(clazz));
}
}

0 comments on commit 925aa2c

Please sign in to comment.