Look at the following class:
public class Presenter {
private final Calculator calculator;
private Integer recentValue;
public Presenter(Calculator calculator) {
this.calculator = calculator;
}
// displays the sum of two integers
public void showSum(int a, int b) {
int sum = calculator.sum(a, b);
recentValue = sum; // update recentValue
System.out.println(sum);
}
public Integer getRecentValue() {
return recentValue;
}
}
Here is a test written to make sure that the most recently displayed number is set correctly:
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
class PresenterTest {
private Calculator calculator = mock(Calculator.class);
private Presenter presenter = new Presenter(calculator);
@Test
void test() {
// missing code
presenter.showSum(5, 3);
int actual = presenter.getRecentValue();
assertEquals(8, actual);
}
}
Select all the options that correctly set up the behavior of the mock object so that the test can be successfully passed.