Search in sources :

Example 1 with ItemUpdatedEvent

use of org.eclipse.smarthome.core.items.events.ItemUpdatedEvent in project smarthome by eclipse.

the class GroupItemTest method testItemUpdateWithItemRegistry.

@Ignore
@Test
public void testItemUpdateWithItemRegistry() {
    GroupItem item = new GroupItem("mySimpleGroupItem");
    item.setLabel("firstLabel");
    itemRegistry.add(item);
    GroupItem updatedItem = (GroupItem) itemRegistry.get("mySimpleGroupItem");
    assertNotNull(updatedItem);
    events.clear();
    updatedItem.setLabel("secondLabel");
    itemRegistry.update(updatedItem);
    waitForAssert(() -> assertThat(events.size(), is(1)));
    List<Event> stateChanges = events.stream().filter(it -> it instanceof ItemUpdatedEvent).collect(Collectors.toList());
    assertThat(stateChanges.size(), is(1));
    ItemUpdatedEvent change = (ItemUpdatedEvent) stateChanges.get(0);
    assertThat(change.getItem().label, is("secondLabel"));
}
Also used : SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) CoreMatchers(org.hamcrest.CoreMatchers) MockitoAnnotations.initMocks(org.mockito.MockitoAnnotations.initMocks) RollershutterItem(org.eclipse.smarthome.core.library.items.RollershutterItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Mock(org.mockito.Mock) OnOffType(org.eclipse.smarthome.core.library.types.OnOffType) UnDefType(org.eclipse.smarthome.core.types.UnDefType) EventFilter(org.eclipse.smarthome.core.events.EventFilter) EventSubscriber(org.eclipse.smarthome.core.events.EventSubscriber) GroupFunctionDTO(org.eclipse.smarthome.core.items.dto.GroupFunctionDTO) GroupFunctionHelper(org.eclipse.smarthome.core.internal.items.GroupFunctionHelper) HashSet(java.util.HashSet) ColorItem(org.eclipse.smarthome.core.library.items.ColorItem) GroupItemStateChangedEvent(org.eclipse.smarthome.core.items.events.GroupItemStateChangedEvent) Temperature(javax.measure.quantity.Temperature) Quantity(javax.measure.Quantity) Pressure(javax.measure.quantity.Pressure) ItemStateConverterImpl(org.eclipse.smarthome.core.internal.items.ItemStateConverterImpl) QuantityType(org.eclipse.smarthome.core.library.types.QuantityType) CoreItemFactory(org.eclipse.smarthome.core.library.CoreItemFactory) StringType(org.eclipse.smarthome.core.library.types.StringType) LinkedList(java.util.LinkedList) State(org.eclipse.smarthome.core.types.State) Dimensionless(javax.measure.quantity.Dimensionless) Before(org.junit.Before) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) RefreshType(org.eclipse.smarthome.core.types.RefreshType) Set(java.util.Set) EventPublisher(org.eclipse.smarthome.core.events.EventPublisher) ItemUpdatedEvent(org.eclipse.smarthome.core.items.events.ItemUpdatedEvent) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) Collectors(java.util.stream.Collectors) RawType(org.eclipse.smarthome.core.library.types.RawType) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) List(java.util.List) HSBType(org.eclipse.smarthome.core.library.types.HSBType) Ignore(org.junit.Ignore) PercentType(org.eclipse.smarthome.core.library.types.PercentType) Units(tec.uom.se.unit.Units) ArithmeticGroupFunction(org.eclipse.smarthome.core.library.types.ArithmeticGroupFunction) UnitProvider(org.eclipse.smarthome.core.i18n.UnitProvider) DimmerItem(org.eclipse.smarthome.core.library.items.DimmerItem) Assert(org.junit.Assert) Event(org.eclipse.smarthome.core.events.Event) Collections(java.util.Collections) GroupItemStateChangedEvent(org.eclipse.smarthome.core.items.events.GroupItemStateChangedEvent) ItemUpdatedEvent(org.eclipse.smarthome.core.items.events.ItemUpdatedEvent) Event(org.eclipse.smarthome.core.events.Event) ItemUpdatedEvent(org.eclipse.smarthome.core.items.events.ItemUpdatedEvent) Ignore(org.junit.Ignore) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Quantity (javax.measure.Quantity)1 Dimensionless (javax.measure.quantity.Dimensionless)1 Pressure (javax.measure.quantity.Pressure)1 Temperature (javax.measure.quantity.Temperature)1 Event (org.eclipse.smarthome.core.events.Event)1 EventFilter (org.eclipse.smarthome.core.events.EventFilter)1 EventPublisher (org.eclipse.smarthome.core.events.EventPublisher)1 EventSubscriber (org.eclipse.smarthome.core.events.EventSubscriber)1 UnitProvider (org.eclipse.smarthome.core.i18n.UnitProvider)1 GroupFunctionHelper (org.eclipse.smarthome.core.internal.items.GroupFunctionHelper)1 ItemStateConverterImpl (org.eclipse.smarthome.core.internal.items.ItemStateConverterImpl)1 GroupFunctionDTO (org.eclipse.smarthome.core.items.dto.GroupFunctionDTO)1 GroupItemStateChangedEvent (org.eclipse.smarthome.core.items.events.GroupItemStateChangedEvent)1 ItemUpdatedEvent (org.eclipse.smarthome.core.items.events.ItemUpdatedEvent)1