io.github.nblxa:turntables-oracle18-java8

Turntables: Support for Oracle18 Java8

License

License

Categories

Categories

Java 8 Languages
GroupId

GroupId

io.github.nblxa
ArtifactId

ArtifactId

turntables-oracle18-java8
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

io.github.nblxa:turntables-oracle18-java8
Turntables: Support for Oracle18 Java8
Project URL

Project URL

http://github.com/nblxa/turntables

Download turntables-oracle18-java8

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.nblxa/turntables-oracle18-java8/ -->
<dependency>
    <groupId>io.github.nblxa</groupId>
    <artifactId>turntables-oracle18-java8</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.nblxa/turntables-oracle18-java8/
implementation 'io.github.nblxa:turntables-oracle18-java8:0.1.0'
// https://jarcasting.com/artifacts/io.github.nblxa/turntables-oracle18-java8/
implementation ("io.github.nblxa:turntables-oracle18-java8:0.1.0")
'io.github.nblxa:turntables-oracle18-java8:jar:0.1.0'
<dependency org="io.github.nblxa" name="turntables-oracle18-java8" rev="0.1.0">
  <artifact name="turntables-oracle18-java8" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.nblxa', module='turntables-oracle18-java8', version='0.1.0')
)
libraryDependencies += "io.github.nblxa" % "turntables-oracle18-java8" % "0.1.0"
[io.github.nblxa/turntables-oracle18-java8 "0.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
io.github.nblxa : turntables-core jar 0.1.0
com.oracle.database.jdbc : ojdbc8 jar 19.8.0.0

provided (1)

Group / Artifact Type Version
com.github.spotbugs : spotbugs-annotations jar 4.1.4

Project Modules

There are no modules declared in this project.

Turntables

Maven Central CircleCI Coverage Status Quality Gate Status

Turntables enables developers to write test assertions for data in tables using a simple fluent interface.

IntelliJ diff in comparison mode

Assertion errors are shown in an IDE-friendly way. The screenshot above demonstrates how IntelliJ IDEA highlights the differences between the actual and expected tables in the sample test.

  @Test
  public void test() {
    Tab actual = Turntables.tab()
        .col("name").key("id")
        .row("Elise", 1)
        .row("Bob", 2);

    Turntables.assertThat(actual)
        .colMode(Settings.ColMode.MATCH_BY_NAME)
        .rowMode(Settings.RowMode.MATCH_BY_KEY)
        .matches()
        .key("id").col("name")
        .row(1, "Alice")
        .row(2, "Bob")
        .asExpected();
  }

JUnit support

Turntables integrates with JUnit to help developers set up initial test data in tables:

@Rule
public TestDataSource testDataSource = TestDataFactory.jdbc(
        "jdbc:mysql://localhost:3306/mydb", "testuser", "str0ngPA55word!");

@TestTable(name = "employees", cleanUpAction = CleanUpAction.DROP)
public Tab testTab = Turntables.tab()
  .col("id").col("name")
  .row(1, "Alice")
  .row(2, "Bob");

Use the table name in test methods to get its contents for assertions.

Tab actual = testDataSource.ingest("employees");

For a complete example with MySQL, see ITMySql.java.

For Oracle, see: ITOracle.java.

Difference to AssertJ-DB

Turntables's main power and difference from AssertJ-DB is the ability to match whole table contents at once using specific rules (e.g. match rows by key or match columns by name) and to present to the developer only the difference that matters for the assertion.

As a result, less code must be written for tests and it's easier to find bugs.

Maven

Turntables extends AssertJ and you'll need both dependencies.

<dependency>
  <groupId>io.github.nblxa</groupId>
  <artifactId>turntables-core</artifactId>
  <version>0.2.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>io.github.nblxa</groupId>
  <artifactId>turntables-mysql</artifactId>
  <version>0.2.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-core</artifactId>
  <version>3.18.1</version>
  <scope>test</scope>
</dependency>

The above example uses a MySQL 8 dependency. If you use Turntables with another JDBC database, see JDBC for additional dependencies.

Build

A quick build skipping integration tests:

./mvnw clean package

Integration tests use Docker.

The Oracle test is containerized using the image quillbuilduser/oracle-18-xe.

Image size is 13GB at the time of writing this, so it's advisable to download it beforehand.

Build with integration tests:

docker run --rm -itd --name oracle -p 1521:1521 quillbuilduser/oracle-18-xe
docker run --rm -itd --name mysql -e MYSQL_ROOT_PASSWORD=tiger -e MYSQL_DATABASE=testdb -p 3306:3306 mysql:8.0.22
( docker logs -f mysql & ) | grep -m1 'MY-010931'
( docker logs -f oracle & ) | grep -m1 'DATABASE IS READY TO USE!'
./mvnw clean verify || true
docker stop oracle 2>/dev/null || true
docker stop mysql 2>/dev/null || true

Versions

Version
0.1.0