use of org.eclipse.smarthome.test.storage.VolatileStorageService in project smarthome by eclipse.
the class NtpOSGiTest method setUp.
@Before
public void setUp() {
VolatileStorageService volatileStorageService = new VolatileStorageService();
registerService(volatileStorageService);
managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
assertNotNull(managedThingProvider);
thingRegistry = getService(ThingRegistry.class);
assertNotNull(thingRegistry);
itemRegistry = getService(ItemRegistry.class);
assertNotNull(itemRegistry);
channelTypeUID = new ChannelTypeUID(NtpBindingConstants.BINDING_ID + ":channelType");
channelTypeProvider = mock(ChannelTypeProvider.class);
when(channelTypeProvider.getChannelType(any(ChannelTypeUID.class), any(Locale.class))).thenReturn(new ChannelType(channelTypeUID, false, "Switch", ChannelKind.STATE, "label", null, null, null, null, null, null));
registerService(channelTypeProvider);
}
use of org.eclipse.smarthome.test.storage.VolatileStorageService in project smarthome by eclipse.
the class AutomaticInboxProcessorTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
when(thing.getConfiguration()).thenReturn(CONFIG);
when(thing.getThingTypeUID()).thenReturn(THING_TYPE_UID);
when(thing.getProperties()).thenReturn(THING_PROPERTIES);
when(thing.getStatus()).thenReturn(ThingStatus.ONLINE);
when(thing.getUID()).thenReturn(THING_UID);
when(thing2.getConfiguration()).thenReturn(CONFIG);
when(thing2.getThingTypeUID()).thenReturn(THING_TYPE_UID);
when(thing2.getProperties()).thenReturn(THING_PROPERTIES);
when(thing2.getStatus()).thenReturn(ThingStatus.ONLINE);
when(thing2.getUID()).thenReturn(THING_UID2);
when(thing3.getConfiguration()).thenReturn(CONFIG);
when(thing3.getThingTypeUID()).thenReturn(THING_TYPE_UID3);
when(thing3.getProperties()).thenReturn(OTHER_THING_PROPERTIES);
when(thing3.getStatus()).thenReturn(ThingStatus.ONLINE);
when(thing3.getUID()).thenReturn(THING_UID3);
when(thingRegistry.stream()).thenReturn(Stream.empty());
when(thingTypeRegistry.getThingType(THING_TYPE_UID)).thenReturn(THING_TYPE);
when(thingTypeRegistry.getThingType(THING_TYPE_UID2)).thenReturn(THING_TYPE2);
when(thingTypeRegistry.getThingType(THING_TYPE_UID3)).thenReturn(THING_TYPE3);
when(thingHandlerFactory.supportsThingType(eq(THING_TYPE_UID))).thenReturn(true);
when(thingHandlerFactory.createThing(eq(THING_TYPE_UID), any(Configuration.class), eq(THING_UID), any(ThingUID.class))).then(invocation -> ThingBuilder.create(THING_TYPE_UID, "test").withConfiguration((Configuration) invocation.getArguments()[1]).build());
inbox = new PersistentInbox();
inbox.setThingRegistry(thingRegistry);
inbox.setStorageService(new VolatileStorageService());
inbox.setManagedThingProvider(thingProvider);
inbox.setConfigDescriptionRegistry(configDescriptionRegistry);
inbox.setThingTypeRegistry(thingTypeRegistry);
inbox.addThingHandlerFactory(thingHandlerFactory);
inboxAutoIgnore = new AutomaticInboxProcessor();
inboxAutoIgnore.setThingRegistry(thingRegistry);
inboxAutoIgnore.setThingTypeRegistry(thingTypeRegistry);
inboxAutoIgnore.setInbox(inbox);
}
use of org.eclipse.smarthome.test.storage.VolatileStorageService in project smarthome by eclipse.
the class SayCommandTest method testSayCommand.
@Test
public void testSayCommand() throws IOException {
String[] methodParameters = new String[2];
methodParameters[0] = SUBCMD_SAY;
if (defaultTTSService != null) {
Dictionary<String, Object> config = new Hashtable<String, Object>();
config.put(CONFIG_DEFAULT_TTS, defaultTTSService);
ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
String pid = "org.eclipse.smarthome.voice";
Configuration configuration = configAdmin.getConfiguration(pid);
configuration.update(config);
}
if (TTSServiceMockShouldBeRegistered) {
registerService(ttsService);
}
if (shouldItemsBePassed) {
VolatileStorageService volatileStorageService = new VolatileStorageService();
registerService(volatileStorageService);
ManagedThingProvider managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
assertNotNull(managedThingProvider);
ItemRegistry itemRegistry = getService(ItemRegistry.class);
assertNotNull(itemRegistry);
Item item = new StringItem("itemName");
if (shouldItemsBeRegistered) {
itemRegistry.add(item);
}
methodParameters[1] = "%" + item.getName() + "%";
if (shouldMultipleItemsBeRegistered) {
Item item1 = new StringItem("itemName1");
itemRegistry.add(item1);
Item item2 = new StringItem("itemName2");
itemRegistry.add(item2);
Item item3 = new StringItem("itemName3");
itemRegistry.add(item3);
methodParameters[1] = "%itemName.%";
}
} else {
methodParameters[1] = "hello";
}
extensionService.execute(methodParameters, console);
assertThat(sink.isStreamProcessed(), is(shouldStreamBeExpected));
}
Aggregations