Use diamond operator where appropriate
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -192,7 +192,7 @@ public class JdbcBatchItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
}
|
||||
else {
|
||||
updateCounts = namedParameterJdbcTemplate.getJdbcOperations()
|
||||
.execute(sql, new PreparedStatementCallback<int[]>() {
|
||||
.execute(sql, new PreparedStatementCallback<>() {
|
||||
@Override
|
||||
public int[] doInPreparedStatement(PreparedStatement ps)
|
||||
throws SQLException, DataAccessException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -74,7 +74,7 @@ public class MultiResourceItemReader<T> extends AbstractItemStreamItemReader<T>
|
||||
this.strict = strict;
|
||||
}
|
||||
|
||||
private Comparator<Resource> comparator = new Comparator<Resource>() {
|
||||
private Comparator<Resource> comparator = new Comparator<>() {
|
||||
|
||||
/**
|
||||
* Compares resource filenames.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -46,6 +46,7 @@ import java.util.Comparator;
|
||||
* is turned off.
|
||||
*
|
||||
* @author peter.zozom
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class RangeArrayPropertyEditor extends PropertyEditorSupport {
|
||||
|
||||
@@ -119,7 +120,7 @@ public class RangeArrayPropertyEditor extends PropertyEditorSupport {
|
||||
}
|
||||
|
||||
// sort array of Ranges
|
||||
Arrays.sort(c, new Comparator<Integer>() {
|
||||
Arrays.sort(c, new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Integer r1, Integer r2) {
|
||||
return ranges[r1].getMin() - ranges[r2].getMin();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -138,7 +138,7 @@ class BatchMessageListenerContainerIntegrationTests {
|
||||
@Override
|
||||
public void onMessage(final Message msg) {
|
||||
try {
|
||||
RetryCallback<Message, Exception> callback = new RetryCallback<Message, Exception>() {
|
||||
RetryCallback<Message, Exception> callback = new RetryCallback<>() {
|
||||
@Override
|
||||
public Message doWithRetry(RetryContext context) throws Exception {
|
||||
try {
|
||||
@@ -150,7 +150,7 @@ class BatchMessageListenerContainerIntegrationTests {
|
||||
throw new RuntimeException("planned failure: " + msg);
|
||||
}
|
||||
};
|
||||
RecoveryCallback<Message> recoveryCallback = new RecoveryCallback<Message>() {
|
||||
RecoveryCallback<Message> recoveryCallback = new RecoveryCallback<>() {
|
||||
@Override
|
||||
public Message recover(RetryContext context) {
|
||||
try {
|
||||
|
||||
@@ -42,9 +42,9 @@ public class User extends org.apache.avro.specific.SpecificRecordBase
|
||||
|
||||
private static SpecificData MODEL$ = new SpecificData();
|
||||
|
||||
private static final BinaryMessageEncoder<User> ENCODER = new BinaryMessageEncoder<User>(MODEL$, SCHEMA$);
|
||||
private static final BinaryMessageEncoder<User> ENCODER = new BinaryMessageEncoder<>(MODEL$, SCHEMA$);
|
||||
|
||||
private static final BinaryMessageDecoder<User> DECODER = new BinaryMessageDecoder<User>(MODEL$, SCHEMA$);
|
||||
private static final BinaryMessageDecoder<User> DECODER = new BinaryMessageDecoder<>(MODEL$, SCHEMA$);
|
||||
|
||||
/**
|
||||
* Return the BinaryMessageEncoder instance used by this class.
|
||||
@@ -70,7 +70,7 @@ public class User extends org.apache.avro.specific.SpecificRecordBase
|
||||
* SchemaStore
|
||||
*/
|
||||
public static BinaryMessageDecoder<User> createDecoder(SchemaStore resolver) {
|
||||
return new BinaryMessageDecoder<User>(MODEL$, SCHEMA$, resolver);
|
||||
return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -47,7 +47,7 @@ public class CompositeKeyFooDao extends JdbcDaoSupport implements FooDao {
|
||||
Map<?, ?> keys = (Map<?, ?>) key;
|
||||
Object[] args = keys.values().toArray();
|
||||
|
||||
RowMapper<Foo> fooMapper = new RowMapper<Foo>() {
|
||||
RowMapper<Foo> fooMapper = new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -70,7 +70,7 @@ class JdbcBatchItemWriterClassicTests {
|
||||
};
|
||||
writer.setSql("SQL");
|
||||
writer.setJdbcTemplate(new NamedParameterJdbcTemplate(jdbcTemplate));
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<String>() {
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<>() {
|
||||
@Override
|
||||
public void setValues(String item, PreparedStatement ps) throws SQLException {
|
||||
list.add(item);
|
||||
@@ -128,7 +128,7 @@ class JdbcBatchItemWriterClassicTests {
|
||||
@Test
|
||||
void testWriteAndFlushWithFailure() throws Exception {
|
||||
final RuntimeException ex = new RuntimeException("bar");
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<String>() {
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<>() {
|
||||
@Override
|
||||
public void setValues(String item, PreparedStatement ps) throws SQLException {
|
||||
list.add(item);
|
||||
@@ -140,7 +140,7 @@ class JdbcBatchItemWriterClassicTests {
|
||||
Exception exception = assertThrows(RuntimeException.class, () -> writer.write(Chunk.of("foo")));
|
||||
assertEquals("bar", exception.getMessage());
|
||||
assertEquals(2, list.size());
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<String>() {
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<>() {
|
||||
@Override
|
||||
public void setValues(String item, PreparedStatement ps) throws SQLException {
|
||||
list.add(item);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -148,7 +148,7 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
|
||||
mapWriter.setSql(sql);
|
||||
mapWriter.setJdbcTemplate(namedParameterJdbcOperations);
|
||||
mapWriter.setItemSqlParameterSourceProvider(new ItemSqlParameterSourceProvider<Map<String, Object>>() {
|
||||
mapWriter.setItemSqlParameterSourceProvider(new ItemSqlParameterSourceProvider<>() {
|
||||
@Override
|
||||
public SqlParameterSource createSqlParameterSource(Map<String, Object> item) {
|
||||
return new MapSqlParameterSource(item);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
* Copyright 2009-2023 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.
|
||||
@@ -119,7 +119,7 @@ class JdbcPagingItemReaderAsyncTests {
|
||||
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<>(
|
||||
Executors.newFixedThreadPool(THREAD_COUNT));
|
||||
for (int i = 0; i < THREAD_COUNT; i++) {
|
||||
completionService.submit(new Callable<List<Foo>>() {
|
||||
completionService.submit(new Callable<>() {
|
||||
@Override
|
||||
public List<Foo> call() throws Exception {
|
||||
List<Foo> list = new ArrayList<>();
|
||||
@@ -162,7 +162,7 @@ class JdbcPagingItemReaderAsyncTests {
|
||||
sortKeys.put("ID", Order.ASCENDING);
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
reader.setQueryProvider(queryProvider);
|
||||
reader.setRowMapper(new RowMapper<Foo>() {
|
||||
reader.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@SpringJUnitConfig(
|
||||
@@ -49,7 +50,7 @@ class JdbcPagingItemReaderClassicParameterTests extends AbstractJdbcPagingItemRe
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
reader.setParameterValues(Collections.<String, Object>singletonMap("limit", 2));
|
||||
reader.setQueryProvider(queryProvider);
|
||||
reader.setRowMapper(new RowMapper<Foo>() {
|
||||
reader.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReaderTests {
|
||||
@@ -54,7 +55,7 @@ public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReade
|
||||
sortKeys.put("ID", Order.ASCENDING);
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
reader.setQueryProvider(queryProvider);
|
||||
reader.setRowMapper(new RowMapper<Foo>() {
|
||||
reader.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class JdbcPagingItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests {
|
||||
|
||||
@@ -45,7 +46,7 @@ public class JdbcPagingItemReaderIntegrationTests extends AbstractGenericDataSou
|
||||
sortKeys.put("ID", Order.ASCENDING);
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
inputSource.setQueryProvider(queryProvider);
|
||||
inputSource.setRowMapper(new RowMapper<Foo>() {
|
||||
inputSource.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@SpringJUnitConfig(
|
||||
locations = "/org/springframework/batch/item/database/JdbcPagingItemReaderParameterTests-context.xml")
|
||||
@@ -54,7 +55,7 @@ class JdbcPagingItemReaderNamedParameterTests extends AbstractJdbcPagingItemRead
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
reader.setParameterValues(Collections.<String, Object>singletonMap("limit", 2));
|
||||
reader.setQueryProvider(queryProvider);
|
||||
reader.setRowMapper(new RowMapper<Foo>() {
|
||||
reader.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class JdbcPagingItemReaderOrderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests {
|
||||
|
||||
@@ -46,7 +47,7 @@ public class JdbcPagingItemReaderOrderIntegrationTests extends AbstractGenericDa
|
||||
sortKeys.put("NAME", Order.DESCENDING);
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
inputSource.setQueryProvider(queryProvider);
|
||||
inputSource.setRowMapper(new RowMapper<Foo>() {
|
||||
inputSource.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -49,6 +49,7 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1
|
||||
*/
|
||||
@SpringJUnitConfig(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@@ -156,7 +157,7 @@ class JdbcPagingRestartIntegrationTests {
|
||||
sortKeys.put("VALUE", Order.ASCENDING);
|
||||
factory.setSortKeys(sortKeys);
|
||||
reader.setQueryProvider(factory.getObject());
|
||||
reader.setRowMapper(new RowMapper<Foo>() {
|
||||
reader.setRowMapper(new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
* Copyright 2009-2023 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.
|
||||
@@ -110,7 +110,7 @@ class JpaPagingItemReaderAsyncTests {
|
||||
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<>(
|
||||
Executors.newFixedThreadPool(THREAD_COUNT));
|
||||
for (int i = 0; i < THREAD_COUNT; i++) {
|
||||
completionService.submit(new Callable<List<Foo>>() {
|
||||
completionService.submit(new Callable<>() {
|
||||
@Override
|
||||
public List<Foo> call() throws Exception {
|
||||
List<Foo> list = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -27,7 +27,7 @@ public class SingleKeyFooDao extends JdbcDaoSupport implements FooDao {
|
||||
@Override
|
||||
public Foo getFoo(Object key) {
|
||||
|
||||
RowMapper<Foo> fooMapper = new RowMapper<Foo>() {
|
||||
RowMapper<Foo> fooMapper = new RowMapper<>() {
|
||||
@Override
|
||||
public Foo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -208,7 +208,7 @@ class JpaPagingItemReaderBuilderTests {
|
||||
Exception exception = assertThrows(IllegalArgumentException.class, builder::build);
|
||||
assertEquals("pageSize must be greater than zero", exception.getMessage());
|
||||
|
||||
builder = new JpaPagingItemReaderBuilder<Foo>();
|
||||
builder = new JpaPagingItemReaderBuilder<>();
|
||||
exception = assertThrows(IllegalArgumentException.class, builder::build);
|
||||
assertEquals("An EntityManagerFactory is required", exception.getMessage());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -34,7 +34,7 @@ public class FlatFileItemReaderCommonTests extends AbstractItemStreamItemReaderT
|
||||
FlatFileItemReader<Foo> tested = new FlatFileItemReader<>();
|
||||
Resource resource = new ByteArrayResource(FOOS.getBytes());
|
||||
tested.setResource(resource);
|
||||
tested.setLineMapper(new LineMapper<Foo>() {
|
||||
tested.setLineMapper(new LineMapper<>() {
|
||||
@Override
|
||||
public Foo mapLine(String line, int lineNumber) {
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -213,7 +213,7 @@ class FlatFileItemReaderTests {
|
||||
|
||||
@Test
|
||||
void testCustomCommentDetectionLogic() throws Exception {
|
||||
reader = new FlatFileItemReader<String>() {
|
||||
reader = new FlatFileItemReader<>() {
|
||||
@Override
|
||||
protected boolean isComment(String line) {
|
||||
return super.isComment(line) || line.endsWith("2");
|
||||
@@ -440,7 +440,7 @@ class FlatFileItemReaderTests {
|
||||
*/
|
||||
@Test
|
||||
void testMappingExceptionWrapping() throws Exception {
|
||||
LineMapper<String> exceptionLineMapper = new LineMapper<String>() {
|
||||
LineMapper<String> exceptionLineMapper = new LineMapper<>() {
|
||||
@Override
|
||||
public String mapLine(String line, int lineNumber) throws Exception {
|
||||
if (lineNumber == 2) {
|
||||
|
||||
@@ -244,7 +244,7 @@ class FlatFileItemWriterTests {
|
||||
*/
|
||||
@Test
|
||||
void testWriteWithConverter() throws Exception {
|
||||
writer.setLineAggregator(new LineAggregator<String>() {
|
||||
writer.setLineAggregator(new LineAggregator<>() {
|
||||
@Override
|
||||
public String aggregate(String item) {
|
||||
return "FOO:" + item;
|
||||
@@ -264,7 +264,7 @@ class FlatFileItemWriterTests {
|
||||
*/
|
||||
@Test
|
||||
void testWriteWithConverterAndString() throws Exception {
|
||||
writer.setLineAggregator(new LineAggregator<String>() {
|
||||
writer.setLineAggregator(new LineAggregator<>() {
|
||||
@Override
|
||||
public String aggregate(String item) {
|
||||
return "FOO:" + item;
|
||||
@@ -783,7 +783,7 @@ class FlatFileItemWriterTests {
|
||||
*/
|
||||
void testLineAggregatorFailure() throws Exception {
|
||||
|
||||
writer.setLineAggregator(new LineAggregator<String>() {
|
||||
writer.setLineAggregator(new LineAggregator<>() {
|
||||
|
||||
@Override
|
||||
public String aggregate(String item) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -32,7 +32,7 @@ class MultiResourceItemReaderFlatFileTests extends AbstractItemStreamItemReaderT
|
||||
MultiResourceItemReader<Foo> multiReader = new MultiResourceItemReader<>();
|
||||
FlatFileItemReader<Foo> fileReader = new FlatFileItemReader<>();
|
||||
|
||||
fileReader.setLineMapper(new LineMapper<Foo>() {
|
||||
fileReader.setLineMapper(new LineMapper<>() {
|
||||
|
||||
@Override
|
||||
public Foo mapLine(String line, int lineNumber) throws Exception {
|
||||
@@ -53,7 +53,7 @@ class MultiResourceItemReaderFlatFileTests extends AbstractItemStreamItemReaderT
|
||||
|
||||
multiReader.setResources(new Resource[] { r1, r2, r3, r4 });
|
||||
multiReader.setSaveState(true);
|
||||
multiReader.setComparator(new Comparator<Resource>() {
|
||||
multiReader.setComparator(new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Resource arg0, Resource arg1) {
|
||||
return 0; // preserve original ordering
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -68,7 +68,7 @@ class MultiResourceItemReaderIntegrationTests {
|
||||
itemReader.setLineMapper(new PassThroughLineMapper());
|
||||
|
||||
tested.setDelegate(itemReader);
|
||||
tested.setComparator(new Comparator<Resource>() {
|
||||
tested.setComparator(new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Resource o1, Resource o2) {
|
||||
return 0; // do not change ordering
|
||||
@@ -212,7 +212,7 @@ class MultiResourceItemReaderIntegrationTests {
|
||||
|
||||
Resource[] resources = new Resource[] { r1, r2, r3 };
|
||||
|
||||
Comparator<Resource> comp = new Comparator<Resource>() {
|
||||
Comparator<Resource> comp = new Comparator<>() {
|
||||
|
||||
/**
|
||||
* Reversed ordering by filename.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -58,7 +58,7 @@ class MultiResourceItemReaderResourceAwareTests {
|
||||
itemReader.setLineMapper(new FooLineMapper());
|
||||
|
||||
tested.setDelegate(itemReader);
|
||||
tested.setComparator(new Comparator<Resource>() {
|
||||
tested.setComparator(new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Resource o1, Resource o2) {
|
||||
return 0; // do not change ordering
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -81,7 +81,7 @@ class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReaderTests
|
||||
multiReader.setDelegate(reader);
|
||||
multiReader.setResources(new Resource[] { r1, r2, r3, r4 });
|
||||
multiReader.setSaveState(true);
|
||||
multiReader.setComparator(new Comparator<Resource>() {
|
||||
multiReader.setComparator(new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Resource arg0, Resource arg1) {
|
||||
return 0; // preserve original ordering
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -44,7 +44,7 @@ class BeanWrapperFieldSetMapperConcurrentTests {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(5);
|
||||
Collection<Future<Boolean>> results = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Future<Boolean> result = executorService.submit(new Callable<Boolean>() {
|
||||
Future<Boolean> result = executorService.submit(new Callable<>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
@@ -327,7 +327,7 @@ class BeanWrapperFieldSetMapperTests {
|
||||
void testAutoPopulateNestedList() throws Exception {
|
||||
TestNestedList nestedList = new TestNestedList();
|
||||
|
||||
BeanWrapperFieldSetMapper<?> mapper = new BeanWrapperFieldSetMapper<Object>() {
|
||||
BeanWrapperFieldSetMapper<?> mapper = new BeanWrapperFieldSetMapper<>() {
|
||||
@Override
|
||||
protected void initBinder(DataBinder binder) {
|
||||
// Use reflection so it compiles (and fails) with Spring 2.5
|
||||
@@ -492,7 +492,7 @@ class BeanWrapperFieldSetMapperTests {
|
||||
@Test
|
||||
void testFieldSpecificCustomEditor() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper<TestTwoDoubles> mapper = new BeanWrapperFieldSetMapper<TestTwoDoubles>() {
|
||||
BeanWrapperFieldSetMapper<TestTwoDoubles> mapper = new BeanWrapperFieldSetMapper<>() {
|
||||
@Override
|
||||
protected void initBinder(DataBinder binder) {
|
||||
binder.registerCustomEditor(Double.TYPE, "value",
|
||||
@@ -512,7 +512,7 @@ class BeanWrapperFieldSetMapperTests {
|
||||
@Test
|
||||
void testFieldSpecificCustomEditorWithRegistry() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper<TestTwoDoubles> mapper = new BeanWrapperFieldSetMapper<TestTwoDoubles>() {
|
||||
BeanWrapperFieldSetMapper<TestTwoDoubles> mapper = new BeanWrapperFieldSetMapper<>() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
super.registerCustomEditors(registry);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.lang.Nullable;
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
class PatternMatchingCompositeLineMapperTests {
|
||||
@@ -65,13 +66,13 @@ class PatternMatchingCompositeLineMapperTests {
|
||||
mapper.setTokenizers(tokenizers);
|
||||
|
||||
Map<String, FieldSetMapper<Name>> fieldSetMappers = new HashMap<>();
|
||||
fieldSetMappers.put("foo*", new FieldSetMapper<Name>() {
|
||||
fieldSetMappers.put("foo*", new FieldSetMapper<>() {
|
||||
@Override
|
||||
public Name mapFieldSet(FieldSet fs) {
|
||||
return new Name(fs.readString(0), fs.readString(1), 0);
|
||||
}
|
||||
});
|
||||
fieldSetMappers.put("bar*", new FieldSetMapper<Name>() {
|
||||
fieldSetMappers.put("bar*", new FieldSetMapper<>() {
|
||||
@Override
|
||||
public Name mapFieldSet(FieldSet fs) {
|
||||
return new Name(fs.readString(1), fs.readString(0), 0);
|
||||
@@ -101,7 +102,7 @@ class PatternMatchingCompositeLineMapperTests {
|
||||
mapper.setTokenizers(tokenizers);
|
||||
|
||||
Map<String, FieldSetMapper<Name>> fieldSetMappers = new HashMap<>();
|
||||
fieldSetMappers.put("foo*", new FieldSetMapper<Name>() {
|
||||
fieldSetMappers.put("foo*", new FieldSetMapper<>() {
|
||||
@Override
|
||||
public Name mapFieldSet(FieldSet fs) {
|
||||
return new Name(fs.readString(0), fs.readString(1), 0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -32,7 +32,7 @@ class FormatterLineAggregatorTests {
|
||||
// object under test
|
||||
private FormatterLineAggregator<String[]> aggregator;
|
||||
|
||||
private final FieldExtractor<String[]> defaultFieldExtractor = new FieldExtractor<String[]>() {
|
||||
private final FieldExtractor<String[]> defaultFieldExtractor = new FieldExtractor<>() {
|
||||
@Override
|
||||
public Object[] extract(String[] item) {
|
||||
return item;
|
||||
@@ -110,7 +110,7 @@ class FormatterLineAggregatorTests {
|
||||
aggregator.setMinimumLength(25);
|
||||
aggregator.setMaximumLength(25);
|
||||
|
||||
aggregator.setFieldExtractor(new FieldExtractor<String[]>() {
|
||||
aggregator.setFieldExtractor(new FieldExtractor<>() {
|
||||
private int[] widths = new int[] { 13, 12 };
|
||||
|
||||
@Override
|
||||
@@ -145,7 +145,7 @@ class FormatterLineAggregatorTests {
|
||||
aggregator.setMinimumLength(24);
|
||||
aggregator.setMaximumLength(24);
|
||||
|
||||
aggregator.setFieldExtractor(new FieldExtractor<String[]>() {
|
||||
aggregator.setFieldExtractor(new FieldExtractor<>() {
|
||||
private int[] widths = new int[] { 13, 11 };
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
class RecursiveCollectionItemTransformerTests {
|
||||
@@ -35,7 +36,7 @@ class RecursiveCollectionItemTransformerTests {
|
||||
|
||||
@Test
|
||||
void testSetDelegateAndPassInString() {
|
||||
aggregator.setDelegate(new LineAggregator<String>() {
|
||||
aggregator.setDelegate(new LineAggregator<>() {
|
||||
@Override
|
||||
public String aggregate(String item) {
|
||||
return "bar";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
* Copyright 2019-2023 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.
|
||||
@@ -108,7 +108,7 @@ class KafkaItemWriterTests {
|
||||
|
||||
@Test
|
||||
void testKafkaTemplateCanBeReferencedFromSubclass() {
|
||||
KafkaItemWriter<String, String> kafkaItemWriter = new KafkaItemWriter<String, String>() {
|
||||
KafkaItemWriter<String, String> kafkaItemWriter = new KafkaItemWriter<>() {
|
||||
@Override
|
||||
protected void writeKeyValue(String key, String value) {
|
||||
this.kafkaTemplate.sendDefault(key, value);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
* Copyright 2020-2023 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.
|
||||
@@ -43,7 +43,7 @@ public abstract class AbstractSynchronizedItemStreamWriterTests {
|
||||
|
||||
private SynchronizedItemStreamWriter<Object> synchronizedItemStreamWriter;
|
||||
|
||||
private final Chunk<Object> testList = new Chunk<Object>();
|
||||
private final Chunk<Object> testList = new Chunk<>();
|
||||
|
||||
private final ExecutionContext testExecutionContext = new ExecutionContext();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2014-2023 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.
|
||||
@@ -35,14 +35,14 @@ class ClassifierCompositeItemProcessorTests {
|
||||
void testBasicClassifierCompositeItemProcessor() throws Exception {
|
||||
ClassifierCompositeItemProcessor<String, String> processor = new ClassifierCompositeItemProcessor<>();
|
||||
|
||||
ItemProcessor<String, String> fooProcessor = new ItemProcessor<String, String>() {
|
||||
ItemProcessor<String, String> fooProcessor = new ItemProcessor<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
return "foo: " + item;
|
||||
}
|
||||
};
|
||||
ItemProcessor<String, String> defaultProcessor = new ItemProcessor<String, String>() {
|
||||
ItemProcessor<String, String> defaultProcessor = new ItemProcessor<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
@@ -68,21 +68,21 @@ class ClassifierCompositeItemProcessorTests {
|
||||
void testGenericsClassifierCompositeItemProcessor() throws Exception {
|
||||
ClassifierCompositeItemProcessor<Number, CharSequence> processor = new ClassifierCompositeItemProcessor<>();
|
||||
|
||||
ItemProcessor<Integer, String> intProcessor = new ItemProcessor<Integer, String>() {
|
||||
ItemProcessor<Integer, String> intProcessor = new ItemProcessor<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(Integer item) throws Exception {
|
||||
return "int: " + item;
|
||||
}
|
||||
};
|
||||
ItemProcessor<Long, StringBuffer> longProcessor = new ItemProcessor<Long, StringBuffer>() {
|
||||
ItemProcessor<Long, StringBuffer> longProcessor = new ItemProcessor<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public StringBuffer process(Long item) throws Exception {
|
||||
return new StringBuffer("long: " + item);
|
||||
}
|
||||
};
|
||||
ItemProcessor<Number, StringBuilder> defaultProcessor = new ItemProcessor<Number, StringBuilder>() {
|
||||
ItemProcessor<Number, StringBuilder> defaultProcessor = new ItemProcessor<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public StringBuilder process(Number item) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -45,13 +45,13 @@ class ClassifierCompositeItemWriterTests {
|
||||
@Test
|
||||
void testWrite() throws Exception {
|
||||
Map<String, ItemWriter<String>> map = new HashMap<>();
|
||||
ItemWriter<String> fooWriter = new ItemWriter<String>() {
|
||||
ItemWriter<String> fooWriter = new ItemWriter<>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> chunk) throws Exception {
|
||||
foos.addAll(chunk.getItems());
|
||||
}
|
||||
};
|
||||
ItemWriter<String> defaultWriter = new ItemWriter<String>() {
|
||||
ItemWriter<String> defaultWriter = new ItemWriter<>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> chunk) throws Exception {
|
||||
defaults.addAll(chunk.getItems());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2014-2023 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.
|
||||
@@ -38,6 +38,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
* </p>
|
||||
*
|
||||
* @author Chris Schaefer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 3.1
|
||||
*/
|
||||
class ScriptItemProcessorTests {
|
||||
@@ -214,7 +215,7 @@ class ScriptItemProcessorTests {
|
||||
void testBshScriptEvaluator() throws Exception {
|
||||
assumeTrue(languageExists("bsh"));
|
||||
|
||||
ScriptItemProcessor<String, Object> scriptItemProcessor = new ScriptItemProcessor<String, Object>();
|
||||
ScriptItemProcessor<String, Object> scriptItemProcessor = new ScriptItemProcessor<>();
|
||||
scriptItemProcessor.setScriptEvaluator(new BshScriptEvaluator());
|
||||
scriptItemProcessor.setScriptSource("String process(String item) { return item.toUpperCase(); } process(item);",
|
||||
"bsh");
|
||||
@@ -227,7 +228,7 @@ class ScriptItemProcessorTests {
|
||||
void testGroovyScriptEvaluator() throws Exception {
|
||||
assumeTrue(languageExists("groovy"));
|
||||
|
||||
ScriptItemProcessor<String, Object> scriptItemProcessor = new ScriptItemProcessor<String, Object>();
|
||||
ScriptItemProcessor<String, Object> scriptItemProcessor = new ScriptItemProcessor<>();
|
||||
scriptItemProcessor.setScriptEvaluator(new GroovyScriptEvaluator());
|
||||
scriptItemProcessor.setScriptSource("def process(item) { return item.toUpperCase() } \n process(item)",
|
||||
"groovy");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -43,13 +43,13 @@ class ClassifierCompositeItemWriterBuilderTests {
|
||||
@Test
|
||||
void testWrite() throws Exception {
|
||||
Map<String, ItemWriter<? super String>> map = new HashMap<>();
|
||||
ItemWriter<String> fooWriter = new ItemWriter<String>() {
|
||||
ItemWriter<String> fooWriter = new ItemWriter<>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> chunk) throws Exception {
|
||||
foos.addAll(chunk.getItems());
|
||||
}
|
||||
};
|
||||
ItemWriter<String> defaultWriter = new ItemWriter<String>() {
|
||||
ItemWriter<String> defaultWriter = new ItemWriter<>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> chunk) throws Exception {
|
||||
defaults.addAll(chunk.getItems());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -104,7 +104,7 @@ class StaxEventItemWriterBuilderTests {
|
||||
|
||||
staxEventItemWriter.afterPropertiesSet();
|
||||
staxEventItemWriter.open(executionContext);
|
||||
staxEventItemWriter.write(new Chunk<Foo>());
|
||||
staxEventItemWriter.write(new Chunk<>());
|
||||
staxEventItemWriter.update(executionContext);
|
||||
staxEventItemWriter.close();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -74,7 +74,7 @@ class ExternalRetryInBatchTests {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "T_BARS");
|
||||
jmsTemplate.convertAndSend("queue", "foo");
|
||||
jmsTemplate.convertAndSend("queue", "bar");
|
||||
provider = new ItemReader<String>() {
|
||||
provider = new ItemReader<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() {
|
||||
@@ -130,7 +130,7 @@ class ExternalRetryInBatchTests {
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
|
||||
RetryCallback<String, Exception> callback = new RetryCallback<>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
// No need for transaction here: the whole
|
||||
@@ -145,7 +145,7 @@ class ExternalRetryInBatchTests {
|
||||
}
|
||||
};
|
||||
|
||||
RecoveryCallback<String> recoveryCallback = new RecoveryCallback<String>() {
|
||||
RecoveryCallback<String> recoveryCallback = new RecoveryCallback<>() {
|
||||
@Override
|
||||
public String recover(RetryContext context) {
|
||||
// aggressive commit on a recovery
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -38,7 +38,7 @@ class DirectPollerTests {
|
||||
@Test
|
||||
void testSimpleSingleThreaded() throws Exception {
|
||||
|
||||
Callable<String> callback = new Callable<String>() {
|
||||
Callable<String> callback = new Callable<>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
@@ -63,7 +63,7 @@ class DirectPollerTests {
|
||||
@Test
|
||||
void testTimeUnit() throws Exception {
|
||||
|
||||
Callable<String> callback = new Callable<String>() {
|
||||
Callable<String> callback = new Callable<>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
@@ -88,7 +88,7 @@ class DirectPollerTests {
|
||||
@Test
|
||||
void testWithError() {
|
||||
|
||||
Callable<String> callback = new Callable<String>() {
|
||||
Callable<String> callback = new Callable<>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -74,7 +74,7 @@ class LogOrRethrowExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void testNotRethrownErrorLevel() throws Throwable {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<Throwable, Level>(Level.RETHROW) {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<>(Level.RETHROW) {
|
||||
@Override
|
||||
public Level classify(Throwable throwable) {
|
||||
return Level.ERROR;
|
||||
@@ -87,7 +87,7 @@ class LogOrRethrowExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void testNotRethrownWarnLevel() throws Throwable {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<Throwable, Level>(Level.RETHROW) {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<>(Level.RETHROW) {
|
||||
@Override
|
||||
public Level classify(Throwable throwable) {
|
||||
return Level.WARN;
|
||||
@@ -100,7 +100,7 @@ class LogOrRethrowExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void testNotRethrownDebugLevel() throws Throwable {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<Throwable, Level>(Level.RETHROW) {
|
||||
handler.setExceptionClassifier(new ClassifierSupport<>(Level.RETHROW) {
|
||||
@Override
|
||||
public Level classify(Throwable throwable) {
|
||||
return Level.DEBUG;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
class SimpleLimitExceptionHandlerTests {
|
||||
|
||||
@@ -156,7 +157,7 @@ class SimpleLimitExceptionHandlerTests {
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
List<Throwable> throwables = new ArrayList<Throwable>() {
|
||||
List<Throwable> throwables = new ArrayList<>() {
|
||||
{
|
||||
for (int i = 0; i < (EXCEPTION_LIMIT); i++) {
|
||||
add(new RuntimeException("below exception limit"));
|
||||
@@ -184,7 +185,7 @@ class SimpleLimitExceptionHandlerTests {
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
List<Throwable> throwables = new ArrayList<Throwable>() {
|
||||
List<Throwable> throwables = new ArrayList<>() {
|
||||
{
|
||||
for (int i = 0; i < (EXCEPTION_LIMIT); i++) {
|
||||
add(new RuntimeException("below exception limit"));
|
||||
|
||||
@@ -97,7 +97,7 @@ class AsynchronousTests {
|
||||
|
||||
assertInitialState();
|
||||
|
||||
container.setMessageListener(new SessionAwareMessageListener<Message>() {
|
||||
container.setMessageListener(new SessionAwareMessageListener<>() {
|
||||
@Override
|
||||
public void onMessage(Message message, Session session) throws JMSException {
|
||||
list.add(message.toString());
|
||||
@@ -133,7 +133,7 @@ class AsynchronousTests {
|
||||
// Prevent us from being overwhelmed after rollback
|
||||
container.setRecoveryInterval(500);
|
||||
|
||||
container.setMessageListener(new SessionAwareMessageListener<Message>() {
|
||||
container.setMessageListener(new SessionAwareMessageListener<>() {
|
||||
@Override
|
||||
public void onMessage(Message message, Session session) throws JMSException {
|
||||
list.add(message.toString());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -153,7 +153,7 @@ class ChunkedRepeatTests extends AbstractTradeBatchTests {
|
||||
|
||||
while (!chunker.ready()) {
|
||||
|
||||
ItemReader<Trade> truncated = new ItemReader<Trade>() {
|
||||
ItemReader<Trade> truncated = new ItemReader<>() {
|
||||
int count = 0;
|
||||
|
||||
@Nullable
|
||||
@@ -165,7 +165,7 @@ class ChunkedRepeatTests extends AbstractTradeBatchTests {
|
||||
}
|
||||
};
|
||||
chunker.reset();
|
||||
template.iterate(new ItemReaderRepeatCallback<Trade>(truncated, processor) {
|
||||
template.iterate(new ItemReaderRepeatCallback<>(truncated, processor) {
|
||||
|
||||
@Override
|
||||
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -191,7 +191,7 @@ class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
|
||||
@Test
|
||||
void testEarlyCompletionWithContext() {
|
||||
|
||||
RepeatStatus result = template.iterate(new ItemReaderRepeatCallback<Trade>(provider, processor) {
|
||||
RepeatStatus result = template.iterate(new ItemReaderRepeatCallback<>(provider, processor) {
|
||||
|
||||
@Override
|
||||
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
|
||||
@@ -219,7 +219,7 @@ class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
|
||||
@Test
|
||||
void testEarlyCompletionWithContextTerminated() {
|
||||
|
||||
RepeatStatus result = template.iterate(new ItemReaderRepeatCallback<Trade>(provider, processor) {
|
||||
RepeatStatus result = template.iterate(new ItemReaderRepeatCallback<>(provider, processor) {
|
||||
|
||||
@Override
|
||||
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
|
||||
|
||||
@@ -223,7 +223,7 @@ class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBatchTest
|
||||
final String threadName = Thread.currentThread().getName();
|
||||
final Set<String> threadNames = new HashSet<>();
|
||||
|
||||
final RepeatCallback stepCallback = new ItemReaderRepeatCallback<Trade>(provider, processor) {
|
||||
final RepeatCallback stepCallback = new ItemReaderRepeatCallback<>(provider, processor) {
|
||||
@Override
|
||||
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
|
||||
assertNotSame(threadName, Thread.currentThread().getName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -65,7 +65,7 @@ class ExternalRetryTests {
|
||||
getMessages(); // drain queue
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "T_BARS");
|
||||
jmsTemplate.convertAndSend("queue", "foo");
|
||||
provider = new ItemReader<String>() {
|
||||
provider = new ItemReader<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() {
|
||||
@@ -95,7 +95,7 @@ class ExternalRetryTests {
|
||||
|
||||
assertInitialState();
|
||||
|
||||
final ItemWriter<Object> writer = new ItemWriter<Object>() {
|
||||
final ItemWriter<Object> writer = new ItemWriter<>() {
|
||||
@Override
|
||||
public void write(final Chunk<?> texts) {
|
||||
|
||||
@@ -130,12 +130,12 @@ class ExternalRetryTests {
|
||||
// Client of retry template has to take care of rollback. This would
|
||||
// be a message listener container in the MDP case.
|
||||
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback<Object>() {
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
final String item = provider.read();
|
||||
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
|
||||
RetryCallback<Object, Exception> callback = new RetryCallback<>() {
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
writer.write(Chunk.of(item));
|
||||
@@ -169,7 +169,7 @@ class ExternalRetryTests {
|
||||
assertInitialState();
|
||||
|
||||
final String item = provider.read();
|
||||
final RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
|
||||
final RetryCallback<String, Exception> callback = new RetryCallback<>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item);
|
||||
@@ -177,7 +177,7 @@ class ExternalRetryTests {
|
||||
}
|
||||
};
|
||||
|
||||
final RecoveryCallback<String> recoveryCallback = new RecoveryCallback<String>() {
|
||||
final RecoveryCallback<String> recoveryCallback = new RecoveryCallback<>() {
|
||||
@Override
|
||||
public String recover(RetryContext context) {
|
||||
recovered.add(item);
|
||||
@@ -189,7 +189,7 @@ class ExternalRetryTests {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
try {
|
||||
result = new TransactionTemplate(transactionManager).execute(new TransactionCallback<String>() {
|
||||
result = new TransactionTemplate(transactionManager).execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public String doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -115,7 +115,7 @@ public class SynchronousTests {
|
||||
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_NESTED);
|
||||
return transactionTemplate.execute(new TransactionCallback<String>() {
|
||||
return transactionTemplate.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public String doInTransaction(TransactionStatus status) {
|
||||
|
||||
@@ -169,7 +169,7 @@ public class SynchronousTests {
|
||||
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_NESTED);
|
||||
return transactionTemplate.execute(new TransactionCallback<String>() {
|
||||
return transactionTemplate.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public String doInTransaction(TransactionStatus status) {
|
||||
|
||||
@@ -234,7 +234,7 @@ public class SynchronousTests {
|
||||
|
||||
TransactionTemplate nestedTxTemplate = new TransactionTemplate(transactionManager);
|
||||
nestedTxTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_NESTED);
|
||||
return nestedTxTemplate.execute(new TransactionCallback<String>() {
|
||||
return nestedTxTemplate.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public String doInTransaction(TransactionStatus nestedStatus) {
|
||||
|
||||
@@ -294,7 +294,7 @@ public class SynchronousTests {
|
||||
// use REQUIRES_NEW so that the retry executes in its own transaction
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
|
||||
return transactionTemplate.execute(new TransactionCallback<String>() {
|
||||
return transactionTemplate.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public String doInTransaction(TransactionStatus status) {
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class ConcurrentTransactionAwareProxyTests {
|
||||
@Test
|
||||
void testTransactionalContains() {
|
||||
final Map<Long, Map<String, String>> map = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap();
|
||||
boolean result = new TransactionTemplate(transactionManager).execute(new TransactionCallback<Boolean>() {
|
||||
boolean result = new TransactionTemplate(transactionManager).execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public Boolean doInTransaction(TransactionStatus status) {
|
||||
return map.containsKey("foo");
|
||||
@@ -124,7 +124,7 @@ class ConcurrentTransactionAwareProxyTests {
|
||||
for (int i = 0; i < outerMax; i++) {
|
||||
|
||||
final int count = i;
|
||||
completionService.submit(new Callable<List<String>>() {
|
||||
completionService.submit(new Callable<>() {
|
||||
@Override
|
||||
public List<String> call() throws Exception {
|
||||
List<String> list = new ArrayList<>();
|
||||
@@ -152,7 +152,7 @@ class ConcurrentTransactionAwareProxyTests {
|
||||
|
||||
for (int i = 0; i < outerMax; i++) {
|
||||
|
||||
completionService.submit(new Callable<List<String>>() {
|
||||
completionService.submit(new Callable<>() {
|
||||
@Override
|
||||
public List<String> call() throws Exception {
|
||||
List<String> result = new ArrayList<>();
|
||||
@@ -192,7 +192,7 @@ class ConcurrentTransactionAwareProxyTests {
|
||||
for (int j = 0; j < numberOfKeys; j++) {
|
||||
final long id = j * 1000 + 123L + i;
|
||||
|
||||
completionService.submit(new Callable<List<String>>() {
|
||||
completionService.submit(new Callable<>() {
|
||||
@Override
|
||||
public List<String> call() throws Exception {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user