Replace explicit type with diamond operator in infrastructure tests module

This commit is contained in:
Drummond Dawson
2018-10-09 19:47:49 -04:00
committed by Mahmoud Ben Hassine
parent 424514a17b
commit eb9e0d1466
17 changed files with 47 additions and 47 deletions

View File

@@ -55,7 +55,7 @@ public class MessagingTests {
private List<String> getMessages() {
String next = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (next != null) {
next = (String) jmsTemplate.receiveAndConvert("queue");
if (next != null)

View File

@@ -62,9 +62,9 @@ public class BatchMessageListenerContainerIntegrationTests {
@Autowired
private BatchMessageListenerContainer container;
private volatile BlockingQueue<String> recovered = new LinkedBlockingQueue<String>();
private volatile BlockingQueue<String> recovered = new LinkedBlockingQueue<>();
private volatile BlockingQueue<String> processed = new LinkedBlockingQueue<String>();
private volatile BlockingQueue<String> processed = new LinkedBlockingQueue<>();
@After
@Before
@@ -103,7 +103,7 @@ public class BatchMessageListenerContainerIntegrationTests {
container.start();
jmsTemplate.convertAndSend("queue", "foo");
jmsTemplate.convertAndSend("queue", "bar");
SortedSet<String> result = new TreeSet<String>();
SortedSet<String> result = new TreeSet<>();
for (int i = 0; i < 2; i++) {
result.add(processed.poll(5, TimeUnit.SECONDS));
}

View File

@@ -101,7 +101,7 @@ public class JdbcPagingItemReaderAsyncTests {
@Test
public void testAsyncReader() throws Throwable {
List<Throwable> throwables = new ArrayList<Throwable>();
List<Throwable> throwables = new ArrayList<>();
int max = 10;
for (int i = 0; i < max; i++) {
try {
@@ -124,13 +124,13 @@ public class JdbcPagingItemReaderAsyncTests {
*/
private void doTest() throws Exception, InterruptedException, ExecutionException {
final ItemReader<Foo> reader = getItemReader();
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<List<Foo>>(Executors
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<>(Executors
.newFixedThreadPool(THREAD_COUNT));
for (int i = 0; i < THREAD_COUNT; i++) {
completionService.submit(new Callable<List<Foo>>() {
@Override
public List<Foo> call() throws Exception {
List<Foo> list = new ArrayList<Foo>();
List<Foo> list = new ArrayList<>();
Foo next = null;
do {
next = reader.read();
@@ -145,7 +145,7 @@ public class JdbcPagingItemReaderAsyncTests {
});
}
int count = 0;
Set<Foo> results = new HashSet<Foo>();
Set<Foo> results = new HashSet<>();
for (int i = 0; i < THREAD_COUNT; i++) {
List<Foo> items = completionService.take().get();
count += items.size();
@@ -160,13 +160,13 @@ public class JdbcPagingItemReaderAsyncTests {
protected ItemReader<Foo> getItemReader() throws Exception {
JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<Foo>();
JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<>();
reader.setDataSource(dataSource);
SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
factory.setDataSource(dataSource);
factory.setSelectClause("select ID, NAME, VALUE");
factory.setFromClause("from T_FOOS");
Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
Map<String, Order> sortKeys = new LinkedHashMap<>();
sortKeys.put("VALUE", Order.ASCENDING);
factory.setSortKeys(sortKeys);
reader.setQueryProvider(factory.getObject());

View File

@@ -125,7 +125,7 @@ public class JdbcPagingQueryIntegrationTests {
@Test
public void testQueryFromStartWithGroupBy() throws Exception {
AbstractSqlPagingQueryProvider queryProvider = (AbstractSqlPagingQueryProvider) getPagingQueryProvider();
Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
Map<String, Order> sortKeys = new LinkedHashMap<>();
sortKeys.put("NAME", Order.ASCENDING);
sortKeys.put("CODE", Order.DESCENDING);
queryProvider.setSortKeys(sortKeys);
@@ -162,7 +162,7 @@ public class JdbcPagingQueryIntegrationTests {
private Map<String, Object> getStartAfterValues(
PagingQueryProvider queryProvider, List<Map<String, Object>> list) {
Map<String, Object> startAfterValues = new LinkedHashMap<String, Object>();
Map<String, Object> startAfterValues = new LinkedHashMap<>();
for (Map.Entry<String, Order> sortKey : queryProvider.getSortKeys().entrySet()) {
startAfterValues.put(sortKey.getKey(), list.get(list.size() - 1).get(sortKey.getKey()));
}
@@ -196,7 +196,7 @@ public class JdbcPagingQueryIntegrationTests {
factory.setDataSource(dataSource);
factory.setSelectClause("select ID, NAME, VALUE");
factory.setFromClause("from T_FOOS");
Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
Map<String, Order> sortKeys = new LinkedHashMap<>();
sortKeys.put("VALUE", Order.ASCENDING);
factory.setSortKeys(sortKeys);
return factory.getObject();
@@ -204,14 +204,14 @@ public class JdbcPagingQueryIntegrationTests {
}
private List<Object> getParameterList(Map<String, Object> values, Map<String, Object> sortKeyValue) {
SortedMap<String, Object> sm = new TreeMap<String, Object>();
SortedMap<String, Object> sm = new TreeMap<>();
if (values != null) {
sm.putAll(values);
}
List<Object> parameterList = new ArrayList<Object>();
List<Object> parameterList = new ArrayList<>();
parameterList.addAll(sm.values());
if (sortKeyValue != null && sortKeyValue.size() > 0) {
List<Map.Entry<String, Object>> keys = new ArrayList<Map.Entry<String,Object>>(sortKeyValue.entrySet());
List<Map.Entry<String, Object>> keys = new ArrayList<>(sortKeyValue.entrySet());
for(int i = 0; i < keys.size(); i++) {
for(int j = 0; j < i; j++) {

View File

@@ -131,7 +131,7 @@ public class JdbcPagingRestartIntegrationTests {
logger.debug("Ids: "+ids);
int startAfterValue = (new Long(ids.get(count - 1).get("ID").toString())).intValue();
logger.debug("Start after: " + startAfterValue);
Map<String, Object> startAfterValues = new LinkedHashMap<String, Object>();
Map<String, Object> startAfterValues = new LinkedHashMap<>();
startAfterValues.put("ID", startAfterValue);
executionContext.put("JdbcPagingItemReader.start.after", startAfterValues);
((ItemStream) reader).open(executionContext);
@@ -150,13 +150,13 @@ public class JdbcPagingRestartIntegrationTests {
protected ItemReader<Foo> getItemReader() throws Exception {
JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<Foo>();
JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<>();
reader.setDataSource(dataSource);
SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
factory.setDataSource(dataSource);
factory.setSelectClause("select ID, NAME, VALUE");
factory.setFromClause("from T_FOOS");
Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
Map<String, Order> sortKeys = new LinkedHashMap<>();
sortKeys.put("VALUE", Order.ASCENDING);
factory.setSortKeys(sortKeys);
reader.setQueryProvider(factory.getObject());

View File

@@ -89,7 +89,7 @@ public class JpaPagingItemReaderAsyncTests {
@Test
public void testAsyncReader() throws Throwable {
List<Throwable> throwables = new ArrayList<Throwable>();
List<Throwable> throwables = new ArrayList<>();
int max = 10;
for (int i = 0; i < max; i++) {
try {
@@ -112,13 +112,13 @@ public class JpaPagingItemReaderAsyncTests {
*/
private void doTest() throws Exception, InterruptedException, ExecutionException {
final JpaPagingItemReader<Foo> reader = getItemReader();
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<List<Foo>>(Executors
CompletionService<List<Foo>> completionService = new ExecutorCompletionService<>(Executors
.newFixedThreadPool(THREAD_COUNT));
for (int i = 0; i < THREAD_COUNT; i++) {
completionService.submit(new Callable<List<Foo>>() {
@Override
public List<Foo> call() throws Exception {
List<Foo> list = new ArrayList<Foo>();
List<Foo> list = new ArrayList<>();
Foo next = null;
do {
next = reader.read();
@@ -133,7 +133,7 @@ public class JpaPagingItemReaderAsyncTests {
});
}
int count = 0;
Set<Foo> results = new HashSet<Foo>();
Set<Foo> results = new HashSet<>();
for (int i = 0; i < THREAD_COUNT; i++) {
List<Foo> items = completionService.take().get();
count += items.size();
@@ -151,7 +151,7 @@ public class JpaPagingItemReaderAsyncTests {
String jpqlQuery = "select f from Foo f";
JpaPagingItemReader<Foo> reader = new JpaPagingItemReader<Foo>();
JpaPagingItemReader<Foo> reader = new JpaPagingItemReader<>();
reader.setQueryString(jpqlQuery);
reader.setEntityManagerFactory(entityManagerFactory);
reader.setPageSize(PAGE_SIZE);

View File

@@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils;
public abstract class AbstractStaxEventReaderItemReaderTests {
protected StaxEventItemReader<Trade> reader = new StaxEventItemReader<Trade>();
protected StaxEventItemReader<Trade> reader = new StaxEventItemReader<>();
@Before
public void setUp() throws Exception {
@@ -46,7 +46,7 @@ public abstract class AbstractStaxEventReaderItemReaderTests {
reader.setResource(new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "input.xml")));
reader.open(new ExecutionContext());
Trade result;
List<Trade> results = new ArrayList<Trade>();
List<Trade> results = new ArrayList<>();
while ((result = reader.read()) != null) {
results.add(result);
}
@@ -59,7 +59,7 @@ public abstract class AbstractStaxEventReaderItemReaderTests {
.addResourcePathToPackagePath(getClass(), "input-nested.xml")));
reader.open(new ExecutionContext());
Trade result;
List<Trade> results = new ArrayList<Trade>();
List<Trade> results = new ArrayList<>();
while ((result = reader.read()) != null) {
results.add(result);
}

View File

@@ -49,7 +49,7 @@ public abstract class AbstractStaxEventWriterItemWriterTests {
private static final int MAX_WRITE = 100;
protected StaxEventItemWriter<Trade> writer = new StaxEventItemWriter<Trade>();
protected StaxEventItemWriter<Trade> writer = new StaxEventItemWriter<>();
private Resource resource;

View File

@@ -53,7 +53,7 @@ public class Jaxb2NamespaceMarshallingTests {
private static final int MAX_WRITE = 100;
private StaxEventItemWriter<QualifiedTrade> writer = new StaxEventItemWriter<QualifiedTrade>();
private StaxEventItemWriter<QualifiedTrade> writer = new StaxEventItemWriter<>();
private Resource resource;

View File

@@ -39,7 +39,7 @@ import org.springframework.util.ClassUtils;
public class Jaxb2NamespaceUnmarshallingTests {
private StaxEventItemReader<QualifiedTrade> reader = new StaxEventItemReader<QualifiedTrade>();
private StaxEventItemReader<QualifiedTrade> reader = new StaxEventItemReader<>();
private Resource resource = new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(),
"domain/trades.xml"));
@@ -66,7 +66,7 @@ public class Jaxb2NamespaceUnmarshallingTests {
@Test
public void testRead() throws Exception {
QualifiedTrade result;
List<QualifiedTrade> results = new ArrayList<QualifiedTrade>();
List<QualifiedTrade> results = new ArrayList<>();
while ((result = reader.read()) != null) {
results.add(result);
}

View File

@@ -28,7 +28,7 @@ public class XStreamUnmarshallingTests extends AbstractStaxEventReaderItemReader
@Override
protected Unmarshaller getUnmarshaller() throws Exception {
XStreamMarshaller unmarshaller = new XStreamMarshaller();
Map<String,Class<?>> aliasesMap = new HashMap<String,Class<?>>();
Map<String,Class<?>> aliasesMap = new HashMap<>();
aliasesMap.put("trade", Trade.class);
aliasesMap.put("isin", String.class);
aliasesMap.put("customer", String.class);

View File

@@ -102,9 +102,9 @@ public class ExternalRetryInBatchTests {
assertEquals(0, count);
}
private List<String> list = new ArrayList<String>();
private List<String> list = new ArrayList<>();
private List<String> recovered = new ArrayList<String>();
private List<String> recovered = new ArrayList<>();
@Test
public void testExternalRetryRecoveryInBatch() throws Exception {
@@ -204,7 +204,7 @@ public class ExternalRetryInBatchTests {
private List<String> getMessages() {
String next = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (next != null) {
next = (String) jmsTemplate.receiveAndConvert("queue");
if (next != null)

View File

@@ -99,7 +99,7 @@ public class AsynchronousTests {
}
}
private volatile List<String> list = new ArrayList<String>();
private volatile List<String> list = new ArrayList<>();
private void assertInitialState() {
int count = jdbcTemplate.queryForObject("select count(*) from T_BARS", Integer.class);
@@ -175,7 +175,7 @@ public class AsynchronousTests {
assertTrue(list.size() >= 1);
String text = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (text != null) {
text = (String) jmsTemplate.receiveAndConvert("queue");
msgs.add(text);

View File

@@ -69,7 +69,7 @@ public class SynchronousTests implements ApplicationContextAware {
private ApplicationContext applicationContext;
private List<String> list = new ArrayList<String>();
private List<String> list = new ArrayList<>();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -152,7 +152,7 @@ public class SynchronousTests implements ApplicationContextAware {
});
String text = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (text != null) {
text = (String) jmsTemplate.receiveAndConvert("queue");
msgs.add(text);
@@ -219,7 +219,7 @@ public class SynchronousTests implements ApplicationContextAware {
});
String text = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (text != null) {
text = (String) txJmsTemplate.receiveAndConvert("queue");
msgs.add(text);

View File

@@ -82,7 +82,7 @@ public class TaskExecutorRepeatTemplateBulkAsynchronousTests {
template.setTaskExecutor(taskExecutor);
template.setThrottleLimit(throttleLimit);
items = Collections.synchronizedList(new ArrayList<String>());
items = Collections.synchronizedList(new ArrayList<>());
callback = new RepeatCallback() {

View File

@@ -86,9 +86,9 @@ public class ExternalRetryTests {
assertEquals(0, count);
}
private List<String> list = new ArrayList<String>();
private List<String> list = new ArrayList<>();
private List<Object> recovered = new ArrayList<Object>();
private List<Object> recovered = new ArrayList<>();
/*
* Message processing is successful on the second attempt but must receive
@@ -248,7 +248,7 @@ public class ExternalRetryTests {
private List<String> getMessages() {
String next = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (next != null) {
next = (String) jmsTemplate.receiveAndConvert("queue");
if (next != null)

View File

@@ -101,7 +101,7 @@ public class SynchronousTests {
assertEquals(0, count);
}
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
/*
* Message processing is successful on the second attempt without having to
@@ -168,7 +168,7 @@ public class SynchronousTests {
assertInitialState();
JmsItemReader<Object> provider = new JmsItemReader<Object>();
JmsItemReader<Object> provider = new JmsItemReader<>();
// provider.setItemType(Message.class);
jmsTemplate.setDefaultDestinationName("queue");
provider.setJmsTemplate(jmsTemplate);
@@ -396,7 +396,7 @@ public class SynchronousTests {
private List<String> getMessages() {
String next = "";
List<String> msgs = new ArrayList<String>();
List<String> msgs = new ArrayList<>();
while (next != null) {
next = (String) jmsTemplate.receiveAndConvert("queue");
if (next != null)