BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
PressureGaugeIOExceptionTest.java
1 package unit.ui.controllers.device_setup_controller.handle_go_button_clicked;
2 
3 import javafx.scene.text.Text;
4 import org.jetbrains.annotations.Contract;
5 import org.junit.Test;
6 
7 import java.io.IOException;
8 import java.util.Optional;
9 
10 import static org.junit.Assert.fail;
11 
15 public final class PressureGaugeIOExceptionTest extends
17 
18  private static final String queryForMessage = "#pvci-io-exception-message";
19 
20  @Contract(" -> !null")
21  @Override
22  public ExpectationsForMockFactory getMockingExpectations(){
23  return new IOExceptionExpectations();
24  }
25 
26  @Test
27  public void testClick(){
28  clickOn(queryForGoButton);
29 
30  Optional<Text> message = lookup(queryForMessage).tryQuery();
31 
32  if (!message.isPresent()){
33  fail(
34  String.format(
35  "Did not find the message. I used the query %s",
36  queryForMessage
37  )
38  );
39  }
40  }
41 
42  private class IOExceptionExpectations extends ExpectationsForMockFactory {
43  public IOExceptionExpectations(){
44  super();
45  thrownExpectation();
46  }
47 
48  private void thrownExpectation(){
49  try {
50  oneOf(factory).makePowerSupply();
51  oneOf(pressureGaugeFactory).makePressureGauge();
52  will(throwException(new IOException("Kaboom")));
53  } catch (Exception error){
54  error.printStackTrace();
55  }
56  }
57  }
58 }
Git Repo