I'm new to Jmockit and I'm trying to mock jdbcTemplate.udpate()
using the following verification,
new Expectations() {{
someRef.flushUpdates();
}};
new Verifications() {{
String query;
jdbcTemplate.update(query = withCapture(), withInstanceOf(Date.class));
times = 1;
}};
The flushUpdate
has an update query,
public void flushUpdates(){
Date now = new Date();
String query = "Update table_name set last_updated = ? ";
jdbcTemplate.update(query,now);
}
The test is to verify if update
query is triggered twice.
But I'm getting the following error.
mockit.internal.MissingInvocation: Missing 1 invocations to:
org.springframework.jdbc.core.JdbcTemplate#update(String, Object[])
with arguments: any String, an instance of java.util.Date
on mock instance: org.springframework.jdbc.core.JdbcTemplate@2d000e80
Does anyone has any idea ?
@Injectable JdbcTemplate jdbcTemplate;
in the base class and also in the test class which was causing the object reference to change when called from theExpectation
inner class. Removing the reference from base class fixes the issue. – Acetous