Skip to content

Commit

Permalink
coverage in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
pain64 committed Jan 5, 2025
1 parent b575e87 commit e3ba2f8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 23 deletions.
5 changes: 5 additions & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ plugins {

}

jacoco {
toolVersion = "0.8.12"
}

repositories {
mavenCentral()
}
Expand Down Expand Up @@ -101,6 +105,7 @@ tasks.test {
tasks.jacocoTestReport {
reports {
csv.required.set(true)
xml.required.set(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ private static Type up(
if (r != null) return r;
}

// We have grantee that we will find
var parent = (Type.ClassType) from.getSuperclass();
saveTypeArguments.accept(parent);
if (from.getSuperclass() instanceof Type.ClassType parent) {
saveTypeArguments.accept(parent);
return up(typeReadWriteSymbol, map, (Symbol.ClassSymbol) parent.tsym);
}

return up(typeReadWriteSymbol, map, (Symbol.ClassSymbol) parent.tsym);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,7 @@ else throw new ValidationException(
className ->
parsedConfig.typeBindings().stream()
.filter(b -> b.className().equals(className))
.findFirst().orElseThrow(() -> new IllegalStateException("unreachable"))
.rwClassName(),
.findFirst().get().rwClassName(),
lineNumber,
sourceMode,
queryMode,
Expand Down
5 changes: 4 additions & 1 deletion lib/src/test/java/net/truej/sql/compiler/GenericArrayRw.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import net.truej.sql.config.TypeReadWrite;

import java.io.Serializable;
import java.sql.*;

public abstract class GenericArrayRw<T> implements TypeReadWrite<T> {
public abstract class GenericArrayRw<T> implements
Serializable, // need for coverage
TypeReadWrite<T> {
abstract T convert(Array array) throws SQLException;

@Override public T get(ResultSet rs, int columnIndex) throws SQLException {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package net.truej.sql.compiler;

import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.TypeTag;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.sun.tools.javac.code.Type;

public class __03__CharTestTrueSqlPlugin {
public class __03__CharTestUnreachable {
@Test public void test() {
Assertions.assertEquals(
Character.class.getName(),
MapperGenerator.boxedClassName("char")
);
Assertions.assertEquals(
"char",
TrueSqlPlugin.arrayClassNameToSourceCodeType("Char")
Expand All @@ -22,4 +26,5 @@ public class __03__CharTestTrueSqlPlugin {
TrueSqlPlugin.primitiveTypeToBoxedClass(new Type.JCPrimitiveType(TypeTag.CHAR, null))
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ static class Handled extends Exception { }
);
}

@TestTemplate public void triedButUnhandled(MainDataSource ds) {
assertThrows(ConstraintViolationException.class, () -> {
try {
ds.q("delete from city").fetchNone();
} catch (ConstraintViolationException ex) {
ex.when(
ds.constraint("users", "users_pk", () -> {
throw new Handled();
})
);
}
});
}

@TestTemplate public void rethrow(MainDataSource ds) {
assertThrows(Handled.class, () -> {
try {
Expand Down

0 comments on commit e3ba2f8

Please sign in to comment.