Use modern language features in tests

This commit is contained in:
Sam Brannen
2022-02-03 15:35:32 +01:00
parent 32cd73261a
commit b3f786728e
58 changed files with 117 additions and 151 deletions

View File

@@ -111,7 +111,7 @@ public class LobSupportTests {
}
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() {
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<>() {
@Override
protected void streamData(ResultSet rs) throws SQLException, IOException {

View File

@@ -107,7 +107,7 @@ public class SqlQueryTests {
given(resultSet.next()).willReturn(true, false);
given(resultSet.getInt(1)).willReturn(1);
SqlQuery<Integer> query = new MappingSqlQueryWithParameters<Integer>() {
SqlQuery<Integer> query = new MappingSqlQueryWithParameters<>() {
@Override
protected Integer mapRow(ResultSet rs, int rownum, @Nullable Object[] params, @Nullable Map<? ,?> context)
throws SQLException {
@@ -129,7 +129,7 @@ public class SqlQueryTests {
@Test
public void testQueryWithoutEnoughParams() {
MappingSqlQuery<Integer> query = new MappingSqlQuery<Integer>() {
MappingSqlQuery<Integer> query = new MappingSqlQuery<>() {
@Override
protected Integer mapRow(ResultSet rs, int rownum) throws SQLException {
return rs.getInt(1);
@@ -147,7 +147,7 @@ public class SqlQueryTests {
@Test
public void testQueryWithMissingMapParams() {
MappingSqlQuery<Integer> query = new MappingSqlQuery<Integer>() {
MappingSqlQuery<Integer> query = new MappingSqlQuery<>() {
@Override
protected Integer mapRow(ResultSet rs, int rownum) throws SQLException {
return rs.getInt(1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.jdbc.support;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -69,12 +68,7 @@ class KeyHolderTests {
@Test
void getKeyWithMultipleKeysInMap() {
@SuppressWarnings("serial")
Map<String, Object> m = new HashMap<String, Object>() {{
put("key", 1);
put("seq", 2);
}};
kh.getKeyList().add(m);
kh.getKeyList().add(Map.of("key", 1, "seq", 2));
assertThat(kh.getKeys()).as("two keys should be in the map").hasSize(2);
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
@@ -110,10 +104,7 @@ class KeyHolderTests {
@Test
void getKeysWithMultipleKeyRows() {
@SuppressWarnings("serial")
Map<String, Object> m = new HashMap<String, Object>() {{
put("key", 1);
put("seq", 2);
}};
Map<String, Object> m = Map.of("key", 1, "seq", 2);
kh.getKeyList().addAll(asList(m, m));
assertThat(kh.getKeyList()).as("two rows should be in the list").hasSize(2);