1 package unit.devices.pvci_pressure_gauge;
3 import com.ghgande.j2mod.modbus.msg.ReadWriteMultipleRequest;
5 import org.jmock.Expectations;
6 import org.junit.Before;
9 import static org.junit.Assert.assertEquals;
16 private Float expectedAnswer = 1.5f;
19 public void setContext()
throws Exception {
20 context.checking(
new ExpectationsForTest());
24 public void getPressure()
throws Exception {
31 private class ExpectationsForTest
extends Expectations {
32 public ExpectationsForTest()
throws Exception {
33 expectationsForModbusConnector();
36 private void expectationsForModbusConnector()
throws Exception {
37 oneOf(mockModbusConnector).getTransactionForRequest(
38 with(any(ReadWriteMultipleRequest.class))
40 will(returnValue(mockTransaction));
42 oneOf(mockModbusConnector).parseFloatFromResponse(mockResponse);
43 will(returnValue(expectedAnswer));