use of org.eclipse.smarthome.core.voice.internal.STTServiceStub 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());
}
use of org.eclipse.smarthome.core.voice.internal.STTServiceStub 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());
}
use of org.eclipse.smarthome.core.voice.internal.STTServiceStub 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());
});
}
use of org.eclipse.smarthome.core.voice.internal.STTServiceStub 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());
}
use of org.eclipse.smarthome.core.voice.internal.STTServiceStub in project smarthome by eclipse.
the class VoiceManagerTest method getParameterOptionsForTheDefaultSTT.
@Test
public void getParameterOptionsForTheDefaultSTT() throws URISyntaxException {
sttService = new STTServiceStub();
registerService(sttService);
boolean isSTTStubInTheOptions = false;
Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultSTT", null);
assertNotNull(options);
for (ParameterOption option : options) {
String optionValue = option.getValue();
String optionLabel = option.getLabel();
String sttStubId = sttService.getId();
String sttLabel = sttService.getLabel(null);
if (optionValue.equals(sttStubId) && optionLabel.equals(sttLabel)) {
isSTTStubInTheOptions = true;
}
}
assertTrue(isSTTStubInTheOptions);
}
Aggregations