Search in sources :

Example 1 with GenericItemChannelLinkProvider

use of org.eclipse.smarthome.model.thing.internal.GenericItemChannelLinkProvider in project smarthome by eclipse.

the class GenericItemChannelLinkProviderJavaTest method testNoAmnesia.

@SuppressWarnings("unchecked")
@Test
public void testNoAmnesia() throws Exception {
    GenericItemChannelLinkProvider provider = new GenericItemChannelLinkProvider();
    provider.addProviderChangeListener(listener);
    provider.startConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    provider.processBindingConfiguration(ITEMS_TESTMODEL_NAME, "Number", ITEM, CHANNEL, new Configuration());
    provider.stopConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    assertThat(provider.getAll().size(), is(1));
    assertThat(provider.getAll().iterator().next().toString(), is(LINK));
    verify(listener, only()).added(same(provider), eq(new ItemChannelLink(ITEM, new ChannelUID(CHANNEL))));
    reset(listener);
    provider.startConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    provider.processBindingConfiguration(ITEMS_TESTMODEL_NAME, "Number", ITEM, CHANNEL, new Configuration());
    provider.stopConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    assertThat(provider.getAll().size(), is(1));
    assertThat(provider.getAll().iterator().next().toString(), is(LINK));
    verify(listener, only()).updated(same(provider), eq(new ItemChannelLink(ITEM, new ChannelUID(CHANNEL))), eq(new ItemChannelLink(ITEM, new ChannelUID(CHANNEL))));
    reset(listener);
    provider.startConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    provider.stopConfigurationUpdate(ITEMS_TESTMODEL_NAME);
    assertThat(provider.getAll().size(), is(0));
    verify(listener, only()).removed(same(provider), eq(new ItemChannelLink(ITEM, new ChannelUID(CHANNEL))));
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) ItemChannelLink(org.eclipse.smarthome.core.thing.link.ItemChannelLink) GenericItemChannelLinkProvider(org.eclipse.smarthome.model.thing.internal.GenericItemChannelLinkProvider) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

Configuration (org.eclipse.smarthome.config.core.Configuration)1 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)1 ItemChannelLink (org.eclipse.smarthome.core.thing.link.ItemChannelLink)1 GenericItemChannelLinkProvider (org.eclipse.smarthome.model.thing.internal.GenericItemChannelLinkProvider)1 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)1 Test (org.junit.Test)1