コード例 #1
0
 @Test
 public void handlesDifferentAttributeSeparators() throws Exception {
   mqttCommandPort.setTopic("test");
   int i = 0;
   for (String s : separators) {
     mqttCommandPort.setAttributeSeparator(s);
     receiveMqttMessage("On", "test/" + TEST_ITEM_NAME + s + ATTRIBUTE);
     i++;
     verify(testItem, times(i)).setAttributeValue(ATTRIBUTE, "On");
   }
 }
コード例 #2
0
 @Test
 public void handlesBadAttributeSeparators() throws Exception {
   mqttCommandPort.setTopic("test");
   int i = 0;
   for (String s : badSeparators) {
     try {
       mqttCommandPort.setAttributeSeparator(s);
       assertThat(true, is(false));
     } catch (IllegalValueException e) {
       assertThat(e.getValue(), is(s));
     }
   }
 }
コード例 #3
0
  @Test
  public void setsAttributeValue() throws Exception {
    mqttCommandPort.setTopic("test");
    receiveMqttMessage("On", "test/" + TEST_ITEM_NAME + ATTRIBUTE_SEPARATOR + ATTRIBUTE);

    verify(testItem).setAttributeValue(ATTRIBUTE, "On");
  }
コード例 #4
0
  @Test
  public void callsCorrectAction() throws Exception {
    mqttCommandPort.setTopic("test");
    receiveMqttMessage("On", "test/" + TEST_ITEM_NAME);

    verify(testItem).callAction("On");
  }
コード例 #5
0
  @Test
  public void findsCorrectHomeItemForActionWithThreeLevelTopic() throws Exception {
    mqttCommandPort.setTopic("test/more/levels");
    receiveMqttMessage("On", "test/more/levels/" + TEST_ITEM_NAME);

    verify(service).openInstance(TEST_ITEM_NAME);
  }
コード例 #6
0
 private void receiveMqttMessage(String value, String topic) {
   Event event = new InternalEvent("Mqtt_Message");
   event.setAttribute("Mqtt.Topic", topic);
   event.setAttribute("Mqtt.Message", value);
   event.setAttribute("Direction", "In");
   mqttCommandPort.receiveEvent(event);
 }
コード例 #7
0
 @Before
 public void setUp() throws Exception {
   mqttCommandPort = new MqttCommandPort();
   service = mock(HomeService.class);
   mqttCommandPort.activate(service);
   testItem = mock(HomeItemProxy.class);
   doReturn(testItem).when(service).openInstance(TEST_ITEM_NAME);
 }