Polishing

This commit is contained in:
Sam Brannen 2023-10-24 11:48:03 +02:00
parent e57b942b4d
commit a803206d5f
2 changed files with 28 additions and 10 deletions

View File

@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Sam Brannen
* @since 6.1
* @see SimpleJdbcInsertTests
*/
class SimpleJdbcInsertIntegrationTests {
@ -90,7 +91,9 @@ class SimpleJdbcInsertIntegrationTests {
insert.compile();
// NOTE: quoted identifiers in H2/HSQL will be UPPERCASE!
assertThat(insert.getInsertString()).isEqualTo("INSERT INTO \"USERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES(?, ?)");
assertThat(insert.getInsertString()).isEqualToIgnoringNewLines("""
INSERT INTO "USERS" ("FIRST_NAME", "LAST_NAME") VALUES(?, ?)
""");
insertJaneSmith(insert);
}
@ -133,7 +136,9 @@ class SimpleJdbcInsertIntegrationTests {
insert.compile();
// NOTE: quoted identifiers in H2/HSQL will be UPPERCASE!
assertThat(insert.getInsertString()).isEqualTo("INSERT INTO \"MY_SCHEMA\".\"USERS\" (\"FIRST_NAME\", \"LAST_NAME\") VALUES(?, ?)");
assertThat(insert.getInsertString()).isEqualToIgnoringNewLines("""
INSERT INTO "MY_SCHEMA"."USERS" ("FIRST_NAME", "LAST_NAME") VALUES(?, ?)
""");
insertJaneSmith(insert);
}

View File

@ -38,10 +38,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Mock object based tests for {@link SimpleJdbcInsert}.
* Mock-based tests for {@link SimpleJdbcInsert}.
*
* @author Thomas Risberg
* @author Sam Brannen
* @see SimpleJdbcInsertIntegrationTests
*/
class SimpleJdbcInsertTests {
@ -64,6 +65,18 @@ class SimpleJdbcInsertTests {
}
@Test
void missingTableName() throws Exception {
SimpleJdbcInsert insert = new SimpleJdbcInsert(dataSource);
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
.isThrownBy(insert::compile)
.withMessage("Table name is required");
// Appease the @AfterEach checks.
connection.close();
}
/**
* This method does not test any functionality but rather only that
* configuration methods can be chained without compiler errors.