Ejemplo n.º 1
0
  @Test
  public void callsCorrectAction() throws Exception {
    mqttCommandPort.setTopic("test");
    receiveMqttMessage("On", "test/" + TEST_ITEM_NAME);

    verify(testItem).callAction("On");
  }
Ejemplo n.º 2
0
  @Test
  public void setsAttributeValue() throws Exception {
    mqttCommandPort.setTopic("test");
    receiveMqttMessage("On", "test/" + TEST_ITEM_NAME + ATTRIBUTE_SEPARATOR + ATTRIBUTE);

    verify(testItem).setAttributeValue(ATTRIBUTE, "On");
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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");
   }
 }
Ejemplo n.º 5
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));
     }
   }
 }