Search in sources :

Example 1 with ConsoleStub

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

use of org.eclipse.smarthome.core.voice.internal.ConsoleStub 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)

Example 3 with ConsoleStub

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

the class VoiceManagerTest method interpretSomethingWithGivenHliIdEhenTheHliIsNotARegisteredService.

@Test
public void interpretSomethingWithGivenHliIdEhenTheHliIsNotARegisteredService() throws InterpretationException {
    stubConsole = new ConsoleStub();
    hliStub = new HumanLanguageInterpreterStub();
    String result;
    exception.expect(InterpretationException.class);
    result = voiceManager.interpret("something", hliStub.getId());
    assertNull(result);
}
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)

Example 4 with ConsoleStub

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

the class VoiceConsoleCommandExtensionTest method setup.

@Before
public void setup() {
    voiceManager = getService(VoiceManager.class, VoiceManagerImpl.class);
    assertNotNull(voiceManager);
    extensionService = getService(ConsoleCommandExtension.class, VoiceConsoleCommandExtension.class);
    assertNotNull(extensionService);
    sink = new SinkStub();
    source = new AudioSourceStub();
    audioManager = new AudioManagerStub();
    console = new ConsoleStub();
    registerService(audioManager);
    registerService(voiceManager);
}
Also used : SinkStub(org.eclipse.smarthome.core.voice.internal.SinkStub) ConsoleStub(org.eclipse.smarthome.core.voice.internal.ConsoleStub) VoiceManagerImpl(org.eclipse.smarthome.core.voice.internal.VoiceManagerImpl) VoiceConsoleCommandExtension(org.eclipse.smarthome.core.voice.internal.VoiceConsoleCommandExtension) AudioSourceStub(org.eclipse.smarthome.core.voice.internal.AudioSourceStub) VoiceConsoleCommandExtension(org.eclipse.smarthome.core.voice.internal.VoiceConsoleCommandExtension) ConsoleCommandExtension(org.eclipse.smarthome.io.console.extensions.ConsoleCommandExtension) AudioManagerStub(org.eclipse.smarthome.core.voice.internal.AudioManagerStub) VoiceManager(org.eclipse.smarthome.core.voice.VoiceManager) Before(org.junit.Before)

Aggregations

ConsoleStub (org.eclipse.smarthome.core.voice.internal.ConsoleStub)4 HumanLanguageInterpreterStub (org.eclipse.smarthome.core.voice.internal.HumanLanguageInterpreterStub)3 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)3 Test (org.junit.Test)3 Hashtable (java.util.Hashtable)1 VoiceManager (org.eclipse.smarthome.core.voice.VoiceManager)1 AudioManagerStub (org.eclipse.smarthome.core.voice.internal.AudioManagerStub)1 AudioSourceStub (org.eclipse.smarthome.core.voice.internal.AudioSourceStub)1 SinkStub (org.eclipse.smarthome.core.voice.internal.SinkStub)1 VoiceConsoleCommandExtension (org.eclipse.smarthome.core.voice.internal.VoiceConsoleCommandExtension)1 VoiceManagerImpl (org.eclipse.smarthome.core.voice.internal.VoiceManagerImpl)1 ConsoleCommandExtension (org.eclipse.smarthome.io.console.extensions.ConsoleCommandExtension)1 Before (org.junit.Before)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1