BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
SetVoltage.java
1 package unit.devices.tdk_lambda_power_supply;
2 
3 import devices.PowerSupply;
5 import org.junit.Before;
6 import org.junit.Test;
7 
8 import java.io.IOException;
9 
10 import static org.junit.Assert.fail;
11 
16 public final class SetVoltage extends TDKLambdaPowerSupplyTestCase {
17  private final Double newVoltage = 5.0;
18 
19  @Before
20  public void setUpCommunicator(){
21  this.communicatorForDevice.setInputStreamData("OK");
22  }
23 
24  @Test
25  public void testSetVoltage(){
26  try {
27  happyPath();
28  assertCorrectMessage(
29  String.format(PowerSupply.SET_VOLTAGE_COMMAND, newVoltage)
30  );
31  }
32  catch (IOException error) {
33  fail(error.getMessage());
34  }
35  }
36 
37  private void happyPath() throws IOException {
38  this.powerSupply.setVoltage(newVoltage);
39  }
40 
41  @Test(expected = ResponseNotOKException.class)
42  public void testSetVoltageError() throws IOException {
43  this.communicatorForDevice.setInputStreamData(errorMessage);
44  this.powerSupply.setVoltage(newVoltage);
45  }
46 
47 }
void setVoltage(double newVoltage)
void setInputStreamData(String dataForDeviceToRead)
Git Repo