BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
GetPressure.java
1 package unit.devices.pvci_pressure_gauge;
2 
3 import com.ghgande.j2mod.modbus.msg.ReadWriteMultipleRequest;
5 import org.jmock.Expectations;
6 import org.junit.Before;
7 import org.junit.Test;
8 
9 import static org.junit.Assert.assertEquals;
10 
14 public final class GetPressure extends PVCiPressureGaugeTestCase {
15 
16  private Float expectedAnswer = 1.5f;
17 
18  @Before
19  public void setContext() throws Exception {
20  context.checking(new ExpectationsForTest());
21  }
22 
23  @Test
24  public void getPressure() throws Exception {
25  assertEquals(
26  expectedAnswer,
27  pressureGauge.getPressure()
28  );
29  }
30 
31  private class ExpectationsForTest extends Expectations {
32  public ExpectationsForTest() throws Exception {
33  expectationsForModbusConnector();
34  }
35 
36  private void expectationsForModbusConnector() throws Exception {
37  oneOf(mockModbusConnector).getTransactionForRequest(
38  with(any(ReadWriteMultipleRequest.class))
39  );
40  will(returnValue(mockTransaction));
41 
42  oneOf(mockModbusConnector).parseFloatFromResponse(mockResponse);
43  will(returnValue(expectedAnswer));
44  }
45  }
46 }
final Mockery context
Git Repo