vendredi 23 janvier 2015

mock anonymous inner class to change outer local final variable

I have the following code snippet where the inner anonymous class will change the outer local final variable.


I want to write unite test code for this code snippet, I can write a test proxy and define my callStoredProcedure within it, although I can't figure out how I can change the outer final variable as the anonymous class does there


I am using Mockito, Any clue?



final List<String> result = new ArrayList<String>();

proxy.callStoredProcedure(param1, param2,
param3, resolveSQL(param4),
new IProxyExtractor<GenericDTO>() {

@Override
public List<GenericDTO> extract(
final int resultSetindex, final ResultSet rs)
throws SQLException {
while (rs.next()) {
result.add(rs.getString(1));
}

return Arrays
.asList(new GenericDTO[] { new ABCDTO() });
}
}, param5, param6);

Aucun commentaire:

Enregistrer un commentaire