Search in sources :

Example 1 with KSServiceStub

use of org.eclipse.smarthome.core.voice.internal.KSServiceStub 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 2 with KSServiceStub

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

the class VoiceManagerTest method getParameterOptionsForTheDefaultKs.

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

Example 3 with KSServiceStub

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

the class VoiceManagerTest method startDialogAndVerifyThatAKSExceptionIsProperlyHandled.

@Test
public void startDialogAndVerifyThatAKSExceptionIsProperlyHandled() {
    sttService = new STTServiceStub();
    ksService = new KSServiceStub();
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    source = new AudioSourceStub();
    registerService(sttService);
    registerService(ksService);
    registerService(ttsService);
    registerService(hliStub);
    registerService(source);
    ksService.setIsKsExceptionExpected(true);
    voiceManager.startDialog(ksService, sttService, ttsService, hliStub, source, sink, null, "", null);
    assertFalse(ksService.isWordSpotted());
}
Also used : TTSServiceStub(org.eclipse.smarthome.core.voice.internal.TTSServiceStub) 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 4 with KSServiceStub

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

the class VoiceManagerTest method startDialogWithoutPassingAnyParameters.

@Test
public void startDialogWithoutPassingAnyParameters() throws IOException, InterruptedException {
    sttService = new STTServiceStub();
    ksService = new KSServiceStub();
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    source = new AudioSourceStub();
    registerService(sttService);
    registerService(ksService);
    registerService(ttsService);
    registerService(hliStub);
    registerService(source);
    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(CONFIG_KEYWORD, "word");
    config.put(CONFIG_DEFAULT_STT, sttService.getId());
    config.put(CONFIG_DEFAULT_KS, ksService.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);
    waitForAssert(() -> {
        try {
            voiceManager.startDialog();
        } catch (Exception ex) {
        // if the configuration is not updated yet the startDialog method will throw and exception which will
        // break the test
        }
        assertTrue(ksService.isWordSpotted());
    });
}
Also used : Configuration(org.osgi.service.cm.Configuration) TTSServiceStub(org.eclipse.smarthome.core.voice.internal.TTSServiceStub) AudioSourceStub(org.eclipse.smarthome.core.voice.internal.AudioSourceStub) Hashtable(java.util.Hashtable) HumanLanguageInterpreterStub(org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub) STTServiceStub(org.eclipse.smarthome.core.voice.internal.STTServiceStub) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) URISyntaxException(java.net.URISyntaxException) InterpretationException(org.eclipse.smarthome.core.voice.text.InterpretationException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) KSServiceStub(org.eclipse.smarthome.core.voice.internal.KSServiceStub) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 5 with KSServiceStub

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

the class VoiceManagerTest method startDialogWhenAllOfTheRequiredServicesAreAvailable.

@Test
public void startDialogWhenAllOfTheRequiredServicesAreAvailable() {
    sttService = new STTServiceStub();
    ksService = new KSServiceStub();
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    source = new AudioSourceStub();
    registerService(sttService);
    registerService(ksService);
    registerService(ttsService);
    registerService(hliStub);
    registerService(source);
    voiceManager.startDialog(ksService, sttService, ttsService, hliStub, source, sink, null, "word", null);
    assertTrue(ksService.isWordSpotted());
}
Also used : TTSServiceStub(org.eclipse.smarthome.core.voice.internal.TTSServiceStub) 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)

Aggregations

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