From 8136ef90305d84aa502064ce8d0201b24fed4d83 Mon Sep 17 00:00:00 2001 From: Christoph Kuhnke Date: Fri, 10 Mar 2023 11:50:18 +0100 Subject: [PATCH] Bug/92 schema name property (#93) Co-authored-by: Christoph Pirkl --- .github/workflows/broken_links_checker.yml | 7 +- .github/workflows/ci-build-next-java.yml | 2 +- .github/workflows/ci-build.yml | 4 +- .project-keeper.yml | 2 +- dependencies.md | 2 +- doc/changes/changelog.md | 1 + doc/changes/changes_7.1.0.md | 34 ++++++ doc/dialects/exasol.md | 2 +- error_code_config.yml | 2 +- pk_generated_parent.pom | 14 ++- pom.xml | 16 +-- .../dialects/exasol/ExasolSqlDialect.java | 9 +- .../dialects/exasol/MandatoryProperty.java | 45 +++++++ .../dialects/exasol/SchemaNameProperty.java | 21 ++++ .../dialects/exasol/ExasolSqlDialectTest.java | 115 ++++++++++++------ .../exasol/IntegrationTestConfiguration.java | 2 +- 16 files changed, 212 insertions(+), 66 deletions(-) create mode 100644 doc/changes/changes_7.1.0.md create mode 100644 src/main/java/com/exasol/adapter/dialects/exasol/MandatoryProperty.java create mode 100644 src/main/java/com/exasol/adapter/dialects/exasol/SchemaNameProperty.java diff --git a/.github/workflows/broken_links_checker.yml b/.github/workflows/broken_links_checker.yml index 29071df..c4ff3be 100644 --- a/.github/workflows/broken_links_checker.yml +++ b/.github/workflows/broken_links_checker.yml @@ -19,9 +19,12 @@ jobs: - name: Configure broken links checker run: | mkdir -p ./target - echo '{ "aliveStatusCodes": [429, 200], "ignorePatterns": [{"pattern": "^https?://(www.)?opensource.org"}] }' > ./target/broken_links_checker.json + echo '{"aliveStatusCodes": [429, 200], "ignorePatterns": [' \ + '{"pattern": "^https?://(www|dev).mysql.com/"},' \ + '{"pattern": "^https?://(www.)?opensource.org"}' \ + ']}' > ./target/broken_links_checker.json - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: use-quiet-mode: 'yes' use-verbose-mode: 'yes' - config-file: ./target/broken_links_checker.json \ No newline at end of file + config-file: ./target/broken_links_checker.json diff --git a/.github/workflows/ci-build-next-java.yml b/.github/workflows/ci-build-next-java.yml index 6a1006c..e0c15cf 100644 --- a/.github/workflows/ci-build-next-java.yml +++ b/.github/workflows/ci-build-next-java.yml @@ -25,7 +25,7 @@ jobs: cache: 'maven' - name: Run tests and build with Maven run: | - mvn --batch-mode --update-snapshots clean package -DtrimStackTrace=false \ + mvn --batch-mode --update-snapshots clean package -DtrimStackTrace=false \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn - name: Publish Test Report uses: scacap/action-surefire-report@v1 diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index c057ee5..744a81f 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -16,7 +16,7 @@ jobs: DEFAULT_DB_VERSION: "7.1.17" runs-on: ubuntu-latest concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.docker_db_version }} steps: - name: Checkout the repository uses: actions/checkout@v3 @@ -58,4 +58,4 @@ jobs: -Dsonar.login=$SONAR_TOKEN env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.project-keeper.yml b/.project-keeper.yml index 9f7cb33..f638d54 100644 --- a/.project-keeper.yml +++ b/.project-keeper.yml @@ -9,4 +9,4 @@ sources: linkReplacements: excludes: - "E-PK-CORE-18: Outdated content: '.github/workflows/ci-build.yml'" - - "E-PK-CORE-18: Outdated content: '.github/workflows/release_droid_upload_github_release_assets.yml'" + - regex: "(?s)E-PK-CORE-53: The dependencies.md file has outdated content.*" diff --git a/dependencies.md b/dependencies.md index 09c8c5d..b8aea44 100644 --- a/dependencies.md +++ b/dependencies.md @@ -94,7 +94,7 @@ [35]: https://sonatype.github.io/ossindex-maven/maven-plugin/ [36]: http://www.apache.org/licenses/LICENSE-2.0.txt [37]: https://maven.apache.org/surefire/maven-surefire-plugin/ -[38]: https://www.mojohaus.org/versions-maven-plugin/ +[38]: https://www.mojohaus.org/versions/versions-maven-plugin/ [39]: https://github.com/exasol/project-keeper/ [40]: https://github.com/exasol/project-keeper/blob/main/LICENSE [41]: https://maven.apache.org/plugins/maven-assembly-plugin/ diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index 10626bf..f350539 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [7.1.0](changes_7.1.0.md) * [7.0.2](changes_7.0.2.md) * [7.0.1](changes_7.0.1.md) * [7.0.0](changes_7.0.0.md) diff --git a/doc/changes/changes_7.1.0.md b/doc/changes/changes_7.1.0.md new file mode 100644 index 0000000..09e027e --- /dev/null +++ b/doc/changes/changes_7.1.0.md @@ -0,0 +1,34 @@ +# Exasol Virtual Schema 7.1.0, released 2023-03-10 + +Code name: Mandatory Property SCHEMA_NAME + +## Summary + +This release updates VSEXA to take virtual schema property `SCHEMA_NAME` as mandatory in order to fix a bug when the property is not set. + +## Bugfixes + +* #92: Fixed broken handling of tables when `SCHEMA_NAME` property is not set + +## Dependency Updates + +### Compile Dependency Updates + +* Updated `com.exasol:error-reporting-java:1.0.0` to `1.0.1` +* Updated `com.exasol:virtual-schema-common-jdbc:10.1.0` to `10.2.0` + +### Test Dependency Updates + +* Updated `com.exasol:exasol-testcontainers:6.5.0` to `6.5.1` +* Updated `com.exasol:test-db-builder-java:3.4.1` to `3.4.2` +* Updated `com.exasol:virtual-schema-common-jdbc:10.1.0` to `10.2.0` +* Updated `org.mockito:mockito-junit-jupiter:5.0.0` to `5.1.1` + +### Plugin Dependency Updates + +* Updated `com.exasol:error-code-crawler-maven-plugin:1.2.1` to `1.2.2` +* Updated `com.exasol:project-keeper-maven-plugin:2.9.1` to `2.9.3` +* Updated `org.apache.maven.plugins:maven-dependency-plugin:3.3.0` to `3.5.0` +* Updated `org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M7` to `3.0.0-M8` +* Updated `org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M7` to `3.0.0-M8` +* Updated `org.codehaus.mojo:versions-maven-plugin:2.13.0` to `2.14.2` diff --git a/doc/dialects/exasol.md b/doc/dialects/exasol.md index 6f1ff5a..496c5b0 100644 --- a/doc/dialects/exasol.md +++ b/doc/dialects/exasol.md @@ -17,7 +17,7 @@ The SQL statement below creates the adapter script, defines the Java class that ```sql CREATE JAVA ADAPTER SCRIPT SCHEMA_FOR_VS_SCRIPT.ADAPTER_SCRIPT_EXASOL AS %scriptclass com.exasol.adapter.RequestDispatcher; - %jar /buckets///virtual-schema-dist-10.1.0-exasol-7.0.2.jar; + %jar /buckets///virtual-schema-dist-10.2.0-exasol-7.1.0.jar; / ``` diff --git a/error_code_config.yml b/error_code_config.yml index 7148afe..14ff225 100644 --- a/error_code_config.yml +++ b/error_code_config.yml @@ -2,4 +2,4 @@ error-tags: VSEXA: packages: - com.exasol.adapter.dialects.exasol - highest-index: 5 \ No newline at end of file + highest-index: 6 \ No newline at end of file diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index fd56cdd..fd46951 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol exasol-virtual-schema-generated-parent - 7.0.2 + 7.1.0 pom UTF-8 @@ -129,7 +129,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.0.0-M8 @@ -140,7 +140,7 @@ org.codehaus.mojo versions-maven-plugin - 2.13.0 + 2.14.2 display-updates @@ -269,6 +269,8 @@ true ossrh https://oss.sonatype.org/ + 15 + 30 @@ -283,7 +285,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.3.0 + 3.5.0 copy-jacoco @@ -303,7 +305,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M7 + 3.0.0-M8 @@ -373,7 +375,7 @@ com.exasol error-code-crawler-maven-plugin - 1.2.1 + 1.2.2 verify diff --git a/pom.xml b/pom.xml index fc86df6..41c461f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,12 +2,12 @@ 4.0.0 exasol-virtual-schema - 7.0.2 + 7.1.0 Exasol Virtual Schema This projects contains the Exasol dialect for Exasol's Virtual Schema https://github.com/exasol/exasol-virtual-schema/ - 10.1.0 + 10.2.0 @@ -33,7 +33,7 @@ com.exasol error-reporting-java - 1.0.0 + 1.0.1 org.glassfish @@ -64,14 +64,14 @@ org.mockito mockito-junit-jupiter - 5.0.0 + 5.1.1 test com.exasol exasol-testcontainers - 6.5.0 + 6.5.1 test @@ -95,7 +95,7 @@ com.exasol test-db-builder-java - 3.4.1 + 3.4.2 test @@ -110,7 +110,7 @@ com.exasol project-keeper-maven-plugin - 2.9.1 + 2.9.3 @@ -195,7 +195,7 @@ exasol-virtual-schema-generated-parent com.exasol - 7.0.2 + 7.1.0 pk_generated_parent.pom diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java index fd9eb96..136fe05 100644 --- a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java +++ b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java @@ -14,6 +14,7 @@ import com.exasol.adapter.dialects.*; import com.exasol.adapter.dialects.rewriting.SqlGenerationContext; import com.exasol.adapter.jdbc.*; +import com.exasol.adapter.properties.*; import com.exasol.errorreporting.ExaError; /** @@ -23,6 +24,7 @@ public class ExasolSqlDialect extends AbstractSqlDialect { static final String EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH = "TIMESTAMP_WITH_LOCAL_TIME_ZONE_USAGE"; static final String NAME = "EXASOL"; private static final Capabilities CAPABILITIES = createCapabilityList(); + private final ValidatorChain dialectPropertyValidators; /** * Create a new instance of the {@link ExasolSqlDialect}. @@ -33,6 +35,10 @@ public class ExasolSqlDialect extends AbstractSqlDialect { public ExasolSqlDialect(final ConnectionFactory connectionFactory, final AdapterProperties properties) { super(connectionFactory, properties, Set.of(CATALOG_NAME_PROPERTY, SCHEMA_NAME_PROPERTY, EXASOL_IMPORT_PROPERTY, EXASOL_CONNECTION_PROPERTY, IS_LOCAL_PROPERTY, IGNORE_ERRORS_PROPERTY)); + this.dialectPropertyValidators = PropertyValidator.chain() // + .add(SchemaNameProperty.validator(NAME)) // + .add(BooleanProperty.validator(EXASOL_IMPORT_PROPERTY)) // + .add(BooleanProperty.validator(IS_LOCAL_PROPERTY)); this.omitParenthesesMap.addAll(Set.of(SYSDATE, SYSTIMESTAMP, CURRENT_SCHEMA, CURRENT_SESSION, CURRENT_STATEMENT, CURRENT_USER, CURRENT_CLUSTER)); } @@ -140,8 +146,7 @@ public String getStringLiteral(final String value) { public void validateProperties() throws PropertyValidationException { super.validateProperties(); checkImportPropertyConsistency(EXASOL_IMPORT_PROPERTY, EXASOL_CONNECTION_PROPERTY); - validateBooleanProperty(EXASOL_IMPORT_PROPERTY); - validateBooleanProperty(IS_LOCAL_PROPERTY); + this.dialectPropertyValidators.validate(this.properties); } @Override diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/MandatoryProperty.java b/src/main/java/com/exasol/adapter/dialects/exasol/MandatoryProperty.java new file mode 100644 index 0000000..1ff79c9 --- /dev/null +++ b/src/main/java/com/exasol/adapter/dialects/exasol/MandatoryProperty.java @@ -0,0 +1,45 @@ +package com.exasol.adapter.dialects.exasol; + +import com.exasol.adapter.AdapterProperties; +import com.exasol.adapter.properties.PropertyValidationException; +import com.exasol.adapter.properties.PropertyValidator; +import com.exasol.errorreporting.ExaError; + +/** + * {@link PropertyValidator} for validation of a mandatory property. + */ +public class MandatoryProperty implements PropertyValidator { + /** + * Create a new validator. + * + * @param dialect name of the current virtual schema dialect to be included in error message + * @param element label for the missing property value + * @param property name of the property + * @return new instance of {@link PropertyValidator} for validation of a mandatory property. + */ + public static PropertyValidator validator(final String dialect, final String element, final String property) { + return new MandatoryProperty(dialect, element, property); + } + + private final String dialect; + private final String element; + private final String property; + + private MandatoryProperty(final String dialect, final String element, final String property) { + this.dialect = dialect; + this.element = element; + this.property = property; + } + + @Override + public void validate(final AdapterProperties properties) throws PropertyValidationException { + if (!properties.hasSchemaName()) { + throw new PropertyValidationException(ExaError.messageBuilder("E-VSEXA-6") + .message("{{dialect|uq}} virtual schema dialect requires to specify a {{element1|uq}}.", + this.dialect, this.element) // + .mitigation("Please specify a {{element2|uq}} using property {{property}}.", // + this.element, this.property) // + .toString()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/SchemaNameProperty.java b/src/main/java/com/exasol/adapter/dialects/exasol/SchemaNameProperty.java new file mode 100644 index 0000000..c9bb9e0 --- /dev/null +++ b/src/main/java/com/exasol/adapter/dialects/exasol/SchemaNameProperty.java @@ -0,0 +1,21 @@ +package com.exasol.adapter.dialects.exasol; + +import com.exasol.adapter.AdapterProperties; +import com.exasol.adapter.properties.PropertyValidator; + +/** + * Validator for property {@link AdapterProperties#SCHEMA_NAME_PROPERTY} + */ +public class SchemaNameProperty { + /** + * @param dialect name of the current dialect + * @return {@link PropertyValidator} for mandatory property {@link AdapterProperties#SCHEMA_NAME_PROPERTY}. + */ + public static PropertyValidator validator(final String dialect) { + return MandatoryProperty.validator(dialect, "schema name", AdapterProperties.SCHEMA_NAME_PROPERTY); + } + + private SchemaNameProperty() { + // only static usage + } +} diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectTest.java b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectTest.java index 187586f..babd729 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectTest.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectTest.java @@ -20,7 +20,6 @@ import java.sql.SQLException; import java.util.*; -import com.exasol.adapter.dialects.rewriting.SqlGenerationContext; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -34,9 +33,12 @@ import com.exasol.adapter.adapternotes.ColumnAdapterNotes; import com.exasol.adapter.adapternotes.ColumnAdapterNotesJsonConverter; import com.exasol.adapter.capabilities.*; -import com.exasol.adapter.dialects.*; +import com.exasol.adapter.dialects.SqlDialect; +import com.exasol.adapter.dialects.SqlGenerator; +import com.exasol.adapter.dialects.rewriting.SqlGenerationContext; import com.exasol.adapter.jdbc.ConnectionFactory; import com.exasol.adapter.metadata.*; +import com.exasol.adapter.properties.PropertyValidationException; import com.exasol.adapter.sql.*; import com.exasol.sql.SqlNormalizer; @@ -171,28 +173,25 @@ void testCreateFromExaQueryRewriter(@Mock final Connection connectionMock) throw @Test void checkValidBoolOptionsWithExaConnection() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(EXASOL_IMPORT_PROPERTY, "TrUe"); - this.rawProperties.put(EXASOL_CONNECTION_PROPERTY, "MY_EXA_CONNECTION"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(EXASOL_IMPORT_PROPERTY, "TrUe") // + .with(EXASOL_CONNECTION_PROPERTY, "MY_EXA_CONNECTION") // + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } @Test void checkValidBoolOptionsWithExaConnectionExplicitlyDisabled() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(EXASOL_IMPORT_PROPERTY, "FalSe"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory().with(EXASOL_IMPORT_PROPERTY, "FalSe").build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } @Test void testInconsistentExasolProperties() { - setMandatoryProperties(); - this.rawProperties.put(EXASOL_CONNECTION_PROPERTY, "localhost:5555"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory().with(EXASOL_CONNECTION_PROPERTY, "localhost:5555") + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); final PropertyValidationException exception = assertThrows(PropertyValidationException.class, sqlDialect::validateProperties); @@ -202,9 +201,9 @@ void testInconsistentExasolProperties() { @Test void testInvalidExasolProperties() { - setMandatoryProperties(); - this.rawProperties.put(EXASOL_IMPORT_PROPERTY, "True"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(EXASOL_IMPORT_PROPERTY, "True") // + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); final PropertyValidationException exception = assertThrows(PropertyValidationException.class, sqlDialect::validateProperties); @@ -214,63 +213,99 @@ void testInvalidExasolProperties() { @Test void testValidateCatalogProperty() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(CATALOG_NAME_PROPERTY, "MY_CATALOG"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(CATALOG_NAME_PROPERTY, "MY_CATALOG") // + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } @Test void testValidateSchemaProperty() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(SCHEMA_NAME_PROPERTY, "MY_SCHEMA"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(SCHEMA_NAME_PROPERTY, "MY_SCHEMA") // + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } @Test void checkInvalidIsLocalProperty() { - setMandatoryProperties(); - this.rawProperties.put(IS_LOCAL_PROPERTY, "asdasd"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(IS_LOCAL_PROPERTY, "asdasd") // + .build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); final PropertyValidationException exception = assertThrows(PropertyValidationException.class, sqlDialect::validateProperties); - assertThat(exception.getMessage(), containsString( - "The value 'asdasd' for the property 'IS_LOCAL' is invalid. It has to be either 'true' or 'false' (case " - + "insensitive)")); + assertThat(exception.getMessage(), containsString("The value 'asdasd' for property 'IS_LOCAL' is invalid." + + " It has to be either 'true' or 'false' (case insensitive)")); } @Test void checkValidIsLocalProperty1() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(IS_LOCAL_PROPERTY, "TrUe"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory().with(IS_LOCAL_PROPERTY, "TrUe").build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } @Test void checkValidIsLocalProperty() throws PropertyValidationException { - setMandatoryProperties(); - this.rawProperties.put(IS_LOCAL_PROPERTY, "FalSe"); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory().with(IS_LOCAL_PROPERTY, "FalSe").build(); final SqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); sqlDialect.validateProperties(); } - private void setMandatoryProperties() { - this.rawProperties.put(AdapterProperties.CONNECTION_NAME_PROPERTY, "MY_CONN"); - } - @Test void testIsTimestampWithLocalTimeZoneEnabled() { - setMandatoryProperties(); - this.rawProperties.put(IGNORE_ERRORS_PROPERTY, EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH); - final AdapterProperties adapterProperties = new AdapterProperties(this.rawProperties); + final AdapterProperties adapterProperties = mandatory() // + .with(IGNORE_ERRORS_PROPERTY, EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH) // + .build(); final ExasolSqlDialect exasolSqlDialect = new ExasolSqlDialect(null, adapterProperties); assertThat(exasolSqlDialect.isTimestampWithLocalTimeZoneEnabled(), equalTo(true)); } + + @Test + void testMissing() throws PropertyValidationException { + final AdapterProperties adapterProperties = mandatory() // + .remove(AdapterProperties.SCHEMA_NAME_PROPERTY) // + .build(); + final ExasolSqlDialect sqlDialect = new ExasolSqlDialect(null, adapterProperties); + final Exception exception = assertThrows(PropertyValidationException.class, + () -> sqlDialect.validateProperties()); + assertThat(exception.getMessage(), + equalTo("E-VSEXA-6: EXASOL virtual schema dialect requires to specify a schema name." + + " Please specify a schema name using property 'SCHEMA_NAME'.")); + } + + AdapterProperties mandatoryWith(final String key, final String value) { + return mandatory().with(key, value).build(); + } + + AdapterPropertiesBuilder mandatory() { + return adapterPropertiesBuilder() // + .with(AdapterProperties.CONNECTION_NAME_PROPERTY, "MY_CONN") // + .with(AdapterProperties.SCHEMA_NAME_PROPERTY, "MY_SCHEMA"); + } + + AdapterPropertiesBuilder adapterPropertiesBuilder() { + return new AdapterPropertiesBuilder(); + } + + static class AdapterPropertiesBuilder { + private final Map raw = new HashMap<>(); + + AdapterPropertiesBuilder with(final String key, final String value) { + this.raw.put(key, value); + return this; + } + + AdapterPropertiesBuilder remove(final String key) { + this.raw.remove(key); + return this; + } + + AdapterProperties build() { + return new AdapterProperties(this.raw); + } + } } \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java b/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java index cf09921..9664412 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java @@ -8,7 +8,7 @@ public final class IntegrationTestConfiguration { * Do not use MavenProjectVersionGetter here to enable reference checker to check if reference points to the latest * version. */ - public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtual-schema-dist-10.1.0-exasol-7.0.2.jar"; + public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtual-schema-dist-10.2.0-exasol-7.1.0.jar"; public static final Path PATH_TO_VIRTUAL_SCHEMAS_JAR = Path.of("target", VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION); private IntegrationTestConfiguration() {