Search in sources :

Example 1 with HumanLanguageInterpreterStub

use of org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub in project smarthome by eclipse.

the class VoiceManagerTest method interpretSomethingWhenTheDefaultHliIsSetAndItIsARegisteredService.

@Test
public void interpretSomethingWhenTheDefaultHliIsSetAndItIsARegisteredService() throws IOException, InterpretationException {
    stubConsole = new ConsoleStub();
    hliStub = new HumanLanguageInterpreterStub();
    registerService(hliStub);
    Dictionary<String, Object> voiceConfig = new Hashtable<String, Object>();
    voiceConfig.put("defaultHLI", hliStub.getId());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    String pid = "org.eclipse.smarthome.voice";
    Configuration configuration = configAdmin.getConfiguration(pid);
    configuration.update(voiceConfig);
    String result = voiceManager.interpret("something", hliStub.getId());
    assertThat(result, is("Interpreted text"));
}
Also used : ConsoleStub(org.eclipse.smarthome.core.voice.internal.ConsoleStub) Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 2 with HumanLanguageInterpreterStub

use of org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub in project smarthome by eclipse.

the class VoiceManagerTest method verifyThatADialogIsNotStartedWhenAnyOfTheRequiredServiceIsNull.

@Test
public void verifyThatADialogIsNotStartedWhenAnyOfTheRequiredServiceIsNull() {
    sttService = new STTServiceStub();
    ksService = new KSServiceStub();
    ttsService = null;
    hliStub = new HumanLanguageInterpreterStub();
    source = new AudioSourceStub();
    exception.expect(IllegalStateException.class);
    voiceManager.startDialog(ksService, sttService, ttsService, hliStub, source, sink, Locale.getDefault(), "word", null);
    assertFalse(ksService.isWordSpotted());
}
Also used : AudioSourceStub(org.eclipse.smarthome.core.voice.internal.AudioSourceStub) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) STTServiceStub(org.eclipse.smarthome.core.voice.internal.STTServiceStub) KSServiceStub(org.eclipse.smarthome.core.voice.internal.KSServiceStub) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 3 with HumanLanguageInterpreterStub

use of org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub in project smarthome by eclipse.

the class VoiceManagerTest method getParameterOptionsForTheDefaultHli.

@Test
public void getParameterOptionsForTheDefaultHli() throws URISyntaxException {
    hliStub = new HumanLanguageInterpreterStub();
    registerService(hliStub);
    boolean isHliStubInTheOptions = false;
    Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultHLI", null);
    assertNotNull(options);
    for (ParameterOption option : options) {
        String optionValue = option.getValue();
        String optionLabel = option.getLabel();
        String hliStubId = hliStub.getId();
        String hliLabel = hliStub.getLabel(null);
        if (optionValue.equals(hliStubId) && optionLabel.equals(hliLabel)) {
            isHliStubInTheOptions = true;
        }
    }
    assertTrue(isHliStubInTheOptions);
}
Also used : ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) URI(java.net.URI) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 4 with HumanLanguageInterpreterStub

use of org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub in project smarthome by eclipse.

the class InterpretCommandTest method setUp.

@Before
public void setUp() throws IOException, InterruptedException {
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    voice = new VoiceStub();
    registerService(voice);
    registerService(hliStub);
    registerService(ttsService);
    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(CONFIG_DEFAULT_TTS, ttsService.getId());
    config.put(CONFIG_DEFAULT_HLI, hliStub.getId());
    config.put(CONFIG_DEFAULT_VOICE, voice.getUID());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    String pid = "org.eclipse.smarthome.voice";
    Configuration configuration = configAdmin.getConfiguration(pid);
    configuration.update(config);
}
Also used : VoiceStub(org.eclipse.smarthome.core.voice.internal.VoiceStub) Configuration(org.osgi.service.cm.Configuration) TTSServiceStub(org.eclipse.smarthome.core.voice.internal.TTSServiceStub) Hashtable(java.util.Hashtable) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) Before(org.junit.Before)

Example 5 with HumanLanguageInterpreterStub

use of org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub in project smarthome by eclipse.

the class VoiceManagerTest method interpretSomethingWithGivenHliIdWhenTheHliIsARegisteredService.

@Test
public void interpretSomethingWithGivenHliIdWhenTheHliIsARegisteredService() throws InterpretationException {
    stubConsole = new ConsoleStub();
    hliStub = new HumanLanguageInterpreterStub();
    registerService(hliStub);
    String result = voiceManager.interpret("something", hliStub.getId());
    assertThat(result, is("Interpreted text"));
}
Also used : ConsoleStub(org.eclipse.smarthome.core.voice.internal.ConsoleStub) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

HumanLanguageInterpreterStub (org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub)9 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)8 Test (org.junit.Test)8 AudioSourceStub (org.eclipse.smarthome.core.voice.internal.AudioSourceStub)4 KSServiceStub (org.eclipse.smarthome.core.voice.internal.KSServiceStub)4 STTServiceStub (org.eclipse.smarthome.core.voice.internal.STTServiceStub)4 TTSServiceStub (org.eclipse.smarthome.core.voice.internal.TTSServiceStub)4 Hashtable (java.util.Hashtable)3 ConsoleStub (org.eclipse.smarthome.core.voice.internal.ConsoleStub)3 Configuration (org.osgi.service.cm.Configuration)3 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)3 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ParameterOption (org.eclipse.smarthome.config.core.ParameterOption)1 VoiceStub (org.eclipse.smarthome.core.voice.internal.VoiceStub)1 InterpretationException (org.eclipse.smarthome.core.voice.text.InterpretationException)1 Before (org.junit.Before)1 ExpectedException (org.junit.rules.ExpectedException)1