@Test public void temperatureSensor() { KnxBus knxBus = new KnxBus(); KnxGroupAddress temperatureGroupAddress = knxBus.newGroupAddress(new KnxAddress("1.1.1"), "Temperature"); TemperatureSensor temperatureSensor = new TemperatureSensor("Temperatuur sensor", "Beschrijving", temperatureGroupAddress); temperatureGroupAddress.onValueChanged( new KnxValueChangedEvent(temperatureGroupAddress.getAddress(), 12.0)); Assert.assertEquals(12.0f, temperatureSensor.getTemperature()); }
@Test public void temperatureSensorListener() { KnxBus knxBus = new KnxBus(); KnxGroupAddress temperatureGroupAddress = knxBus.newGroupAddress(new KnxAddress("1.1.1"), "Temperature"); TemperatureSensor temperatureSensor = new TemperatureSensor("Temperatuur sensor", "Beschrijving", temperatureGroupAddress); DeviceListener deviceListener = Mockito.mock(DeviceListener.class); temperatureGroupAddress.setValue(12.0); temperatureSensor.register(deviceListener); temperatureGroupAddress.onValueChanged( new KnxValueChangedEvent(temperatureGroupAddress.getAddress(), 13.0)); Mockito.verify(deviceListener).onDeviceStateChanged(temperatureSensor); }