I'm trying to create unit tests for my repository, but I can't mock the QLDBDriver. I've searched for information, but I couldn't find anything for Java, and everything I've tried hasn't worked.
For example I'm trying to test this method.
public DataQLDB getDataById(String id) {
return qldbDriver.execute(transactionExecutor -> {
try {
IonString ionId = ionSystem.newString(id);
Result result = transactionExecutor.execute(
"SELECT * FROM Data WHERE id = ?", ionId
);
Iterator<IonValue> it = result.iterator();
if (!it.hasNext()) {
throw new DataNotFoundException(id);
}
return mapper.readValue(it.next(), DataQLDB.class);
} catch (IOException e) {
throw new TransactionExecutorException(e.getMessage());
}
});
}
I Mock the QldbDriver and injectMock in the qldbRepository but only verify the driver execute. I need to test inside the qldbDriver.execute. How can I mock the transactionExecutor.execute?