Search in sources :

Example 1 with ItemProvider

use of org.eclipse.smarthome.core.items.ItemProvider in project smarthome by eclipse.

the class RunRuleModuleTest method before.

@Before
public void before() {
    registerService(new ItemProvider() {

        @Override
        public void addProviderChangeListener(final ProviderChangeListener<Item> listener) {
        }

        @Override
        public void removeProviderChangeListener(final ProviderChangeListener<Item> listener) {
        }

        @Override
        public Collection<Item> getAll() {
            return Arrays.asList(new Item[] { new SwitchItem("switch1"), new SwitchItem("switch2"), new SwitchItem("switch3"), new SwitchItem("ruleTrigger") });
        }
    });
    registerService(volatileStorageService);
}
Also used : ItemProvider(org.eclipse.smarthome.core.items.ItemProvider) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Item(org.eclipse.smarthome.core.items.Item) Collection(java.util.Collection) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Before(org.junit.Before)

Example 2 with ItemProvider

use of org.eclipse.smarthome.core.items.ItemProvider in project smarthome by eclipse.

the class RuntimeRuleTest method before.

@Before
public void before() {
    registerService(new ItemProvider() {

        @Override
        public void addProviderChangeListener(final ProviderChangeListener<Item> listener) {
        }

        @Override
        public void removeProviderChangeListener(final ProviderChangeListener<Item> listener) {
        }

        @Override
        public Collection<Item> getAll() {
            return Arrays.asList(new Item[] { new SwitchItem("myMotionItem"), new SwitchItem("myPresenceItem"), new SwitchItem("myLampItem"), new SwitchItem("myMotionItem2"), new SwitchItem("myPresenceItem2"), new SwitchItem("myLampItem2"), new SwitchItem("myMotionItem3"), new SwitchItem("myPresenceItem3"), new SwitchItem("myLampItem3"), new SwitchItem("myMotionItem4"), new SwitchItem("myPresenceItem4"), new SwitchItem("myLampItem4") });
        }
    });
    registerService(volatileStorageService);
}
Also used : ItemProvider(org.eclipse.smarthome.core.items.ItemProvider) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Item(org.eclipse.smarthome.core.items.Item) Collection(java.util.Collection) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Before(org.junit.Before)

Example 3 with ItemProvider

use of org.eclipse.smarthome.core.items.ItemProvider in project smarthome by eclipse.

the class ScriptEngineOSGiTest method setup.

@Before
public void setup() {
    registerVolatileStorageService();
    EventPublisher eventPublisher = event -> {
    };
    registerService(eventPublisher);
    itemRegistry = getService(ItemRegistry.class);
    assertNotNull(itemRegistry);
    itemProvider = new ItemProvider() {

        @Override
        public void addProviderChangeListener(ProviderChangeListener<Item> listener) {
        }

        @Override
        public Collection<Item> getAll() {
            return Lists.newArrayList(new SwitchItem(ITEM_NAME), createNumberItem(NUMBER_ITEM_TEMPERATURE, Temperature.class), createNumberItem(NUMBER_ITEM_LENGTH, Length.class), new NumberItem(NUMBER_ITEM_DECIMAL));
        }

        @Override
        public void removeProviderChangeListener(ProviderChangeListener<Item> listener) {
        }
    };
    registerService(itemProvider);
    ScriptServiceUtil scriptServiceUtil = getService(ScriptServiceUtil.class);
    assertNotNull(scriptServiceUtil);
    scriptEngine = ScriptServiceUtil.getScriptEngine();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) ProviderChangeListener(org.eclipse.smarthome.core.common.registry.ProviderChangeListener) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Collection(java.util.Collection) EventPublisher(org.eclipse.smarthome.core.events.EventPublisher) OnOffType(org.eclipse.smarthome.core.library.types.OnOffType) ItemProvider(org.eclipse.smarthome.core.items.ItemProvider) Test(org.junit.Test) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) Item(org.eclipse.smarthome.core.items.Item) ScriptServiceUtil(org.eclipse.smarthome.model.script.ScriptServiceUtil) ItemRegistry(org.eclipse.smarthome.core.items.ItemRegistry) Lists(com.google.common.collect.Lists) Temperature(javax.measure.quantity.Temperature) Length(javax.measure.quantity.Length) QuantityType(org.eclipse.smarthome.core.library.types.QuantityType) After(org.junit.After) Assert(org.junit.Assert) State(org.eclipse.smarthome.core.types.State) NonNull(org.eclipse.jdt.annotation.NonNull) Before(org.junit.Before) ItemProvider(org.eclipse.smarthome.core.items.ItemProvider) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) EventPublisher(org.eclipse.smarthome.core.events.EventPublisher) ScriptServiceUtil(org.eclipse.smarthome.model.script.ScriptServiceUtil) Collection(java.util.Collection) ItemRegistry(org.eclipse.smarthome.core.items.ItemRegistry) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Before(org.junit.Before)

Aggregations

Collection (java.util.Collection)3 Item (org.eclipse.smarthome.core.items.Item)3 ItemProvider (org.eclipse.smarthome.core.items.ItemProvider)3 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)3 Before (org.junit.Before)3 Lists (com.google.common.collect.Lists)1 Length (javax.measure.quantity.Length)1 Temperature (javax.measure.quantity.Temperature)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ProviderChangeListener (org.eclipse.smarthome.core.common.registry.ProviderChangeListener)1 EventPublisher (org.eclipse.smarthome.core.events.EventPublisher)1 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)1 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)1 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)1 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)1 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)1 State (org.eclipse.smarthome.core.types.State)1 ScriptServiceUtil (org.eclipse.smarthome.model.script.ScriptServiceUtil)1 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1