2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
8 package wtf
.metio
.yosql
.codegen
.dao
;
10 import org
.junit
.jupiter
.api
.Assertions
;
11 import org
.junit
.jupiter
.api
.Test
;
12 import wtf
.metio
.yosql
.internals
.testing
.configs
.SqlConfigurations
;
13 import wtf
.metio
.yosql
.models
.configuration
.ResultRowConverter
;
14 import wtf
.metio
.yosql
.models
.immutables
.SqlConfiguration
;
17 * Verifies that {@link JdbcBlocks}s work correctly.
19 abstract class JdbcBlocksTCK
{
22 * @return A new {@link JdbcBlocks}.
24 abstract JdbcBlocks
generator();
26 abstract String
getConnectionInlineExpectation();
28 abstract String
prepareStatementInlineExpectation();
30 abstract String
prepareCallInlineExpectation();
32 abstract String
getMetaDataStatementExpectation();
34 abstract String
executeQueryInlineExpectation();
36 abstract String
returnExecuteUpdateWithReturnExpectation();
38 abstract String
returnExecuteUpdateWithoutReturnExpectation();
40 abstract String
executeBatchExpectation();
42 abstract String
closeResultSetExpectation();
44 abstract String
closePrepareStatementExpectation();
46 abstract String
closeConnectionExpectation();
48 abstract String
executeStatementExpectation();
50 abstract String
openConnectionExpectation();
52 abstract String
tryPrepareCallableExpectation();
54 abstract String
createStatementExpectation();
56 abstract String
prepareBatchExpectation();
58 abstract String
pickVendorQueryExpectation();
60 abstract String
logExecutedQueryExpectation();
62 abstract String
logExecutedBatchQueryExpectation();
64 abstract String
returnAsMultipleExpectation();
66 abstract String
returnAsSingleExpectation();
68 abstract String
returnAsSingleWithThrowExpectation();
70 abstract String
setParametersExpectation();
72 abstract String
setBatchParametersExpectation();
75 final void getConnectionInline() {
76 Assertions
.assertEquals(
77 getConnectionInlineExpectation(),
78 generator().getConnectionInline().toString());
82 final void prepareStatementInline() {
83 Assertions
.assertEquals(
84 prepareStatementInlineExpectation(),
85 generator().prepareStatementInline().toString());
89 final void prepareCallInline() {
90 Assertions
.assertEquals(
91 prepareCallInlineExpectation(),
92 generator().prepareCallInline().toString());
96 final void getMetaDataStatement() {
97 Assertions
.assertEquals(
98 getMetaDataStatementExpectation(),
99 generator().getMetaDataStatement().toString());
103 final void executeQueryInline() {
104 Assertions
.assertEquals(
105 executeQueryInlineExpectation(),
106 generator().executeQueryInline().toString());
110 final void returnExecuteUpdateWithReturn() {
111 Assertions
.assertEquals(
112 returnExecuteUpdateWithReturnExpectation(),
113 generator().returnExecuteUpdate(SqlConfiguration
.copyOf(SqlConfigurations
.sqlConfiguration())
114 .withWritesReturnUpdateCount(true)).toString());
118 final void returnExecuteUpdateWithoutReturn() {
119 Assertions
.assertEquals(
120 returnExecuteUpdateWithoutReturnExpectation(),
121 generator().returnExecuteUpdate(SqlConfiguration
.copyOf(SqlConfigurations
.sqlConfiguration())
122 .withWritesReturnUpdateCount(false)).toString());
126 final void executeBatch() {
127 Assertions
.assertEquals(
128 executeBatchExpectation(),
129 generator().executeBatch().toString());
133 final void closeResultSet() {
134 Assertions
.assertEquals(
135 closeResultSetExpectation(),
136 generator().closeResultSet().toString());
140 final void closePrepareStatement() {
141 Assertions
.assertEquals(
142 closePrepareStatementExpectation(),
143 generator().closePrepareStatement().toString());
147 final void closeConnection() {
148 Assertions
.assertEquals(
149 closeConnectionExpectation(),
150 generator().closeConnection().toString());
154 final void executeStatement() {
155 Assertions
.assertEquals(
156 executeStatementExpectation(),
157 generator().executeStatement(SqlConfigurations
.sqlConfiguration()).toString());
161 final void openConnection() {
162 Assertions
.assertEquals(
163 openConnectionExpectation(),
164 generator().openConnection().toString());
168 final void tryPrepareCallable() {
169 Assertions
.assertEquals(
170 tryPrepareCallableExpectation(),
171 generator().tryPrepareCallable().toString());
175 final void createStatement() {
176 Assertions
.assertEquals(
177 createStatementExpectation(),
178 generator().createStatement(SqlConfigurations
.sqlConfiguration()).toString());
182 final void prepareBatch() {
183 Assertions
.assertEquals(
184 prepareBatchExpectation(),
185 generator().prepareBatch(SqlConfigurations
.sqlConfiguration()).toString());
189 final void pickVendorQuery() {
190 Assertions
.assertEquals(
191 pickVendorQueryExpectation(),
192 generator().pickVendorQuery(SqlConfigurations
.sqlStatement()).toString());
196 final void logExecutedQuery() {
197 Assertions
.assertEquals(
198 logExecutedQueryExpectation(),
199 generator().logExecutedQuery(SqlConfigurations
.sqlConfiguration()).toString());
203 final void logExecutedBatchQuery() {
204 Assertions
.assertEquals(
205 logExecutedBatchQueryExpectation(),
206 generator().logExecutedBatchQuery(SqlConfigurations
.sqlConfiguration()).toString());
210 final void returnAsMultiple() {
211 final var converter
= ResultRowConverter
.builder()
212 .setAlias("converter")
213 .setConverterType("com.example.Converter")
214 .setMethodName("apply")
215 .setResultType("com.example.Domain")
217 Assertions
.assertEquals(
218 returnAsMultipleExpectation(),
219 generator().returnAsMultiple(converter
).toString());
223 final void returnAsSingle() {
224 Assertions
.assertEquals(
225 returnAsSingleExpectation(),
226 generator().returnAsSingle(SqlConfigurations
.sqlConfiguration()).toString());
230 final void returnAsSingleWithThrow() {
231 Assertions
.assertEquals(
232 returnAsSingleWithThrowExpectation(),
233 generator().returnAsSingle(SqlConfiguration
.copyOf(SqlConfigurations
.sqlConfiguration())
234 .withThrowOnMultipleResultsForSingle(true)).toString());
238 final void setParameters() {
239 Assertions
.assertEquals(
240 setParametersExpectation(),
241 generator().setParameters(SqlConfigurations
.sqlConfiguration()).toString());
245 final void setBatchParameters() {
246 Assertions
.assertEquals(
247 setBatchParametersExpectation(),
248 generator().setBatchParameters(SqlConfigurations
.sqlConfiguration()).toString());