BakeoutController-Basic  0.1
A Controller for the Omicron vacuum chamber
HandleRefreshButtonClickedNoPowerSupply.java
1 package unit.ui.controllers.device_list_controller;
2 
3 import devices.PowerSupply;
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 
18 public final class HandleRefreshButtonClickedNoPowerSupply extends
20 
21  @Before
22  public void setUpForPowerSupply() {
23  applicationContext.getBean(Mockery.class).checking(
24  new ExpectationsForPowerSupply()
25  );
26  }
27 
28  @Test
29  public void testPowerSupply() {
30  clickOn(queryForRefreshButton);
31 
32  Optional<Text> message = lookup(queryForPowerSupply).tryQuery();
33 
34  if (!message.isPresent()) {
35  fail("The test did not make the power supply message appear");
36  }
37  }
38 
39  private class ExpectationsForPowerSupply extends Expectations {
40  public ExpectationsForPowerSupply() {
41  oneOf(applicationContext.getBean(DeviceContainer.class))
42  .hasPowerSupply();
43  will(returnValue(Boolean.TRUE));
44 
45  oneOf(applicationContext.getBean(DeviceContainer.class))
46  .getPowerSupply();
47  will(returnValue(applicationContext.getBean(PowerSupply.class)));
48 
49  oneOf(applicationContext.getBean(DeviceContainer.class))
50  .hasPressureGauge();
51  will(returnValue(Boolean.FALSE));
52  }
53  }
54 }
Git Repo