Search in sources :

Example 1 with ScriptServiceUtil

use of org.eclipse.smarthome.model.script.ScriptServiceUtil 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

Lists (com.google.common.collect.Lists)1 Collection (java.util.Collection)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 Item (org.eclipse.smarthome.core.items.Item)1 ItemProvider (org.eclipse.smarthome.core.items.ItemProvider)1 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)1 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)1 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)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 After (org.junit.After)1