IN PROGRESS - BATCH-709: Change all collections to use generics
This commit is contained in:
@@ -17,7 +17,7 @@ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExi
|
||||
|
||||
public static final String ELSE_KEY = "else";
|
||||
|
||||
private Map<Integer, ExitStatus> mappings;
|
||||
private Map<Object, ExitStatus> mappings;
|
||||
|
||||
public ExitStatus getExitStatus(int exitCode) {
|
||||
ExitStatus exitStatus = (ExitStatus) mappings.get(new Integer(exitCode));
|
||||
@@ -32,7 +32,7 @@ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExi
|
||||
* @param mappings <code>Integer</code> exit code keys to
|
||||
* {@link org.springframework.batch.repeat.ExitStatus} values.
|
||||
*/
|
||||
public void setMappings(Map<Integer, ExitStatus> mappings) {
|
||||
public void setMappings(Map<Object, ExitStatus> mappings) {
|
||||
Assert.notNull(mappings.get(ELSE_KEY));
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
|
||||
protected static final String ID_COLUMN = "ID";
|
||||
|
||||
private List creditsBeforeUpdate;
|
||||
private List<BigDecimal> creditsBeforeUpdate;
|
||||
|
||||
/**
|
||||
* @param jdbcTemplate
|
||||
@@ -62,10 +62,11 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
/**
|
||||
* All customers have the same credit
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void validatePreConditions() throws Exception {
|
||||
super.validatePreConditions();
|
||||
ensureState();
|
||||
creditsBeforeUpdate = (List) new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
creditsBeforeUpdate = (List<BigDecimal>) new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
|
||||
return jdbcTemplate.query(ALL_CUSTOMERS, new RowMapper() {
|
||||
@@ -100,7 +101,7 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
*/
|
||||
protected void validatePostConditions() throws Exception {
|
||||
|
||||
final List matches = new ArrayList();
|
||||
final List<BigDecimal> matches = new ArrayList<BigDecimal>();
|
||||
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
@@ -130,7 +131,7 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
/**
|
||||
* @param matches
|
||||
*/
|
||||
protected void checkMatches(List matches) {
|
||||
protected void checkMatches(List<BigDecimal> matches) {
|
||||
// no-op...
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -47,7 +46,7 @@ public class CompositeItemWriterSampleFunctionalTests extends AbstractValidating
|
||||
}
|
||||
|
||||
private void checkOutputTable() {
|
||||
final List trades = new ArrayList() {{
|
||||
final List<Trade> trades = new ArrayList<Trade>() {{
|
||||
add(new Trade("UK21341EAH41", 211, new BigDecimal("31.11"), "customer1"));
|
||||
add(new Trade("UK21341EAH42", 212, new BigDecimal("32.11"), "customer2"));
|
||||
add(new Trade("UK21341EAH43", 213, new BigDecimal("33.11"), "customer3"));
|
||||
@@ -72,13 +71,13 @@ public class CompositeItemWriterSampleFunctionalTests extends AbstractValidating
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void checkOutputFile() throws FileNotFoundException, IOException {
|
||||
List outputLines = IOUtils.readLines(
|
||||
List<String> outputLines = IOUtils.readLines(
|
||||
new FileInputStream("target/test-outputs/20070122.testStream.ParallelCustomerReportStep.TEMP.txt"));
|
||||
|
||||
String output = "";
|
||||
for (Iterator iterator = outputLines.listIterator(); iterator.hasNext();) {
|
||||
String line = (String) iterator.next();
|
||||
for (String line : outputLines) {
|
||||
output += line;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HibernateFailureJobFunctionalTests extends
|
||||
*
|
||||
* @see org.springframework.batch.sample.AbstractCustomerCreditIncreaseTests#checkMatches(java.util.List)
|
||||
*/
|
||||
protected void checkMatches(List matches) {
|
||||
protected void checkMatches(List<BigDecimal> matches) {
|
||||
assertFalse(matches.contains(new BigDecimal(2)));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
|
||||
private static final String GET_TRADES = "select ISIN, QUANTITY, PRICE, CUSTOMER from TRADE order by ISIN";
|
||||
private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME";
|
||||
|
||||
private List customers;
|
||||
private List trades;
|
||||
private List<Customer> customers;
|
||||
private List<Trade> trades;
|
||||
private int activeRow = 0;
|
||||
|
||||
private JdbcOperations jdbcTemplate;
|
||||
private Map credits = new HashMap();
|
||||
private Map<String, Double> credits = new HashMap<String, Double>();
|
||||
|
||||
/**
|
||||
* @param jdbcTemplate the jdbcTemplate to set
|
||||
@@ -55,13 +55,14 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.test.AbstractSingleSpringContextTests#onSetUp()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
jdbcTemplate.update("delete from TRADE");
|
||||
List list = jdbcTemplate.queryForList("select name, CREDIT from customer");
|
||||
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
|
||||
Map map = (Map) iterator.next();
|
||||
credits.put(map.get("NAME"), new Double(((Number)map.get("CREDIT")).doubleValue()));
|
||||
List<Map<?, ?>> list = jdbcTemplate.queryForList("select name, CREDIT from customer");
|
||||
for (Iterator<Map<?,?>> iterator = list.iterator(); iterator.hasNext();) {
|
||||
Map<?,?> map = iterator.next();
|
||||
credits.put((String) map.get("NAME"), new Double(((Number)map.get("CREDIT")).doubleValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,12 +74,12 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
|
||||
|
||||
// assertTrue(((Resource)applicationContext.getBean("customerFileLocator")).exists());
|
||||
|
||||
customers = new ArrayList() {{add(new Customer("customer1", (((Double)credits.get("customer1")).doubleValue() - 98.34)));
|
||||
add(new Customer("customer2", (((Double)credits.get("customer2")).doubleValue() - 18.12 - 12.78)));
|
||||
add(new Customer("customer3", (((Double)credits.get("customer3")).doubleValue() - 109.25)));
|
||||
add(new Customer("customer4", (((Double)credits.get("customer4")).doubleValue() - 123.39)));}};
|
||||
customers = new ArrayList<Customer>() {{add(new Customer("customer1", (credits.get("customer1").doubleValue() - 98.34)));
|
||||
add(new Customer("customer2", (credits.get("customer2").doubleValue() - 18.12 - 12.78)));
|
||||
add(new Customer("customer3", (credits.get("customer3").doubleValue() - 109.25)));
|
||||
add(new Customer("customer4", (credits.get("customer4").doubleValue() - 123.39)));}};
|
||||
|
||||
trades = new ArrayList() {{add(new Trade("UK21341EAH45", 978, new BigDecimal("98.34"), "customer1"));
|
||||
trades = new ArrayList<Trade>() {{add(new Trade("UK21341EAH45", 978, new BigDecimal("98.34"), "customer1"));
|
||||
add(new Trade("UK21341EAH46", 112, new BigDecimal("18.12"), "customer2"));
|
||||
add(new Trade("UK21341EAH47", 245, new BigDecimal("12.78"), "customer2"));
|
||||
add(new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JobExecutionNotificationPublisherTests extends TestCase {
|
||||
JobExecutionNotificationPublisher publisher = new JobExecutionNotificationPublisher();
|
||||
|
||||
public void testRepeatOperationsOpenUsed() throws Exception {
|
||||
final List list = new ArrayList();
|
||||
final List<Notification> list = new ArrayList<Notification>();
|
||||
publisher.setNotificationPublisher(new NotificationPublisher() {
|
||||
public void sendNotification(Notification notification) throws UnableToSendNotificationException {
|
||||
list.add(notification);
|
||||
@@ -42,7 +42,7 @@ public class JobExecutionNotificationPublisherTests extends TestCase {
|
||||
});
|
||||
publisher.onApplicationEvent(new SimpleMessageApplicationEvent(this, "foo"));
|
||||
assertEquals(1, list.size());
|
||||
String message = ((Notification) list.get(0)).getMessage();
|
||||
String message = list.get(0).getMessage();
|
||||
assertTrue("Message does not contain 'foo': ", message.indexOf("foo") > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.sample.domain.Order;
|
||||
|
||||
public class FlatFileOrderWriterTests extends TestCase {
|
||||
|
||||
List list = new ArrayList();
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
|
||||
private ItemWriter output = new AbstractItemWriter() {
|
||||
public void write(Object output) {
|
||||
@@ -47,7 +47,7 @@ public class FlatFileOrderWriterTests extends TestCase {
|
||||
order.setCustomer(new Customer());
|
||||
order.setBilling(new BillingInfo());
|
||||
order.setBillingAddress(new Address());
|
||||
List lineItems = new ArrayList();
|
||||
List<LineItem> lineItems = new ArrayList<LineItem>();
|
||||
LineItem item = new LineItem();
|
||||
item.setPrice(BigDecimal.valueOf(0));
|
||||
lineItems.add(item);
|
||||
@@ -59,7 +59,7 @@ public class FlatFileOrderWriterTests extends TestCase {
|
||||
LineAggregator aggregator = new StubLineAggregator();
|
||||
|
||||
//create map of aggregators and set it to writer
|
||||
Map aggregators = new HashMap();
|
||||
Map<String, LineAggregator> aggregators = new HashMap<String, LineAggregator>();
|
||||
|
||||
OrderTransformer converter = new OrderTransformer();
|
||||
aggregators.put("header", aggregator);
|
||||
@@ -77,7 +77,7 @@ public class FlatFileOrderWriterTests extends TestCase {
|
||||
//verify method calls
|
||||
assertEquals(1, list.size());
|
||||
assertTrue(list.get(0) instanceof List);
|
||||
assertEquals("02007/06/01", ((List) list.get(0)).get(0));
|
||||
assertEquals("02007/06/01", ((List<?>) list.get(0)).get(0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springframework.batch.sample.dao;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -23,11 +24,11 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
|
||||
private JobSupport jobConfiguration;
|
||||
|
||||
private Set jobExecutionIds = new HashSet();
|
||||
private Set<Long> jobExecutionIds = new HashSet<Long>();
|
||||
|
||||
private Set jobIds = new HashSet();
|
||||
private Set<Long> jobIds = new HashSet<Long>();
|
||||
|
||||
private List list = new ArrayList();
|
||||
private List<Serializable> list = new ArrayList<Serializable>();
|
||||
|
||||
public void setRepository(JobRepository repository) {
|
||||
this.repository = repository;
|
||||
@@ -55,18 +56,18 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
|
||||
protected void onTearDownAfterTransaction() throws Exception {
|
||||
startNewTransaction();
|
||||
for (Iterator iterator = jobExecutionIds.iterator(); iterator.hasNext();) {
|
||||
Long id = (Long) iterator.next();
|
||||
for (Iterator<Long> iterator = jobExecutionIds.iterator(); iterator.hasNext();) {
|
||||
Long id = iterator.next();
|
||||
getJdbcTemplate().update("DELETE FROM BATCH_JOB_EXECUTION where JOB_EXECUTION_ID=?", new Object[] { id });
|
||||
}
|
||||
for (Iterator iterator = jobIds.iterator(); iterator.hasNext();) {
|
||||
Long id = (Long) iterator.next();
|
||||
for (Iterator<Long> iterator = jobIds.iterator(); iterator.hasNext();) {
|
||||
Long id = iterator.next();
|
||||
getJdbcTemplate().update("DELETE FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", new Object[] { id });
|
||||
}
|
||||
setComplete();
|
||||
endTransaction();
|
||||
for (Iterator iterator = jobIds.iterator(); iterator.hasNext();) {
|
||||
Long id = (Long) iterator.next();
|
||||
for (Iterator<Long> iterator = jobIds.iterator(); iterator.hasNext();) {
|
||||
Long id = iterator.next();
|
||||
int count = getJdbcTemplate().queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", new Object[] { id });
|
||||
assertEquals(0, count);
|
||||
}
|
||||
|
||||
@@ -16,17 +16,19 @@
|
||||
package org.springframework.batch.sample.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.file.transform.DelimitedLineAggregator;
|
||||
import org.springframework.batch.item.file.transform.LineAggregator;
|
||||
import org.springframework.batch.sample.domain.Address;
|
||||
import org.springframework.batch.sample.domain.BillingInfo;
|
||||
import org.springframework.batch.sample.domain.Customer;
|
||||
import org.springframework.batch.sample.domain.LineItem;
|
||||
import org.springframework.batch.sample.domain.Order;
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ public class OrderTransformerTests extends TestCase {
|
||||
private OrderTransformer converter = new OrderTransformer();
|
||||
|
||||
public void testConvert() throws Exception {
|
||||
converter.setAggregators(new HashMap() {
|
||||
converter.setAggregators(new HashMap<String, LineAggregator>() {
|
||||
{
|
||||
put("header", new DelimitedLineAggregator());
|
||||
put("customer", new DelimitedLineAggregator());
|
||||
@@ -53,7 +55,7 @@ public class OrderTransformerTests extends TestCase {
|
||||
order.setCustomer(new Customer());
|
||||
order.setBillingAddress(new Address());
|
||||
order.setBilling(new BillingInfo());
|
||||
order.setLineItems(Collections.EMPTY_LIST);
|
||||
order.setLineItems(new ArrayList<LineItem>());
|
||||
order.setTotalPrice(new BigDecimal(10));
|
||||
Object result = converter.transform(order);
|
||||
assertTrue(result instanceof Collection);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class OrderItemReaderTests extends TestCase {
|
||||
assertEquals(o.getShipping(), shippingInfo);
|
||||
//there should be 3 line items
|
||||
assertEquals(3, o.getLineItems().size());
|
||||
for (Iterator i = o.getLineItems().iterator(); i.hasNext();) {
|
||||
for (Iterator<?> i = o.getLineItems().iterator(); i.hasNext();) {
|
||||
assertEquals(i.next(),item);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RemoteLauncherTests extends TestCase {
|
||||
|
||||
private static Log logger = LogFactory.getLog(RemoteLauncherTests.class);
|
||||
|
||||
private static List errors = new ArrayList();
|
||||
private static List<Exception> errors = new ArrayList<Exception>();
|
||||
|
||||
private static Thread thread;
|
||||
|
||||
@@ -134,7 +134,7 @@ public class RemoteLauncherTests extends TestCase {
|
||||
* @param interfaceType
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
private static Object getMBean(MBeanServerConnectionFactoryBean connectionFactory, String objectName, Class interfaceType)
|
||||
private static Object getMBean(MBeanServerConnectionFactoryBean connectionFactory, String objectName, Class<?> interfaceType)
|
||||
throws MalformedObjectNameException {
|
||||
MBeanProxyFactoryBean factory = new MBeanProxyFactoryBean();
|
||||
factory.setObjectName(objectName);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.quartz;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -47,7 +48,7 @@ public class JobLauncherDetailsTests extends TestCase {
|
||||
|
||||
private TriggerFiredBundle firedBundle;
|
||||
|
||||
private List list = new ArrayList();
|
||||
private List<Serializable> list = new ArrayList<Serializable>();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
details.setJobLauncher(new JobLauncher() {
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package org.springframework.batch.sample.tasklet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.sample.tasklet.ConfigurableSystemProcessExitCodeMapper;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigurableSystemProcessExitCodeMapper}
|
||||
@@ -21,7 +18,7 @@ public class ConfigurableSystemProcessExitCodeMapperTests extends TestCase {
|
||||
* Regular usage scenario - mapping adheres to injected values
|
||||
*/
|
||||
public void testMapping() {
|
||||
Map mappings = new HashMap() {{
|
||||
Map<Object, ExitStatus> mappings = new HashMap<Object, ExitStatus>() {{
|
||||
put(new Integer(0), ExitStatus.FINISHED);
|
||||
put(new Integer(1), ExitStatus.FAILED);
|
||||
put(new Integer(2), ExitStatus.CONTINUABLE);
|
||||
@@ -33,8 +30,7 @@ public class ConfigurableSystemProcessExitCodeMapperTests extends TestCase {
|
||||
mapper.setMappings(mappings);
|
||||
|
||||
//check explicitly defined values
|
||||
for (Iterator iterator = mappings.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) iterator.next();
|
||||
for (Map.Entry<Object, ExitStatus> entry : mappings.entrySet()) {
|
||||
if (entry.getKey().equals(ConfigurableSystemProcessExitCodeMapper.ELSE_KEY)) continue;
|
||||
|
||||
int exitCode = ((Integer)entry.getKey()).intValue();
|
||||
@@ -50,7 +46,7 @@ public class ConfigurableSystemProcessExitCodeMapperTests extends TestCase {
|
||||
* Else clause is required in the injected map - setter checks its presence.
|
||||
*/
|
||||
public void testSetMappingsMissingElseClause() {
|
||||
Map missingElse = Collections.EMPTY_MAP;
|
||||
Map<Object, ExitStatus> missingElse = new HashMap<Object, ExitStatus>();
|
||||
try {
|
||||
mapper.setMappings(missingElse);
|
||||
fail();
|
||||
@@ -59,7 +55,7 @@ public class ConfigurableSystemProcessExitCodeMapperTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
|
||||
Map containsElse = new HashMap() {{
|
||||
Map<Object, ExitStatus> containsElse = new HashMap<Object, ExitStatus>() {{
|
||||
put(ConfigurableSystemProcessExitCodeMapper.ELSE_KEY, ExitStatus.FAILED);
|
||||
}};
|
||||
// no error expected now
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ExceptionThrowingItemReaderProxyTests extends TestCase {
|
||||
|
||||
//create module and set item processor and iteration count
|
||||
ExceptionThrowingItemReaderProxy itemReader = new ExceptionThrowingItemReaderProxy();
|
||||
itemReader.setItemReader(new ListItemReader(new ArrayList() {{
|
||||
itemReader.setItemReader(new ListItemReader(new ArrayList<String>() {{
|
||||
add("a");
|
||||
add("b");
|
||||
add("c");
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class JobSupport implements BeanNameAware, Job {
|
||||
|
||||
private List steps = new ArrayList();
|
||||
private List<Step> steps = new ArrayList<Step>();
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -98,11 +98,11 @@ public class JobSupport implements BeanNameAware, Job {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.IJob#getSteps()
|
||||
*/
|
||||
public List getSteps() {
|
||||
public List<Step> getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void setSteps(List steps) {
|
||||
public void setSteps(List<Step> steps) {
|
||||
this.steps.clear();
|
||||
this.steps.addAll(steps);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user