Пример #1
0
  @Test
  public void should_return_error_if_no_device_matches_a_command() {
    // given
    TestDummy device = new TestDummy("lampe1");
    device.getSetList().parse("on off");
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor("schalte lampe 1", context);

    // then
    assertThat(result).contains(new VoiceResult.Error(VoiceResult.ErrorType.NO_DEVICE_MATCHED));
  }
Пример #2
0
  @Test
  public void should_ignore_devices_not_containing_the_target_state_in_the_setlist() {
    // given
    TestDummy device = new TestDummy("lampe");
    device.getSetList().parse("off");
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor("schalte lampe on", context);

    // then
    assertThat(result).contains(new VoiceResult.Error(VoiceResult.ErrorType.NO_DEVICE_MATCHED));
  }
Пример #3
0
  @Test
  public void should_handle_event_maps() {
    // given
    TestDummy device = new TestDummy("lampe");
    device.getSetList().parse("on off");
    device.setEventmap("on:hallo");
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor("schalte lampe hallo", context);

    // then
    assertThat(result).contains(new VoiceResult.Success("lampe", "on"));
  }
Пример #4
0
  @Test
  @UseDataProvider("voiceCommandsForDevice")
  public void should_find_out_correct_voice_result(CommandTestCase testCase) {
    // given
    TestDummy device = new TestDummy(testCase.deviceName);
    device.getSetList().parse("on off");
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor(testCase.command, context);

    // then
    assertThat(result).contains(testCase.voiceResult);
  }
Пример #5
0
  @UseDataProvider("pronunciation")
  @Test
  public void should_treat_voice_pronunciation_attribute(String pronunciation) {
    // given
    TestDummy device = new TestDummy("lampe");
    device.getSetList().parse("on off");
    device.setPronunciation(pronunciation);
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor("set " + pronunciation + " on", context);

    // then
    assertThat(result).contains(new VoiceResult.Success("lampe", "on"));
  }
Пример #6
0
  @Test
  @UseDataProvider("shortcutCommandsForDevice")
  public void should_handle_shortcuts(CommandTestCase commandTestCase) {
    // given
    TestDummy device = new TestDummy(commandTestCase.deviceName);
    device.setPronunciation("garten leuchte");
    device.getSetList().parse("on off");
    RoomDeviceList deviceList = new RoomDeviceList("").addDevice(device, context);
    doReturn(deviceList)
        .when(roomListService)
        .getAllRoomsDeviceList(Optional.<String>absent(), context);

    // when
    Optional<VoiceResult> result = service.resultFor(commandTestCase.command, context);

    // then
    assertThat(result).contains(commandTestCase.voiceResult);
  }