Search in sources :

Example 1 with ItemRegistryImpl

use of org.eclipse.smarthome.core.internal.items.ItemRegistryImpl in project smarthome by eclipse.

the class ItemRegistryImplTest method assertCommandDescriptionServiceGetsRemoved.

@Test
public void assertCommandDescriptionServiceGetsRemoved() {
    CommandDescriptionService commandDescriptionService = mock(CommandDescriptionService.class);
    ((ItemRegistryImpl) itemRegistry).setCommandDescriptionService(commandDescriptionService);
    GenericItem item = spy(new SwitchItem("Item1"));
    itemProvider.add(item);
    verify(item).setCommandDescriptionService(any(CommandDescriptionService.class));
    ((ItemRegistryImpl) itemRegistry).unsetCommandDescriptionService(commandDescriptionService);
    verify(item).setCommandDescriptionService(null);
}
Also used : CommandDescriptionService(org.eclipse.smarthome.core.service.CommandDescriptionService) ItemRegistryImpl(org.eclipse.smarthome.core.internal.items.ItemRegistryImpl) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 2 with ItemRegistryImpl

use of org.eclipse.smarthome.core.internal.items.ItemRegistryImpl in project smarthome by eclipse.

the class ItemRegistryImplTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    ItemFactory coreItemFactory = new CoreItemFactory();
    GenericItem cameraItem1 = new SwitchItem(CAMERA_ITEM_NAME1);
    GenericItem cameraItem2 = new SwitchItem(CAMERA_ITEM_NAME2);
    GenericItem cameraItem3 = new NumberItem(CAMERA_ITEM_NAME3);
    GenericItem cameraItem4 = new NumberItem(CAMERA_ITEM_NAME4);
    cameraItem1.addTag(CAMERA_TAG);
    cameraItem2.addTag(CAMERA_TAG);
    cameraItem2.addTag(SENSOR_TAG);
    cameraItem3.addTag(CAMERA_TAG);
    cameraItem4.addTag(CAMERA_TAG_UPPERCASE);
    // setup ManageItemProvider with necessary dependencies:
    itemProvider = new ManagedItemProvider() {

        {
            setStorageService(new VolatileStorageService());
            addItemFactory(coreItemFactory);
        }
    };
    itemProvider.add(new SwitchItem(ITEM_NAME));
    itemProvider.add(cameraItem1);
    itemProvider.add(cameraItem2);
    itemProvider.add(cameraItem3);
    itemProvider.add(cameraItem4);
    // setup ItemRegistryImpl with necessary dependencies:
    itemRegistry = new ItemRegistryImpl() {

        {
            addProvider(itemProvider);
            setManagedProvider(itemProvider);
            setEventPublisher(ItemRegistryImplTest.this.eventPublisher);
            setStateDescriptionService(mock(StateDescriptionService.class));
            setUnitProvider(mock(UnitProvider.class));
            setItemStateConverter(mock(ItemStateConverter.class));
        }
    };
}
Also used : CoreItemFactory(org.eclipse.smarthome.core.library.CoreItemFactory) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) CoreItemFactory(org.eclipse.smarthome.core.library.CoreItemFactory) VolatileStorageService(org.eclipse.smarthome.test.storage.VolatileStorageService) ItemRegistryImpl(org.eclipse.smarthome.core.internal.items.ItemRegistryImpl) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Before(org.junit.Before)

Example 3 with ItemRegistryImpl

use of org.eclipse.smarthome.core.internal.items.ItemRegistryImpl in project smarthome by eclipse.

the class ItemRegistryImplTest method assertCommandDescriptionServiceGetsInjected.

@Test
public void assertCommandDescriptionServiceGetsInjected() {
    GenericItem item = spy(new SwitchItem("Item1"));
    itemProvider.add(item);
    verify(item).setCommandDescriptionService(null);
    ((ItemRegistryImpl) itemRegistry).setCommandDescriptionService(mock(CommandDescriptionService.class));
    verify(item).setCommandDescriptionService(any(CommandDescriptionService.class));
}
Also used : CommandDescriptionService(org.eclipse.smarthome.core.service.CommandDescriptionService) ItemRegistryImpl(org.eclipse.smarthome.core.internal.items.ItemRegistryImpl) SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Aggregations

ItemRegistryImpl (org.eclipse.smarthome.core.internal.items.ItemRegistryImpl)3 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)3 CommandDescriptionService (org.eclipse.smarthome.core.service.CommandDescriptionService)2 JavaTest (org.eclipse.smarthome.test.java.JavaTest)2 Test (org.junit.Test)2 CoreItemFactory (org.eclipse.smarthome.core.library.CoreItemFactory)1 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)1 VolatileStorageService (org.eclipse.smarthome.test.storage.VolatileStorageService)1 Before (org.junit.Before)1