### Question:
DMLSQLRevertEngine implements SQLRevertEngine { @Override public Optional<RevertSQLResult> revert() { Optional<String> sql = sqlRevertExecutor.revertSQL(); if (!sql.isPresent()) { return Optional.absent(); } RevertSQLResult result = new RevertSQLResult(sql.get()); sqlRevertExecutor.fillParameters(result); return Optional.of(result); }  @Override Optional<RevertSQLResult> revert();  }### Answer:
@Test public void assertRevertSQLNotExist() { when(sqlRevertExecutor.revertSQL()).thenReturn(Optional.<String>absent()); Optional<RevertSQLResult> actual = sqlRevertEngine.revert(); assertFalse(actual.isPresent()); }
@Test public void assertRevertSQLExist() { when(sqlRevertExecutor.revertSQL()).thenReturn(Optional.of("revert sql")); Optional<RevertSQLResult> actual = sqlRevertEngine.revert(); assertTrue(actual.isPresent()); verify(sqlRevertExecutor).fillParameters(any(RevertSQLResult.class)); }