BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
HandleRefreshButtonClickedPressureGauge.java
1 package unit.ui.controllers.device_list_controller;
2 
4 import javafx.scene.text.Text;
6 import org.jmock.Expectations;
7 import org.jmock.Mockery;
8 import org.junit.Before;
9 import org.junit.Test;
10 
11 import java.util.Optional;
12 
13 import static org.junit.Assert.fail;
14 
21 
22  @Before
23  public void setContext(){
24  applicationContext.getBean(Mockery.class).checking(
25  new ExpectationsForTest()
26  );
27  }
28 
29  @Test
30  public void testPressureGauge(){
31  clickOn(queryForRefreshButton);
32 
33  Optional<Text> message = lookup(queryForPressureGaugeMessage)
34  .tryQuery();
35 
36  if (!message.isPresent()){
37  String failMessage = String.format(
38  "The test did not make the message with id %s appear",
39  queryForPressureGaugeMessage
40  );
41  fail(failMessage);
42  }
43  }
44 
45  private class ExpectationsForTest extends Expectations {
46 
47  private final DeviceContainer registry = applicationContext.getBean(
48  DeviceContainer.class
49  );
50 
51  private final PressureGauge gauge = applicationContext.getBean
52  (Mockery.class).mock(PressureGauge.class);
53 
54  public ExpectationsForTest(){
55  oneOf(registry).hasPowerSupply();
56  will(returnValue(Boolean.FALSE));
57 
58  oneOf(registry).hasPressureGauge();
59  will(returnValue(Boolean.TRUE));
60 
61  oneOf(registry).getPressureGauge();
62  will(returnValue(gauge));
63  }
64  }
65 }
Git Repo