Initial Development #1
@ -60,18 +60,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
|
||||||
<compilerPlugins>
|
|
||||||
<plugin>kotlinx-serialization</plugin>
|
|
||||||
</compilerPlugins>
|
|
||||||
</configuration>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-maven-serialization</artifactId>
|
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
@ -69,7 +68,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>test-compile</id>
|
<id>test-compile</id>
|
||||||
<phase>test-compile</phase>
|
<phase>process-test-sources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test-compile</goal>
|
<goal>test-compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package solutions.bitbadger.documents.java.java.integration.common;
|
|
||||||
|
|
||||||
import solutions.bitbadger.documents.java.integration.ThrowawayDatabase;
|
|
||||||
import solutions.bitbadger.documents.java.java.testDocs.JsonDocument;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static solutions.bitbadger.documents.java.integration.TypesKt.TEST_TABLE;
|
|
||||||
|
|
||||||
final public class Count {
|
|
||||||
|
|
||||||
public static void all(ThrowawayDatabase db) {
|
|
||||||
JsonDocument.load(db);
|
|
||||||
assertEquals(5L, solutions.bitbadger.documents.java.Count.all(TEST_TABLE, db.getConn()),
|
|
||||||
"There should have been 5 documents in the table");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Count() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,62 @@
|
|||||||
|
package solutions.bitbadger.documents.java.java.integration.common;
|
||||||
|
|
||||||
|
import solutions.bitbadger.documents.common.Field;
|
||||||
|
import solutions.bitbadger.documents.java.Count;
|
||||||
|
import solutions.bitbadger.documents.java.integration.ThrowawayDatabase;
|
||||||
|
import solutions.bitbadger.documents.java.java.testDocs.JsonDocument;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static solutions.bitbadger.documents.java.integration.TypesKt.TEST_TABLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for the `Count` object
|
||||||
|
*/
|
||||||
|
final public class CountFunctions {
|
||||||
|
|
||||||
|
public static void all(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(5L, Count.all(TEST_TABLE, db.getConn()), "There should have been 5 documents in the table");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byFieldsNumeric(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(3L, Count.byFields(TEST_TABLE, List.of(Field.between("numValue", 10, 20)), db.getConn()),
|
||||||
|
"There should have been 3 matching documents");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byFieldsAlpha(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(1L, Count.byFields(TEST_TABLE, List.of(Field.between("value", "aardvark", "apple")), db.getConn()),
|
||||||
|
"There should have been 1 matching document");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byContainsMatch(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(2L, Count.byContains(TEST_TABLE, Map.of("value", "purple"), db.getConn()),
|
||||||
|
"There should have been 2 matching documents");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byContainsNoMatch(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(0L, Count.byContains(TEST_TABLE, Map.of("value", "magenta"), db.getConn()),
|
||||||
|
"There should have been no matching documents");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byJsonPathMatch(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(2L, Count.byJsonPath(TEST_TABLE, "$.numValue ? (@ < 5)", db.getConn()),
|
||||||
|
"There should have been 2 matching documents");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void byJsonPathNoMatch(ThrowawayDatabase db) {
|
||||||
|
JsonDocument.load(db);
|
||||||
|
assertEquals(0L, Count.byJsonPath(TEST_TABLE, "$.numValue ? (@ > 100)", db.getConn()),
|
||||||
|
"There should have been no matching documents");
|
||||||
|
}
|
||||||
|
|
||||||
|
private CountFunctions() {
|
||||||
|
}
|
||||||
|
}
|
@ -3,20 +3,67 @@ package solutions.bitbadger.documents.java.java.integration.postgresql;
|
|||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import solutions.bitbadger.documents.java.integration.postgresql.PgDB;
|
import solutions.bitbadger.documents.java.integration.postgresql.PgDB;
|
||||||
import solutions.bitbadger.documents.java.java.integration.common.Count;
|
import solutions.bitbadger.documents.java.java.integration.common.CountFunctions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostgreSQL integration tests for the `Count` object / `count*` connection extension functions
|
* PostgreSQL integration tests for the `Count` object / `count*` connection extension functions
|
||||||
*/
|
*/
|
||||||
@DisplayName("Java | PostgreSQL: Count")
|
@DisplayName("Java | Java | PostgreSQL: Count")
|
||||||
public class CountIT {
|
public class CountIT {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("all counts all documents")
|
@DisplayName("all counts all documents")
|
||||||
public void all() {
|
public void all() {
|
||||||
try (PgDB db = new PgDB()) {
|
try (PgDB db = new PgDB()) {
|
||||||
Count.all(db);
|
CountFunctions.all(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byFields counts documents by a numeric value")
|
||||||
|
public void byFieldsNumeric() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byFieldsNumeric(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byFields counts documents by a alphanumeric value")
|
||||||
|
public void byFieldsAlpha() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byFieldsAlpha(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byContains counts documents when matches are found")
|
||||||
|
public void byContainsMatch() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byContainsMatch(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byContains counts documents when no matches are found")
|
||||||
|
public void byContainsNoMatch() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byContainsNoMatch(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byJsonPath counts documents when matches are found")
|
||||||
|
public void byJsonPathMatch() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byJsonPathMatch(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byJsonPath counts documents when no matches are found")
|
||||||
|
public void byJsonPathNoMatch() {
|
||||||
|
try (PgDB db = new PgDB()) {
|
||||||
|
CountFunctions.byJsonPathNoMatch(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package solutions.bitbadger.documents.java.java.integration.sqlite;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import solutions.bitbadger.documents.common.DocumentException;
|
||||||
|
import solutions.bitbadger.documents.java.integration.sqlite.SQLiteDB;
|
||||||
|
import solutions.bitbadger.documents.java.java.integration.common.CountFunctions;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQLite integration tests for the `Count` object / `count*` connection extension functions
|
||||||
|
*/
|
||||||
|
@DisplayName("Java | Java | SQLite: Count")
|
||||||
|
public class CountIT {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("all counts all documents")
|
||||||
|
public void all() {
|
||||||
|
try (SQLiteDB db = new SQLiteDB()) {
|
||||||
|
CountFunctions.all(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byFields counts documents by a numeric value")
|
||||||
|
public void byFieldsNumeric() {
|
||||||
|
try (SQLiteDB db = new SQLiteDB()) {
|
||||||
|
CountFunctions.byFieldsNumeric(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byFields counts documents by a alphanumeric value")
|
||||||
|
public void byFieldsAlpha() {
|
||||||
|
try (SQLiteDB db = new SQLiteDB()) {
|
||||||
|
CountFunctions.byFieldsAlpha(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byContains fails")
|
||||||
|
public void byContainsMatch() {
|
||||||
|
try (SQLiteDB db = new SQLiteDB()) {
|
||||||
|
assertThrows(DocumentException.class, () -> CountFunctions.byContainsMatch(db));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("byJsonPath fails")
|
||||||
|
public void byJsonPathMatch() {
|
||||||
|
try (SQLiteDB db = new SQLiteDB()) {
|
||||||
|
assertThrows(DocumentException.class, () -> CountFunctions.byJsonPathMatch(db));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.code.style>official</kotlin.code.style>
|
<kotlin.code.style>official</kotlin.code.style>
|
||||||
<kotlin.compiler.jvmTarget>${java.version}</kotlin.compiler.jvmTarget>
|
<kotlin.compiler.jvmTarget>${java.version}</kotlin.compiler.jvmTarget>
|
||||||
<kotlin.version>2.1.0</kotlin.version>
|
<kotlin.version>2.1.10</kotlin.version>
|
||||||
<serialization.version>1.8.0</serialization.version>
|
<serialization.version>1.8.0</serialization.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user