Skip to content

Commit

Permalink
#124: Improved test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
redcatbear committed May 3, 2019
1 parent 5e9f110 commit 8164552
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected DataType mapJdbcTypeOther(final JdbcTypeDescription jdbcTypeDescriptio
} else {
LOGGER.finer(() -> "Mapping JDBC type OTHER [" + jdbcTypeDescription.getTypeName()
+ "] to maximum size VARCHAR.");
return DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8);
}
return DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.dialects.*;
import com.exasol.adapter.metadata.DataType;
import com.exasol.adapter.metadata.DataType.ExaCharset;

class RedshiftColumnMetadataReaderTest extends AbstractColumnMetadataReaderTest {
@BeforeEach
Expand Down Expand Up @@ -40,4 +41,10 @@ void testMapJdbcTypeOtherDouble() {
assertThat(this.columnMetadataReader.mapJdbcType(new JdbcTypeDescription(Types.OTHER, 0, 0, 0, "double")),
equalTo(DataType.createDouble()));
}

@Test
void testMapJdbcTypeOtherUnknownToMaxVarChar() {
assertThat(this.columnMetadataReader.mapJdbcType(new JdbcTypeDescription(Types.OTHER, 0, 0, 0, "unknown")),
equalTo(DataType.createMaximumSizeVarChar(ExaCharset.UTF8)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static com.exasol.adapter.capabilities.ScalarFunctionCapability.*;
import static com.exasol.reflect.ReflectionUtils.getMethodReturnViaReflection;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
Expand All @@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.Map;

import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -30,6 +29,8 @@
import com.exasol.adapter.capabilities.Capabilities;
import com.exasol.adapter.dialects.PropertyValidationException;
import com.exasol.adapter.dialects.SqlDialect;
import com.exasol.adapter.dialects.SqlDialect.NullSorting;
import com.exasol.adapter.sql.ScalarFunction;

@ExtendWith(MockitoExtension.class)
class RedshiftSqlDialectTest {
Expand Down Expand Up @@ -97,7 +98,7 @@ void testValidateDialectNameProperty() {
final SqlDialect sqlDialect = new RedshiftSqlDialect(null, adapterProperties);
final PropertyValidationException exception = assertThrows(PropertyValidationException.class,
sqlDialect::validateProperties);
MatcherAssert.assertThat(exception.getMessage(), containsString(
assertThat(exception.getMessage(), containsString(
"The dialect REDSHIFT cannot have the name ORACLE. You specified the wrong dialect name or created the wrong dialect class."));
}

Expand All @@ -114,4 +115,40 @@ private void setMandatoryProperties(final String sqlDialectProperty) {
this.rawProperties.put(AdapterProperties.SQL_DIALECT_PROPERTY, sqlDialectProperty);
this.rawProperties.put(AdapterProperties.CONNECTION_NAME_PROPERTY, "MY_CONN");
}

@Test
void testGetScalarFunctionAliases() {
final Map<ScalarFunction, String> scalarFunctionAliases = this.dialect.getScalarFunctionAliases();
assertThat(scalarFunctionAliases, aMapWithSize(5));
}

@Test
void testGetAggregateFunctionAliases() {
assertThat(this.dialect.getAggregateFunctionAliases(), aMapWithSize(0));
}

@Test
void testApplyQuote() {
assertThat(this.dialect.applyQuote("Foo\"Bar"), equalTo("\"Foo\"\"Bar\""));
}

@Test
void testRequiresCatalogQualifiedTableNames() {
assertThat(this.dialect.requiresCatalogQualifiedTableNames(null), equalTo(false));
}

@Test
void testRequiresSchemaQualifiedTableNames() {
assertThat(this.dialect.requiresSchemaQualifiedTableNames(null), equalTo(true));
}

@Test
void testGetDefaultNullSorting() {
assertThat(this.dialect.getDefaultNullSorting(), equalTo(NullSorting.NULLS_SORTED_AT_END));
}

@Test
void testGetStringLiteral() {
assertThat(this.dialect.getStringLiteral("Foo'Bar"), equalTo("'Foo''Bar'"));
}
}

0 comments on commit 8164552

Please sign in to comment.