Search in sources :

Example 1 with DiscoveryServiceMock

use of org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMock in project smarthome by eclipse.

the class DiscoveryServiceRegistryOSGiTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    registerVolatileStorageService();
    thingRegistry = getService(ThingRegistry.class);
    assertNotNull(thingRegistry);
    inbox = getService(Inbox.class);
    assertNotNull(inbox);
    discoveryServiceMockForBinding1 = new DiscoveryServiceMock(new ThingTypeUID(ANY_BINDING_ID_1, ANY_THING_TYPE_1), 1);
    discoveryServiceMockForBinding2 = new ExtendedDiscoveryServiceMock(new ThingTypeUID(ANY_BINDING_ID_2, ANY_THING_TYPE_2), 3);
    discoveryServiceMockForBinding3Bridge1 = new DiscoveryServiceMockOfBridge(new ThingTypeUID(ANY_BINDING_ID_3, ANY_THING_TYPE_3), 1, BRIDGE_UID_1);
    discoveryServiceMockForBinding3Bridge2 = new DiscoveryServiceMockOfBridge(new ThingTypeUID(ANY_BINDING_ID_3, ANY_THING_TYPE_3), 1, BRIDGE_UID_2);
    discoveryServiceFaultyMock = new DiscoveryServiceMock(new ThingTypeUID(FAULTY_BINDING_ID, FAULTY_THING_TYPE), 1, true);
    extendedDiscoveryServiceMock = new ExtendedDiscoveryServiceMock(new ThingTypeUID(EXTENDED_BINDING_ID, EXTENDED_THING_TYPE), 1, true);
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), discoveryServiceMockForBinding1, null));
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), discoveryServiceMockForBinding2, null));
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), discoveryServiceMockForBinding3Bridge1, null));
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), discoveryServiceMockForBinding3Bridge2, null));
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), discoveryServiceFaultyMock, null));
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), extendedDiscoveryServiceMock, null));
    discoveryServiceRegistry = getService(DiscoveryServiceRegistry.class);
}
Also used : ExtendedDiscoveryServiceMock(org.eclipse.smarthome.config.setup.test.discovery.ExtendedDiscoveryServiceMock) DiscoveryServiceMockOfBridge(org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMockOfBridge) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Inbox(org.eclipse.smarthome.config.discovery.inbox.Inbox) ThingRegistry(org.eclipse.smarthome.core.thing.ThingRegistry) ExtendedDiscoveryServiceMock(org.eclipse.smarthome.config.setup.test.discovery.ExtendedDiscoveryServiceMock) DiscoveryServiceMock(org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMock) Before(org.junit.Before)

Example 2 with DiscoveryServiceMock

use of org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMock in project smarthome by eclipse.

the class DiscoveryServiceRegistryOSGiTest method testStartScan_twoDiscoveryServices.

@Test
public void testStartScan_twoDiscoveryServices() {
    ScanListener mockScanListener1 = mock(ScanListener.class);
    DiscoveryService anotherDiscoveryServiceMock = new DiscoveryServiceMock(new ThingTypeUID(ANY_BINDING_ID_1, ANY_THING_TYPE_1), 1);
    serviceRegs.add(bundleContext.registerService(DiscoveryService.class.getName(), anotherDiscoveryServiceMock, null));
    discoveryServiceRegistry.addDiscoveryListener(mockDiscoveryListener);
    discoveryServiceRegistry.startScan(new ThingTypeUID(ANY_BINDING_ID_1, ANY_THING_TYPE_1), mockScanListener1);
    waitForAssert(() -> mockScanListener1.onFinished(), 2000, DFL_SLEEP_TIME);
    verify(mockDiscoveryListener, times(2)).thingDiscovered(any(), any());
}
Also used : ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) ExtendedDiscoveryServiceMock(org.eclipse.smarthome.config.setup.test.discovery.ExtendedDiscoveryServiceMock) DiscoveryServiceMock(org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMock) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

DiscoveryServiceMock (org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMock)2 ExtendedDiscoveryServiceMock (org.eclipse.smarthome.config.setup.test.discovery.ExtendedDiscoveryServiceMock)2 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)2 Inbox (org.eclipse.smarthome.config.discovery.inbox.Inbox)1 DiscoveryServiceMockOfBridge (org.eclipse.smarthome.config.setup.test.discovery.DiscoveryServiceMockOfBridge)1 ThingRegistry (org.eclipse.smarthome.core.thing.ThingRegistry)1 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)1 Before (org.junit.Before)1 Test (org.junit.Test)1