1 package io.github.magwas.coder.tests;
2
3 import static org.mockito.Mockito.mock;
4
5 import java.util.function.Consumer;
6
7 import io.github.magwas.coder.SystemDependency;
8 import io.github.magwas.coder.SystemExitSimulationException;
9
10 public class SystemDependencyStub {
11
12 public static Consumer<String> printlnMock;
13
14 @SuppressWarnings("unchecked")
15 public static SystemDependency stub() {
16 SystemDependency mock = new SystemDependency();
17 mock.exit = (Integer n) -> {
18 throw new SystemExitSimulationException(n);
19 };
20 printlnMock = mock(Consumer.class);
21 mock.println = printlnMock;
22 return mock;
23 }
24 }