BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
VoltageProviderTestCase.java
1 package unit.kernel.models.variables.voltage_provider;
2 
3 import devices.PowerSupply;
4 import kernel.Kernel;
9 import org.jetbrains.annotations.Contract;
10 import org.jmock.Expectations;
11 import org.junit.Before;
13 
17 public abstract class VoltageProviderTestCase extends VariablesTestCase {
18  protected VariableProvider<Voltage> provider;
19 
20  protected PowerSupply mockPowerSupply = context.mock(PowerSupply.class);
21 
22  protected Kernel mockKernel = context.mock(Kernel.class);
23 
24  protected TaskRunner mockTaskRunner = context.mock(TaskRunner.class);
25 
26  @Before
27  public void setUp(){
28  context.checking(getExpectations());
29  setProvider();
30  }
31 
32  @Contract(" -> !null")
33  protected abstract ExpectationsForTest getExpectations();
34 
35 
36  private void setProvider(){
37  provider = new VoltageProvider(mockPowerSupply, mockKernel);
38  }
39 
40  protected class ExpectationsForTest extends Expectations {
41  public ExpectationsForTest(){
42  expectationsForKernel();
43  expectationsForTaskRunner();
44  }
45 
46  private void expectationsForKernel(){
47  oneOf(mockKernel).getTaskRunner();
48  will(returnValue(mockTaskRunner));
49  }
50 
51  private void expectationsForTaskRunner(){
52  oneOf(mockTaskRunner).execute(with(any(Runnable.class)));
53  }
54  }
55 }
final Mockery context
Git Repo