]> git.basschouten.com Git - openhab-addons.git/commitdiff
Migrate tests to JUnit 5 (#8519)
authorWouter Born <github@maindrain.net>
Mon, 21 Sep 2020 16:21:26 +0000 (18:21 +0200)
committerGitHub <noreply@github.com>
Mon, 21 Sep 2020 16:21:26 +0000 (18:21 +0200)
Signed-off-by: Wouter Born <github@maindrain.net>
478 files changed:
bundles/org.openhab.binding.astro/src/test/java/org/openhab/binding/astro/internal/calc/SunCalcTest.java
bundles/org.openhab.binding.astro/src/test/java/org/openhab/binding/astro/internal/model/SunTest.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/actions/AVMFritzHeatingActionsTest.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzTemplateListModelTest.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/HeatingModelTest.java
bundles/org.openhab.binding.bluetooth.airthings/src/test/java/org/openhab/binding/bluetooth/airthings/AirthingsWavePlusParserTest.java
bundles/org.openhab.binding.bluetooth.am43/src/test/java/org/openhab/binding/bluetooth/am43/CommandTest.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/test/java/org/openhab/binding/bluetooth/bluegiga/internal/attributeclient/BlueGigaFindInformationFoundEventTest.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/test/java/org/openhab/binding/bluetooth/bluegiga/internal/eir/EirRecordTest.java
bundles/org.openhab.binding.bluetooth.daikinmadoka/src/test/java/org/openhab/binding/bluetooth/daikinmadoka/internal/MadokaMessageTest.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/BluetoothAddressTest.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryServiceTest.java
bundles/org.openhab.binding.bsblan/src/test/java/org/openhab/binding/bsblan/internal/BsbLanHandlerFactoryTests.java
bundles/org.openhab.binding.bsblan/src/test/java/org/openhab/binding/bsblan/internal/api/BsbLanApiContentConverterTests.java
bundles/org.openhab.binding.bsblan/src/test/java/org/openhab/binding/bsblan/internal/helper/BsbLanParameterConverterTests.java
bundles/org.openhab.binding.buienradar/src/test/java/org/openhab/binding/buienradar/BuienradarPredictionAPITest.java
bundles/org.openhab.binding.danfossairunit/src/test/java/org/openhab/binding/danfossairunit/internal/ValueCacheTest.java
bundles/org.openhab.binding.darksky/src/test/java/org/openhab/binding/darksky/internal/utils/ByteArrayFileCacheTest.java
bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/DeconzTest.java
bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java
bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/SensorsTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/FadeActionTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/UtilTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/ValueSetTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/ArtnetBridgeHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/ChaserThingHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/ColorThingHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/DimmerThingHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/DmxBridgeHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/Lib485BridgeHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/SacnBridgeHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandlerTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/multiverse/BaseChannelTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/internal/multiverse/DmxChannelTest.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/test/AbstractDmxThingTestParent.java
bundles/org.openhab.binding.doorbird/src/test/java/org/openhab/binding/doorbird/internal/DoorbirdInfoTest.java
bundles/org.openhab.binding.doorbird/src/test/java/org/openhab/binding/doorbird/internal/SipStatusTest.java
bundles/org.openhab.binding.draytonwiser/src/test/java/org/openhab/binding/draytonwiser/internal/discovery/DraytonWiserDiscoveryServiceTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/TelegramReaderUtil.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDeviceTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/SmartyDecrypterTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/p1telegram/P1TelegramParserTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDetectorTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryServiceTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/meter/DSMRMeterTest.java
bundles/org.openhab.binding.dwdunwetter/src/test/java/org/openhab/binding/dwdunwetter/DwdUnwetterHandlerTest.java
bundles/org.openhab.binding.dwdunwetter/src/test/java/org/openhab/binding/dwdunwetter/internal/data/DwdWarningCacheTest.java
bundles/org.openhab.binding.dwdunwetter/src/test/java/org/openhab/binding/dwdunwetter/internal/data/DwdWarningsDataTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/actions/Enigma2ActionsTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/handler/Enigma2HandlerTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/internal/Enigma2ClientTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/internal/Enigma2HandlerFactoryTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/internal/Enigma2RemoteKeyTest.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/internal/discovery/Enigma2DiscoveryParticipantTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/AbstractFMIResponseParsingTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIRequestTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIResponseParsingEmptyTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIResponseParsingExceptionReportTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIResponseParsingInvalidOrUnexpectedXmlTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIResponseParsingMultiplePlacesTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIResponseParsingSinglePlaceTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/ParsingStationsTest.java
bundles/org.openhab.binding.foobot/src/test/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandlerTest.java
bundles/org.openhab.binding.foobot/src/test/java/org/openhab/binding/foobot/internal/handler/FoobotDeviceHandlerTest.java
bundles/org.openhab.binding.freebox/src/test/java/org/openhab/binding/freebox/internal/api/FreeboxApiManagerTest.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/FSInternetRadioDiscoveryParticipantJavaTest.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/FSInternetRadioHandlerJavaTest.java
bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/HDPowerViewJUnitTests.java
bundles/org.openhab.binding.heos/src/test/java/org/openhab/binding/heos/internal/json/HeosJsonParserEventTest.java
bundles/org.openhab.binding.heos/src/test/java/org/openhab/binding/heos/internal/json/HeosJsonParserResponseTest.java
bundles/org.openhab.binding.heos/src/test/java/org/openhab/binding/heos/internal/json/dto/HeosCommandTupleTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/communicator/client/RpcClientTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/communicator/virtual/ButtonDatapointTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/converter/BaseConverterTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/converter/ConvertFromBindingTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/converter/ConvertToBindingTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/converter/ConverterFactoryTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/discovery/HomematicDeviceDiscoveryServiceTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/handler/SimplePortPoolTest.java
bundles/org.openhab.binding.homematic/src/test/java/org/openhab/binding/homematic/internal/type/UidUtilsTest.java
bundles/org.openhab.binding.hue/src/test/java/org/openhab/binding/hue/internal/ApiVersionTest.java
bundles/org.openhab.binding.hue/src/test/java/org/openhab/binding/hue/internal/HueBridgeTest.java
bundles/org.openhab.binding.hue/src/test/java/org/openhab/binding/hue/internal/LightStateConverterTest.java
bundles/org.openhab.binding.hue/src/test/java/org/openhab/binding/hue/internal/SceneTest.java
bundles/org.openhab.binding.hue/src/test/java/org/openhab/binding/hue/internal/handler/HueLightHandlerTest.java
bundles/org.openhab.binding.icalendar/src/test/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendarTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ButtonPressDurationDetectorTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/SignalLevelConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DateTimeTypeWSDateValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DateTimeTypeWSTimeValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSBooleanValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSEnumValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSFloatingPointValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSIntegerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSTimerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/DecimalTypeWSWeekdayValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/OnOffTypeWSBooleanValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/OnOffTypeWSIntegerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/OpenClosedTypeWSBooleanValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/OpenClosedTypeWSIntegerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/PercentTypeWSIntegerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/StringTypeWSEnumValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/UpDownTypeWSBooleanValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/converters/UpDownTypeWSIntegerValueConverterTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/IhcClientTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/ResourceFileUtils.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcAirlinkManagementServiceTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcAuthenticationServiceTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcConfigurationServiceTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcControllerServiceTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcResourceInteractionServiceTest.java
bundles/org.openhab.binding.ihc/src/test/java/org/openhab/binding/ihc/internal/ws/services/IhcTimeServiceTest.java
bundles/org.openhab.binding.innogysmarthome/src/test/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocketTest.java
bundles/org.openhab.binding.innogysmarthome/src/test/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandlerTest.java
bundles/org.openhab.binding.knx/src/test/java/org/openhab/binding/knx/internal/channel/KNXChannelTypeTest.java
bundles/org.openhab.binding.knx/src/test/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapperTest.java
bundles/org.openhab.binding.kodi/src/test/java/org/openhab/binding/kodi/internal/utils/ByteArrayFileCacheTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/impl/FileIconTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImplIT.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ActionTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ApplicationTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/AudioTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/BluetoothTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/FrameTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/GoalDataTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/UpdateActionTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetUpdatesTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/BrightnessModeTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/DisplayTypeTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IconTypeTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IpModeTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/PriorityTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundCategoryTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundTest.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/WifiEncryptionTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/ModuleActionsTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/pchkdiscovery/LcnPchkDiscoveryServiceTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/AbstractTestLcnModuleSubHandler.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleBinarySensorSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleHostCommandSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleKeyLockTableSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleLedSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleLogicSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleOutputSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRelaySubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRollershutterOutputSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRollershutterRelaySubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarLockSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleRvarSetpointSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleS0CounterSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleThresholdSubHandlerTest.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/subhandler/LcnModuleVariableSubHandlerTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlAlarmNoPresenceTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlAlarmWithPresenceTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlDimmerTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlIRoomControllerV2Test.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlInfoOnlyAnalogTempTagTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlInfoOnlyAnalogTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlInfoOnlyDigitalTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlJalousieTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlLeftRightAnalogTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlLeftRightDigitalTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlLightControllerV2Test.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlMeterTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlPushbuttonTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlRadioTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlRadioTest2.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlSliderTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlSwitchTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlTextStateTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlTimedSwitchTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlTrackerTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlUpDownAnalogTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlUpDownDigitalTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlValueSelectorIncrTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlValueSelectorTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxControlWebPageTest.java
bundles/org.openhab.binding.loxone/src/test/java/org/openhab/binding/loxone/internal/controls/LxServerHandlerDummy.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/ConditionHandlerTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/DTOTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/HTTPHandlerEvalTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/HTTPHandlerValueTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/NoiseHandlerTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/NumberTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/PMHandlerTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/util/DateTimeTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/util/FileReader.java
bundles/org.openhab.binding.mail/src/test/java/org/openhab/binding/mail/MailBuilderTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/FCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/MCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/SCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/SConfigCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/TCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/command/ZCommandTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/CMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/ConfigurationTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/FMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/HMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/LMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/MMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/MessageProcessorTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/NMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/SMessageTest.java
bundles/org.openhab.binding.max/src/test/java/org/openhab/binding/max/internal/message/UtilsTest.java
bundles/org.openhab.binding.miio/src/test/java/org/openhab/binding/miio/internal/ActionConditionTest.java
bundles/org.openhab.binding.miio/src/test/java/org/openhab/binding/miio/internal/ReadmeHelper.java
bundles/org.openhab.binding.miio/src/test/java/org/openhab/binding/miio/internal/RoboMapViewer.java
bundles/org.openhab.binding.miio/src/test/java/org/openhab/binding/miio/internal/UtilsTest.java
bundles/org.openhab.binding.millheat/src/test/java/org/openhab/binding/millheat/internal/MillHeatAccountHandlerTest.java
bundles/org.openhab.binding.modbus.e3dc/src/test/java/org/openhab/binding/modbus/e3dc/dto/DataBlockTest.java
bundles/org.openhab.binding.modbus.e3dc/src/test/java/org/openhab/binding/modbus/e3dc/dto/InfoTest.java
bundles/org.openhab.binding.modbus.e3dc/src/test/java/org/openhab/binding/modbus/e3dc/internal/handler/E3DCHandlerStateTest.java
bundles/org.openhab.binding.modbus.e3dc/src/test/java/org/openhab/binding/modbus/e3dc/modbus/ParserNameTest.java
bundles/org.openhab.binding.modbus.e3dc/src/test/java/org/openhab/binding/modbus/e3dc/util/DataConverterTest.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/AtomicStampedKeyValueTest.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/ChannelStateTests.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/ChannelStateTransformationTests.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/internal/handler/GenericThingHandlerTests.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/SubscribeFieldToMQTTtopicTests.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/values/ValueTests.java
bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/HAConfigurationTests.java
bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/HaIDTests.java
bundles/org.openhab.binding.mqtt.homie/src/test/java/org/openhab/binding/mqtt/homie/generic/internal/mapping/HomieChildMapTests.java
bundles/org.openhab.binding.mqtt.homie/src/test/java/org/openhab/binding/mqtt/homie/internal/handler/HomieThingHandlerTests.java
bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandlerTest.java
bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/handler/BrokerHandlerTest.java
bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/internal/discovery/ServiceDiscoveryServiceTest.java
bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/internal/ssl/PinningSSLContextProviderTest.java
bundles/org.openhab.binding.nanoleaf/src/test/java/org/openhab/binding/nanoleaf/internal/LayoutTest.java
bundles/org.openhab.binding.nanoleaf/src/test/java/org/openhab/binding/nanoleaf/internal/TouchTest.java
bundles/org.openhab.binding.nanoleaf/src/test/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandlerTest.java
bundles/org.openhab.binding.neohub/src/test/java/org/openhab/binding/neohub/test/NeoHubTestData.java
bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/discovery/NetatmoModuleDiscoveryServiceTest.java
bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/presence/NAPresenceCameraHandlerTest.java
bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandlerTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/PresenceDetectionTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/PresenceDetectionValuesTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/WakeOnLanPacketSenderTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/dhcp/DHCPTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/discovery/DiscoveryTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/handler/NetworkHandlerTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/toberemoved/cache/ExpiringCacheAsyncTest.java
bundles/org.openhab.binding.network/src/test/java/org/openhab/binding/network/internal/utils/LatencyParserTest.java
bundles/org.openhab.binding.networkupstools/src/test/java/org/openhab/binding/networkupstools/internal/NutNameChannelsTest.java
bundles/org.openhab.binding.networkupstools/src/test/java/org/openhab/binding/networkupstools/internal/NutNameTest.java
bundles/org.openhab.binding.networkupstools/src/test/java/org/openhab/binding/networkupstools/internal/nut/NutApiTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/handler/NibeHeatPumpHandlerCommand2NibeTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/handler/NibeHeatPumpHandlerNibe2StateTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/ModbusDataReadOutMessageTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/ModbusReadRequestMessageTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/ModbusReadResponseMessageTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/ModbusWriteRequestMessageTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/ModbusWriteResponseMessageTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/message/NibeHeatPumpProtocolTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/models/PumpModelTest.java
bundles/org.openhab.binding.nibeheatpump/src/test/java/org/openhab/binding/nibeheatpump/internal/models/VariableInformationTest.java
bundles/org.openhab.binding.omnikinverter/src/test/java/org/openhab/binding/omnikinverter/internal/test/OmnikInverterMessageTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/CompletenessTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/OwserverDeviceParameterTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/SensorIdTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/UtilTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/BAE0910Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS18x20Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS1923Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2401Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2405Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2406_DS2413Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2408Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2423Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DS2438Test.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/DeviceTestParent.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/device/EDS006xTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/internal/BasicThingHandlerTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/internal/EDSSensorThingHandlerTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/internal/MultisensorThingHandlerTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/internal/OwserverBridgeHandlerTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/owserver/OwserverConnectionTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/test/AbstractThingHandlerTest.java
bundles/org.openhab.binding.onewire/src/test/java/org/openhab/binding/onewire/test/OwserverTestServer.java
bundles/org.openhab.binding.paradoxalarm/src/test/java/tests/TestCreateCommandPayload.java
bundles/org.openhab.binding.paradoxalarm/src/test/java/tests/TestEncryptionHandler.java
bundles/org.openhab.binding.paradoxalarm/src/test/java/tests/TestGetBytes.java
bundles/org.openhab.binding.paradoxalarm/src/test/java/tests/TestParadoxUtil.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBBQTemperatureMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBarometricMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComBlinds1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCamera1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComChimeMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentEnergyMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurrentMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComCurtain1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComDateTimeMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEdisioTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComEnergyMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFS20MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanFalmecMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDc2MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDcMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComGasMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHomeConfortTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComHumidityMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComIOLinesMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceControlMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComInterfaceMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComInvalidMessageTypeTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting3MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting4MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting6MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComPowerMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXMeterMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRadiator1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRainMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRemoteControlMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComRfyMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComSecurity2MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityBarometricMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureHumidityMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTemperatureRainMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTestHelper.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat1MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat2MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat3MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComThermostat4MessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComTransmitterMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUVMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComUndecodedRFMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWaterMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWeightMessageTest.java
bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComWindMessageTest.java
bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/RobonectClientTest.java
bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/handler/RobonectHandlerTest.java
bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/WireHelper.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/dto/GetPodDetailsResponseTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/dto/GetPodsResponseTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/dto/SetAcStatePropertyRequestTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/dto/SetAcStatePropertyResponseTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/dto/SetTimerRequestTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/handler/SensiboAccountHandlerTest.java
bundles/org.openhab.binding.sensibo/src/test/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandlerTest.java
bundles/org.openhab.binding.siemensrds/src/test/java/org/openhab/binding/siemensrds/test/RdsTestData.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/java/org/openhab/binding/sleepiq/api/impl/typeadapters/LocalTimeTypeAdapter.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/java/org/openhab/binding/sleepiq/api/impl/typeadapters/OffsetDateTimeTypeAdapter.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/java/org/openhab/binding/sleepiq/api/impl/typeadapters/OffsetTimeTypeAdapter.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/java/org/openhab/binding/sleepiq/api/impl/typeadapters/TemporalTypeAdapter.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/java/org/openhab/binding/sleepiq/api/impl/typeadapters/ZonedDateTimeTypeAdapter.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/BedSideStatusTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/BedStatusTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/BedTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/BedsResponseTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/FamilyStatusTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/PauseModeTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/SleeperTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/SleepersResponseTest.java
bundles/org.openhab.binding.sleepiq/src/3rdparty/test/org/openhab/binding/sleepiq/api/model/TimeSinceTest.java
bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestMeterReading.java
bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestNegateBit.java
bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/AbstractSnmpTargetHandlerTest.java
bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/SnmpTargetHandlerTest.java
bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/StringChannelTest.java
bundles/org.openhab.binding.snmp/src/test/java/org/openhab/binding/snmp/internal/SwitchChannelTest.java
bundles/org.openhab.binding.teleinfo/src/test/java/org/openhab/binding/teleinfo/internal/reader/io/TeleinfoInputStreamTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/CryptUtilTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/PropertiesCollectorTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeDiscoveryServiceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactoryTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/DeviceTestBase.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/DimmerDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/EncodingTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/EnergySwitchDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/PowerStripDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/RangeExtenderDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/device/SwitchDeviceTest.java
bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandlerTest.java
bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/TradfriColorTest.java
bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryServiceTest.java
bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java
bundles/org.openhab.binding.upb/src/test/java/org/openhab/binding/upb/internal/message/MessageBuilderTest.java
bundles/org.openhab.binding.wifiled/src/test/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTOTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/YamahaReceiverHandlerTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/XMLProtocolFactoryTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/AbstractXMLProtocolTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/AbstractZoneControlXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/DeviceDescriptorXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/DeviceInformationXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputConverterXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithPlayControlXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithPresetControlXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/SystemControlXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/ZoneBControlXMLTest.java
bundles/org.openhab.binding.yamahareceiver/src/test/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/ZoneControlXMLTest.java
bundles/org.openhab.binding.yeelight/src/test/java/org/openhab/binding/yeelight/internal/YeelightHandlerFactoryTest.java
bundles/org.openhab.binding.yeelight/src/test/java/org/openhab/binding/yeelight/internal/lib/device/DeviceBaseTest.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/automation/RuleConditionHandlerTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/CommonSetup.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/ItemUIDtoHueIDMappingTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/LightsAndGroupsTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/RulesTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/SceneTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/ScheduleTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/SensorTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/UsersAndConfigTests.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/upnp/UpnpTests.java
bundles/org.openhab.io.mqttembeddedbroker/src/test/java/org/openhab/io/mqttembeddedbroker/internal/MqttEmbeddedBrokerServiceTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/BasicBitArrayTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/BitUtilitiesCommandToRegistersTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/BitUtilitiesExtractStringFromRegistersTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/BitUtilitiesTranslateCommand2BooleanTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/IntegrationTestSupport.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/ModbusSlaveEndpointTestCase.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/SmokeTest.java
bundles/org.openhab.io.transport.modbus/src/test/java/org/openhab/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java
bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractTwoItemIntegrationTest.java
bundles/org.openhab.transform.jinja/src/test/java/org/openhab/transform/jinja/internal/JinjaTransformationServiceTest.java
bundles/org.openhab.transform.jsonpath/src/test/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationServiceTest.java
bundles/org.openhab.transform.map/src/test/java/org/openhab/transform/map/internal/MapTransformationServiceTest.java
bundles/org.openhab.transform.regex/src/test/java/org/openhab/transform/regex/internal/RegExTransformationServiceTest.java
bundles/org.openhab.transform.scale/src/test/java/org/openhab/transform/scale/internal/ScaleTransformServiceTest.java
bundles/org.openhab.transform.xpath/src/test/java/org/openhab/transform/xpath/internal/XPathTransformationServiceTest.java
bundles/org.openhab.transform.xslt/src/test/java/org/openhab/transform/xslt/internal/XsltTransformationServiceTest.java
bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/MacTTSVoiceTest.java
bundles/org.openhab.voice.mactts/src/test/java/org/openhab/voice/mactts/internal/TTSServiceMacOSTest.java
itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroCommandTest.java
itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java
itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/test/AstroStateTest.java
itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryServiceOSGiTest.java
itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzThingHandlerOSGiTest.java
itests/org.openhab.binding.feed.tests/src/main/java/org/openhab/binding/feed/test/FeedHandlerTest.java
itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/AbstractHueOSGiTestParent.java
itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/HueLightDiscoveryServiceOSGiTest.java
itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/discovery/HueBridgeDiscoveryParticipantOSGITest.java
itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/discovery/HueBridgeNupnpDiscoveryOSGITest.java
itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/handler/HueBridgeHandlerOSGiTest.java
itests/org.openhab.binding.max.tests/src/main/java/org/openhab/binding/max/test/MaxCubeBridgeHandlerOSGiTest.java
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/ModbusDataHandlerTest.java
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/ModbusPollerThingHandlerTest.java
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/ModbusTcpThingHandlerTest.java
itests/org.openhab.binding.mqtt.homeassistant.tests/pom.xml
itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/DiscoverComponentsTest.java
itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/EmbeddedBrokerTools.java
itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/HomeAssistantMQTTImplementationTest.java
itests/org.openhab.binding.mqtt.homie.tests/pom.xml
itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/EmbeddedBrokerTools.java
itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/HomieImplementationTest.java
itests/org.openhab.binding.ntp.tests/src/main/java/org/openhab/binding/ntp/test/NtpOSGiTest.java
itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java
itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryParticipantOSGITest.java
itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriHandlerOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryParticipantTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoLinkDiscoveryServiceOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/handler/test/WemoHandlerOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/handler/test/WemoHandlerTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/handler/test/WemoLightHandlerOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/handler/test/WemoMakerHandlerOSGiTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/test/GenericWemoLightOSGiTestParent.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/test/GenericWemoOSGiTest.java
itests/org.openhab.io.mqttembeddedbroker.tests/pom.xml
itests/org.openhab.io.mqttembeddedbroker.tests/src/main/java/org/openhab/io/mqttembeddedbroker/EmbeddedBrokerTools.java
itests/org.openhab.io.mqttembeddedbroker.tests/src/main/java/org/openhab/io/mqttembeddedbroker/MoquetteTest.java

index 3609f9554fc89aafd2546111adaaa66ddb14d1f4..928947bb1e68e51ff3135b1f225d2da8c6b14eb7 100644 (file)
  */
 package org.openhab.binding.astro.internal.calc;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.TimeZone;
 
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.astro.internal.model.Sun;
 import org.openhab.binding.astro.internal.model.SunPhaseName;
 
@@ -51,7 +51,7 @@ public class SunCalcTest {
 
     private SunCalc sunCalc;
 
-    @Before
+    @BeforeEach
     public void init() {
         sunCalc = new SunCalc();
     }
@@ -178,7 +178,7 @@ public class SunCalcTest {
     }
 
     @Test
-    @Ignore
+    @Disabled
     public void testRangesForCoherenceBetweenNightEndAndAstroDawnStart() {
         Sun sun = sunCalc.getSunInfo(FEB_27_2019, AMSTERDAM_LATITUDE, AMSTERDAM_LONGITUDE, AMSTERDAM_ALTITUDE, false);
 
index 387a6ab0ca857a5a38e92dcc2ef050af59493b22..a0d16972f11e54bccdacf28f8a46770d54973e3b 100644 (file)
  */
 package org.openhab.binding.astro.internal.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.ZoneId;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.astro.internal.config.AstroChannelConfig;
 import org.openhab.binding.astro.internal.util.PropertyUtils;
 import org.openhab.core.library.types.StringType;
@@ -39,7 +39,7 @@ public class SunTest {
 
     private static ZoneId ZONE = ZoneId.systemDefault();
 
-    @Before
+    @BeforeEach
     public void init() {
         sun = new Sun();
         config = new AstroChannelConfig();
@@ -68,13 +68,14 @@ public class SunTest {
                 PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE));
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testGetStateWhenNullPhase() throws Exception {
         sun.setPhase(null);
 
         assertNull(sun.getPhase());
-        assertEquals(UnDefType.UNDEF,
-                PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE));
+
+        assertThrows(NullPointerException.class, () -> assertEquals(UnDefType.UNDEF,
+                PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE)));
     }
 
     @Test
index e044d590fc139299917fb1e4397667fd5ff88b45..a18edccc47b347c28d6882beb3ad96f70f9f6f20 100644 (file)
  */
 package org.openhab.binding.avmfritz.actions;
 
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.avmfritz.internal.handler.AVMFritzHeatingActionsHandler;
 import org.openhab.core.thing.binding.ThingActions;
 import org.openhab.core.thing.binding.ThingHandler;
@@ -26,6 +28,7 @@ import org.openhab.core.thing.binding.ThingHandler;
  *
  * @author Christoph Weitkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class AVMFritzHeatingActionsTest {
 
     private final ThingActions thingActionsStub = new ThingActions() {
@@ -43,32 +46,32 @@ public class AVMFritzHeatingActionsTest {
 
     private AVMFritzHeatingActions heatingActions;
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
-
         heatingActions = new AVMFritzHeatingActions();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetBoostModeThingActionsIsNull() {
-        AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetBoostModeThingActionsIsNotPushoverThingActions() {
-        AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetBoostModeThingHandlerIsNull() {
-        AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetBoostModeDurationNull() {
         heatingActions.setThingHandler(heatingActionsHandler);
-        AVMFritzHeatingActions.setBoostMode(heatingActions, null);
+        assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(heatingActions, null));
     }
 
     @Test
@@ -77,25 +80,29 @@ public class AVMFritzHeatingActionsTest {
         AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetWindowOpenModeThingActionsIsNull() {
-        AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() {
-        AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetWindowOpenModeThingHandlerIsNull() {
-        AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L));
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSetWindowOpenModeDurationNull() {
         heatingActions.setThingHandler(heatingActionsHandler);
-        AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null);
+        assertThrows(IllegalArgumentException.class,
+                () -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null));
     }
 
     @Test
index 05f12bc7b730d4f09d27117642b4389177d42695..b5ce63c9f2aac3ddf17beeef48b9693888db2ff3 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.avmfritz.internal.dto;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
 
 import java.io.StringReader;
@@ -23,8 +23,8 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.avmfritz.internal.util.JAXBUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@ public class AVMFritzDeviceListModelTest {
 
     private @NonNullByDefault({}) DeviceListModel devices;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         //@formatter:off
         String xml =
index 6f333090e915fce889a134361321a54c0b23ee17..63255bde9312c8178a27d39b4f10f60430435a8e 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.avmfritz.internal.dto;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.StringReader;
 import java.util.Optional;
@@ -21,8 +21,8 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.avmfritz.internal.dto.templates.TemplateListModel;
 import org.openhab.binding.avmfritz.internal.dto.templates.TemplateModel;
 import org.openhab.binding.avmfritz.internal.util.JAXBUtils;
@@ -41,7 +41,7 @@ public class AVMFritzTemplateListModelTest {
 
     private @NonNullByDefault({}) TemplateListModel templates;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         //@formatter:off
         String xml =
index af7bf9ea4a35d66da92f5d9fbd653e3f1c396bfa..361bd55dd06612a00488463e30cd26dc078a1ef2 100644 (file)
  */
 package org.openhab.binding.avmfritz.internal.dto;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.math.BigDecimal;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link HeatingModel} methods.
index 6b2f760a2aed73616f102d78c6e91d0734b5c840..a24a9c44afb7a4c98eaa94a368bc28f5409890a1 100644 (file)
  */
 package org.openhab.binding.bluetooth.airthings;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bluetooth.airthings.internal.AirthingsParserException;
 import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataParser;
 
@@ -27,22 +27,22 @@ import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataPar
 @NonNullByDefault
 public class AirthingsWavePlusParserTest {
 
-    @Test(expected = AirthingsParserException.class)
-    public void testWrongVersion() throws AirthingsParserException {
+    @Test
+    public void testWrongVersion() {
         int[] data = { 5, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0, 0, 4, 20 };
-        new AirthingsWavePlusDataParser(data);
+        assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
     }
 
-    @Test(expected = AirthingsParserException.class)
-    public void testEmptyData() throws AirthingsParserException {
+    @Test
+    public void testEmptyData() {
         int[] data = {};
-        new AirthingsWavePlusDataParser(data);
+        assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
     }
 
-    @Test(expected = AirthingsParserException.class)
+    @Test
     public void testWrongDataLen() throws AirthingsParserException {
         int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0 };
-        new AirthingsWavePlusDataParser(data);
+        assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
     }
 
     @Test
index a8b232664d969041e0ccef328dd958ef2bef42ca..a455da00c4ae6c9e9fdc9491b79442e8e9861b1e 100644 (file)
  */
 package org.openhab.binding.bluetooth.am43;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bluetooth.am43.internal.command.ControlCommand;
 import org.openhab.binding.bluetooth.am43.internal.command.GetAllCommand;
 import org.openhab.binding.bluetooth.am43.internal.data.ControlAction;
@@ -31,7 +32,7 @@ public class CommandTest {
     public void findAllCommandTest() {
         byte[] expected = HexUtils.hexToBytes("00ff00009aa701013d");
         byte[] actual = new GetAllCommand().getRequest();
-        Assert.assertArrayEquals(expected, actual);
+        assertArrayEquals(expected, actual);
     }
 
     @Test
@@ -39,7 +40,7 @@ public class CommandTest {
         byte[] expected = HexUtils.hexToBytes("00ff00009a0a01cc5d");
         byte[] actual = new ControlCommand(ControlAction.STOP).getRequest();
 
-        Assert.assertArrayEquals(expected, actual);
+        assertArrayEquals(expected, actual);
     }
 
     @Test
@@ -47,6 +48,6 @@ public class CommandTest {
         byte[] expected = HexUtils.hexToBytes("00ff00009a0a01dd4c");
         byte[] actual = new ControlCommand(ControlAction.OPEN).getRequest();
 
-        Assert.assertArrayEquals(expected, actual);
+        assertArrayEquals(expected, actual);
     }
 }
index d7e5cfe94371a7a6616f9a175e470c83c1f01029..1498bd745fe82a260f3b4c19f71511d04885fe1e 100644 (file)
  */
 package org.openhab.binding.bluetooth.bluegiga.internal.attributeclient;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bluetooth.bluegiga.internal.command.attributeclient.BlueGigaFindInformationFoundEvent;
 
 /**
index 8b9cdf4cb83840ca4c426dd29e84e586bf0d557d..406dadf7c4e334804caf200738d20ec6ee44fef9 100644 (file)
  */
 package org.openhab.binding.bluetooth.bluegiga.internal.eir;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests {@link EirRecord}.
index aecdad1d9ebf3c485c93c92c6a78b31411414c2b..20e831881933d5afc74dfad637b9a5e234562229 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.bluetooth.daikinmadoka.internal;
 
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue;
 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetIndoorOutoorTemperatures;
index b4fe82408d272609bc76d0b463e72fee3943efd0..26384efb15994e64cf607f078a67cadb15fece73 100644 (file)
@@ -12,7 +12,9 @@
  */
 package org.openhab.binding.bluetooth;
 
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests {@link BluetoothAddress}.
@@ -21,14 +23,14 @@ import org.junit.Test;
  */
 public class BluetoothAddressTest {
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testConstructorWithNullParam() {
-        new BluetoothAddress(null);
+        assertThrows(IllegalArgumentException.class, () -> new BluetoothAddress(null));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testConstructorWithoutColons() {
-        new BluetoothAddress("123456789ABC");
+        assertThrows(IllegalArgumentException.class, () -> new BluetoothAddress("123456789ABC"));
     }
 
     @Test
index 2345caccf0659213753139e47fd526e3efac9c75..07b85168206f72f9c86a0f0b0f7b6cf01b16e468 100644 (file)
@@ -13,6 +13,8 @@
 package org.openhab.binding.bluetooth.discovery.internal;
 
 import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Collections;
 import java.util.List;
@@ -25,16 +27,18 @@ import org.apache.commons.lang.RandomStringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.bluetooth.BluetoothAdapter;
 import org.openhab.binding.bluetooth.BluetoothAddress;
 import org.openhab.binding.bluetooth.BluetoothBindingConstants;
@@ -59,8 +63,10 @@ import org.slf4j.LoggerFactory;
  *
  * @author Connor Petty - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
-@RunWith(MockitoJUnitRunner.class)
+@Disabled("Needs to be updated for OH3")
 public class BluetoothDiscoveryServiceTest {
 
     private static final int TIMEOUT = 2000;
@@ -69,13 +75,10 @@ public class BluetoothDiscoveryServiceTest {
 
     private @NonNullByDefault({}) BluetoothDiscoveryService discoveryService;
 
-    @Spy
-    private @NonNullByDefault({}) MockDiscoveryParticipant participant1 = new MockDiscoveryParticipant();
+    private @Spy @NonNullByDefault({}) MockDiscoveryParticipant participant1 = new MockDiscoveryParticipant();
+    private @Mock @NonNullByDefault({}) DiscoveryListener mockDiscoveryListener;
 
-    @Mock
-    private @NonNullByDefault({}) DiscoveryListener mockDiscoveryListener;
-
-    @Before
+    @BeforeEach
     public void setup() {
         discoveryService = new BluetoothDiscoveryService();
         discoveryService.addDiscoveryListener(mockDiscoveryListener);
@@ -185,12 +188,12 @@ public class BluetoothDiscoveryServiceTest {
         DiscoveryResult result1 = results.get(0);
         DiscoveryResult result2 = results.get(1);
 
-        Assert.assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
-        Assert.assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
-        Assert.assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
-        Assert.assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
-        Assert.assertEquals(result1.getLabel(), result2.getLabel());
-        Assert.assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
+        assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
+        assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
+        assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
+        assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
+        assertEquals(result1.getLabel(), result2.getLabel());
+        assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
     }
 
     @Test
@@ -308,7 +311,7 @@ public class BluetoothDiscoveryServiceTest {
 
         DiscoveryResult result = resultCaptor.getValue();
 
-        Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
+        assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
 
         Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved(
                 ArgumentMatchers.same(discoveryService),
@@ -330,7 +333,7 @@ public class BluetoothDiscoveryServiceTest {
 
         DiscoveryResult result = resultCaptor.getValue();
 
-        Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
+        assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
 
         discoveryService.deviceRemoved(device);
 
@@ -382,7 +385,7 @@ public class BluetoothDiscoveryServiceTest {
 
         DiscoveryResult result = resultCaptor.getValue();
 
-        Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
+        assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
 
         device.setManufacturerId(10);
 
@@ -450,7 +453,7 @@ public class BluetoothDiscoveryServiceTest {
                 ArgumentMatchers.same(discoveryService),
                 ArgumentMatchers.argThat(arg -> arg.getThingTypeUID().equals(participant2.typeUID)));
 
-        Assert.assertEquals(1, callCount.get());
+        assertEquals(1, callCount.get());
     }
 
     @Test
@@ -471,12 +474,12 @@ public class BluetoothDiscoveryServiceTest {
         DiscoveryResult result1 = results.get(0);
         DiscoveryResult result2 = results.get(1);
 
-        Assert.assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
-        Assert.assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
-        Assert.assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
-        Assert.assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
-        Assert.assertEquals(result1.getLabel(), result2.getLabel());
-        Assert.assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
+        assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
+        assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
+        assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
+        assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
+        assertEquals(result1.getLabel(), result2.getLabel());
+        assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
     }
 
     @Test
@@ -499,12 +502,12 @@ public class BluetoothDiscoveryServiceTest {
         ThingUID result1 = results.get(0);
         ThingUID result2 = results.get(1);
 
-        Assert.assertNotEquals(result1.getBridgeIds(), result2.getBridgeIds());
-        Assert.assertThat(result1.getBridgeIds().get(0),
+        assertNotEquals(result1.getBridgeIds(), result2.getBridgeIds());
+        assertThat(result1.getBridgeIds().get(0),
                 anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId())));
-        Assert.assertThat(result2.getBridgeIds().get(0),
+        assertThat(result2.getBridgeIds().get(0),
                 anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId())));
-        Assert.assertEquals(result1.getId(), result2.getId());
+        assertEquals(result1.getId(), result2.getId());
     }
 
     private class RoamingDiscoveryParticipant implements BluetoothDiscoveryParticipant {
@@ -555,7 +558,8 @@ public class BluetoothDiscoveryServiceTest {
 
         @Override
         public @NonNull ThingUID getThingUID(BluetoothDiscoveryDevice device) {
-            String id = device.getName() != null ? device.getName() : RandomStringUtils.randomAlphabetic(6);
+            String deviceName = device.getName();
+            String id = deviceName != null ? deviceName : RandomStringUtils.randomAlphabetic(6);
             return new ThingUID(typeUID, device.getAdapter().getUID(), id);
         }
     }
index 08e125dff92f9c19f6b2d528e1c345f0c56aea69..c2206cb83d36e5df43f83a420106589d1d977ab6 100644 (file)
  */
 package org.openhab.binding.bsblan.internal;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.thing.ThingTypeUID;
 
 /**
index b9900cba5e1441aac0b3f6ec64e1bf29bcaf7103..237ccb5739707504a45c0f8709dd243700ad887f 100644 (file)
  */
 package org.openhab.binding.bsblan.internal.api;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterQueryResponseDTO;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterSetRequestDTO;
index 341c5d7efbca46f0b4cbedd167be02e086c9f217..dfdfbba4825c52c5325b231f4dd8a800b0e83df6 100644 (file)
  */
 package org.openhab.binding.bsblan.internal.helper;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
@@ -219,10 +217,10 @@ public class BsbLanParameterConverterTests {
 
     @Test
     public void testGetValueForNumberValueChannel() {
-        assertNull("1", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.ON));
-        assertNull("0", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.OFF));
-        assertEquals("42", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(42)));
-        assertEquals("22.5", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(22.5)));
+        assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.ON), "1");
+        assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.OFF), "0");
+        assertEquals(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(42)), "42");
+        assertEquals(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(22.5)), "22.5");
         assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE,
                 new StringType("Not a number value")));
         assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new StringType("")));
index a336b1a33c337b73fc058efdcf35961b13272e72..7d72bfadc5e43555b3541d1a6aaac67dd1da2587 100644 (file)
  */
 package org.openhab.binding.buienradar;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.math.BigDecimal;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Optional;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarParseException;
 import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI;
 import org.openhab.binding.buienradar.internal.buienradarapi.Prediction;
index 7be3278e5c84c5015651ae4cab868cb7532c9046..eb8d59625399e6ddd1eac84cd168ba7b052275c2 100644 (file)
  */
 package org.openhab.binding.danfossairunit.internal;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 
 /**
index 6ccbd50b0740997ecb7db98b158454f02089d686..eb1ab1075cd70a1cefefef55c696aef6bd5a24b8 100644 (file)
 package org.openhab.binding.darksky.internal.utils;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.ConfigConstants;
 
 /**
@@ -45,18 +45,18 @@ public class ByteArrayFileCacheTest {
 
     private ByteArrayFileCache subject;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         subject = new ByteArrayFileCache(SERVICE_PID);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         // delete all files
         subject.clear();
     }
 
-    @AfterClass
+    @AfterAll
     public static void cleanUp() {
         // delete all folders
         SERVICE_CACHE_FOLDER.delete();
index d74125b00a1e52a17c986b50893b9663ce84cf40..4eba739960e3f718362dc537e117da8a57aa2934 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.deconz;
 
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -23,11 +23,14 @@ import java.time.ZonedDateTime;
 
 import org.apache.commons.io.IOUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.deconz.internal.Util;
 import org.openhab.binding.deconz.internal.discovery.ThingDiscoveryService;
 import org.openhab.binding.deconz.internal.dto.BridgeFullState;
@@ -49,23 +52,18 @@ import com.google.gson.GsonBuilder;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public class DeconzTest {
     private @NonNullByDefault({}) Gson gson;
 
-    @Mock
-    private @NonNullByDefault({}) DiscoveryListener discoveryListener;
+    private @Mock @NonNullByDefault({}) DiscoveryListener discoveryListener;
+    private @Mock @NonNullByDefault({}) DeconzBridgeHandler bridgeHandler;
+    private @Mock @NonNullByDefault({}) Bridge bridge;
 
-    @Mock
-    private @NonNullByDefault({}) DeconzBridgeHandler bridgeHandler;
-
-    @Mock
-    private @NonNullByDefault({}) Bridge bridge;
-
-    @Before
+    @BeforeEach
     public void initialize() {
-        initMocks(this);
-
         Mockito.doAnswer(answer -> bridge).when(bridgeHandler).getThing();
         Mockito.doAnswer(answer -> new ThingUID("deconz", "mybridge")).when(bridge).getUID();
 
@@ -78,9 +76,9 @@ public class DeconzTest {
     @Test
     public void discoveryTest() throws IOException {
         BridgeFullState bridgeFullState = getObjectFromJson("discovery.json", BridgeFullState.class, gson);
-        Assert.assertNotNull(bridgeFullState);
-        Assert.assertEquals(6, bridgeFullState.lights.size());
-        Assert.assertEquals(9, bridgeFullState.sensors.size());
+        assertNotNull(bridgeFullState);
+        assertEquals(6, bridgeFullState.lights.size());
+        assertEquals(9, bridgeFullState.sensors.size());
 
         ThingDiscoveryService discoveryService = new ThingDiscoveryService();
         discoveryService.setThingHandler(bridgeHandler);
@@ -98,10 +96,10 @@ public class DeconzTest {
     @Test
     public void dateTimeConversionTest() {
         DateTimeType dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09Z");
-        Assert.assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:00Z")), dateTime);
+        assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:00Z")), dateTime);
 
         dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09:47");
-        Assert.assertEquals(
-                new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:47Z")).toZone(ZoneId.systemDefault()), dateTime);
+        assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:47Z")).toZone(ZoneId.systemDefault()),
+                dateTime);
     }
 }
index 775ffdd4eb4377d25b6532a3a57cdcc4e6e8f6d4..85df1150b4c95248dec4715ad40b116a20d78099 100644 (file)
@@ -12,9 +12,8 @@
  */
 package org.openhab.binding.deconz;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.ArgumentMatchers.*;
 import static org.openhab.binding.deconz.internal.BindingConstants.*;
 
 import java.io.IOException;
@@ -23,11 +22,12 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.deconz.internal.StateDescriptionProvider;
 import org.openhab.binding.deconz.internal.dto.LightMessage;
 import org.openhab.binding.deconz.internal.handler.LightThingHandler;
@@ -53,20 +53,16 @@ import com.google.gson.GsonBuilder;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 @NonNullByDefault
 public class LightsTest {
     private @NonNullByDefault({}) Gson gson;
 
-    @Mock
-    private @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
+    private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
+    private @Mock @NonNullByDefault({}) StateDescriptionProvider stateDescriptionProvider;
 
-    @Mock
-    private @NonNullByDefault({}) StateDescriptionProvider stateDescriptionProvider;
-
-    @Before
+    @BeforeEach
     public void initialize() {
-        initMocks(this);
-
         GsonBuilder gsonBuilder = new GsonBuilder();
         gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer());
         gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter());
@@ -76,7 +72,7 @@ public class LightsTest {
     @Test
     public void colorTemperatureLightUpdateTest() throws IOException {
         LightMessage lightMessage = DeconzTest.getObjectFromJson("colortemperature.json", LightMessage.class, gson);
-        Assert.assertNotNull(lightMessage);
+        assertNotNull(lightMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "light");
         ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@@ -122,7 +118,7 @@ public class LightsTest {
     @Test
     public void dimmableLightUpdateTest() throws IOException {
         LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable.json", LightMessage.class, gson);
-        Assert.assertNotNull(lightMessage);
+        assertNotNull(lightMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "light");
         ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@@ -139,7 +135,7 @@ public class LightsTest {
     @Test
     public void dimmableLightOverrangeUpdateTest() throws IOException {
         LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_overrange.json", LightMessage.class, gson);
-        Assert.assertNotNull(lightMessage);
+        assertNotNull(lightMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "light");
         ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@@ -156,7 +152,7 @@ public class LightsTest {
     @Test
     public void dimmableLightUnderrangeUpdateTest() throws IOException {
         LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_underrange.json", LightMessage.class, gson);
-        Assert.assertNotNull(lightMessage);
+        assertNotNull(lightMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "light");
         ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@@ -173,7 +169,7 @@ public class LightsTest {
     @Test
     public void windowCoveringUpdateTest() throws IOException {
         LightMessage lightMessage = DeconzTest.getObjectFromJson("windowcovering.json", LightMessage.class, gson);
-        Assert.assertNotNull(lightMessage);
+        assertNotNull(lightMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "light");
         ChannelUID channelUID_pos = new ChannelUID(thingUID, CHANNEL_POSITION);
index 5df5bb5a4a67ecd2c200d47f3f795f73731b629a..76bd257460182777e13a9dd46653b47c1fa7c9b7 100644 (file)
  */
 package org.openhab.binding.deconz;
 
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.deconz.internal.BindingConstants.*;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.deconz.internal.dto.SensorMessage;
 import org.openhab.binding.deconz.internal.handler.SensorThermostatThingHandler;
 import org.openhab.binding.deconz.internal.handler.SensorThingHandler;
@@ -52,17 +53,15 @@ import com.google.gson.GsonBuilder;
  * @author Jan N. Klug - Initial contribution
  * @author Lukas Agethen - Added Thermostat
  */
+@ExtendWith(MockitoExtension.class)
 @NonNullByDefault
 public class SensorsTest {
     private @NonNullByDefault({}) Gson gson;
 
-    @Mock
-    private @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
+    private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
 
-    @Before
+    @BeforeEach
     public void initialize() {
-        initMocks(this);
-
         GsonBuilder gsonBuilder = new GsonBuilder();
         gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer());
         gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter());
@@ -72,7 +71,7 @@ public class SensorsTest {
     @Test
     public void carbonmonoxideSensorUpdateTest() throws IOException {
         SensorMessage sensorMessage = DeconzTest.getObjectFromJson("carbonmonoxide.json", SensorMessage.class, gson);
-        Assert.assertNotNull(sensorMessage);
+        assertNotNull(sensorMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "sensor");
         ChannelUID channelUID = new ChannelUID(thingUID, "carbonmonoxide");
@@ -88,7 +87,7 @@ public class SensorsTest {
     @Test
     public void thermostatSensorUpdateTest() throws IOException {
         SensorMessage sensorMessage = DeconzTest.getObjectFromJson("thermostat.json", SensorMessage.class, gson);
-        Assert.assertNotNull(sensorMessage);
+        assertNotNull(sensorMessage);
 
         ThingUID thingUID = new ThingUID("deconz", "sensor");
         ChannelUID channelValveUID = new ChannelUID(thingUID, "valve");
index 643edc7fd9f35975f7dcc485323f1dec4349e8c5..83010b138d968e6dac121e4be4c1f1ddb4e005a7 100644 (file)
@@ -13,9 +13,9 @@
 package org.openhab.binding.dmx.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.internal.action.ActionState;
 import org.openhab.binding.dmx.internal.action.FadeAction;
 import org.openhab.binding.dmx.internal.multiverse.DmxChannel;
index aeb1dacc44f7e0848eaaf7ba0b19b8d4b52f4f7b..025f4eb43a9e07b182a63bccb013f55974a39eea 100644 (file)
@@ -13,9 +13,9 @@
 package org.openhab.binding.dmx.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.internal.multiverse.DmxChannel;
 import org.openhab.core.library.types.PercentType;
 
index 46b552968645fcad326786519028a724e3ae2a15..918879882c3c568c240dcc9d4b4981a8ba19805c 100644 (file)
 package org.openhab.binding.dmx.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases ValueSet
index e0eecaf2b2a2c4520feecba936020fc3ab6355b8..87c522efd2669531fd79ad9169d147fd1f6bd17c 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@@ -21,9 +22,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.test.java.JavaTest;
 import org.openhab.core.thing.Bridge;
@@ -53,7 +54,7 @@ public class ArtnetBridgeHandlerTest extends JavaTest {
     private Bridge bridge;
     private ArtnetBridgeHandler bridgeHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         bridgeProperties = new HashMap<>();
         bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@@ -79,7 +80,7 @@ public class ArtnetBridgeHandlerTest extends JavaTest {
         bridgeHandler.initialize();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         bridgeHandler.dispose();
     }
index b5a0935390ddba0b06ec12fcfb67ebb3bcd55531..8d3f126df82d1599f3c71a3cdb965b11d26a03e1 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.dmx.internal.handler;
 
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@@ -24,8 +24,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
 import org.openhab.binding.dmx.test.TestBridgeHandler;
 import org.openhab.core.config.core.Configuration;
@@ -61,7 +61,7 @@ public class ChaserThingHandlerTest extends AbstractDmxThingTestParent {
     private TestBridgeHandler dmxBridgeHandler;
     private ChaserThingHandler chaserThingHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setup();
 
index 1c6bf28c55d17a370d395255b42110bb9d16c1c8..37905a36f853ef0fbe143623526a092cc5612185 100644 (file)
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.number.IsCloseTo.closeTo;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.DecimalType;
@@ -58,7 +59,7 @@ public class ColorThingHandlerTest extends AbstractDmxThingTestParent {
     private final ChannelUID CHANNEL_UID_BRIGHTNESS_G = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_G);
     private final ChannelUID CHANNEL_UID_BRIGHTNESS_B = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_B);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setup();
         thingProperties = new HashMap<>();
index f8d9dcd98ca350c8b2220dea40c157eee26de12d..1848857ec87c5ffd3fd14747cf12beda698512d2 100644 (file)
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.number.IsCloseTo.closeTo;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
@@ -51,7 +52,7 @@ public class DimmerThingHandlerTest extends AbstractDmxThingTestParent {
     private final ThingUID THING_UID_DIMMER = new ThingUID(THING_TYPE_DIMMER, "testdimmer");
     private final ChannelUID CHANNEL_UID_BRIGHTNESS = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setup();
 
index ae318e0a94d8104bd8b62add9c251b24bf71bd90..cea0a562d365789df5b518c998cf27fad261b854 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@@ -21,10 +22,10 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openhab.binding.dmx.internal.DmxBridgeHandler;
 import org.openhab.binding.dmx.internal.multiverse.BaseDmxChannel;
@@ -93,7 +94,7 @@ public class DmxBridgeHandlerTest extends JavaTest {
     private Bridge bridge;
     private DmxBridgeHandlerImpl bridgeHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         bridgeProperties = new HashMap<>();
         bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge")
@@ -112,7 +113,7 @@ public class DmxBridgeHandlerTest extends JavaTest {
         bridgeHandler.initialize();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         bridgeHandler.dispose();
     }
@@ -122,13 +123,13 @@ public class DmxBridgeHandlerTest extends JavaTest {
         waitForAssert(() -> assertEquals(ThingStatus.ONLINE, bridge.getStatusInfo().getStatus()));
     }
 
-    @Ignore("https://github.com/eclipse/smarthome/issues/6015#issuecomment-411313627")
+    @Disabled("https://github.com/eclipse/smarthome/issues/6015#issuecomment-411313627")
     @Test
     public void assertSendDmxDataIsCalled() {
         Mockito.verify(bridgeHandler, after(500).atLeast(9)).sendDmxData();
     }
 
-    @Ignore("https://github.com/eclipse/smarthome/issues/6015")
+    @Disabled("https://github.com/eclipse/smarthome/issues/6015")
     @Test
     public void assertMuteChannelMutesOutput() {
         bridgeHandler.handleCommand(CHANNEL_UID_MUTE, OnOffType.ON);
index 94742283a4f0db68076c012c9369156c258665e2..b12cf32d98cc82ddb27b672d04aea3eb91225493 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.dmx.internal.handler;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@@ -20,9 +20,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.test.java.JavaTest;
 import org.openhab.core.thing.Bridge;
@@ -51,7 +51,7 @@ public class Lib485BridgeHandlerTest extends JavaTest {
     private Bridge bridge;
     private Lib485BridgeHandler bridgeHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         bridgeProperties = new HashMap<>();
         bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@@ -76,7 +76,7 @@ public class Lib485BridgeHandlerTest extends JavaTest {
         bridgeHandler.initialize();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         bridgeHandler.dispose();
     }
index 808b126e19cc2ade1f84cc0ad1acf46385283e07..0938b8f99abee3110684c588c892a889c5ac3b15 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@@ -21,9 +22,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.test.java.JavaTest;
 import org.openhab.core.thing.Bridge;
@@ -52,7 +53,7 @@ public class SacnBridgeHandlerTest extends JavaTest {
     private Bridge bridge;
     private SacnBridgeHandler bridgeHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         bridgeProperties = new HashMap<>();
         bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@@ -79,7 +80,7 @@ public class SacnBridgeHandlerTest extends JavaTest {
         bridgeHandler.initialize();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         bridgeHandler.dispose();
     }
index 22423988e59993c96fe20d1ecb80d2b671c09447..c7dea415347afbd85be6162b01c621e5f2d70cad 100644 (file)
  */
 package org.openhab.binding.dmx.internal.handler;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.number.IsCloseTo.closeTo;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
@@ -54,7 +55,7 @@ public class TunableWhiteThingHandlerTest extends AbstractDmxThingTestParent {
     private final ChannelUID CHANNEL_UID_BRIGHTNESS_WW = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_WW);
     private final ChannelUID CHANNEL_UID_COLOR_TEMP = new ChannelUID(THING_UID_DIMMER, CHANNEL_COLOR_TEMPERATURE);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setup();
 
index 6b0e022a776cabbc34e4d2d99fa04368cb8b9fce..7582a45b35c4b0d4ec603c33a418f519aabfe7a3 100644 (file)
 package org.openhab.binding.dmx.internal.multiverse;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for BaseChannel
index 5a36dda0a7d85f6a16154c30c3d5c56c718786e4..4f76d2fdc348a8f7b280f216fcec5d2040cbeccf 100644 (file)
 package org.openhab.binding.dmx.internal.multiverse;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openhab.binding.dmx.internal.DmxBindingConstants.ListenerType;
 import org.openhab.binding.dmx.internal.action.FadeAction;
@@ -37,7 +37,7 @@ public class DmxChannelTest {
     DimmerThingHandler dimmerThingHandler;
     long currentTime;
 
-    @Before
+    @BeforeEach
     public void setup() {
         dimmerThingHandler = Mockito.mock(DimmerThingHandler.class);
         dmxChannel = new DmxChannel(0, 1, 0);
index b6c3c893e6fc8da7cd3480a7817c0198e7fe41c5..d41d1a37688b78dbdf614a7f25b4b386d2a6dcf6 100644 (file)
  */
 package org.openhab.binding.dmx.test;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.number.IsCloseTo.closeTo;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.dmx.test.TestBridgeHandler.THING_TYPE_TEST_BRIDGE;
index e762c1f5a9853fd1ec25e5e4571bac3bbb6701af..cea89a7c4e18a8ac27d3fcd0cb5b84a48b7bde0d 100644 (file)
  */
 package org.openhab.binding.doorbird.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.doorbird.internal.api.DoorbirdInfo;
 
 /**
index 5e9f9e500a3845a57408f2daee37c09d03b7f915..2bf5697f8d59711c621efb499d8fd69855a7cbdb 100644 (file)
  */
 package org.openhab.binding.doorbird.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.doorbird.internal.api.SipStatus;
 
 /**
index 95b25921a96661b9f57f3c49572e0c3b6ddfdcd8..45e7574f5eb001846cfd4591da3a4ea4e2787493 100644 (file)
 package org.openhab.binding.draytonwiser.internal.discovery;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
@@ -28,17 +28,18 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.HttpContentResponse;
 import org.eclipse.jetty.client.HttpResponse;
 import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.server.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.draytonwiser.internal.DraytonWiserBindingConstants;
 import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi;
 import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApiException;
@@ -55,35 +56,22 @@ import org.openhab.core.thing.ThingUID;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(Parameterized.class)
+@ExtendWith(MockitoExtension.class)
 public class DraytonWiserDiscoveryServiceTest {
 
-    @Mock
-    private HeatHubHandler bridgeHandler;
-    @Mock
-    private Bridge bridge;
-    @Mock
-    private HttpClient httpClient;
-    @Mock
-    private Request request;
+    private @Mock HeatHubHandler bridgeHandler;
+    private @Mock Bridge bridge;
+    private @Mock HttpClient httpClient;
+    private @Mock Request request;
 
     private DraytonWiserApi api;
-    private final String jsonFile;
-    private final int expectedResults;
-
-    public DraytonWiserDiscoveryServiceTest(final String jsonFile, final int expectedResults) {
-        this.jsonFile = jsonFile;
-        this.expectedResults = expectedResults;
-    }
 
-    @Parameters(name = "{0}")
     public static List<Object[]> data() {
         return Arrays.asList(new Object[] { "../test1.json", 11 }, new Object[] { "../test2.json", 22 });
     }
 
-    @Before
+    @BeforeEach
     public void before() {
-        initMocks(this);
         api = new DraytonWiserApi(httpClient);
         api.setConfiguration(new HeatHubConfiguration());
 
@@ -96,12 +84,13 @@ public class DraytonWiserDiscoveryServiceTest {
         doReturn(new ThingUID(DraytonWiserBindingConstants.THING_TYPE_BRIDGE, "1")).when(bridge).getUID();
     }
 
-    @Test
-    public void testDiscovery() throws IOException, URISyntaxException, InterruptedException, TimeoutException,
-            ExecutionException, DraytonWiserApiException {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testDiscovery(final String jsonFile, final int expectedResults) throws IOException, URISyntaxException,
+            InterruptedException, TimeoutException, ExecutionException, DraytonWiserApiException {
         final byte[] content = Files.readAllBytes(Paths.get(getClass().getResource(jsonFile).toURI()));
         final HttpResponse response = new HttpResponse(null, null);
-        response.status(Response.SC_OK);
+        response.status(HttpServletResponse.SC_OK);
         doReturn(new HttpContentResponse(response, content, null, null)).when(request).send();
         final List<DiscoveryResult> discoveryResults = new ArrayList<>();
         final DraytonWiserDiscoveryService service = new DraytonWiserDiscoveryService() {
index ad23950d24a2cbd10874d5e4c4bf1bf5204477cf..4225a45ef85418bbff586e37eaae02ddb23a770a 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.dsmr.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -63,9 +63,9 @@ public final class TelegramReaderUtil {
 
         parser.setLenientMode(true);
         parser.parse(telegram, telegram.length);
-        assertNotNull("Telegram state should have been set. (Missing newline at end of message?)", p1Telegram.get());
-        assertEquals("Expected TelegramState should be as expected", expectedTelegramState,
-                p1Telegram.get().getTelegramState());
+        assertNotNull(p1Telegram.get(), "Telegram state should have been set. (Missing newline at end of message?)");
+        assertEquals(expectedTelegramState, p1Telegram.get().getTelegramState(),
+                "Expected TelegramState should be as expected");
         return p1Telegram.get();
     }
 }
index 456dae30e2edd83977909b95980d00c52a940e46..9a4c5d25f752325e134dbdc7c41dd32c1aebb3b2 100644 (file)
  */
 package org.openhab.binding.dsmr.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -25,9 +24,11 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Stream;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.dsmr.internal.DSMRBindingConstants;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.DSMRSerialAutoDevice.DeviceState;
@@ -45,22 +46,20 @@ import org.openhab.core.io.transport.serial.SerialPortManager;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class DSMRSerialAutoDeviceTest {
 
     private static final String DUMMY_PORTNAME = "/dev/dummy-serial";
     private static final String TELEGRAM_NAME = "dsmr_50";
 
-    @Mock
-    private SerialPortIdentifier mockIdentifier;
-    @Mock
-    private ScheduledExecutorService scheduler;
-    @Mock
-    private SerialPort mockSerialPort;
+    private @Mock SerialPortIdentifier mockIdentifier;
+    private @Mock ScheduledExecutorService scheduler;
+    private @Mock SerialPort mockSerialPort;
 
     private SerialPortManager serialPortManager = new SerialPortManager() {
         @Override
         public SerialPortIdentifier getIdentifier(String name) {
-            assertEquals("Expect the passed serial port name", DUMMY_PORTNAME, name);
+            assertEquals(DUMMY_PORTNAME, name, "Expect the passed serial port name");
             return mockIdentifier;
         }
 
@@ -71,9 +70,8 @@ public class DSMRSerialAutoDeviceTest {
     };
     private SerialPortEventListener serialPortEventListener;
 
-    @Before
+    @BeforeEach
     public void setUp() throws PortInUseException, TooManyListenersException {
-        initMocks(this);
         doAnswer(a -> {
             serialPortEventListener = a.getArgument(0);
             return null;
@@ -100,18 +98,18 @@ public class DSMRSerialAutoDeviceTest {
             DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener,
                     new DSMRTelegramListener(), scheduler, 1);
             device.start();
-            assertSame("Expect to be starting discovery state", DeviceState.DISCOVER_SETTINGS, device.getState());
+            assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be starting discovery state");
             serialPortEventListener
                     .serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.BI, false, true));
-            assertSame("Expect to be still in discovery state", DeviceState.DISCOVER_SETTINGS, device.getState());
+            assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be still in discovery state");
             serialPortEventListener
                     .serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.DATA_AVAILABLE, false, true));
-            assertSame("Expect to be in normal state", DeviceState.NORMAL, device.getState());
+            assertSame(DeviceState.NORMAL, device.getState(), "Expect to be in normal state");
             device.restart();
-            assertSame("Expect not to start rediscovery when in normal state", DeviceState.NORMAL, device.getState());
+            assertSame(DeviceState.NORMAL, device.getState(), "Expect not to start rediscovery when in normal state");
             device.stop();
         }
-        assertNotNull("Expected to have read a telegram", telegramRef.get());
+        assertNotNull(telegramRef.get(), "Expected to have read a telegram");
     }
 
     @Test
@@ -137,19 +135,19 @@ public class DSMRSerialAutoDeviceTest {
             DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener,
                     new DSMRTelegramListener(), scheduler, 1);
             device.start();
-            assertSame("Expected an error", DSMRConnectorErrorEvent.IN_USE, eventRef.get());
-            assertSame("Expect to be in error state", DeviceState.ERROR, device.getState());
+            assertSame(DSMRConnectorErrorEvent.IN_USE, eventRef.get(), "Expected an error");
+            assertSame(DeviceState.ERROR, device.getState(), "Expect to be in error state");
             // Trigger device to restart
             mockValidSerialPort();
             device.restart();
-            assertSame("Expect to be starting discovery state", DeviceState.DISCOVER_SETTINGS, device.getState());
+            assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be starting discovery state");
             // Trigger device to go into error stage with port doesn't exist.
             mockIdentifier = null;
             device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, new DSMRTelegramListener(),
                     scheduler, 1);
             device.start();
-            assertSame("Expected an error", DSMRConnectorErrorEvent.DONT_EXISTS, eventRef.get());
-            assertSame("Expect to be in error state", DeviceState.ERROR, device.getState());
+            assertSame(DSMRConnectorErrorEvent.DONT_EXISTS, eventRef.get(), "Expected an error");
+            assertSame(DeviceState.ERROR, device.getState(), "Expect to be in error state");
         }
     }
 
index d7146f308291d453212e7028cce9cd97d1ae1bc4..7d5a82d481fa89ff24878d76bb5d8752db6d6b58 100644 (file)
 package org.openhab.binding.dsmr.internal.device;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.nio.charset.StandardCharsets;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramListener;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramParser;
index 71bea364b699cea015101b6499722cc1f0e53e4b..29bf399e7fb05a79e1649be13e2fe484e427237a 100644 (file)
  */
 package org.openhab.binding.dsmr.internal.device.p1telegram;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
 
@@ -30,11 +27,9 @@ import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramSt
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(value = Parameterized.class)
 public class P1TelegramParserTest {
 
     // @formatter:off
-    @Parameters(name = "{0}")
     public static final List<Object[]> data() {
         return Arrays.asList(new Object[][] {
             { "ace4000", 59, },
@@ -52,17 +47,13 @@ public class P1TelegramParserTest {
     }
     // @formatter:on
 
-    @Parameter(0)
-    public String telegramName;
-
-    @Parameter(1)
-    public int numberOfCosemObjects;
-
-    @Test
-    public void testParsing() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testParsing(final String telegramName, final int numberOfCosemObjects) {
         P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK);
-        assertEquals("Should not have any unknown cosem objects", 0, telegram.getUnknownCosemObjects().size());
-        assertEquals("Expected number of objects", numberOfCosemObjects,
-                telegram.getCosemObjects().stream().mapToInt(co -> co.getCosemValues().size()).sum());
+        assertEquals(0, telegram.getUnknownCosemObjects().size(), "Should not have any unknown cosem objects");
+        assertEquals(numberOfCosemObjects,
+                telegram.getCosemObjects().stream().mapToInt(co -> co.getCosemValues().size()).sum(),
+                "Expected number of objects");
     }
 }
index 9c1f7b7efdc890334af4e338cbd28018fd6c5e59..eed77d068f4f8f9fed7f1b2b70637c1dba1ff2e3 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.dsmr.internal.discovery;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*;
 
 import java.util.Arrays;
@@ -24,11 +24,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.cosem.CosemObject;
 import org.openhab.binding.dsmr.internal.device.cosem.CosemObjectType;
@@ -42,11 +39,9 @@ import org.openhab.binding.dsmr.internal.meter.DSMRMeterType;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(value = Parameterized.class)
 public class DSMRMeterDetectorTest {
 
     // @formatter:off
-    @Parameters(name = "{0}")
     public static final List<Object[]> data() {
         return Arrays.asList(new Object[][] {
             { "ace4000", EnumSet.of( ELECTRICITY_ACE4000, GAS_ACE4000)},
@@ -64,30 +59,26 @@ public class DSMRMeterDetectorTest {
     }
     // @formatter:on
 
-    @Parameter(0)
-    public String telegramName;
-
-    @Parameter(1)
-    public Set<DSMRMeterType> expectedMeters;
-
-    @Test
-    public void testDetectMeters() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testDetectMeters(final String telegramName, final Set<DSMRMeterType> expectedMeters) {
         P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK);
         DSMRMeterDetector detector = new DSMRMeterDetector();
         Entry<Collection<DSMRMeterDescriptor>, Map<CosemObjectType, CosemObject>> entry = detector
                 .detectMeters(telegram);
         Collection<DSMRMeterDescriptor> detectMeters = entry.getKey();
 
-        assertEquals("Should detect correct number of meters: " + Arrays.toString(detectMeters.toArray()),
-                expectedMeters.size(), detectMeters.size());
-        assertEquals("Should not have any undetected cosem objects: ", Collections.emptyMap(), entry.getValue());
-        assertEquals("Should not have any unknown cosem objects", Collections.emptyList(),
-                telegram.getUnknownCosemObjects());
+        assertEquals(expectedMeters.size(), detectMeters.size(),
+                "Should detect correct number of meters: " + Arrays.toString(detectMeters.toArray()));
+        assertEquals(Collections.emptyMap(), entry.getValue(), "Should not have any undetected cosem objects: ");
+        assertEquals(Collections.emptyList(), telegram.getUnknownCosemObjects(),
+                "Should not have any unknown cosem objects");
         for (DSMRMeterType meter : expectedMeters) {
             assertEquals(
+
+                    1, detectMeters.stream().filter(e -> e.getMeterType() == meter).count(),
                     String.format("Meter '%s' not found: %s", meter,
-                            Arrays.toString(detectMeters.toArray(new DSMRMeterDescriptor[0]))),
-                    1, detectMeters.stream().filter(e -> e.getMeterType() == meter).count());
+                            Arrays.toString(detectMeters.toArray(new DSMRMeterDescriptor[0]))));
         }
     }
 }
index 041fe56247ee46e22d68b17b8bb219a44a5d11e9..33a70e0f317befae5ba0241a0cbc2546c972c36f 100644 (file)
  */
 package org.openhab.binding.dsmr.internal.discovery;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*;
 
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.TooManyListenersException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Answers;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
@@ -37,7 +36,6 @@ import org.openhab.binding.dsmr.internal.handler.DSMRBridgeHandler;
 import org.openhab.binding.dsmr.internal.handler.DSMRMeterHandler;
 import org.openhab.binding.dsmr.internal.meter.DSMRMeterDescriptor;
 import org.openhab.binding.dsmr.internal.meter.DSMRMeterType;
-import org.openhab.core.io.transport.serial.PortInUseException;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingUID;
 
@@ -46,22 +44,15 @@ import org.openhab.core.thing.ThingUID;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class DSMRMeterDiscoveryServiceTest {
 
     private static final String EXPECTED_CONFIGURED_TELEGRAM = "dsmr_50";
     private static final String UNREGISTERED_METER_TELEGRAM = "unregistered_meter";
 
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private DSMRBridgeHandler bridge;
-    @Mock
-    private Thing thing;
-    @Mock
-    private DSMRMeterHandler meterHandler;
-
-    @Before
-    public void setUp() throws PortInUseException, TooManyListenersException {
-        initMocks(this);
-    }
+    private @Mock(answer = Answers.RETURNS_DEEP_STUBS) DSMRBridgeHandler bridge;
+    private @Mock Thing thing;
+    private @Mock DSMRMeterHandler meterHandler;
 
     /**
      * Test if discovery reports when the user has incorrectly configured the binding with the wrong meter types.
@@ -100,12 +91,12 @@ public class DSMRMeterDiscoveryServiceTest {
         when(bridge.getThing().getThings()).thenReturn(things);
 
         service.telegramReceived(expected);
-        assertNotNull("Should have invalid configured meters", invalidConfiguredRef.get());
-        assertTrue("Should have found specific invalid meter",
-                invalidConfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V4_2));
-        assertNotNull("Should have undetected meters", unconfiguredRef.get());
-        assertTrue("Should have found specific undetected meter",
-                unconfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V5_0));
+        assertNotNull(invalidConfiguredRef.get(), "Should have invalid configured meters");
+        assertTrue(invalidConfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V4_2),
+                "Should have found specific invalid meter");
+        assertNotNull(unconfiguredRef.get(), "Should have undetected meters");
+        assertTrue(unconfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V5_0),
+                "Should have found specific undetected meter");
     }
 
     /**
@@ -128,6 +119,6 @@ public class DSMRMeterDiscoveryServiceTest {
         when(bridge.getThing().getThings()).thenReturn(Collections.emptyList());
 
         service.telegramReceived(telegram);
-        assertTrue("Should have found an unregistered meter", unregisteredMeter.get());
+        assertTrue(unregisteredMeter.get(), "Should have found an unregistered meter");
     }
 }
index 0952dab62704e45c80271ee673cf3e77ce0ecc9e..87bc2a20452d3042ddd49d05c2d4fcad6d4b7452 100644 (file)
  */
 package org.openhab.binding.dsmr.internal.meter;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 import org.openhab.binding.dsmr.internal.device.cosem.CosemObject;
 import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
@@ -40,7 +40,7 @@ public class DSMRMeterTest {
 
         List<CosemObject> filterMeterValues = meter
                 .filterMeterValues(TelegramReaderUtil.readTelegram("dsmr_50", TelegramState.OK).getCosemObjects());
-        assertEquals("Filter should return all required objects", DSMRMeterType.DEVICE_V5.requiredCosemObjects.length,
-                filterMeterValues.size());
+        assertEquals(DSMRMeterType.DEVICE_V5.requiredCosemObjects.length, filterMeterValues.size(),
+                "Filter should return all required objects");
     }
 }
index 3c7ec1d6e46d952868a0598a77f0937d276aab7d..f0a904556e4fe170053f24e020429387d9f363b6 100644 (file)
 package org.openhab.binding.dwdunwetter;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.InputStream;
 import java.util.List;
@@ -26,10 +25,14 @@ import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.commons.lang.StringUtils;
 import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.dwdunwetter.internal.DwdUnwetterBindingConstants;
 import org.openhab.binding.dwdunwetter.internal.handler.DwdUnwetterHandler;
 import org.openhab.core.config.core.Configuration;
@@ -51,19 +54,17 @@ import org.w3c.dom.NodeList;
  *
  * @author Martin Koehler - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class DwdUnwetterHandlerTest extends JavaTest {
 
     private ThingHandler handler;
 
-    @Mock
-    private ThingHandlerCallback callback;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Thing thing;
 
-    @Mock
-    private Thing thing;
-
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
         handler = new DwdUnwetterHandler(thing);
         handler.setCallback(callback);
         // mock getConfiguration to prevent NPEs
index 85399a180339547c8c3451fc6c844d7d62b0720c..a709fbf33eecfd575e192670f76cb66264f61027 100644 (file)
 package org.openhab.binding.dwdunwetter.internal.data;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.time.Instant;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link DwdWarningCache}
@@ -29,7 +29,7 @@ public class DwdWarningCacheTest {
 
     private DwdWarningCache cache;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         cache = new DwdWarningCache();
     }
index d480a5af679f5e31d0b0c620bea03a04162a73fd..e52a4a911220051c42a0a738aa69173a6a43cea1 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.dwdunwetter.internal.data;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -23,8 +23,8 @@ import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.time.ZoneId;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.UnDefType;
@@ -47,7 +47,7 @@ public class DwdWarningsDataTest {
     private TestDataProvider testDataProvider;
     private DwdWarningsData warningsData;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         this.testDataProvider = new TestDataProvider();
         loadXmlFromFile();
index 5f353d866544f9ab1dff95160dc67c31530ef021..827c76af90232d987c26d71b2019674bab9ffe6c 100644 (file)
  */
 package org.openhab.binding.enigma2.actions;
 
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.enigma2.handler.Enigma2Handler;
 import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
 
@@ -37,7 +38,7 @@ public class Enigma2ActionsTest {
     private Enigma2Handler enigma2Handler;
     public static final String SOME_TEXT = "some Text";
 
-    @Before
+    @BeforeEach
     public void setUp() {
         enigma2Handler = mock(Enigma2Handler.class);
         enigma2Actions = new Enigma2Actions();
@@ -109,9 +110,9 @@ public class Enigma2ActionsTest {
         verify(enigma2Handler).sendRcCommand("KEY_1");
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSendRcCommandStaticWithException() {
-        Enigma2Actions.sendRcCommand(null, "KEY_1");
+        assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendRcCommand(null, "KEY_1"));
     }
 
     @Test
@@ -126,9 +127,9 @@ public class Enigma2ActionsTest {
         verify(enigma2Handler).sendInfo(10, SOME_TEXT);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSendInfoStaticWithException() {
-        Enigma2Actions.sendInfo(null, SOME_TEXT);
+        assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendInfo(null, SOME_TEXT));
     }
 
     @Test
@@ -143,9 +144,9 @@ public class Enigma2ActionsTest {
         verify(enigma2Handler).sendError(10, SOME_TEXT);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSendErrorStaticWithException() {
-        Enigma2Actions.sendError(null, SOME_TEXT);
+        assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendError(null, SOME_TEXT));
     }
 
     @Test
@@ -160,9 +161,9 @@ public class Enigma2ActionsTest {
         verify(enigma2Handler).sendWarning(10, SOME_TEXT);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSendWarningStaticWithException() {
-        Enigma2Actions.sendWarning(null, SOME_TEXT);
+        assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendWarning(null, SOME_TEXT));
     }
 
     @Test
@@ -177,8 +178,8 @@ public class Enigma2ActionsTest {
         verify(enigma2Handler).sendQuestion(10, SOME_TEXT);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSendQuestionStaticWithException() {
-        Enigma2Actions.sendQuestion(null, SOME_TEXT);
+        assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendQuestion(null, SOME_TEXT));
     }
 }
index 11b9b1f47053c059dc8ecc745bf0b9e479f7263c..f5b2e63ef6b9fa28e715b3a2582adb7b61985ad6 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.enigma2.handler;
 
 import static org.eclipse.jdt.annotation.Checks.requireNonNull;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
 import java.time.LocalDateTime;
@@ -23,15 +23,20 @@ import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.enigma2.actions.Enigma2Actions;
 import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
 import org.openhab.binding.enigma2.internal.Enigma2Client;
 import org.openhab.binding.enigma2.internal.Enigma2Configuration;
 import org.openhab.binding.enigma2.internal.Enigma2RemoteKey;
 import org.openhab.core.config.core.Configuration;
-import org.openhab.core.library.types.*;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.NextPreviousType;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.PlayPauseType;
+import org.openhab.core.library.types.StringType;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.binding.ThingHandlerCallback;
@@ -58,7 +63,7 @@ public class Enigma2HandlerTest {
     @Nullable
     private ThingHandlerCallback callback;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         enigma2Client = mock(Enigma2Client.class);
         thing = mock(Thing.class);
index 702b5e9563bbcf6ea57e6b25790252e8fed8150b..ce27a64f3a9ec6c2753334868d950d10e91e6c5b 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.binding.enigma2.internal;
 
 import static org.eclipse.jdt.annotation.Checks.requireNonNull;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.*;
 
 import java.io.IOException;
@@ -22,8 +23,8 @@ import java.time.LocalDateTime;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * The {@link Enigma2ClientTest} class is responsible for testing {@link Enigma2Client}.
@@ -41,7 +42,7 @@ public class Enigma2ClientTest {
     @Nullable
     private Enigma2HttpClient enigma2HttpClient;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         enigma2HttpClient = mock(Enigma2HttpClient.class);
         enigma2Client = spy(new Enigma2Client("localhost:8080", "user", "password", 5));
index 845d7cfdb14043ebd6fa5b2a43c5ab0e3d24a2cf..27c0ee75c9f897a133d7cdb5982e27aa96e4e2bd 100644 (file)
 package org.openhab.binding.enigma2.internal;
 
 import static org.eclipse.jdt.annotation.Checks.requireNonNull;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.THING_TYPE_DEVICE;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
index 218d7efa62622b979c746b1b2a527b1492fecc10..2eb6515449b599e6ecffe17833968a6b3a06f3d8 100644 (file)
  */
 package org.openhab.binding.enigma2.internal;
 
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * The {@link Enigma2RemoteKeyTest} class is responsible for testing {@link Enigma2RemoteKey}.
index 0e6c941e735108b26a60f78d70c344725720cb6c..556bde9f734b5d51e0ca6598e06c3b360de2046e 100644 (file)
 package org.openhab.binding.enigma2.internal.discovery;
 
 import static org.eclipse.jdt.annotation.Checks.requireNonNull;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.Mockito.when;
 
 import java.net.Inet4Address;
 import java.net.InetAddress;
@@ -25,8 +24,8 @@ import javax.jmdns.ServiceInfo;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
 import org.openhab.binding.enigma2.internal.Enigma2HttpClient;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -47,7 +46,7 @@ public class Enigma2DiscoveryParticipantTest {
     @Nullable
     private Enigma2DiscoveryParticipant enigma2DiscoveryParticipant;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         enigma2HttpClient = mock(Enigma2HttpClient.class);
         serviceInfo = mock(ServiceInfo.class);
index 2aed2a5e5a3f518c757cc9ad21c233a58f677098..832aac0f2f58b550be3e50c6b442c23741b3e0c6 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.fmiweather;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -30,7 +30,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeMatcher;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 import org.openhab.binding.fmiweather.internal.client.Client;
 import org.openhab.binding.fmiweather.internal.client.Data;
 import org.openhab.binding.fmiweather.internal.client.FMIResponse;
@@ -47,7 +47,7 @@ public class AbstractFMIResponseParsingTest {
     @NonNullByDefault({})
     protected Client client;
 
-    @Before
+    @BeforeEach
     public void setUpClient() {
         client = new Client();
     }
index 0dac14230dfe1aa711b4e5fd3f31c07a5da82854..d5a2ccc0d7cf16fbae6b4ad3c1d12c713ba241df 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.math.BigDecimal;
 import java.util.AbstractMap;
@@ -22,7 +22,7 @@ import java.util.List;
 import java.util.Map.Entry;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.FMISID;
 import org.openhab.binding.fmiweather.internal.client.ForecastRequest;
 import org.openhab.binding.fmiweather.internal.client.LatLon;
index 7fbfb341958170dcbea17db2488ee0128fde2a71..0cfdcb81b534990b638b0542eaa40731b24cb815 100644 (file)
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.nio.file.Path;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.Client;
 import org.openhab.binding.fmiweather.internal.client.FMIResponse;
 
@@ -33,7 +34,7 @@ public class FMIResponseParsingEmptyTest extends AbstractFMIResponseParsingTest
 
     private FMIResponse observationsResponse;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         client = new Client();
         try {
index 971fccfdea567fb14ef8d2224c1c7d644b82d7e8..d4825f4283b26d806a4100a83012dd762f23cfb6 100644 (file)
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.nio.file.Path;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
 
 /**
index 3871d8ed03284f8ac39cc9d4f8c4dc11d2300462..fc3a1be7bb1e104cee25a60cb22f8344df9cda4b 100644 (file)
  */
 package org.openhab.binding.fmiweather;
 
-import java.io.IOException;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.nio.file.Path;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
 import org.xml.sax.SAXParseException;
 
@@ -30,13 +31,15 @@ public class FMIResponseParsingInvalidOrUnexpectedXmlTest extends AbstractFMIRes
 
     private Path observations1 = getTestResource("observations_single_place.xml");
 
-    @Test(expected = SAXParseException.class)
-    public void testInvalidXml() throws IOException, Throwable {
-        parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<"));
+    @Test
+    public void testInvalidXml() {
+        assertThrows(SAXParseException.class,
+                () -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<")));
     }
 
-    @Test(expected = FMIResponseException.class)
-    public void testUnexpectedXml() throws IOException, Throwable {
-        parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>"));
+    @Test
+    public void testUnexpectedXml() {
+        assertThrows(FMIResponseException.class,
+                () -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>")));
     }
 }
index 09b7b73483a8edbb76b849ba4ddf54f894a73d44..0b74663d4cd64d2fde1e5dbd79320440de248226 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.math.BigDecimal;
 import java.nio.file.Path;
@@ -21,8 +21,8 @@ import java.util.Optional;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.Data;
 import org.openhab.binding.fmiweather.internal.client.FMIResponse;
 import org.openhab.binding.fmiweather.internal.client.Location;
@@ -60,7 +60,7 @@ public class FMIResponseParsingMultiplePlacesTest extends AbstractFMIResponsePar
     private Location pointWithNoName = new Location("19.9,61.0973", "61.09726,19.90000", new BigDecimal("61.09726"),
             new BigDecimal("19.90000"));
 
-    @Before
+    @BeforeEach
     public void setUp() {
         try {
             observationsMultiplePlacesResponse = parseMultiPointCoverageXml(
index e0b5c1e3eba395768fe82af9c392433f4018d0b2..6cab15ec61b32632ef57083e18e2d33debeb4bf6 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.math.BigDecimal;
 import java.nio.file.Path;
@@ -21,8 +22,8 @@ import java.util.Optional;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.Data;
 import org.openhab.binding.fmiweather.internal.client.FMIResponse;
 import org.openhab.binding.fmiweather.internal.client.Location;
@@ -46,7 +47,7 @@ public class FMIResponseParsingSinglePlaceTest extends AbstractFMIResponseParsin
     private Location emasalo = new Location("Porvoo Emäsalo", "101023", new BigDecimal("60.20382"),
             new BigDecimal("25.62546"));
 
-    @Before
+    @BeforeEach
     public void setUp() {
         try {
             observationsResponse1 = parseMultiPointCoverageXml(readTestResourceUtf8(observations1));
index a4e3389f6a5e23e088e5c8b370b888ef172180d3..de9ce53e45103e882516d7a039eee07408b3e696 100644 (file)
 package org.openhab.binding.fmiweather;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.math.BigDecimal;
 import java.nio.file.Path;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.fmiweather.internal.client.Location;
 
 /**
index 8f4455d28140373ddc953d647bc4d7952dbc2352..7824f180cf987447df0e484d14de7aa1d10623e1 100644 (file)
  */
 package org.openhab.binding.foobot.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.openhab.binding.foobot.internal.FoobotApiConnector;
 import org.openhab.binding.foobot.internal.FoobotApiException;
@@ -50,7 +50,7 @@ public class FoobotAccountHandlerTest {
     public void testSensorDataToState() throws IOException, FoobotApiException {
         final List<FoobotDevice> deviceList = handler.getDeviceList();
 
-        assertFalse("Device list should not return empty", deviceList.isEmpty());
-        assertEquals("1234567890ABCDEF", deviceList.get(0).getUuid());
+        assertFalse(deviceList.isEmpty(), "Device list should not return empty");
+        assertEquals(deviceList.get(0).getUuid(), "1234567890ABCDEF");
     }
 }
index 71e2fcf5c64b83b45b3865c4cdb363b8caab9564..8041d8bb662cff55432a595c64d29bacd015b516 100644 (file)
  */
 package org.openhab.binding.foobot.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.io.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.openhab.binding.foobot.internal.FoobotApiConnector;
 import org.openhab.binding.foobot.internal.FoobotApiException;
@@ -52,7 +52,7 @@ public class FoobotDeviceHandlerTest {
     public void testSensorDataToState() throws IOException, FoobotApiException {
         final FoobotJsonData sensorData = connector.getSensorData("1234");
 
-        assertNotNull("No sensor data read", sensorData);
+        assertNotNull(sensorData, "No sensor data read");
         assertEquals(handler.sensorDataToState("temperature", sensorData), new QuantityType(12.345, SIUnits.CELSIUS));
         assertEquals(handler.sensorDataToState("gpi", sensorData), new DecimalType(5.6789012));
     }
index e5de49ad2eb0349833078d1e0c736009cb356515..f1f00de3cce4851373e18c57141c9710ea41213a 100644 (file)
  */
 package org.openhab.binding.freebox.internal.api;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  *
@@ -27,6 +28,6 @@ public class FreeboxApiManagerTest {
     public void hmacSha1Test() throws Exception {
         String expected = "25dad1bb5604321f12b755cc9d755d1480cf7989";
         String actual = FreeboxApiManager.hmacSha1("Token1234", "Challenge");
-        Assert.assertEquals(expected, actual);
+        assertEquals(expected, actual);
     }
 }
index a836cbba757579ec7424d645b0c1a069495934d6..64c49979a422eff7dc7c602b04ade5c362de6d9b 100644 (file)
  */
 package org.openhab.binding.fsinternetradio.test;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.jupnp.model.meta.DeviceDetails;
 import org.jupnp.model.meta.ManufacturerDetails;
@@ -80,7 +80,7 @@ public class FSInternetRadioDiscoveryParticipantJavaTest {
     String DEFAULT_RADIO_THING_UID = String.format("%s:%s:%s", RADIO_BINDING_ID, RADIO_THING_TYPE_ID,
             DEFAULT_RADIO_SERIAL_NUMBER);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         discoveryParticipant = new FSInternetRadioDiscoveryParticipant();
     }
index e03b7c0b53387d476131c4d506bed73344d3d4bd..b4de21d03c6ad6a6105e5e6d5ffd9d3070fe0de2 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.fsinternetradio.test;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.isA;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants.*;
@@ -29,11 +30,10 @@ import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.servlet.ServletHolder;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants;
 import org.openhab.binding.fsinternetradio.internal.handler.FSInternetRadioHandler;
@@ -124,7 +124,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
     private static final String DEFAULT_CONFIG_PROPERTY_REFRESH = "1";
     private static final Configuration DEFAULT_COMPLETE_CONFIGURATION = createDefaultConfiguration();
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() throws Exception {
         ServletHolder holder = new ServletHolder(radioServiceDummy);
         server = new TestServer(DEFAULT_CONFIG_PROPERTY_IP, DEFAULT_CONFIG_PROPERTY_PORT, TIMEOUT, holder);
@@ -134,12 +134,12 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         httpClient.start();
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         createThePowerChannel();
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownClass() throws Exception {
         server.stopServer();
         httpClient.stop();
@@ -147,13 +147,13 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
     private static @NonNull Channel getChannel(final @NonNull Thing thing, final @NonNull String channelId) {
         final Channel channel = thing.getChannel(channelId);
-        Assert.assertNotNull(channel);
+        assertNotNull(channel);
         return channel;
     }
 
     private static @NonNull ChannelUID getChannelUID(final @NonNull Thing thing, final @NonNull String channelId) {
         final ChannelUID channelUID = getChannel(thing, channelId).getUID();
-        Assert.assertNotNull(channelUID);
+        assertNotNull(channelUID);
         return channelUID;
     }
 
@@ -290,15 +290,15 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
         radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
         waitForAssert(() -> {
-            assertTrue("We should be able to turn on the radio",
-                    radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
+            assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
+                    "We should be able to turn on the radio");
             radioServiceDummy.clearRequestParameters();
         });
 
         radioHandler.handleCommand(powerChannelUID, OnOffType.OFF);
         waitForAssert(() -> {
-            assertTrue("We should be able to turn off the radio",
-                    radioServiceDummy.containsRequestParameter(0, CHANNEL_POWER));
+            assertTrue(radioServiceDummy.containsRequestParameter(0, CHANNEL_POWER),
+                    "We should be able to turn off the radio");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -308,8 +308,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
          */
         radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
         waitForAssert(() -> {
-            assertTrue("We should be able to turn on the radio",
-                    radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
+            assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
+                    "We should be able to turn on the radio");
             radioServiceDummy.clearRequestParameters();
         });
     }
@@ -333,15 +333,15 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
         radioHandler.handleCommand(muteChannelUID, OnOffType.ON);
         waitForAssert(() -> {
-            assertTrue("We should be able to mute the radio",
-                    radioServiceDummy.containsRequestParameter(1, CHANNEL_MUTE));
+            assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_MUTE),
+                    "We should be able to mute the radio");
             radioServiceDummy.clearRequestParameters();
         });
 
         radioHandler.handleCommand(muteChannelUID, OnOffType.OFF);
         waitForAssert(() -> {
-            assertTrue("We should be able to unmute the radio",
-                    radioServiceDummy.containsRequestParameter(0, CHANNEL_MUTE));
+            assertTrue(radioServiceDummy.containsRequestParameter(0, CHANNEL_MUTE),
+                    "We should be able to unmute the radio");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -370,8 +370,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
         radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1"));
         waitForAssert(() -> {
-            assertTrue("We should be able to update the mode channel correctly",
-                    radioServiceDummy.containsRequestParameter(1, CHANNEL_MODE));
+            assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_MODE),
+                    "We should be able to update the mode channel correctly");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -381,8 +381,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
          */
         radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("3"));
         waitForAssert(() -> {
-            assertTrue("We should be able to update the mode channel correctly",
-                    radioServiceDummy.containsRequestParameter(3, CHANNEL_MODE));
+            assertTrue(radioServiceDummy.containsRequestParameter(3, CHANNEL_MODE),
+                    "We should be able to update the mode channel correctly");
             radioServiceDummy.clearRequestParameters();
         });
     }
@@ -450,8 +450,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("36"));
 
         waitForAssert(() -> {
-            assertTrue("The volume should not exceed the maximum value",
-                    radioServiceDummy.containsRequestParameter(32, VOLUME));
+            assertTrue(radioServiceDummy.containsRequestParameter(32, VOLUME),
+                    "The volume should not exceed the maximum value");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -459,8 +459,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         radioHandler.handleCommand(absoluteVolumeChannelUID, IncreaseDecreaseType.INCREASE);
 
         waitForAssert(() -> {
-            assertTrue("The volume should not be increased above the maximum value",
-                    radioServiceDummy.areRequestParametersEmpty());
+            assertTrue(radioServiceDummy.areRequestParametersEmpty(),
+                    "The volume should not be increased above the maximum value");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -468,16 +468,16 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         radioHandler.handleCommand(absoluteVolumeChannelUID, UpDownType.UP);
 
         waitForAssert(() -> {
-            assertTrue("The volume should not be increased above the maximum value",
-                    radioServiceDummy.areRequestParametersEmpty());
+            assertTrue(radioServiceDummy.areRequestParametersEmpty(),
+                    "The volume should not be increased above the maximum value");
             radioServiceDummy.clearRequestParameters();
         });
 
         // Trying to set a value that is lower than the minimum volume value
         radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("-10"));
         waitForAssert(() -> {
-            assertTrue("The volume should not be decreased below 0",
-                    radioServiceDummy.containsRequestParameter(0, VOLUME));
+            assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
+                    "The volume should not be decreased below 0");
             radioServiceDummy.clearRequestParameters();
         });
 
@@ -489,8 +489,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         // trying to set the volume
         radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("15"));
         waitForAssert(() -> {
-            assertTrue("We should be able to set the volume correctly",
-                    radioServiceDummy.containsRequestParameter(15, VOLUME));
+            assertTrue(radioServiceDummy.containsRequestParameter(15, VOLUME),
+                    "We should be able to set the volume correctly");
             radioServiceDummy.clearRequestParameters();
         });
     }
@@ -586,16 +586,16 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
          */
         radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("50"));
         waitForAssert(() -> {
-            assertTrue("We should be able to set the volume correctly using percentages.",
-                    radioServiceDummy.containsRequestParameter(16, VOLUME));
+            assertTrue(radioServiceDummy.containsRequestParameter(16, VOLUME),
+                    "We should be able to set the volume correctly using percentages.");
             radioServiceDummy.clearRequestParameters();
         });
 
         radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("15"));
 
         waitForAssert(() -> {
-            assertTrue("We should be able to set the volume correctly using percentages.",
-                    radioServiceDummy.containsRequestParameter(4, VOLUME));
+            assertTrue(radioServiceDummy.containsRequestParameter(4, VOLUME),
+                    "We should be able to set the volume correctly using percentages.");
             radioServiceDummy.clearRequestParameters();
         });
     }
@@ -605,31 +605,31 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
             // First we have to make sure that the item state is 0
             radioHandler.handleCommand(channelUID, DecimalType.valueOf("0"));
             waitForAssert(() -> {
-                assertTrue("We should be able to turn on the radio",
-                        radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
+                assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
+                        "We should be able to turn on the radio");
                 radioServiceDummy.clearRequestParameters();
             });
 
             radioHandler.handleCommand(channelUID, IncreaseDecreaseType.INCREASE);
 
             waitForAssert(() -> {
-                assertTrue("We should be able to increase the volume correctly",
-                        radioServiceDummy.containsRequestParameter(1, VOLUME));
+                assertTrue(radioServiceDummy.containsRequestParameter(1, VOLUME),
+                        "We should be able to increase the volume correctly");
                 radioServiceDummy.clearRequestParameters();
             });
 
             radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE);
             waitForAssert(() -> {
-                assertTrue("We should be able to increase the volume correctly",
-                        radioServiceDummy.containsRequestParameter(0, VOLUME));
+                assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
+                        "We should be able to increase the volume correctly");
                 radioServiceDummy.clearRequestParameters();
             });
 
             // Trying to decrease one more time
             radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE);
             waitForAssert(() -> {
-                assertFalse("We should be able to decrease the volume correctly",
-                        radioServiceDummy.containsRequestParameter(0, VOLUME));
+                assertFalse(radioServiceDummy.containsRequestParameter(0, VOLUME),
+                        "We should be able to decrease the volume correctly");
                 radioServiceDummy.clearRequestParameters();
             });
         }
@@ -640,30 +640,30 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
             // First we have to make sure that the item state is 0
             radioHandler.handleCommand(channelUID, DecimalType.valueOf("0"));
             waitForAssert(() -> {
-                assertTrue("We should be able to turn on the radio",
-                        radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
+                assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
+                        "We should be able to turn on the radio");
                 radioServiceDummy.clearRequestParameters();
             });
 
             radioHandler.handleCommand(channelUID, UpDownType.UP);
             waitForAssert(() -> {
-                assertTrue("We should be able to increase the volume correctly",
-                        radioServiceDummy.containsRequestParameter(1, VOLUME));
+                assertTrue(radioServiceDummy.containsRequestParameter(1, VOLUME),
+                        "We should be able to increase the volume correctly");
                 radioServiceDummy.clearRequestParameters();
             });
 
             radioHandler.handleCommand(channelUID, UpDownType.DOWN);
             waitForAssert(() -> {
-                assertTrue("We should be able to decrease the volume correctly",
-                        radioServiceDummy.containsRequestParameter(0, VOLUME));
+                assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
+                        "We should be able to decrease the volume correctly");
                 radioServiceDummy.clearRequestParameters();
             });
 
             // Trying to decrease one more time
             radioHandler.handleCommand(channelUID, UpDownType.DOWN);
             waitForAssert(() -> {
-                assertTrue("We shouldn't be able to decrease the volume below 0",
-                        radioServiceDummy.areRequestParametersEmpty());
+                assertTrue(radioServiceDummy.areRequestParametersEmpty(),
+                        "We shouldn't be able to decrease the volume below 0");
                 radioServiceDummy.clearRequestParameters();
             });
         }
@@ -687,8 +687,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
         radioHandler.handleCommand(presetChannelUID, DecimalType.valueOf("100"));
         waitForAssert(() -> {
-            assertTrue("We should be able to set value to the preset",
-                    radioServiceDummy.containsRequestParameter(100, PRESET));
+            assertTrue(radioServiceDummy.containsRequestParameter(100, PRESET),
+                    "We should be able to set value to the preset");
             radioServiceDummy.clearRequestParameters();
         });
     }
index 81ab1bea0123e0faf98731949427fcc7ff2f4f65..2858f7bccf78865f5d078593f6dd3bd59b0725d5 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.hdpowerview;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.hdpowerview.internal.api.ActuatorClass.*;
 import static org.openhab.binding.hdpowerview.internal.api.CoordinateSystem.*;
 
@@ -28,7 +28,7 @@ import javax.ws.rs.client.ClientBuilder;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.hdpowerview.internal.HDPowerViewWebTargets;
 import org.openhab.binding.hdpowerview.internal.HubMaintenanceException;
 import org.openhab.binding.hdpowerview.internal.api.CoordinateSystem;
index 80a43e6c8c1be022aab55ad8fd06ea771da6fbc0..19149801732c4616053bcf91ac47c2c312e8e68b 100644 (file)
 package org.openhab.binding.heos.internal.json;
 
 import static java.lang.Long.valueOf;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute;
 import org.openhab.binding.heos.internal.json.dto.HeosEvent;
 import org.openhab.binding.heos.internal.json.dto.HeosEventObject;
index 97ca0cd761fafa447e28a1ad4e609a6faf4da628..661d0aec4b6e6a743275d44e40b6458b0edd754f 100644 (file)
  */
 package org.openhab.binding.heos.internal.json;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.heos.internal.json.dto.HeosCommand;
 import org.openhab.binding.heos.internal.json.dto.HeosCommandGroup;
 import org.openhab.binding.heos.internal.json.dto.HeosErrorCode;
index 0e6acdd6f904e959fac64b1c23cd556dcdb7ecd9..4633ca118251348a3f6ebe884e2005fe8e670cc5 100644 (file)
  */
 package org.openhab.binding.heos.internal.json.dto;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.heos.internal.json.dto.HeosCommand.*;
 import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.SYSTEM;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests to validate the functioning of the HeosCommandTuple
index 8106da4ef7154b0e6d05e6387ca17e5feed945ef..a9c958997ffc08b45d07c4c64f29e06f1c3d3965 100644 (file)
@@ -20,8 +20,8 @@ import static org.openhab.binding.homematic.test.util.RpcClientMockImpl.*;
 
 import java.io.IOException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.communicator.message.RpcRequest;
 import org.openhab.binding.homematic.internal.communicator.message.XmlRpcRequest;
 import org.openhab.binding.homematic.internal.model.HmChannel;
@@ -36,7 +36,7 @@ public class RpcClientTest extends JavaTest {
 
     private RpcClientMockImpl rpcClient;
 
-    @Before
+    @BeforeEach
     public void setup() throws IOException {
         this.rpcClient = new RpcClientMockImpl();
     }
index 7fcff03350542ad30756e448d8b8ae0d8bc3464e..e948a7f147662bf5f38995bed7e6e2775f022b70 100644 (file)
@@ -17,8 +17,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.IOException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.misc.HomematicClientException;
 import org.openhab.binding.homematic.internal.misc.HomematicConstants;
 import org.openhab.binding.homematic.internal.misc.MiscUtils;
@@ -44,7 +44,7 @@ public class ButtonDatapointTest extends JavaTest {
     private MockEventReceiver mockEventReceiver;
     private final ButtonVirtualDatapointHandler bvdpHandler = new ButtonVirtualDatapointHandler();
 
-    @Before
+    @BeforeEach
     public void setup() throws IOException {
         this.mockEventReceiver = new MockEventReceiver();
     }
index 380607a32e852b51d98a0f33e172163848f21a37..4737cd8ce880befbea74a0db336be35d6de92d2b 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.homematic.internal.converter;
 
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 import org.openhab.binding.homematic.internal.model.HmChannel;
 import org.openhab.binding.homematic.internal.model.HmDatapoint;
 import org.openhab.binding.homematic.internal.model.HmDevice;
@@ -34,7 +34,7 @@ public class BaseConverterTest {
     protected final HmDatapoint integerQuantityDp = new HmDatapoint("floatIntegerDp", "", HmValueType.INTEGER, null,
             false, HmParamsetType.VALUES);
 
-    @Before
+    @BeforeEach
     public void setup() {
         HmChannel stubChannel = new HmChannel("stubChannel", 0);
         stubChannel.setDevice(new HmDevice("LEQ123456", HmInterface.RF, "HM-STUB-DEVICE", "", "", ""));
index 6f78cfe1259cd60afbc163d3484be8c7549e9f57..3c019a28bbfa42d133b475e05aa4444f06553d7a 100644 (file)
@@ -13,9 +13,9 @@
 package org.openhab.binding.homematic.internal.converter;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter;
 import org.openhab.binding.homematic.internal.model.HmDatapoint;
 import org.openhab.core.library.types.DecimalType;
index 7d996a8a589cb461b413cb127ca4c819d6418eb5..8f78938b90176916d4a26a9427bd258e54d01bdd 100644 (file)
@@ -14,8 +14,9 @@ package org.openhab.binding.homematic.internal.converter;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter;
 import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter;
 import org.openhab.binding.homematic.internal.converter.type.QuantityTypeConverter;
@@ -99,15 +100,15 @@ public class ConvertToBindingTest extends BaseConverterTest {
         assertThat(convertedValue, is(42));
     }
 
-    @Test(expected = ConverterException.class)
-    public void testQuantityTypeConverterFailsToConvertDecimalType() throws ConverterException {
+    @Test
+    public void testQuantityTypeConverterFailsToConvertDecimalType() {
         QuantityTypeConverter converter = new QuantityTypeConverter();
-        converter.convertToBinding(new DecimalType(99.9), floatDp);
+        assertThrows(ConverterException.class, () -> converter.convertToBinding(new DecimalType(99.9), floatDp));
     }
 
-    @Test(expected = ConverterException.class)
-    public void testDecimalTypeConverterFailsToConvertQuantityType() throws ConverterException {
+    @Test
+    public void testDecimalTypeConverterFailsToConvertQuantityType() {
         DecimalTypeConverter converter = new DecimalTypeConverter();
-        converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp);
+        assertThrows(ConverterException.class, () -> converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp));
     }
 }
index be8fde7081032989d1f869f48dd7d5c82830d5e3..1ef01829fcf2caa1ae50bbed02fe3187db2fcd01 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.homematic.internal.converter;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter;
 import org.openhab.binding.homematic.internal.converter.type.OnOffTypeConverter;
 import org.openhab.binding.homematic.internal.converter.type.OpenClosedTypeConverter;
index 6ac6ef647540d01215620a068f319931b647e10d..c78e8822062de0b617a3d96b772109fd3337ad29 100644 (file)
@@ -21,8 +21,8 @@ import static org.openhab.binding.homematic.test.util.DimmerHelper.createDimmerH
 
 import java.io.IOException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
 import org.openhab.binding.homematic.internal.handler.HomematicBridgeHandler;
 import org.openhab.binding.homematic.internal.model.HmDevice;
@@ -46,7 +46,7 @@ public class HomematicDeviceDiscoveryServiceTest extends JavaTest {
     private HomematicDeviceDiscoveryService homematicDeviceDiscoveryService;
     private HomematicBridgeHandler homematicBridgeHandler;
 
-    @Before
+    @BeforeEach
     public void setup() throws IOException {
         this.homematicBridgeHandler = mockHomematicBridgeHandler();
         this.homematicDeviceDiscoveryService = new HomematicDeviceDiscoveryService();
index e22056af39c05c57d94fc90e12a48bea577576f2..9e693b6bb3cf6fa0540226af277d15df08160abb 100644 (file)
@@ -19,8 +19,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link org.openhab.binding.homematic.internal.handler.SimplePortPool}.
@@ -31,7 +31,7 @@ public class SimplePortPoolTest {
 
     private SimplePortPool simplePortPool;
 
-    @Before
+    @BeforeEach
     public void setup() {
         this.simplePortPool = new SimplePortPool();
     }
index f70ad96815bab5e926a27e7fd1d72f7f949b20fd..9d976a80d1d36bead9c1a95d6c6f7f895f0cd788 100644 (file)
@@ -17,7 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.openhab.binding.homematic.test.util.BridgeHelper.createHomematicBridge;
 import static org.openhab.binding.homematic.test.util.DimmerHelper.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.homematic.internal.model.HmChannel;
 import org.openhab.binding.homematic.internal.model.HmDatapoint;
 import org.openhab.binding.homematic.internal.model.HmDatapointInfo;
index aac7516caf03f25ef7f267625a584658e9866b0c..25725d24c76c14b2b1f0d08117e26c025ca469bb 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.hue.internal;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  *
index 702106d926d7cdf7a3350b8c58f8dd5113d26f0e..2415342bf9f865d86de506a5ca069829f915c695 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.hue.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
@@ -23,7 +23,7 @@ import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openhab.binding.hue.internal.HttpClient.Result;
 import org.openhab.binding.hue.internal.exceptions.ApiException;
index 01c9116b9e01fddcf0d525a6111c870d61490adb..74e7b1db8a3ba50369e474edf112155537d45df8 100644 (file)
 package org.openhab.binding.hue.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.hue.internal.State.ColorMode;
 import org.openhab.binding.hue.internal.handler.LightStateConverter;
 import org.openhab.core.library.types.DecimalType;
index efd0326e7c8e5361a6e195eb5e508dfdbaf35a8d..66484dccf4ad086e6d3a4d249312644e86863f71 100644 (file)
 package org.openhab.binding.hue.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author HJiang - initial contribution
index 90d12cbcda9c8d3c3c5ff6c30a8a625064fa9fb0..87b22e43890c9b9dacedc4cc60cfd7e3c25e1f4a 100644 (file)
  */
 package org.openhab.binding.hue.internal.handler;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.hue.internal.HueBindingConstants.*;
 
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.hue.internal.FullConfig;
 import org.openhab.binding.hue.internal.FullLight;
@@ -65,7 +65,7 @@ public class HueLightHandlerTest {
 
     private Gson gson;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         gson = new Gson();
     }
index e210be20ecc618a814a2b6e531a5d000fa85c889..dead9ac63c01dfcb942f571f9ab37799d6020d72 100644 (file)
  */
 package org.openhab.binding.icalendar.internal.logic;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.time.Instant;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.HSBType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
@@ -45,7 +45,7 @@ public class BiweeklyPresentableCalendarTest {
     private AbstractPresentableCalendar calendar2;
     private AbstractPresentableCalendar calendar3;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException, CalendarException {
         calendar = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test.ics"));
         calendar2 = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test2.ics"));
index ecc9cdaebcb875fff599049bb73d0f897d143b75..5ffb675da416cc8e975d598c99783ffb9023bfa2 100644 (file)
  */
 package org.openhab.binding.ihc.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.Duration;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for IHC / ELKO binding
index bcdc0bd5a2b397dca1b4ca4ba68c285b6f6dc9e0..6cf995eb4d450a2146d5e0b928450b9b3596ee18 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for IHC / ELKO binding
index 94b6252076e3c960c705d8e6ed0bf67a45e3a54c..34bd8eff44125850bf3c3ae51a333af3327ed308 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSDateValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index 2d08cf61c630138d44c1ca457a4d7ff85bc8db38..99c99e5d68fca8f1b0372568fae7a95f802ba5a8 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimeValue;
index bb56d4595c3b7509e8251fe230a342b8690aa204..945302d8c28d3d88b5ce4fc6a6da7551cc06741b 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index b82905807d3384d9b635ecc1ff702cfa9dd2e156..65dcc5ea40ffbf128a30e4941375f2a2d0b8f8b7 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSEnumValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index b1f0c6c27b8d46ca89043486b2b06b0f5a945140..02e2214f8cb4595e19482c9c6946ab6665726ca3 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSFloatingPointValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -42,16 +42,18 @@ public class DecimalTypeWSFloatingPointValueConverterTest {
         assertEquals(new DecimalType(2.54), type);
     }
 
-    @Test(expected = ConversionException.class)
-    public void testMinExceed() throws ConversionException {
+    @Test
+    public void testMinExceed() {
         WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100);
-        val = convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null));
+        assertThrows(ConversionException.class,
+                () -> convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)));
     }
 
-    @Test(expected = ConversionException.class)
-    public void testMaxExceed() throws ConversionException {
+    @Test
+    public void testMaxExceed() {
         WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100);
-        val = convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null));
+        assertThrows(ConversionException.class,
+                () -> convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)));
     }
 
     private WSFloatingPointValue convertFromOHType(WSFloatingPointValue IHCvalue, Type OHval,
index 2b9ad2512fb86c594a5ca496f34c3fc3533138e6..03ecc558551061f65099e561a0ed9bf4d7831c4d 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -42,16 +42,18 @@ public class DecimalTypeWSIntegerValueConverterTest {
         assertEquals(new DecimalType(2), type);
     }
 
-    @Test(expected = ConversionException.class)
-    public void testMinExceed() throws ConversionException {
+    @Test
+    public void testMinExceed() {
         WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
-        val = convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null));
+        assertThrows(ConversionException.class,
+                () -> convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)));
     }
 
-    @Test(expected = ConversionException.class)
-    public void testMaxExceed() throws ConversionException {
+    @Test
+    public void testMaxExceed() {
         WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
-        val = convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null));
+        assertThrows(ConversionException.class,
+                () -> convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)));
     }
 
     private WSIntegerValue convertFromOHType(WSIntegerValue IHCvalue, Type OHval,
index 4f7864b80c5e919a87d62a820d27a61aa676c144..cd90699e0b0a5855ed1f40dce40a440ecc6940f0 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimerValue;
index cdf7ceb4f6d92c10924fa6b1ead5af86f2e33181..3cfa0f21b53e7534c4a0f8a0ce56d4c3d7e53e88 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSWeekdayValue;
index 89f5fb375c555d8dafa775079a07618e6ac5b9fa..82e920423e1601fea47427c51a89b9172c53dfcb 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index a25a3d5b5d45e777e8c8dd0cc226d52b13819629..3d6c4dfafa9d52d76716f5b60b347140f621a8b5 100644 (file)
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -69,15 +69,15 @@ public class OnOffTypeWSIntegerValueConverterTest {
         assertEquals(OnOffType.ON, type);
     }
 
-    @Test(expected = ConversionException.class)
-    public void testOnLevelledError() throws ConversionException {
+    @Test
+    public void testOnLevelledError() {
         WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
 
         Map<Command, Object> commandLevels = new HashMap<>();
         commandLevels.put(OnOffType.ON, "70");
 
-        val = convertFromOHType(val, OnOffType.ON,
-                new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels)));
+        assertThrows(ConversionException.class, () -> convertFromOHType(val, OnOffType.ON,
+                new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels))));
     }
 
     @Test
index f7e4b086f6b0961634d3b2a6dc56c3832c177413..875eef0571769e1c93864e931c961c8a13d0088a 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index f44cd05624ad2dc71f307e64d37a8705829046ec..8fc8acd2cdb44da6b552256dbe81182e236e3f89 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index 69cddaaf3c5ee529ed84254e185d821c8f7367ff..11273a08e019c1f00e6992ec75315e3e7e5360da 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index d65c0b3674f75768b32d5f37a2d70ef37d356476..5f56b39afd6b3ad5ae03503090fa74638e41a710 100644 (file)
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.projectfile.IhcEnumValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSEnumValue;
index 9fa584d81824bb6728c3cee312acf561d01756bf..e0bb7cafd75b15b32538fd725aaaf7aa86942562 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index e9d9a90aefdc58efb49fbefdec9a2063c1aa84c9..36a9bcb3ac1ed758c28a95adb6755e3c11b27e8d 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.ihc.internal.converters;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
 import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
index 28661f82c72e1164e60728d07edd86b26dea1fda..22fb22f98d863536b169865bbc07577189a08247 100644 (file)
  */
 package org.openhab.binding.ihc.internal.ws;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 import java.io.UnsupportedEncodingException;
 import java.net.SocketTimeoutException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentMatchers;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSFile;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSProjectInfo;
@@ -34,7 +34,7 @@ public class IhcClientTest {
 
     private IhcClient ihcClient;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcClient = spy(new IhcClient("test1", "test2", "test3"));
         WSProjectInfo projectInfo = new WSProjectInfo();
index 6fa549ed8946f596213f29a87b2b3252b7ef36d3..6d73811663a98ee1fa7a03b46fd65819bd301f77 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.BufferedReader;
 import java.io.IOException;
index e40186c51c83889223aa5362ab94def609eef7f4..c3cb9256c6be7c434e4d9e2630eff5b0a00d9fcb 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -21,8 +21,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSRFDevice;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -42,7 +42,7 @@ public class IhcAirlinkManagementServiceTest {
     private String query;
     private final int timeout = 100;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcAirlinkManagementService = spy(new IhcAirlinkManagementService(host, timeout, new IhcConnectionPool()));
 
index 4c7144906ab3e87634cbfc5755f61764fc209412..b05eaa96359c5cb5ccadd6e37e0c0e03365b8e35 100644 (file)
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 import java.net.SocketTimeoutException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSLoginResult;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -37,7 +37,7 @@ public class IhcAuthenticationServiceTest {
     private final String url = "https://1.1.1.1/ws/AuthenticationService";
     private final int timeout = 100;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcAuthenticationService = spy(new IhcAuthenticationService(host, timeout, new IhcConnectionPool()));
 
index b3f8109cb3b993985bbf299c96528621ac734464..d880f8fb38446d18e68d118362f16bb1b5d77fd7 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSSystemInfo;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -43,7 +43,7 @@ public class IhcConfigurationServiceTest {
     private Map<String, String> requestProps = new HashMap<>();
     private final int timeout = 100;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcConfigurationService = spy(new IhcConfigurationService(host, timeout, new IhcConnectionPool()));
         requestProps.clear();
index 0c8f208b85db8edb241ae91c2c2635a34c8fd52c..4b566699b30b2417792a8b28c221c778ae35d370 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
@@ -21,8 +21,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.IhcClient;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSControllerState;
@@ -45,7 +45,7 @@ public class IhcControllerServiceTest {
     private String query;
     private final int timeout = 100;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcControllerService = spy(new IhcControllerService(host, timeout, new IhcConnectionPool()));
 
@@ -138,6 +138,6 @@ public class IhcControllerServiceTest {
         final byte[] expectedResult = "LvVF4VWSi0WqRKps7lGH6U....OBCl1gwKGbvYM1SDh".getBytes();
         final WSFile result = ihcControllerService.getProjectSegment(1, 1001, 2002);
 
-        assertTrue("Result bytes doesn't match to expected bytes", Arrays.equals(expectedResult, result.getData()));
+        assertTrue(Arrays.equals(expectedResult, result.getData()), "Result bytes doesn't match to expected bytes");
     }
 }
index bfe461cdbc77b504b4345fd6b0c42cf7291f51d7..c4282050a85b709dad72d5d1c191fd76223c3e29 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
@@ -20,8 +20,8 @@ import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
 import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
@@ -46,7 +46,7 @@ public class IhcResourceInteractionServiceTest {
     private final String host = "1.1.1.1";
     private final String url = "https://1.1.1.1/ws/ResourceInteractionService";
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcResourceInteractionService = spy(new IhcResourceInteractionService(host, 0, new IhcConnectionPool()));
 
index 51871759aff066e387a8017ae8562e3b6e0d691e..fcbdecd3a25407bfb5fccbe4da2346c3456c025d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.ihc.internal.ws.services;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.WSTimeManagerSettings;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -42,7 +42,7 @@ public class IhcTimeServiceTest {
     private Map<String, String> requestProps = new HashMap<>();
     private final int timeout = 100;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IhcExecption, SocketTimeoutException {
         ihcTimeService = spy(new IhcTimeService(host, timeout, new IhcConnectionPool()));
 
index c56ff3552fe7f321b0d7913ecdcbd019032817c1..9b2e83041b80adc9163093b3d43e6a82d364513b 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.innogysmarthome.internal;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 import java.net.URI;
@@ -22,8 +22,8 @@ import java.util.concurrent.Future;
 import org.eclipse.jetty.websocket.api.Session;
 import org.eclipse.jetty.websocket.api.StatusCode;
 import org.eclipse.jetty.websocket.client.WebSocketClient;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
 
 /**
@@ -36,7 +36,7 @@ public class InnogyWebSocketTest {
     private WebSocketClient webSocketClientMock;
     private Session sessionMock;
 
-    @Before
+    @BeforeEach
     public void before() throws Exception {
         sessionMock = mock(Session.class);
 
index 018880661c9ba1ff1c289203440145ae39baf1ec..974a343a931d193f14f5da6e828bb00847126d99 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.innogysmarthome.internal.handler;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 import java.net.ConnectException;
@@ -23,8 +23,8 @@ import java.util.concurrent.ScheduledFuture;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jetty.client.HttpClient;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
 import org.openhab.binding.innogysmarthome.internal.InnogyWebSocket;
 import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
@@ -47,7 +47,7 @@ public class InnogyBridgeHandlerTest {
     private Bridge bridgeMock;
     private InnogyWebSocket webSocketMock;
 
-    @Before
+    @BeforeEach
     public void before() throws Exception {
         bridgeMock = mock(Bridge.class);
         when(bridgeMock.getUID()).thenReturn(new ThingUID("innogysmarthome", "bridge"));
index f8a161b66f0917518b0c91a935209d04266bd86b..c13b751dd59ed1cf7180b6f19736a40d20e53ed4 100644 (file)
  */
 package org.openhab.binding.knx.internal.channel;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  *
@@ -30,7 +30,7 @@ public class KNXChannelTypeTest {
 
     private KNXChannelType ct;
 
-    @Before
+    @BeforeEach
     public void setup() {
         ct = new MyKNXChannelType("");
     }
index 20f8b6fd5acb0ac00e769cb46acc5c33bdeaec53..81c72f0edcc582d09560db7c69c79dd2a9f9060e 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.knx.internal.dpt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 
 /**
index b2f2bf319c9595a3c8f1c690f2b3f562a650dec4..79d5ef97752783cb53e29b21106e75446a4d3b9c 100644 (file)
 package org.openhab.binding.kodi.internal.utils;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.ConfigConstants;
 
 /**
@@ -45,18 +45,18 @@ public class ByteArrayFileCacheTest {
 
     private ByteArrayFileCache subject;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         subject = new ByteArrayFileCache(SERVICE_PID);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         // delete all files
         subject.clear();
     }
 
-    @AfterClass
+    @AfterAll
     public static void cleanUp() {
         // delete all folders
         SERVICE_CACHE_FOLDER.delete();
index 9d71534b78bf5f92e159b264d4633aa0df5c5261..e2b8052c39cc6017a0b84ff0700e4b0f96048253 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
 
 import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link LocalTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class LocalTimeTypeAdapter extends TemporalTypeAdapter<LocalTime> {
 
-  public LocalTimeTypeAdapter() {
-    super(LocalTime::parse);
-  }
+    public LocalTimeTypeAdapter() {
+        super(LocalTime::parse);
+    }
 }
index 68fda33ae85c4fe9b5e0ca90b5d0d16c9699a9ba..fab6a92bf6dd7043fe8183ab942aafd820e645ab 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
 
 import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link OffsetDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter<OffsetDateTime> {
 
-  public OffsetDateTimeTypeAdapter() {
-    super(OffsetDateTime::parse);
-  }
+    public OffsetDateTimeTypeAdapter() {
+        super(OffsetDateTime::parse);
+    }
 }
index c72859c0dda66aade7fbda6e7778490db76e366b..1035cc4f936ee7d6d25e10398ab66778e7d455d4 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
 
 import java.time.OffsetTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link OffsetTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class OffsetTimeTypeAdapter extends TemporalTypeAdapter<OffsetTime> {
 
-  public OffsetTimeTypeAdapter() {
-    super(OffsetTime::parse);
-  }
+    public OffsetTimeTypeAdapter() {
+        super(OffsetTime::parse);
+    }
 }
index 35fd20cf20ebaf3e3a3dce6b8e4706544cf262f5..df751bd2948858767d2ce991b4aab2ecb14ef9b3 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
 
 import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link ZonedDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter<ZonedDateTime> {
 
-  public ZonedDateTimeTypeAdapter() {
-    super(ZonedDateTime::parse);
-  }
+    public ZonedDateTimeTypeAdapter() {
+        super(ZonedDateTime::parse);
+    }
 }
index 652ab975522e60203742b0555a6f39e8ade062d0..beca8b4343fd3ff4e5efb0264c0e279b697f7845 100644 (file)
@@ -15,9 +15,9 @@
  */
 package org.openhab.binding.lametrictime.api.impl;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
 public class FileIconTest extends AbstractTest
index 5fb6b5acf5e3d444395d8526e0e570d493d20996..5dfb0570d6a7e9e8f7da8d2f287b7d0d1d7b32d0 100644 (file)
@@ -15,6 +15,8 @@
  */
 package org.openhab.binding.lametrictime.api.local.impl;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -22,9 +24,9 @@ import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Properties;
 
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.local.ApplicationActionException;
 import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
 import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException;
@@ -62,14 +64,14 @@ import org.openhab.binding.lametrictime.api.test.TestUtil;
  * integration-test'.
  * </p>
  */
-@Ignore
+@Disabled
 public class LaMetricTimeLocalImplIT {
     private static final String PROP_HOST = "host";
     private static final String PROP_API_KEY = "apiKey";
 
     private static LaMetricTimeLocalImpl local;
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() throws IOException {
         File file = TestUtil.getTestDataPath(LaMetricTimeLocalImplIT.class, "device.properties").toFile();
         if (!file.exists()) {
@@ -126,9 +128,9 @@ public class LaMetricTimeLocalImplIT {
         local.getNotifications();
     }
 
-    @Test(expected = NotificationNotFoundException.class)
-    public void testGetInvalidNotification() throws NotificationNotFoundException {
-        local.getNotification("invalid");
+    @Test
+    public void testGetInvalidNotification() {
+        assertThrows(NotificationNotFoundException.class, () -> local.getNotification("invalid"));
     }
 
     @Test
@@ -202,9 +204,9 @@ public class LaMetricTimeLocalImplIT {
         local.getApplication(CoreApps.weather().getPackageName());
     }
 
-    @Test(expected = ApplicationNotFoundException.class)
-    public void testGetInvalidApplication() throws ApplicationNotFoundException {
-        local.getApplication("invalid");
+    @Test
+    public void testGetInvalidApplication() {
+        assertThrows(ApplicationNotFoundException.class, () -> local.getApplication("invalid"));
     }
 
     @Test
index aed37d22fc5d1445cdef99aed0c9c15ccebff4cb..a8c71a2e836eefa00f3aebf7dc39afcefb1e5fd5 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Iterator;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -33,7 +33,7 @@ public class ActionTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index f208c962fbde1eab4234d4271291e9ecc69ed24a..a450205d4fd2d97ad73781e08ece4eb3b39ca9f2 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Iterator;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -33,7 +33,7 @@ public class ApplicationTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index f0ed9eebe444aabded05f89a7a992f436ca49e1d..d44394f2b0afd7a6bda5fa90fc0da8a4c313226b 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -30,7 +30,7 @@ public class AudioTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index 37d9997d9b38bb9a21466b442e37bad68c9d5cf4..b9de4e4967be7ba1b9ee21046d7d02075912f1d9 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -30,7 +30,7 @@ public class BluetoothTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index 8e983a9192bcf30010f9d99b34218c4c4c97f93c..7cebb0323b192f4f6b6dae37463afefb92ef5483 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Arrays;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -31,7 +31,7 @@ public class FrameTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index 7c179b21364d6e417254dc1e2f0d591da6c09cd6..1324688ba6bf4de06df255089a6a2fef8b6313cf 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -30,7 +30,7 @@ public class GoalDataTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index ae9997257bd0f6a4725a887d19f98353986af32e..03f283ca079085676b0c25e5f02a63415c8fe322 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.TreeMap;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class UpdateActionTest extends AbstractTest
-{
+public class UpdateActionTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
     @SuppressWarnings("serial")
-    public void testSerialize() throws Exception
-    {
+    public void testSerialize() throws Exception {
         UpdateAction action = new UpdateAction().withId("countdown.configure")
-                                                // @formatter:off
+        // @formatter:off
                                                 .withParameters(new TreeMap<String, Parameter>(){{put("duration", new IntegerParameter().withValue(30));}});
                                                 // @formatter:on
         assertEquals(readJson("update-action.json"), gson.toJson(action));
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testDeserialize() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("update-action.json")))
-        {
-            gson.fromJson(reader, UpdateAction.class);
+    @Test
+    public void testDeserialize() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("update-action.json"))) {
+            assertThrows(UnsupportedOperationException.class, () -> gson.fromJson(reader, UpdateAction.class));
         }
     }
 }
index b6ff3b03e85f82100aed0708c670115a39be75cb..b3dc05e606e2c89e2b5a2849ca5a83d5714c2eb5 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.HashMap;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -32,7 +32,7 @@ public class WidgetTest extends AbstractTest
 {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass()
     {
         gson = GsonGenerator.create(true);
index 04b80e99b86302cb95b6d6f46078eae90c10d406..c59ea62d416636102936d5ddbd06bdbf3580c14c 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.local.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
 import org.openhab.binding.lametrictime.api.test.AbstractTest;
 
@@ -32,7 +32,7 @@ import com.google.gson.Gson;
 public class WidgetUpdatesTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
index b5144e2e563fa018187f9d13b2d64d593fd2e252..d65608dc2c761eff99fd98b9041035f03ee5330c 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode;
+import org.junit.jupiter.api.Test;
 
-public class BrightnessModeTest
-{
+public class BrightnessModeTest {
     @Test
-    public void testConversion()
-    {
-        for (BrightnessMode value : BrightnessMode.values())
-        {
+    public void testConversion() {
+        for (BrightnessMode value : BrightnessMode.values()) {
             assertEquals(value, BrightnessMode.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(BrightnessMode.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(BrightnessMode.toEnum(null));
     }
 }
index 60c5acb797e97000cf1f8e4ba1119bc21c41e86b..bfdd9077031d34f4dbd1283006aec313fced93b2 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.DisplayType;
+import org.junit.jupiter.api.Test;
 
-public class DisplayTypeTest
-{
+public class DisplayTypeTest {
     @Test
-    public void testConversion()
-    {
-        for (DisplayType value : DisplayType.values())
-        {
+    public void testConversion() {
+        for (DisplayType value : DisplayType.values()) {
             assertEquals(value, DisplayType.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(DisplayType.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(DisplayType.toEnum(null));
     }
 }
index 64673e10de55a7ef27942c8d14be170318eea9a2..5bba62567d0644e2071170109c44429d056013f0 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.IconType;
+import org.junit.jupiter.api.Test;
 
-public class IconTypeTest
-{
+public class IconTypeTest {
     @Test
-    public void testConversion()
-    {
-        for (IconType value : IconType.values())
-        {
+    public void testConversion() {
+        for (IconType value : IconType.values()) {
             assertEquals(value, IconType.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(IconType.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(IconType.toEnum(null));
     }
 }
index 0eb47d886b6307be59e214766ce0d3796a420d5b..9598236e122e3e92eabb87cefacdad6bef4d706e 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class IpModeTest
-{
+public class IpModeTest {
     @Test
-    public void testConversion()
-    {
-        for (IpMode value : IpMode.values())
-        {
+    public void testConversion() {
+        for (IpMode value : IpMode.values()) {
             assertEquals(value, IpMode.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(IpMode.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(IpMode.toEnum(null));
     }
 }
index 23cea5d79bd98b9e4ed192aca6dc66b8a3c0cd64..c6ff1523788a351437ec557b9ee522495d5c13bb 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.Priority;
+import org.junit.jupiter.api.Test;
 
-public class PriorityTest
-{
+public class PriorityTest {
     @Test
-    public void testConversion()
-    {
-        for (Priority value : Priority.values())
-        {
+    public void testConversion() {
+        for (Priority value : Priority.values()) {
             assertEquals(value, Priority.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(Priority.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(Priority.toEnum(null));
     }
 }
index 6e0eb919776ff7cb5be397fe1c4717ca9b4341b7..bef0a94b00a78574a7c0c924607af59cc489b54b 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.SoundCategory;
+import org.junit.jupiter.api.Test;
 
-public class SoundCategoryTest
-{
+public class SoundCategoryTest {
     @Test
-    public void testConversion()
-    {
-        for (SoundCategory value : SoundCategory.values())
-        {
+    public void testConversion() {
+        for (SoundCategory value : SoundCategory.values()) {
             assertEquals(value, SoundCategory.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(SoundCategory.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(SoundCategory.toEnum(null));
     }
 }
index 35ae61c1ff0ccb8a71b184552fb886e05a928981..1e3c895490fafee6030193ce115b0defbbdd13dc 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.openhab.binding.lametrictime.api.model.enums.Sound;
+import org.junit.jupiter.api.Test;
 
-public class SoundTest
-{
+public class SoundTest {
     @Test
-    public void testConversion()
-    {
-        for (Sound value : Sound.values())
-        {
+    public void testConversion() {
+        for (Sound value : Sound.values()) {
             assertEquals(value, Sound.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(Sound.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(Sound.toEnum(null));
     }
 }
index 4ead807b2b8c07e4ba7897c460a1a149a2e43b83..724efeec951918a08df49eeb91995fcdccda9a39 100644 (file)
  */
 package org.openhab.binding.lametrictime.api.model.enums;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class WifiEncryptionTest
-{
+public class WifiEncryptionTest {
     @Test
-    public void testConversion()
-    {
-        for (WifiEncryption value : WifiEncryption.values())
-        {
+    public void testConversion() {
+        for (WifiEncryption value : WifiEncryption.values()) {
             assertEquals(value, WifiEncryption.toEnum(value.toRaw()));
         }
     }
 
     @Test
-    public void testInvalidRawValue()
-    {
+    public void testInvalidRawValue() {
         assertNull(WifiEncryption.toEnum("invalid raw value"));
     }
 
     @Test
-    public void testNullRawValue()
-    {
+    public void testNullRawValue() {
         assertNull(WifiEncryption.toEnum(null));
     }
 }
index 2867607cc6d90fbb5965b4b7312189e2afcfbe4c..57be019be473090b468c7452f63158a07c3f7a03 100644 (file)
  */
 package org.openhab.binding.lcn.internal;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.*;
 
 import java.nio.ByteBuffer;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.lcn.internal.common.LcnDefs;
 import org.openhab.binding.lcn.internal.common.LcnException;
 
@@ -33,6 +34,7 @@ import org.openhab.binding.lcn.internal.common.LcnException;
  *
  * @author Fabian Wolter - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 @NonNullByDefault
 public class ModuleActionsTest {
     private LcnModuleActions a = new LcnModuleActions();
@@ -40,9 +42,8 @@ public class ModuleActionsTest {
     @Captor
     private @NonNullByDefault({}) ArgumentCaptor<byte[]> byteBufferCaptor;
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         a = new LcnModuleActions();
         a.setThingHandler(handler);
     }
index 38feefcc263626a9480ec2ad7834739bab2ff492..1bfb5768f68d8e8e6efa330f50a0206ab2a35bf1 100644 (file)
  */
 package org.openhab.binding.lcn.internal.pchkdiscovery;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for {@link LcnPchkDiscoveryService}.
@@ -30,7 +30,7 @@ public class LcnPchkDiscoveryServiceTest {
     private ServicesResponse r = s.xmlToServiceResponse(RESPONSE);
     private static final String RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><ServicesResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"servicesresponse.xsd\"><Version major=\"1\" minor=\"0\" /><Server requestId=\"1548\" machineId=\"b8:27:eb:fe:a4:bb\" machineName=\"raspberrypi\" osShort=\"Unix/Linux\" osLong=\"Unix/Linux\">LCN-PCHK 3.2.2 running on Unix/Linux</Server><Services /><ExtServices><ExtService name=\"LcnPchkBus\" major=\"1\" minor=\"0\" prot=\"TCP\" localPort=\"4114\">PCHK 3.2.2 bus</ExtService></ExtServices></ServicesResponse>";
 
-    @Before
+    @BeforeEach
     public void setUp() {
         s = new LcnPchkDiscoveryService();
         r = s.xmlToServiceResponse(RESPONSE);
index 7cee0058d48b5f791f4d04d1b030d9504c56865a..50378fff0ef2e7d660c6192fc8e0d2283b84b1a2 100644 (file)
@@ -15,8 +15,11 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.when;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.lcn.internal.LcnModuleHandler;
 import org.openhab.binding.lcn.internal.connection.ModInfo;
 
@@ -25,19 +28,15 @@ import org.openhab.binding.lcn.internal.connection.ModInfo;
  *
  * @author Fabian Wolter - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public class AbstractTestLcnModuleSubHandler {
-    @Mock
-    protected @NonNullByDefault({}) LcnModuleHandler handler;
-    @Mock
-    protected @NonNullByDefault({}) ModInfo info;
 
-    public AbstractTestLcnModuleSubHandler() {
-        setUp();
-    }
+    protected @Mock @NonNullByDefault({}) LcnModuleHandler handler;
+    protected @Mock @NonNullByDefault({}) ModInfo info;
 
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         when(handler.isMyAddress("000", "005")).thenReturn(true);
     }
 }
index 201ab8a0f84fa63645f7a087c05d7be4403a7103..0b179abd191f9cb8e95bbdb548da177a3ac1c253 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.core.library.types.OpenClosedType;
 
@@ -30,7 +30,7 @@ public class LcnModuleBinarySensorSubHandlerTest extends AbstractTestLcnModuleSu
     private @NonNullByDefault({}) LcnModuleBinarySensorSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index f755ca764a23fa8ebcccdd64dfd9cdc426c33409..450523929588cee170a66afa2e0af71d1942cf3e 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 
 /**
@@ -29,7 +29,7 @@ public class LcnModuleHostCommandSubHandlerTest extends AbstractTestLcnModuleSub
     private @NonNullByDefault({}) LcnModuleHostCommandSubHandler subHandler;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index e63912a2782e56b3aadc419561f0bae7c9ae316f..7daa3a2ac582d6ea4ad553155d08750d55749224 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.core.library.types.OnOffType;
@@ -31,7 +31,7 @@ public class LcnModuleKeyLockTableSubHandlerTest extends AbstractTestLcnModuleSu
     private @NonNullByDefault({}) LcnModuleKeyLockTableSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index b00599c38f733991b3db55a07c7d0dbf2351b6a6..6a90e6c723f4e145fce1413a7e45975424b836d0 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnDefs;
 import org.openhab.binding.lcn.internal.common.LcnException;
@@ -33,7 +33,7 @@ public class LcnModuleLedSubHandlerTest extends AbstractTestLcnModuleSubHandler
     private @NonNullByDefault({}) LcnModuleLedSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index a777e20a97c92e429246c727d942f674fd4d8387..4c64593b53e2aa05d54e71a1c51d4db0c0b2e083 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.core.library.types.StringType;
 
@@ -37,7 +37,7 @@ public class LcnModuleLogicSubHandlerTest extends AbstractTestLcnModuleSubHandle
     private @NonNullByDefault({}) LcnModuleLogicSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 973ba6889bf56abe4bc691d3425a7d359df6122d..454409aefe63b6a2c54db0127148bea6bfc01f62 100644 (file)
@@ -17,8 +17,8 @@ import static org.mockito.Mockito.verify;
 import java.math.BigDecimal;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.DimmerOutputCommand;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnDefs;
@@ -36,7 +36,7 @@ public class LcnModuleOutputSubHandlerTest extends AbstractTestLcnModuleSubHandl
     private @NonNullByDefault({}) LcnModuleOutputSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index f8b5a32ba3def1ea8e4a8ef49c0dab23a8378927..2adb9909435986e4e1b8f31341a910d8a1dc9e6f 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.core.library.types.OnOffType;
@@ -32,7 +32,7 @@ public class LcnModuleRelaySubHandlerTest extends AbstractTestLcnModuleSubHandle
     private @NonNullByDefault({}) LcnModuleRelaySubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 6f8b20d69460b1f17a2e96c25b937edad81157e5..34d873ca2ebd67b36da020fea5f6efdef18315b6 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.core.library.types.StopMoveType;
@@ -32,7 +32,7 @@ public class LcnModuleRollershutterOutputSubHandlerTest extends AbstractTestLcnM
     private @NonNullByDefault({}) LcnModuleRollershutterOutputSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index ec501017d75f29dface2761865f55441bc2a5685..d548cb6a3e4d0b5a31ec608cf16a098e38b165df 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.core.library.types.StopMoveType;
@@ -32,7 +32,7 @@ public class LcnModuleRollershutterRelaySubHandlerTest extends AbstractTestLcnMo
     private @NonNullByDefault({}) LcnModuleRollershutterRelaySubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 82650bb815ff6ebbc6799173d12fa2ce9610d4dc..600443cf27b932c543d82e18589f19fb2c7b41d6 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.core.library.types.OnOffType;
@@ -31,7 +31,7 @@ public class LcnModuleRvarLockSubHandlerTest extends AbstractTestLcnModuleSubHan
     private @NonNullByDefault({}) LcnModuleRvarLockSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 495f4fcaa2e33757d921a71e60d8e88671eeef36..f9015a6c4cbc0093ee226372ed648f6c0e7cc568 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.binding.lcn.internal.common.Variable;
@@ -34,7 +34,7 @@ public class LcnModuleRvarSetpointSubHandlerTest extends AbstractTestLcnModuleSu
     private @NonNullByDefault({}) LcnModuleRvarSetpointSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 4247435cb39f5fd46f86b3596f0e7163c3785963..c13e320261f356cfe9b56fad72dc97948a248986 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.verify;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.core.library.types.DecimalType;
 
@@ -30,7 +30,7 @@ public class LcnModuleS0CounterSubHandlerTest extends AbstractTestLcnModuleSubHa
     private @NonNullByDefault({}) LcnModuleS0CounterSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 7c1fc0cca760e4ad6bd29871677ae947d5efd82a..f52a4f5bd9621cb606c13ff63b0fbb57cc52ce52 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.binding.lcn.internal.common.Variable;
@@ -32,7 +32,7 @@ public class LcnModuleThresholdSubHandlerTest extends AbstractTestLcnModuleSubHa
     private @NonNullByDefault({}) LcnModuleThresholdSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index 72ac0c2c56229f800398f3e17ce7e85ac596064c..9f552f305b18731cea176ae2494038777b5ea075 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.lcn.internal.subhandler;
 import static org.mockito.Mockito.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
 import org.openhab.binding.lcn.internal.common.LcnException;
 import org.openhab.binding.lcn.internal.common.Variable;
@@ -33,7 +33,7 @@ public class LcnModuleVariableSubHandlerTest extends AbstractTestLcnModuleSubHan
     private @NonNullByDefault({}) LcnModuleVariableSubHandler l;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
 
index cda257bb6e777ff2a5d5bc9518ca903d36e80aee..cd319f38649d165de7642f24e1f064b086f91cb6 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -20,8 +20,8 @@ import java.time.ZonedDateTime;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
@@ -50,7 +50,7 @@ public class LxControlAlarmNoPresenceTest extends LxControlTest {
     private static final String numberChannels[] = { NEXT_LEVEL_CHANNEL, NEXT_LEVEL_DELAY_CHANNEL,
             NEXT_LEVEL_DELAY_TOTAL_CHANNEL, LEVEL_CHANNEL, ARMED_DELAY_CHANNEL, ARMED_TOTAL_DELAY_CHANNEL };
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("233d5db0-0333-5865-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Burglar Alarm No Presence");
index e1b4eaa491f3885077a7067c7de701f09f009417..410ddcd5e77ca828d1fa93d04a6c38f1b5471cc6 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 
 /**
@@ -26,7 +26,7 @@ public class LxControlAlarmWithPresenceTest extends LxControlAlarmNoPresenceTest
     private static final String MOTION_SENSORS_CHANNEL = " / Motion Sensors";
 
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("133d5db0-0333-5865-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Burglar Alarm With Presence");
index 392238b808cdb3ed2c6d1b9ae0cc19f8a9585135..7fea2ec2b8b2ff3e248077ea7a7e061dfb0fc4c0 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -26,7 +26,7 @@ import org.openhab.core.library.types.StopMoveType;
  *
  */
 public class LxControlDimmerTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("131b19cd-03c0-640f-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Dimmer Control");
index e696961fa501f6a216f1c74414a4a3566d21c8ce..6ee55a6be09a0627f49c704c5a77bc9969c878f7 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.loxone.internal.controls;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 
@@ -41,7 +41,7 @@ public class LxControlIRoomControllerV2Test extends LxControlTest {
     private static final String FROST_PROTECT_TEMPERATURE_CHANNEL = "/ Frost Protect Temperature";
     private static final String HEAT_PROTECT_TEMPERATURE_CHANNEL = "/ Heat Protect Temperature";
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("14328f8a-21c9-7c0d-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Intelligent Room Controller");
index b1d60db91ac9448efb5dbac19b121533b6026313..47f92136f4a184064a3f71522c1d766c5a6b2544 100644 (file)
@@ -14,8 +14,8 @@ package org.openhab.binding.loxone.internal.controls;
 
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for (@link LxControlInfoOnlyAnalog} - check tags for temperature category
@@ -24,7 +24,7 @@ import org.junit.Test;
  *
  */
 public class LxControlInfoOnlyAnalogTempTagTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("0fec5dc3-003e-8800-ffff555fb0c34b9e", "0fe3a451-0283-2afa-ffff403fb0c34b9e",
                 "0fb99a98-02df-46f1-ffff403fb0c34b9e", "Info Only Analog Temperature");
index a8160890cdb5b88a8d70fc6877ed44010d63d307..2937d5fd93601ceec24ceaf33c9e55e05a4cd476 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.types.UnDefType;
 
@@ -24,7 +24,7 @@ import org.openhab.core.types.UnDefType;
  *
  */
 public class LxControlInfoOnlyAnalogTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("0fec5dc3-003e-8800-ffff403fb0c34b9e", "0fe3a451-0283-2afa-ffff403fb0c34b9e",
                 "0fe665f4-0161-4773-ffff403fb0c34b9e", "Info Only Analog");
index b693a9b904bd9979e9a61751041299260f115671..37ff36644792cbcf7e5e28b20c10cada14a9b5b5 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.UnDefType;
 
@@ -24,7 +24,7 @@ import org.openhab.core.types.UnDefType;
  *
  */
 public class LxControlInfoOnlyDigitalTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("101b50f7-0306-98fb-ffff403fb0c34b9e", "0e368d32-014f-4604-ffff403fb0c34b9e",
                 "101b563d-0302-78bd-ffff403fb0c34b9e", "Info Only Digital");
index e23057159fdb8df8349cdd56783e2319311b3d6f..6260fce202f65cf2faf652e1cc2640bbdc2f82b6 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.loxone.internal.controls;
 import java.util.Collections;
 import java.util.Set;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -35,7 +35,7 @@ public class LxControlJalousieTest extends LxControlTest {
     private static final String SHADE_CHANNEL = " / Shade";
     private static final String AUTO_SHADE_CHANNEL = " / Auto Shade";
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("0e367c09-0161-e2c1-ffff403fb0c34b9e", "0e368d32-014f-4604-ffff403fb0c34b9e",
                 "0b734138-033e-02d8-ffff403fb0c34b9e", "Window Blinds");
index 77ce5df91aa2700b508506199fb91ea5255d12e4..8835bbe7b01b65eb9fcd02f7040accedfd224517 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 
 /**
  * Test class for (@link LxControlLeftRightAnalog}
@@ -22,7 +22,7 @@ import org.junit.Before;
  */
 public class LxControlLeftRightAnalogTest extends LxControlUpDownAnalogTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         min = 1072.123;
         max = 1123.458;
index b7fc9efd9c5ca3e96b3265aac215770ecafa4395..2173c94b275e14bb05cce8f567680b37d97fdc9c 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for (@link LxControlLeftRightDigital}
@@ -23,7 +23,7 @@ import org.junit.Test;
  */
 public class LxControlLeftRightDigitalTest extends LxControlUpDownDigitalTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         upChannel = " / Left";
         downChannel = " / Right";
index 5ce78d1748c86db3208bab89991b58ede8e0a3b0..7a564e01c82e67cb2d3c4b1dc4bad345da85ab87 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.loxone.internal.controls;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.BufferedReader;
 import java.io.InputStream;
@@ -24,8 +25,8 @@ import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.loxone.internal.types.LxUuid;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
@@ -40,7 +41,7 @@ import org.openhab.core.types.UnDefType;
  *
  */
 public class LxControlLightControllerV2Test extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("1076668f-0101-7076-ffff403fb0c34b9e", "0b734138-03ac-03f0-ffff403fb0c34b9e",
                 "0b734138-033e-02d4-ffff403fb0c34b9e", "Lighting controller");
index 7bdde5149b4a30ee53b2af914ba4e76d5a2cc797..52073a832549338978d73299fad647f5f9187f5a 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 
@@ -28,7 +28,7 @@ public class LxControlMeterTest extends LxControlTest {
     private static final String TOTAL_VALUE_CHANNEL = " / Total";
     private static final String RESET_CHANNEL = " / Reset";
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("13b3ea27-00fc-6f1b-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Energy Meter");
index 235f31e755a4aa7cc391ec86c9ace5669a23479f..49c82170f58af0db8d313e5159944380ff77882d 100644 (file)
@@ -14,8 +14,8 @@ package org.openhab.binding.loxone.internal.controls;
 
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -28,7 +28,7 @@ import org.openhab.core.library.types.StringType;
  */
 public class LxControlPushbuttonTest extends LxControlSwitchTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("0e3684cc-026e-28e0-ffff403fb0c34b9e", "0b734138-038c-035e-ffff403fb0c34b9e",
                 "0b734138-033e-02d8-ffff403fb0c34b9e", "Kitchen All Blinds Up");
index 9df6a33450703c6317ed7d74538811ae65152e8c..171445e05f95c831f001ecc1a5ee4a22aa8e2b5c 100644 (file)
@@ -16,8 +16,8 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -30,7 +30,7 @@ import org.openhab.core.types.StateOption;
  *
  */
 public class LxControlRadioTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("4255054f-0355-af47-ffff403fb0c34b9e", "11d68cf4-0080-7697-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Sprinkler 1");
index be5d1530dc54cef5f988eaf5321402b511bec384..5b0e590170b6bf2a4dd9ddf13b6872689027dd9f 100644 (file)
@@ -16,8 +16,8 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.StateOption;
@@ -30,7 +30,7 @@ import org.openhab.core.types.StateOption;
  */
 public class LxControlRadioTest2 extends LxControlRadioTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("1255054f-0355-af47-ffff403fb0c34b9e", "11d68cf4-0080-7697-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Sprinkler 2");
index b443c6c787145859e523bb4b4281b38d4b6086a7..1a7a34ce65aaef7884e24561edb957a69141aa75 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for (@link LxControlSlider} - this is actually the same control as up down analog
@@ -23,7 +23,7 @@ import org.junit.Test;
  */
 public class LxControlSliderTest extends LxControlUpDownAnalogTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         min = 120.0;
         max = 450.0;
index 0ec12f34616b625f445ed23112e4d31c6fbd5622..71d54f714f2b8e0f047282b7198a7e4404f935e1 100644 (file)
@@ -14,8 +14,8 @@ package org.openhab.binding.loxone.internal.controls;
 
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -28,7 +28,7 @@ import org.openhab.core.types.UnDefType;
  *
  */
 public class LxControlSwitchTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("0f2f6b5d-0349-83b1-ffff403fb0c34b9e", "0b734138-038c-0382-ffff403fb0c34b9e",
                 "0b734138-033e-02d4-ffff403fb0c34b9e", "Switch Button");
index 29e68c5a995fe041c0ede615c435201e1714535a..387b28abd100c681222b26443c402dab5fdc17b0 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
index b025adfa22e27ef57e094dcae55c47dac5876958..2e0c5c93965952db3463c79fb3c6913c909cc6b3 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.StringType;
 
 /**
@@ -23,7 +23,7 @@ import org.openhab.core.library.types.StringType;
  *
  */
 public class LxControlTextStateTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("106bed36-016d-6dd8-ffffffe6109fb656", "0b734138-038c-0386-ffff403fb0c34b9e",
                 "0fe665f4-0161-4773-ffff403fb0c34b9e", "Gate");
index 24301d31ef352344f67d7c2a8af29ba6e97cecea..2573a1185234814a74cbd494a7c23197054eb900 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.loxone.internal.controls;
 import java.math.BigDecimal;
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 
@@ -29,7 +29,7 @@ import org.openhab.core.library.types.OnOffType;
 public class LxControlTimedSwitchTest extends LxControlTest {
     private static final String DELAY_CHANNEL = " / Deactivation Delay";
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("1326771c-030e-3a7c-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Stairwell Light Switch");
index a6b1cf95d34540e98d6d4d528f56b673a0522e99..f1bdf7625d498bbc806cf8f2f69189e31fc7de46 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.StringType;
 
 /**
@@ -23,7 +23,7 @@ import org.openhab.core.library.types.StringType;
  *
  */
 public class LxControlTrackerTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("132aa43b-01d4-56ea-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Tracker Control");
index f29c0b33ce24a8cef85690763ff0e79bf93f1292..5e8f91b4d37e7355b91b8f5a08875ab84762473c 100644 (file)
@@ -14,8 +14,8 @@ package org.openhab.binding.loxone.internal.controls;
 
 import java.math.BigDecimal;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.types.UnDefType;
 
@@ -31,7 +31,7 @@ public class LxControlUpDownAnalogTest extends LxControlTest {
     Double step;
     String format;
 
-    @Before
+    @BeforeEach
     public void setup() {
         min = 50.0;
         max = 150.0;
index 8175e6e2b271f0913d7b5f432ca01e2b030eb293..ceea9ea7309da6c4df3ee1182229a2138c710295 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 
 /**
@@ -26,7 +26,7 @@ public class LxControlUpDownDigitalTest extends LxControlTest {
     String upChannel;
     String downChannel;
 
-    @Before
+    @BeforeEach
     public void setup() {
         upChannel = " / Up";
         downChannel = " / Down";
index a380704a1fd6e14ffc0d0715d49ccf3db18d3c2d..02aca116de276fa84f7297536fc6468f44c4d814 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.PercentType;
 
@@ -25,7 +25,7 @@ import org.openhab.core.library.types.PercentType;
  */
 public class LxControlValueSelectorIncrTest extends LxControlValueSelectorTest {
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("132a7b7e-0022-3aac-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Selection Switch Increase Only");
index 01bbdd4de812bc41092edf1c6f1027ddab17876f..10f0b662f8b95dd1d6f532a2490d82dd47b8bbd0 100644 (file)
@@ -14,8 +14,8 @@ package org.openhab.binding.loxone.internal.controls;
 
 import java.math.BigDecimal;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.OnOffType;
@@ -31,7 +31,7 @@ import org.openhab.core.library.types.StopMoveType;
 public class LxControlValueSelectorTest extends LxControlTest {
     private static final String NUMBER_CHANNEL = " / Number";
 
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("432a7b7e-0022-3aac-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Selection Switch");
index c41185c96fef26fba029b07aa1f3bc658feaf05b..294da7e682dda13e282e55d4227373c8f59ebaa6 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.StringType;
 
 /**
@@ -23,7 +23,7 @@ import org.openhab.core.library.types.StringType;
  *
  */
 public class LxControlWebPageTest extends LxControlTest {
-    @Before
+    @BeforeEach
     public void setup() {
         setupControl("132d2791-00f8-d532-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
                 "0fe650c2-0004-d446-ffff504f9410790f", "Webpage 1");
index fb0e408861a265b0a83036a2cadf9f6c769e90f3..556fee4c4b45318e48fc908a39f46f09c167001d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.loxone.internal.controls;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.BufferedReader;
 import java.io.IOException;
index 107358f5a467c4d80036c334811d85de9b4d9584..60e38be4a66b7aff491b68dd4a1fe9a67ec5325c 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.HashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
 import org.openhab.binding.luftdateninfo.internal.mock.ConditionHandlerExtension;
 import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
@@ -47,11 +47,11 @@ public class ConditionHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
         if (pmJson != null) {
             UpdateStatus result = condHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.OK, result);
-            assertEquals("Temperature", QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature());
-            assertEquals("Humidity", QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity());
-            assertEquals("Pressure", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure());
-            assertEquals("Pressure Sea", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea());
+            assertEquals(UpdateStatus.OK, result, "Valid update");
+            assertEquals(QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
+            assertEquals(QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
+            assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
+            assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
         } else {
             assertTrue(false);
         }
@@ -70,11 +70,11 @@ public class ConditionHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/condition-result-plus-pressure.json");
         if (pmJson != null) {
             UpdateStatus result = condHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.OK, result);
-            assertEquals("Temperature", QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature());
-            assertEquals("Humidity", QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity());
-            assertEquals("Pressure", QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure());
-            assertEquals("Pressure Sea", QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea());
+            assertEquals(UpdateStatus.OK, result, "Valid update");
+            assertEquals(QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
+            assertEquals(QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
+            assertEquals(QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
+            assertEquals(QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
         } else {
             assertTrue(false);
         }
@@ -93,7 +93,7 @@ public class ConditionHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
         if (pmJson != null) {
             UpdateStatus result = condHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
+            assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
         } else {
             assertTrue(false);
         }
@@ -110,7 +110,7 @@ public class ConditionHandlerTest {
 
         ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
         UpdateStatus result = condHandler.updateChannels("[]");
-        assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
+        assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
     }
 
     @Test
@@ -124,6 +124,6 @@ public class ConditionHandlerTest {
 
         ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
         UpdateStatus result = condHandler.updateChannels(null);
-        assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
+        assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
     }
 }
index 5333db193f284fd541a30d127b0969f9023b155f..7e59c6a2442da09c832c6e04de7c9ce9af87ac73 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.dto.SensorData;
 import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
 import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
@@ -39,7 +39,7 @@ public class DTOTest {
         Gson gson = new Gson();
         SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
         // System.out.println(valueArray.length);
-        assertEquals("Array size", 2, valueArray.length);
+        assertEquals(2, valueArray.length, "Array size");
 
         SensorData d = valueArray[0];
         // Assure latest data is taken
@@ -52,9 +52,9 @@ public class DTOTest {
         assertNotNull(d);
         sensorDataVaueList.forEach(v -> {
             if (v.getValueType().equals(HTTPHandler.TEMPERATURE)) {
-                assertEquals("Temperature", "22.70", v.getValue());
+                assertEquals("22.70", v.getValue(), "Temperature");
             } else if (v.getValueType().equals(HTTPHandler.HUMIDITY)) {
-                assertEquals("Humidity", "61.00", v.getValue());
+                assertEquals("61.00", v.getValue(), "Humidity");
             }
         });
     }
@@ -65,7 +65,7 @@ public class DTOTest {
         Gson gson = new Gson();
         SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
         // System.out.println(valueArray.length);
-        assertEquals("Array size", 2, valueArray.length);
+        assertEquals(2, valueArray.length, "Array size");
 
         SensorData d = valueArray[0];
         // Assure latest data is taken
index 6e0d0cedb36f6f084a2f47e44d5300f58f2779cd..53d70691a459097c28a27065652373b08e29f9a7 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
 import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
 import org.openhab.binding.luftdateninfo.internal.util.FileReader;
@@ -37,7 +37,7 @@ public class HTTPHandlerEvalTest {
     private @Nullable List<SensorDataValue> noise;
     private HTTPHandler http = new HTTPHandler();
 
-    @Before
+    @BeforeEach
     public void setUp() {
         String conditionsStr = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
         assertNotNull(conditionsStr);
index 587f7977aaf8ba33b7ba3c52a2b6880cab68bcaa..1ea6da258093a9db1dc2f28a54d7e2eea2ac2aa8 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
 import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
 import org.openhab.binding.luftdateninfo.internal.util.FileReader;
@@ -57,9 +57,9 @@ public class HTTPHandlerValueTest {
 
     private void testSensorValue(SensorDataValue s) {
         if (s.getValueType().equals(HTTPHandler.TEMPERATURE)) {
-            assertEquals("Temperature resource 1", "22.70", s.getValue());
+            assertEquals("22.70", s.getValue(), "Temperature resource 1");
         } else if (s.getValueType().equals(HTTPHandler.HUMIDITY)) {
-            assertEquals("Humidity resource 1", "61.00", s.getValue());
+            assertEquals("61.00", s.getValue(), "Humidity resource 1");
         } else {
             assertTrue(false);
         }
index 4436b886534d0e7e672bddae3ae7a8c25f6b31bf..86031b10655cebd9deaf44cefc1ae7f5a3418b8a 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.HashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
 import org.openhab.binding.luftdateninfo.internal.mock.NoiseHandlerExtension;
 import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
@@ -46,13 +46,13 @@ public class NoiseHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
         if (pmJson != null) {
             UpdateStatus result = noiseHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.OK, result);
-            assertEquals("Noise EQ", QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseEQCache());
-            assertEquals("Noise Min", QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseMinCache());
-            assertEquals("Noise Max", QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseMaxCache());
+            assertEquals(UpdateStatus.OK, result, "Valid update");
+            assertEquals(QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
+                    "Noise EQ");
+            assertEquals(QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
+                    "Noise Min");
+            assertEquals(QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
+                    "Noise Max");
         } else {
             assertTrue(false);
         }
@@ -71,13 +71,13 @@ public class NoiseHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
         if (pmJson != null) {
             UpdateStatus result = noiseHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
-            assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseEQCache());
-            assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseMinCache());
-            assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
-                    noiseHandler.getNoiseMaxCache());
+            assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
+            assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
+                    "Values undefined");
+            assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
+                    "Values undefined");
+            assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
+                    "Values undefined");
         } else {
             assertTrue(false);
         }
@@ -94,7 +94,7 @@ public class NoiseHandlerTest {
 
         NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
         UpdateStatus result = noiseHandler.updateChannels("[]");
-        assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
+        assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
     }
 
     @Test
@@ -108,6 +108,6 @@ public class NoiseHandlerTest {
 
         NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
         UpdateStatus result = noiseHandler.updateChannels(null);
-        assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
+        assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
     }
 }
index 0aad57ac37e4f417aacff3037cdd7040a5a9cd35..dc54c7322743aa994a3026b9130e2b1c1cba8f6b 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
 
 /**
@@ -30,32 +30,32 @@ public class NumberTest {
     public void testRoundingUp() {
         double d1 = 1.95;
         double d1r2 = NumberUtils.round(d1, 2);
-        assertEquals("Double 1.95, 2 places ", "1.95", Double.toString(d1r2));
+        assertEquals("1.95", Double.toString(d1r2), "Double 1.95, 2 places");
         // System.out.println("D1R2 " + d1r2);
         double d1r1 = NumberUtils.round(d1, 1);
         // System.out.println("D1R1 " + d1r1);
-        assertEquals("Double 1.95, 1 place ", "2.0", Double.toString(d1r1));
+        assertEquals("2.0", Double.toString(d1r1), "Double 1.95, 1 place");
     }
 
     @Test
     public void testRoundingDown() {
         double d1 = 1.94;
         double d1r2 = NumberUtils.round(d1, 2);
-        assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
+        assertEquals("1.94", Double.toString(d1r2), "Double 1.94, 2 places");
         // System.out.println("D1R2 " + d1r2);
         double d1r1 = NumberUtils.round(d1, 1);
         // System.out.println("D1R1 " + d1r1);
-        assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
+        assertEquals("1.9", Double.toString(d1r1), "Double 1.94, 1 place");
     }
 
     @Test
     public void testStringNumbers() {
         String d1 = "1.94";
         double d1r2 = NumberUtils.round(d1, 2);
-        assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
+        assertEquals("1.94", Double.toString(d1r2), "Double 1.94, 2 places");
         // System.out.println("D1R2 " + d1r2);
         double d1r1 = NumberUtils.round(d1, 1);
         // System.out.println("D1R1 " + d1r1);
-        assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
+        assertEquals("1.9", Double.toString(d1r1), "Double 1.94, 1 place");
     }
 }
index f6caa8ce8ec25ed6e409d9a8414640a3b78c3c97..5d2be09909a78d530a508f347e49b23cf6e52212 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.HashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.ConfigStatus;
 import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.LifecycleStatus;
 import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
@@ -64,7 +64,7 @@ public class PMHandlerTest {
          * Test if config status is 0 = CONFIG_OK for valid configuration. Take real int for comparison instead of
          * BaseHandler constants - in case of change test needs to be adapted
          */
-        assertEquals("Handler Configuration status", ConfigStatus.OK, pmHandler.getConfigStatus());
+        assertEquals(ConfigStatus.OK, pmHandler.getConfigStatus(), "Handler Configuration status");
     }
 
     @Test
@@ -93,7 +93,7 @@ public class PMHandlerTest {
          * Test if config status is 3 = CONFIG_SENSOR_NUMBER for invalid configuration with non-number sensorid. Take
          * real int for comparison instead of BaseHandler constants - in case of change test needs to be adapted
          */
-        assertEquals("Handler Configuration status", ConfigStatus.SENSOR_ID_NEGATIVE, pmHandler.getConfigStatus());
+        assertEquals(ConfigStatus.SENSOR_ID_NEGATIVE, pmHandler.getConfigStatus(), "Handler Configuration status");
     }
 
     @Test
@@ -110,11 +110,11 @@ public class PMHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/pm-result.json");
         if (pmJson != null) {
             UpdateStatus result = pmHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.OK, result);
-            assertEquals("PM25", QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
-                    pmHandler.getPM25Cache());
-            assertEquals("PM100", QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
-                    pmHandler.getPM100Cache());
+            assertEquals(UpdateStatus.OK, result, "Valid update");
+            assertEquals(QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
+                    "PM25");
+            assertEquals(QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
+                    "PM100");
         } else {
             assertTrue(false);
         }
@@ -133,11 +133,11 @@ public class PMHandlerTest {
         String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
         if (pmJson != null) {
             UpdateStatus result = pmHandler.updateChannels(pmJson);
-            assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
-            assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
-                    pmHandler.getPM25Cache());
-            assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
-                    pmHandler.getPM100Cache());
+            assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
+            assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
+                    "Values undefined");
+            assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
+                    "Values undefined");
         } else {
             assertTrue(false);
         }
@@ -154,7 +154,7 @@ public class PMHandlerTest {
 
         PMHandlerExtension pmHandler = new PMHandlerExtension(t);
         UpdateStatus result = pmHandler.updateChannels("[]");
-        assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
+        assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
     }
 
     @Test
@@ -168,6 +168,6 @@ public class PMHandlerTest {
 
         PMHandlerExtension pmHandler = new PMHandlerExtension(t);
         UpdateStatus result = pmHandler.updateChannels(null);
-        assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
+        assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
     }
 }
index 52cf44f86b651c9d31d264120145b91af1615406..1a44a4a313ee9618eec581b8984f77861bd43fb5 100644 (file)
  */
 package org.openhab.binding.luftdateninfo.internal.util;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeParseException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.luftdateninfo.internal.utils.DateTimeUtils;
 
 /**
@@ -34,12 +34,12 @@ public class DateTimeTest {
         String jsonDateString = "2020-08-14 14:53:21";
         try {
             LocalDateTime dt = LocalDateTime.from(DateTimeUtils.DTF.parse(jsonDateString));
-            assertEquals("Day ", 14, dt.getDayOfMonth());
-            assertEquals("Month ", 8, dt.getMonthValue());
-            assertEquals("Year ", 2020, dt.getYear());
+            assertEquals(14, dt.getDayOfMonth(), "Day");
+            assertEquals(8, dt.getMonthValue(), "Month");
+            assertEquals(2020, dt.getYear(), "Year");
 
             String s = dt.format(DateTimeUtils.DTF);
-            assertEquals("String ", jsonDateString, s);
+            assertEquals(jsonDateString, s, "String");
         } catch (DateTimeParseException e) {
             assertFalse(true);
         }
index 7e45afec003553eee12b10ae17be68ff588dfacc..3ef1d3e62e04c1cd4affd46c1605d30c8b26e397 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.luftdateninfo.internal.util;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.BufferedReader;
 import java.io.FileInputStream;
index b4d79bc742030f7e3bdfa7edf724ba652c38b8e3..fef52aeece88bf2b5059dc6aa0246e0a1c1e12c6 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.mail;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -26,7 +27,7 @@ import org.apache.commons.mail.EmailException;
 import org.apache.commons.mail.HtmlEmail;
 import org.apache.commons.mail.MultiPartEmail;
 import org.apache.commons.mail.SimpleEmail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.mail.internal.MailBuilder;
 
 /**
@@ -40,19 +41,20 @@ public class MailBuilderTest {
     private static final String TEST_STRING = "test";
     private static final String TEST_EMAIL = "foo@bar.zinga";
 
-    @Test(expected = AddressException.class)
-    public void illegalToAddressThrowsException() throws AddressException {
-        MailBuilder builder = new MailBuilder("foo bar.zinga");
+    @Test
+    public void illegalToAddressThrowsException() {
+        assertThrows(AddressException.class, () -> new MailBuilder("foo bar.zinga"));
     }
 
-    @Test(expected = EmailException.class)
-    public void illegalFromAddressThrowsException() throws AddressException, EmailException {
-        Email mail = new MailBuilder("TEST_EMAIL").withSender("foo bar.zinga").build();
+    @Test
+    public void illegalFromAddressThrowsException() {
+        assertThrows(EmailException.class, () -> new MailBuilder("TEST_EMAIL").withSender("foo bar.zinga").build());
     }
 
-    @Test(expected = MalformedURLException.class)
-    public void illegalURLThrowsException() throws AddressException, MalformedURLException {
-        MailBuilder builder = new MailBuilder("TEST_EMAIL").withURLAttachment("foo bar.zinga");
+    @Test
+    public void illegalURLThrowsException() {
+        assertThrows(MalformedURLException.class,
+                () -> new MailBuilder("TEST_EMAIL").withURLAttachment("foo bar.zinga"));
     }
 
     @Test
index 6c1375cac98442edeba1a2f5f8d713466976add1..bb18cb14ac91c0a7a5fc443b367b5bd15c7f6b2a 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for {@link FCommand}.
index 20776b8f68a37f0f7a92e66b247857f52dcea8ec..76f637bfc3ba0e3754cb2c1ce6b4e306fed5ff18 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.Device;
 import org.openhab.binding.max.internal.device.DeviceConfiguration;
 import org.openhab.binding.max.internal.device.RoomInformation;
index 84fb25a1e4ec93fb6024ef87e1344e716caa372d..9158fc06685c423c312fe80126d49d71daf94bc1 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.Utils;
 import org.openhab.binding.max.internal.device.ThermostatModeType;
 
index d1513aabb29ea671af896eac809e86b74beb30f0..78c907f83c17a40c1f76dad77d4ae68b312e02b6 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.command.SConfigCommand.ConfigCommandType;
 
 /**
index a860aa7ad25ebaf821ec06380feeef8927c35aa4..06f2a97aba3831d1e89aa07a8c2d68ebd7879da3 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Base64;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.Utils;
 
 /**
index bee7c71dc15167e06a61f3e84118f4789f1cddc5..05a9754e17ffc7c2653c7ac4fcfd63ae8c81fa1d 100644 (file)
  */
 package org.openhab.binding.max.internal.command;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for {@link ZCommand}.
index 7d7cc86b3b705bc9be0d43b543d39e2760be7d4a..fa2b181bda9e5911232ede3aed2ec1b2456bfd27 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.DeviceType;
 
 /**
index 7b4afccb2c08181fa4db0ed19906ff2bb151eaad..9a39c29613bcb2c182d1816955708951afb0e39a 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.DeviceConfiguration;
 import org.openhab.binding.max.internal.device.DeviceType;
 
@@ -35,7 +35,7 @@ public class ConfigurationTest {
     private final CMessage message = new CMessage(RAW_DATA);
     private @Nullable DeviceConfiguration configuration;
 
-    @Before
+    @BeforeEach
     public void before() {
         configuration = DeviceConfiguration.create(message);
     }
index 3ffed114e1b0735e65d737afc15f84b51c3a25b8..d13b3c62e71bb1e21a2e9fa6165fb148ab931e2d 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for {@link FMessage}.
index f2b6d1617fcd424220fbea7793d4dced839c5833..a93f1122b096bcc677f551265889ff8dfa1614c6 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Date;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.Utils;
 
 /**
index 2627839a98629b006c93f5ddec7e088b3f45c26c..3d8ce442422859b5518faa0781d2d8a648f8247d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -21,8 +21,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.Device;
 import org.openhab.binding.max.internal.device.DeviceConfiguration;
 import org.openhab.binding.max.internal.device.DeviceInformation;
@@ -46,7 +46,7 @@ public class LMessageTest {
     private final LMessage message = new LMessage(RAWDATA);
     private final List<DeviceConfiguration> configurations = new ArrayList<>();
 
-    @Before
+    @BeforeEach
     public void setUp() {
         createTestDevices();
     }
@@ -90,10 +90,10 @@ public class LMessageTest {
     @Test
     public void allDevicesCreatedFromMessage() {
         Collection<? extends Device> devices = message.getDevices(configurations);
-        assertEquals("Incorrect number of devices created", testDevices.size(), devices.size());
+        assertEquals(testDevices.size(), devices.size(), "Incorrect number of devices created");
         for (Device device : devices) {
-            assertTrue("Unexpected device created: " + device.getRFAddress(),
-                    testDevices.containsKey(device.getRFAddress()));
+            assertTrue(testDevices.containsKey(device.getRFAddress()),
+                    "Unexpected device created: " + device.getRFAddress());
         }
     }
 
@@ -101,7 +101,7 @@ public class LMessageTest {
     public void isCorrectErrorState() {
         for (Device device : message.getDevices(configurations)) {
             Device testDevice = testDevices.get(device.getRFAddress());
-            assertEquals("Error set incorrectly in Device", testDevice.isError(), device.isError());
+            assertEquals(testDevice.isError(), device.isError(), "Error set incorrectly in Device");
         }
     }
 }
index 216e8bd0ebc3778ea56742dc3136ce8175ae4916..18c5e3a982d694f197a19f3fbdcd8b616781dd5b 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.DeviceInformation;
 import org.openhab.binding.max.internal.device.DeviceType;
 import org.openhab.binding.max.internal.device.RoomInformation;
index c7a7d395b1be2e7e75da706fe643df14dc1b24a4..2aab5f21682f2c756f57bec2e90e52e0cc9118b3 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.exceptions.IncompleteMessageException;
 import org.openhab.binding.max.internal.exceptions.IncorrectMultilineIndexException;
 import org.openhab.binding.max.internal.exceptions.MessageIsWaitingException;
@@ -31,12 +32,12 @@ public class MessageProcessorTest {
     private final MessageProcessor processor = new MessageProcessor();
 
     private void commonMessageTest(String line, Message expectedMessage) throws Exception {
-        Assert.assertTrue(this.processor.addReceivedLine(line));
-        Assert.assertTrue(this.processor.isMessageAvailable());
+        assertTrue(this.processor.addReceivedLine(line));
+        assertTrue(this.processor.isMessageAvailable());
         Message message = this.processor.pull();
-        Assert.assertNotNull(message);
-        Assert.assertEquals(message.getClass().getName(), expectedMessage.getClass().getName());
-        Assert.assertEquals(expectedMessage.getPayload(), message.getPayload());
+        assertNotNull(message);
+        assertEquals(message.getClass().getName(), expectedMessage.getClass().getName());
+        assertEquals(expectedMessage.getPayload(), message.getPayload());
     }
 
     @Test
@@ -101,12 +102,12 @@ public class MessageProcessorTest {
         String expectedString = line1 + line2_part2;
         MMessage expectedMessage = new MMessage(expectedString);
 
-        Assert.assertFalse(this.processor.addReceivedLine(line1));
-        Assert.assertTrue(this.processor.addReceivedLine(line2));
+        assertFalse(this.processor.addReceivedLine(line1));
+        assertTrue(this.processor.addReceivedLine(line2));
         Message message = this.processor.pull();
-        Assert.assertNotNull(message);
-        Assert.assertEquals(message.getClass().getName(), MMessage.class.getName());
-        Assert.assertEquals(expectedMessage.getPayload(), message.getPayload());
+        assertNotNull(message);
+        assertEquals(message.getClass().getName(), MMessage.class.getName());
+        assertEquals(expectedMessage.getPayload(), message.getPayload());
     }
 
     @Test
@@ -116,16 +117,16 @@ public class MessageProcessorTest {
 
         try {
             this.processor.addReceivedLine(line2);
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (IncorrectMultilineIndexException e) {
             // OK, correct Exception was thrown
         }
 
         try {
             this.processor.reset();
-            Assert.assertFalse(this.processor.addReceivedLine(line1));
+            assertFalse(this.processor.addReceivedLine(line1));
             this.processor.addReceivedLine(line2);
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (IncorrectMultilineIndexException e) {
             // OK, correct Exception was thrown
         }
@@ -137,20 +138,20 @@ public class MessageProcessorTest {
         String line2 = "M:00,01,VgIBAQpXb2huemltbWVyAAAAAQMQV6lMRVEwOTgyMTU2DldhbmR0aGVybW9zdGF0AQE=";
 
         try {
-            Assert.assertTrue(this.processor.addReceivedLine(line1));
+            assertTrue(this.processor.addReceivedLine(line1));
             this.processor.addReceivedLine(line2);
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (MessageIsWaitingException e) {
             // OK, correct Exception was thrown
         }
 
         Message message = this.processor.pull();
-        Assert.assertNotNull(message);
-        Assert.assertEquals(message.getClass().getName(), HMessage.class.getName());
+        assertNotNull(message);
+        assertEquals(message.getClass().getName(), HMessage.class.getName());
         this.processor.addReceivedLine(line2);
         message = this.processor.pull();
-        Assert.assertNotNull(message);
-        Assert.assertEquals(message.getClass().getName(), MMessage.class.getName());
+        assertNotNull(message);
+        assertEquals(message.getClass().getName(), MMessage.class.getName());
     }
 
     @Test
@@ -159,9 +160,9 @@ public class MessageProcessorTest {
         String line2 = "H:KHA0007199,081dd4,0113,00000000,0d524351,10,30,0f0407,1130,03,0000";
 
         try {
-            Assert.assertFalse(this.processor.addReceivedLine(line1));
+            assertFalse(this.processor.addReceivedLine(line1));
             this.processor.addReceivedLine(line2);
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (IncompleteMessageException e) {
             // OK, correct Exception was thrown
         }
@@ -172,8 +173,8 @@ public class MessageProcessorTest {
         String rawData = "X:0ff1bc,EQ/xvAQJEAJMRVEwNzk0MDA3";
 
         try {
-            Assert.assertFalse(this.processor.addReceivedLine(rawData));
-            Assert.fail("Expected exception was not thrown.");
+            assertFalse(this.processor.addReceivedLine(rawData));
+            fail("Expected exception was not thrown.");
         } catch (UnsupportedMessageTypeException e) {
             // OK, correct Exception was thrown
         }
@@ -187,7 +188,7 @@ public class MessageProcessorTest {
 
         try {
             this.processor.pull();
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (NoMessageAvailableException e) {
             // OK, correct Exception was thrown
         }
@@ -199,7 +200,7 @@ public class MessageProcessorTest {
 
         try {
             this.processor.addReceivedLine(line1);
-            Assert.fail("Expected exception was not thrown.");
+            fail("Expected exception was not thrown.");
         } catch (UnprocessableMessageException e) {
             // OK, correct Exception was thrown
         }
index 7d949a6488020b93fec3ade6918c3ebf3e40caf5..6ecedb3cab775121c79538c653ae9e11cf01e899 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.device.DeviceType;
 
 /**
index ae206f5597f115f2624bf6224b339983ce7e6900..0091a61eedb5f82aafb9d04546366acea0d1bb77 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for {@link FMessage}.
index aca103813f7682abb4f2d87ee681ebb664fdc45d..2d5a536941325837be737a7a158e1857963a5640 100644 (file)
  */
 package org.openhab.binding.max.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Date;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.max.internal.Utils;
 
 /**
index 8f11fd0f8617958b132b6318d5a2372904e225d0..cb1e53736c412e9e9da05fd6a6bff6aba3a1c69b 100644 (file)
  */
 package org.openhab.binding.miio.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Collections;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.miio.internal.basic.ActionConditions;
 import org.openhab.binding.miio.internal.basic.MiIoDeviceActionCondition;
 
index f9b1203465958ca1a9b3af5cd035f1e8835bd54c..47af2f63e71747eb8258d3d916771099434181e5 100644 (file)
@@ -25,7 +25,7 @@ import java.util.List;
 import org.apache.commons.io.FileUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Ignore;
+import org.junit.jupiter.api.Disabled;
 import org.openhab.binding.miio.internal.basic.MiIoBasicChannel;
 import org.openhab.binding.miio.internal.basic.MiIoBasicDevice;
 import org.slf4j.Logger;
@@ -53,7 +53,7 @@ public class ReadmeHelper {
     private static final Logger LOGGER = LoggerFactory.getLogger(ReadmeHelper.class);
     private static final String BASEFILE = "./README.base.md";
 
-    @Ignore
+    @Disabled
     public static void main(String[] args) {
         ReadmeHelper rm = new ReadmeHelper();
         LOGGER.info("## Creating device list");
index 68d1b6b5d43b0dd7f2fda8432104cf45339eca40..36c585a392593123197ed3e682cdb2fef0442d2d 100644 (file)
@@ -45,7 +45,7 @@ import javax.swing.filechooser.FileSystemView;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Ignore;
+import org.junit.jupiter.api.Disabled;
 import org.openhab.binding.miio.internal.robot.RRMapDraw;
 import org.openhab.binding.miio.internal.robot.RRMapFileParser;
 import org.slf4j.Logger;
@@ -75,7 +75,7 @@ public class RoboMapViewer extends JFrame {
     protected MapPoint fromLocation = new MapPoint();
     private static final long serialVersionUID = 2623447051590306992L;
 
-    @Ignore
+    @Disabled
     public static void main(String args[]) {
         System.setProperty("swing.defaultlaf", "javax.swing.plaf.metal.MetalLookAndFeel");
         RoboMapViewer vc = new RoboMapViewer(args);
index 7784294ef10933da46e3f4306e913461c0b055d5..6a27b64303554b20382a5a865b8a8820e6d077de 100644 (file)
  */
 package org.openhab.binding.miio.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test case for {@link Utils}
index 3484d863cc9674804aedd7d3efdb882eefb493cd..93c9d38bc78f839ffae77cbfb3e0a1d1ad4b0630 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.millheat.internal;
 
 import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
@@ -20,13 +21,14 @@ import java.io.IOException;
 
 import org.apache.commons.io.IOUtils;
 import org.eclipse.jetty.client.HttpClient;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.millheat.internal.config.MillheatAccountConfiguration;
 import org.openhab.binding.millheat.internal.handler.MillheatAccountHandler;
 import org.openhab.binding.millheat.internal.model.MillheatModel;
@@ -35,38 +37,45 @@ import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingUID;
 import org.osgi.framework.BundleContext;
 
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.client.WireMock;
 import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
 
 /**
  * @author Arne Seime - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class MillHeatAccountHandlerTest {
-    @Rule
-    public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.options().dynamicPort());
 
-    @Mock
-    private Bridge millheatAccountMock;
+    private WireMockServer wireMockServer;
 
     private HttpClient httpClient;
-    @Mock
-    private Configuration configuration;
 
-    @Mock
-    private BundleContext bundleContext;
+    private @Mock BundleContext bundleContext;
+    private @Mock Configuration configuration;
+    private @Mock Bridge millheatAccountMock;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
+        wireMockServer = new WireMockServer(WireMockConfiguration.options().dynamicPort());
+        wireMockServer.start();
+
+        int port = wireMockServer.port();
+        WireMock.configureFor("localhost", port);
+
         httpClient = new HttpClient();
         httpClient.start();
-        MillheatAccountHandler.authEndpoint = "http://localhost:" + wireMockRule.port() + "/zc-account/v1/";
-        MillheatAccountHandler.serviceEndpoint = "http://localhost:" + wireMockRule.port() + "/millService/v1/";
+
+        MillheatAccountHandler.authEndpoint = "http://localhost:" + port + "/zc-account/v1/";
+        MillheatAccountHandler.serviceEndpoint = "http://localhost:" + port + "/millService/v1/";
     }
 
-    @After
+    @AfterEach
     public void shutdown() throws Exception {
         httpClient.stop();
+        wireMockServer.stop();
+        wireMockServer.resetAll();
     }
 
     @Test
@@ -99,7 +108,7 @@ public class MillHeatAccountHandlerTest {
         final MillheatAccountHandler subject = new MillheatAccountHandler(millheatAccountMock, httpClient,
                 bundleContext);
         MillheatModel model = subject.refreshModel();
-        Assert.assertEquals(1, model.getHomes().size());
+        assertEquals(1, model.getHomes().size());
 
         verify(postRequestedFor(urlMatching("/millService/v1/selectHomeList")));
         verify(postRequestedFor(urlMatching("/millService/v1/selectRoombyHome")));
index 300a6f2db7468eaf79832e14a2590e8c09a7d225..460c9c9b043b382b99228b4ca5287b5a7bc0461d 100644 (file)
  */
 package org.openhab.binding.modbus.e3dc.dto;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Optional;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.modbus.e3dc.internal.dto.EmergencyBlock;
 import org.openhab.binding.modbus.e3dc.internal.dto.PowerBlock;
 import org.openhab.binding.modbus.e3dc.internal.dto.StringBlock;
@@ -36,7 +36,7 @@ import org.openhab.core.library.types.OnOffType;
 public class DataBlockTest {
     private Parser mc;
 
-    @Before
+    @BeforeEach
     public void setup() {
         byte[] dataBlock = new byte[] { 0, -14, 0, 0, -2, -47, -1, -1, 2, 47, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 99, 99, 0, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
@@ -50,10 +50,10 @@ public class DataBlockTest {
         Optional<Data> dataOpt = mc.parse(DataType.POWER);
         assertTrue(dataOpt.isPresent());
         PowerBlock b = (PowerBlock) dataOpt.get();
-        assertEquals("PV Supply", "242.0 W", b.pvPowerSupply.toString());
-        assertEquals("Grid Supply", "14.0 W", b.gridPowerSupply.toString());
-        assertEquals("Grid Consumption", "0.0 W", b.gridPowerConsumpition.toString());
-        assertEquals("Battery Supply", "303.0 W", b.batteryPowerSupply.toString());
+        assertEquals("242.0 W", b.pvPowerSupply.toString(), "PV Supply");
+        assertEquals("14.0 W", b.gridPowerSupply.toString(), "Grid Supply");
+        assertEquals("0.0 W", b.gridPowerConsumpition.toString(), "Grid Consumption");
+        assertEquals("303.0 W", b.batteryPowerSupply.toString(), "Battery Supply");
     }
 
     @Test
@@ -65,10 +65,10 @@ public class DataBlockTest {
         Optional<WallboxBlock> o = a.getWallboxBlock(0);
         WallboxBlock b = o.get();
         assertNotNull(b);
-        assertEquals("Wallbox available", OnOffType.ON, b.wbAvailable);
-        assertEquals("Wallbox Sunmode", OnOffType.ON, b.wbSunmode);
-        assertEquals("Wallbox 1phase", OnOffType.OFF, b.wb1phase);
-        assertEquals("Wallbox charging", OnOffType.OFF, b.wbCharging);
+        assertEquals(OnOffType.ON, b.wbAvailable, "Wallbox available");
+        assertEquals(OnOffType.ON, b.wbSunmode, "Wallbox Sunmode");
+        assertEquals(OnOffType.OFF, b.wb1phase, "Wallbox 1phase");
+        assertEquals(OnOffType.OFF, b.wbCharging, "Wallbox charging");
     }
 
     @Test
@@ -76,14 +76,14 @@ public class DataBlockTest {
         Optional<Data> dataOpt = mc.parse(DataType.EMERGENCY);
         assertTrue(dataOpt.isPresent());
         EmergencyBlock b = (EmergencyBlock) dataOpt.get();
-        assertEquals("EMS Status", EmergencyBlock.EP_NOT_SUPPORTED, b.epStatus.toFullString());
-        assertEquals("Battery charging locked", OnOffType.OFF, b.batteryChargingLocked);
-        assertEquals("Battery discharging locked", OnOffType.OFF, b.batteryDischargingLocked);
-        assertEquals("EP possible", OnOffType.OFF, b.epPossible);
-        assertEquals("Weather Predicted charging", OnOffType.OFF, b.weatherPredictedCharging);
-        assertEquals("Regulation Status", OnOffType.OFF, b.regulationStatus);
-        assertEquals("Charge Lock Time", OnOffType.OFF, b.chargeLockTime);
-        assertEquals("Discharge Lock Time", OnOffType.OFF, b.dischargeLockTime);
+        assertEquals(EmergencyBlock.EP_NOT_SUPPORTED, b.epStatus.toFullString(), "EMS Status");
+        assertEquals(OnOffType.OFF, b.batteryChargingLocked, "Battery charging locked");
+        assertEquals(OnOffType.OFF, b.batteryDischargingLocked, "Battery discharging locked");
+        assertEquals(OnOffType.OFF, b.epPossible, "EP possible");
+        assertEquals(OnOffType.OFF, b.weatherPredictedCharging, "Weather Predicted charging");
+        assertEquals(OnOffType.OFF, b.regulationStatus, "Regulation Status");
+        assertEquals(OnOffType.OFF, b.chargeLockTime, "Charge Lock Time");
+        assertEquals(OnOffType.OFF, b.dischargeLockTime, "Discharge Lock Time");
     }
 
     @Test
@@ -91,26 +91,26 @@ public class DataBlockTest {
         Optional<Data> dataOpt = mc.parse(DataType.STRINGS);
         assertTrue(dataOpt.isPresent());
         StringBlock b = (StringBlock) dataOpt.get();
-        assertEquals("String 1 V", 381, b.string1Volt.intValue());
-        assertEquals("String 1 V", "V", b.string1Volt.getUnit().toString());
-        assertEquals("String 2 V", 533, b.string2Volt.intValue());
-        assertEquals("String 1 V", "V", b.string2Volt.getUnit().toString());
-        assertEquals("String 3 V", 0, b.string3Volt.intValue());
-        assertEquals("String 1 V", "V", b.string3Volt.getUnit().toString());
+        assertEquals(381, b.string1Volt.intValue(), "String 1 V");
+        assertEquals("V", b.string1Volt.getUnit().toString(), "String 1 V");
+        assertEquals(533, b.string2Volt.intValue(), "String 2 V");
+        assertEquals("V", b.string2Volt.getUnit().toString(), "String 1 V");
+        assertEquals(0, b.string3Volt.intValue(), "String 3 V");
+        assertEquals("V", b.string3Volt.getUnit().toString(), "String 1 V");
 
-        assertEquals("String 1 A", 0.27, b.string1Ampere.doubleValue(), 0.01);
-        assertEquals("String 1 A", "A", b.string1Ampere.getUnit().toString());
-        assertEquals("String 2 A", 0.26, b.string2Ampere.doubleValue(), 0.01);
-        assertEquals("String 2 A", "A", b.string2Ampere.getUnit().toString());
-        assertEquals("String 3 A", 0, b.string3Ampere.doubleValue(), 0.01);
-        assertEquals("String 3 A", "A", b.string3Ampere.getUnit().toString());
+        assertEquals(0.27, b.string1Ampere.doubleValue(), 0.01, "String 1 A");
+        assertEquals("A", b.string1Ampere.getUnit().toString(), "String 1 A");
+        assertEquals(0.26, b.string2Ampere.doubleValue(), 0.01, "String 2 A");
+        assertEquals("A", b.string2Ampere.getUnit().toString(), "String 2 A");
+        assertEquals(0, b.string3Ampere.doubleValue(), 0.01, "String 3 A");
+        assertEquals("A", b.string3Ampere.getUnit().toString(), "String 3 A");
 
-        assertEquals("String 1 W", 103, b.string1Watt.intValue());
-        assertEquals("String 1 W", "W", b.string1Watt.getUnit().toString());
-        assertEquals("String 2 W", 139, b.string2Watt.intValue());
-        assertEquals("String 2 W", "W", b.string2Watt.getUnit().toString());
-        assertEquals("String 3 W", 0, b.string3Watt.intValue());
-        assertEquals("String 3 W", "W", b.string3Watt.getUnit().toString());
+        assertEquals(103, b.string1Watt.intValue(), "String 1 W");
+        assertEquals("W", b.string1Watt.getUnit().toString(), "String 1 W");
+        assertEquals(139, b.string2Watt.intValue(), "String 2 W");
+        assertEquals("W", b.string2Watt.getUnit().toString(), "String 2 W");
+        assertEquals(0, b.string3Watt.intValue(), "String 3 W");
+        assertEquals("W", b.string3Watt.getUnit().toString(), "String 3 W");
     }
 
     @Test
index 29d949ad287ec67ab0c85664b7b1f5c742da7bc4..ad0dfc2622914876592f04bd50cd1d3f0a10b435 100644 (file)
  */
 package org.openhab.binding.modbus.e3dc.dto;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Optional;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.modbus.e3dc.internal.dto.InfoBlock;
 import org.openhab.binding.modbus.e3dc.internal.modbus.Data;
 import org.openhab.binding.modbus.e3dc.internal.modbus.Data.DataType;
@@ -31,7 +31,7 @@ import org.openhab.binding.modbus.e3dc.internal.modbus.Parser;
 public class InfoTest {
     private Parser mc;
 
-    @Before
+    @BeforeEach
     public void setup() {
         byte[] infoBlock = new byte[] { -29, -36, 1, 2, 0, -120, 69, 51, 47, 68, 67, 32, 71, 109, 98, 72, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 32, 69, 32, 65, 73, 79, 0, 0, 0, 0, 0, 0,
@@ -48,10 +48,10 @@ public class InfoTest {
         assertTrue(infoOpt.isPresent());
         InfoBlock b = (InfoBlock) infoOpt.get();
         assertNotNull(b);
-        assertEquals("MagicByte", "E3DC", b.modbusId.toString());
-        assertEquals("Model", "S10 E AIO", b.modelName.toString());
-        assertEquals("Firmware", "S10_2020_04", b.firmware.toString());
-        assertEquals("Manufacturer", "E3/DC GmbH", b.manufacturer.toString());
+        assertEquals("E3DC", b.modbusId.toString(), "MagicByte");
+        assertEquals("S10 E AIO", b.modelName.toString(), "Model");
+        assertEquals("S10_2020_04", b.firmware.toString(), "Firmware");
+        assertEquals("E3/DC GmbH", b.manufacturer.toString(), "Manufacturer");
     }
 
     @Test
index 695b2fac832c11188394469c16b36ae29ba772e1..dce81bf59f82ce334e93f3881fb29c36e1d5b09d 100644 (file)
@@ -18,7 +18,7 @@ import java.nio.ByteBuffer;
 import java.util.HashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentMatchers;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
index 77cbd612864f914a57c3647af792da67f7db09a7..7c7445faaaa849f70b5f37f3f0c8faa3b03a0fe9 100644 (file)
  */
 package org.openhab.binding.modbus.e3dc.modbus;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.modbus.e3dc.internal.modbus.Data.DataType;
 import org.openhab.binding.modbus.e3dc.internal.modbus.Parser;
 
@@ -30,11 +30,11 @@ public class ParserNameTest {
     @Test
     public void testDebugNames() {
         Parser mcInfo = new Parser(DataType.INFO);
-        assertEquals("Debug Name Info", "org.openhab.binding.modbus.e3dc.internal.modbus.Parser:INFO",
-                mcInfo.toString());
+        assertEquals("org.openhab.binding.modbus.e3dc.internal.modbus.Parser:INFO", mcInfo.toString(),
+                "Debug Name Info");
 
         Parser mcPower = new Parser(DataType.DATA);
-        assertEquals("Debug Name Power", "org.openhab.binding.modbus.e3dc.internal.modbus.Parser:DATA",
-                mcPower.toString());
+        assertEquals("org.openhab.binding.modbus.e3dc.internal.modbus.Parser:DATA", mcPower.toString(),
+                "Debug Name Power");
     }
 }
index 119decbe614cd6e468c50518ad730c73639c2a5f..bac87348121911f1d6ffcd3d9987e515a601b9bd 100644 (file)
  */
 package org.openhab.binding.modbus.e3dc.util;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.nio.ByteBuffer;
 import java.util.BitSet;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.modbus.e3dc.internal.dto.DataConverter;
 
 /**
@@ -34,28 +34,28 @@ public class DataConverterTest {
         // Reg 69 value 65098 bytes [-2, 74]
         // Reg 70 value 65535 bytes [-1, -1]
         byte[] b = new byte[] { -2, -74, -1, -1 };
-        assertEquals("Negative Value", -330, DataConverter.getInt32Swap(ByteBuffer.wrap(b)));
+        assertEquals(-330, DataConverter.getInt32Swap(ByteBuffer.wrap(b)), "Negative Value");
     }
 
     @Test
     public void testBitset() {
         byte[] b = new byte[] { 3, 16 };
         BitSet s = BitSet.valueOf(b);
-        assertEquals("Bit0", true, s.get(0));
-        assertEquals("Bit1", true, s.get(1));
-        assertEquals("Bit2", false, s.get(2));
-        assertEquals("Bit3", false, s.get(3));
-        assertEquals("Bit4", false, s.get(4));
-        assertEquals("Bit5", false, s.get(5));
-        assertEquals("Bit6", false, s.get(6));
-        assertEquals("Bit7", false, s.get(7));
-        assertEquals("Bit8", false, s.get(8));
-        assertEquals("Bit9", false, s.get(9));
-        assertEquals("Bit10", false, s.get(10));
-        assertEquals("Bit11", false, s.get(11));
-        assertEquals("Bit12", true, s.get(12));
-        assertEquals("Bit13", false, s.get(13));
-        assertEquals("Bit14", false, s.get(14));
-        assertEquals("Bit15", false, s.get(15));
+        assertEquals(true, s.get(0), "Bit0");
+        assertEquals(true, s.get(1), "Bit1");
+        assertEquals(false, s.get(2), "Bit2");
+        assertEquals(false, s.get(3), "Bit3");
+        assertEquals(false, s.get(4), "Bit4");
+        assertEquals(false, s.get(5), "Bit5");
+        assertEquals(false, s.get(6), "Bit6");
+        assertEquals(false, s.get(7), "Bit7");
+        assertEquals(false, s.get(8), "Bit8");
+        assertEquals(false, s.get(9), "Bit9");
+        assertEquals(false, s.get(10), "Bit10");
+        assertEquals(false, s.get(11), "Bit11");
+        assertEquals(true, s.get(12), "Bit12");
+        assertEquals(false, s.get(13), "Bit13");
+        assertEquals(false, s.get(14), "Bit14");
+        assertEquals(false, s.get(15), "Bit15");
     }
 }
index ba852f6e00c49ce43ec6bebdd2deec4fca30fc13..1f6d1f6f64bb58a2f249e4ec7a42b91da616e753 100644 (file)
 package org.openhab.binding.modbus.internal;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
 public class AtomicStampedKeyValueTest {
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testInitWithNullValue() {
-        new AtomicStampedValue<>(0, null);
+        assertThrows(NullPointerException.class, () -> new AtomicStampedValue<>(0, null));
     }
 
     @Test
index 71de8c7b5cdffc3564068fca4c9000214645a876..a4c4e46d4fd800a879ee4935a596237c6034148d 100644 (file)
 package org.openhab.binding.mqtt.generic;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.math.BigDecimal;
 import java.time.ZonedDateTime;
@@ -31,11 +31,15 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.mapping.ColorMode;
 import org.openhab.binding.mqtt.generic.values.ColorValue;
 import org.openhab.binding.mqtt.generic.values.DateTimeValue;
@@ -55,26 +59,21 @@ import org.openhab.core.thing.ChannelUID;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class ChannelStateTests {
-    @Mock
-    private MqttBrokerConnection connection;
 
-    @Mock
-    private ChannelStateUpdateListener channelStateUpdateListener;
-
-    @Mock
-    private ChannelUID channelUID;
-
-    @Spy
-    private TextValue textValue;
+    private @Mock MqttBrokerConnection connection;
+    private @Mock ChannelStateUpdateListener channelStateUpdateListener;
+    private @Mock ChannelUID channelUID;
+    private @Spy TextValue textValue;
 
     private ScheduledExecutorService scheduler;
 
     private ChannelConfig config = ChannelConfigBuilder.create("state", "command").build();
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
         CompletableFuture<Void> voidFutureComplete = new CompletableFuture<>();
         voidFutureComplete.complete(null);
         doReturn(voidFutureComplete).when(connection).unsubscribeAll();
@@ -87,7 +86,7 @@ public class ChannelStateTests {
         scheduler = new ScheduledThreadPoolExecutor(1);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         scheduler.shutdownNow();
     }
@@ -308,8 +307,8 @@ public class ChannelStateTests {
         subject.processMessage("state", datetime.getBytes());
 
         String channelState = value.getChannelState().toString();
-        assertTrue("Expected '" + channelState + "' to start with '" + datetime + "'",
-                channelState.startsWith(datetime));
+        assertTrue(channelState.startsWith(datetime),
+                "Expected '" + channelState + "' to start with '" + datetime + "'");
         assertThat(value.getMQTTpublishValue(null), is(datetime));
     }
 
index 005a7be28affdbf1feeba746c2b9a33db774f22e..4d829faf3f395c389cf410602ea29f0562a91f60 100644 (file)
 package org.openhab.binding.mqtt.generic;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.mqtt.generic.internal.handler.ThingChannelConstants.*;
 
 import java.util.concurrent.CompletableFuture;
 
 import javax.naming.ConfigurationException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler;
 import org.openhab.binding.mqtt.handler.AbstractBrokerHandler;
 import org.openhab.core.config.core.Configuration;
@@ -44,32 +47,21 @@ import org.openhab.core.transform.TransformationService;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class ChannelStateTransformationTests {
 
-    @Mock
-    private TransformationService jsonPathService;
-
-    @Mock
-    private TransformationServiceProvider transformationServiceProvider;
-
-    @Mock
-    private ThingHandlerCallback callback;
-
-    @Mock
-    private Thing thing;
-
-    @Mock
-    private AbstractBrokerHandler bridgeHandler;
-
-    @Mock
-    private MqttBrokerConnection connection;
+    private @Mock TransformationService jsonPathService;
+    private @Mock TransformationServiceProvider transformationServiceProvider;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Thing thing;
+    private @Mock AbstractBrokerHandler bridgeHandler;
+    private @Mock MqttBrokerConnection connection;
 
     private GenericMQTTThingHandler thingHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() throws ConfigurationException, MqttException {
-        initMocks(this);
-
         ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
 
         // Mock the thing: We need the thingUID and the bridgeUID
index 4ef12460acd7ec9c11f90363523c4a3db965ff28..18a1948906aba095a22dacd69d064e335aad47d3 100644 (file)
 package org.openhab.binding.mqtt.generic.internal.handler;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.mqtt.generic.internal.handler.ThingChannelConstants.*;
 
 import java.util.concurrent.CompletableFuture;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.ChannelConfig;
 import org.openhab.binding.mqtt.generic.ChannelConfigBuilder;
 import org.openhab.binding.mqtt.generic.ChannelState;
@@ -51,26 +55,21 @@ import org.openhab.core.types.RefreshType;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class GenericThingHandlerTests {
-    @Mock
-    private ThingHandlerCallback callback;
 
-    @Mock
-    private Thing thing;
-
-    @Mock
-    private AbstractBrokerHandler bridgeHandler;
-
-    @Mock
-    private MqttBrokerConnection connection;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Thing thing;
+    private @Mock AbstractBrokerHandler bridgeHandler;
+    private @Mock MqttBrokerConnection connection;
 
     private GenericMQTTThingHandler thingHandler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
 
-        MockitoAnnotations.initMocks(this);
         // Mock the thing: We need the thingUID and the bridgeUID
         when(thing.getUID()).thenReturn(testGenericThing);
         when(thing.getChannels()).thenReturn(thingChannelList);
@@ -100,11 +99,12 @@ public class GenericThingHandlerTests {
         doReturn(thingStatus).when(thingHandler).getBridgeStatus();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void initializeWithUnknownThingUID() {
         ChannelConfig config = textConfiguration().as(ChannelConfig.class);
-        thingHandler.createChannelState(config, new ChannelUID(testGenericThing, "test"),
-                ValueFactory.createValueState(config, unknownChannel.getId()));
+        assertThrows(IllegalArgumentException.class,
+                () -> thingHandler.createChannelState(config, new ChannelUID(testGenericThing, "test"),
+                        ValueFactory.createValueState(config, unknownChannel.getId())));
     }
 
     @Test
index d032c80481169f1d1f03d28a81854b6b06f71541..73d1bdfaab6befcd9b6eddc0a7466c0bf48a6a97 100644 (file)
@@ -14,7 +14,8 @@ package org.openhab.binding.mqtt.generic.mapping;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
@@ -29,12 +30,15 @@ import java.util.stream.Stream;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
 import org.mockito.Spy;
 import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass.AttributeChanged;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
 
@@ -53,6 +57,8 @@ import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class MqttTopicClassMapperTests {
     @Retention(RetentionPolicy.RUNTIME)
     @Target({ FIELD })
@@ -113,9 +119,8 @@ public class MqttTopicClassMapperTests {
     // A completed future is returned for a subscribe call to the attributes
     final CompletableFuture<Boolean> future = CompletableFuture.completedFuture(true);
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         doReturn(CompletableFuture.completedFuture(true)).when(connection).subscribe(any(), any());
         doReturn(CompletableFuture.completedFuture(true)).when(connection).unsubscribe(any(), any());
         injectedFields = (int) Stream.of(countInjectedFields.getClass().getDeclaredFields())
@@ -189,7 +194,7 @@ public class MqttTopicClassMapperTests {
 
             // Check each value if the assignment worked
             if (!f.field.getType().isArray()) {
-                assertNotNull(f.field.getName() + " is null", f.field.get(attributes));
+                assertNotNull(f.field.get(attributes), f.field.getName() + " is null");
                 // Consider if a mapToField was used that would manipulate the received value
                 MQTTvalueTransform mapToField = f.field.getAnnotation(MQTTvalueTransform.class);
                 String prefix = mapToField != null ? mapToField.prefix() : "";
index b9f83b6b767beb87422038aa9e7ca7e44545a10d..2f2aee0819edfd86573f36fb0c91caf12544e2a2 100644 (file)
@@ -14,7 +14,8 @@ package org.openhab.binding.mqtt.generic.mapping;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 
@@ -32,10 +33,13 @@ import java.util.concurrent.TimeoutException;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.mapping.SubscribeFieldToMQTTtopic.FieldChanged;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
 
@@ -44,6 +48,8 @@ import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class SubscribeFieldToMQTTtopicTests {
     @Retention(RetentionPolicy.RUNTIME)
     @Target({ FIELD })
@@ -101,13 +107,12 @@ public class SubscribeFieldToMQTTtopicTests {
     @Mock
     FieldChanged fieldChanged;
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         doReturn(CompletableFuture.completedFuture(true)).when(connection).subscribe(any(), any());
     }
 
-    @Test(expected = TimeoutException.class)
+    @Test
     public void TimeoutIfNoMessageReceive()
             throws InterruptedException, NoSuchFieldException, ExecutionException, TimeoutException {
         final Field field = Attributes.class.getField("Int");
@@ -115,10 +120,11 @@ public class SubscribeFieldToMQTTtopicTests {
 
         SubscribeFieldToMQTTtopic subscriber = new SubscribeFieldToMQTTtopic(scheduler, field, fieldChanged,
                 "homie/device123", false);
-        subscriber.subscribeAndReceive(connection, 1000).get(50, TimeUnit.MILLISECONDS);
+        assertThrows(TimeoutException.class,
+                () -> subscriber.subscribeAndReceive(connection, 1000).get(50, TimeUnit.MILLISECONDS));
     }
 
-    @Test(expected = ExecutionException.class)
+    @Test
     public void MandatoryMissing()
             throws InterruptedException, NoSuchFieldException, ExecutionException, TimeoutException {
         final Field field = Attributes.class.getField("Int");
@@ -126,7 +132,7 @@ public class SubscribeFieldToMQTTtopicTests {
 
         SubscribeFieldToMQTTtopic subscriber = new SubscribeFieldToMQTTtopic(scheduler, field, fieldChanged,
                 "homie/device123", true);
-        subscriber.subscribeAndReceive(connection, 50).get();
+        assertThrows(ExecutionException.class, () -> subscriber.subscribeAndReceive(connection, 50).get());
     }
 
     @Test
index 6d35ee9360089feeccdd90f4ec397d941925780b..f6cf26f264f6f1d8608f74de387616d4b18ac7be 100644 (file)
 package org.openhab.binding.mqtt.generic.values;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.math.BigDecimal;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.mqtt.generic.mapping.ColorMode;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.HSBType;
@@ -45,10 +46,10 @@ public class ValueTests {
         return TypeParser.parseCommand(v.getSupportedCommandTypes(), str);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void illegalTextStateUpdate() {
         TextValue v = new TextValue("one,two".split(","));
-        v.update(p(v, "three"));
+        assertThrows(IllegalArgumentException.class, () -> v.update(p(v, "three")));
     }
 
     public void textStateUpdate() {
@@ -71,34 +72,34 @@ public class ValueTests {
         assertThat(((HSBType) v.getChannelState()).getBrightness().intValue(), is(1));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void illegalColorUpdate() {
         ColorValue v = new ColorValue(ColorMode.RGB, null, null, 10);
-        v.update(p(v, "255,255,abc"));
+        assertThrows(IllegalArgumentException.class, () -> v.update(p(v, "255,255,abc")));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void illegalNumberCommand() {
         NumberValue v = new NumberValue(null, null, null, null);
-        v.update(OnOffType.OFF);
+        assertThrows(IllegalArgumentException.class, () -> v.update(OnOffType.OFF));
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void illegalPercentCommand() {
         PercentageValue v = new PercentageValue(null, null, null, null, null);
-        v.update(new StringType("demo"));
+        assertThrows(IllegalStateException.class, () -> v.update(new StringType("demo")));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void illegalOnOffCommand() {
         OnOffValue v = new OnOffValue(null, null);
-        v.update(new DecimalType(101.0));
+        assertThrows(IllegalArgumentException.class, () -> v.update(new DecimalType(101.0)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void illegalPercentUpdate() {
         PercentageValue v = new PercentageValue(null, null, null, null, null);
-        v.update(new DecimalType(101.0));
+        assertThrows(IllegalArgumentException.class, () -> v.update(new DecimalType(101.0)));
     }
 
     @Test
@@ -309,10 +310,10 @@ public class ValueTests {
         assertEquals(((PercentType) v.getChannelState()).floatValue(), 100.0f, 0.01f);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void percentCalcInvalid() {
         PercentageValue v = new PercentageValue(new BigDecimal(10.0), new BigDecimal(110.0), new BigDecimal(1.0), null,
                 null);
-        v.update(new DecimalType(9.0));
+        assertThrows(IllegalArgumentException.class, () -> v.update(new DecimalType(9.0)));
     }
 }
index 374d7584874f4e166b4f701bea8467183f309292..e4ba92c55482e0bcdcfaf62bb56d173f5942a36c 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.mqtt.homeassistant.internal;
 
 import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
-import static org.junit.Assert.assertThat;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -23,7 +23,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.mqtt.homeassistant.internal.BaseChannelConfiguration.Connection;
 
 import com.google.gson.Gson;
index d7511c5c5849acdb187e86777ab15784ba585f0f..9b4692763ca1d99ae0857db119e7f5d84c64e00c 100644 (file)
 package org.openhab.binding.mqtt.homeassistant.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsCollectionContaining.hasItem;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsIterableContaining.hasItem;
 
 import java.util.Collection;
 import java.util.Collections;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
 
 /**
index 1443661c0a369e923624ce3b393332f78470bcfa..0f01f57205bcc569552e293c3e1e88b6e4c93e08 100644 (file)
 package org.openhab.binding.mqtt.homie.generic.internal.mapping;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.util.concurrent.CompletableFuture;
 import java.util.function.Function;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.tools.ChildMap;
 import org.openhab.binding.mqtt.homie.internal.handler.ThingChannelConstants;
 import org.openhab.binding.mqtt.homie.internal.homie300.DeviceCallback;
@@ -36,6 +38,8 @@ import org.openhab.binding.mqtt.homie.internal.homie300.NodeAttributes;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class HomieChildMapTests {
     private @Mock DeviceCallback callback;
 
@@ -59,11 +63,6 @@ public class HomieChildMapTests {
         callback.nodeRemoved(node);
     }
 
-    @Before
-    public void setUp() {
-        initMocks(this);
-    }
-
     public static class AddedAction implements Function<Node, CompletableFuture<Void>> {
         @Override
         public CompletableFuture<Void> apply(Node t) {
index 042c14a51f2c42bd1aa036d41d12c2dd7d5b8ebb..998b65fca69b54126096eb7c88c85ac2ca5a2b58 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.mqtt.homie.internal.handler;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.mqtt.homie.internal.handler.ThingChannelConstants.TEST_HOMIE_THING;
@@ -30,11 +31,14 @@ import java.util.concurrent.TimeUnit;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.generic.ChannelState;
 import org.openhab.binding.mqtt.generic.MqttChannelTypeProvider;
 import org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass;
@@ -75,26 +79,18 @@ import org.openhab.core.types.TypeParser;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class HomieThingHandlerTests {
-    @Mock
-    private ThingHandlerCallback callback;
 
     private Thing thing;
 
-    @Mock
-    private AbstractBrokerHandler bridgeHandler;
-
-    @Mock
-    private MqttBrokerConnection connection;
-
-    @Mock
-    private ScheduledExecutorService scheduler;
-
-    @Mock
-    private ScheduledFuture<?> scheduledFuture;
-
-    @Mock
-    private ThingTypeRegistry thingTypeRegistry;
+    private @Mock AbstractBrokerHandler bridgeHandler;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock MqttBrokerConnection connection;
+    private @Mock ScheduledExecutorService scheduler;
+    private @Mock ScheduledFuture<?> scheduledFuture;
+    private @Mock ThingTypeRegistry thingTypeRegistry;
 
     private HomieThingHandler thingHandler;
 
@@ -104,14 +100,12 @@ public class HomieThingHandlerTests {
     private final String deviceTopic = "homie/" + deviceID;
 
     // A completed future is returned for a subscribe call to the attributes
-    CompletableFuture<@Nullable Void> future = CompletableFuture.completedFuture(null);
+    private CompletableFuture<@Nullable Void> future = CompletableFuture.completedFuture(null);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         final ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
 
-        MockitoAnnotations.initMocks(this);
-
         final Configuration config = new Configuration();
         config.put("basetopic", "homie");
         config.put("deviceid", deviceID);
index d45b5a6ee909a8633e3791ea5ae6afebc2f2f49f..f6ff6355877a916249e9b826f6aff0b252bfbe8b 100644 (file)
 package org.openhab.binding.mqtt.handler;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.internal.MqttThingID;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
@@ -38,24 +42,20 @@ import org.osgi.service.cm.ConfigurationException;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class AbstractBrokerHandlerTest {
     private final String HOST = "tcp://123.1.2.3";
     private final int PORT = 80;
     private SystemBrokerHandler handler;
     int stateChangeCounter = 0;
 
-    @Mock
-    private ThingHandlerCallback callback;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Bridge thing;
+    private @Mock MqttService service;
 
-    @Mock
-    private Bridge thing;
-
-    @Mock
-    private MqttService service;
-
-    @Before
+    @BeforeEach
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         doReturn(MqttThingID.getThingUID(HOST, PORT)).when(thing).getUID();
         doReturn(new Configuration(Collections.singletonMap("brokerid", MqttThingID.getThingUID(HOST, PORT).getId())))
                 .when(thing).getConfiguration();
index dfef63e65298b4633ec580c3c722ce8b11c152e6..b56ebf508ed68b9eb90db44440571acce65458f8 100644 (file)
 package org.openhab.binding.mqtt.handler;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.internal.MqttThingID;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
@@ -44,26 +47,22 @@ import org.osgi.service.cm.ConfigurationException;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class BrokerHandlerTest {
     private ScheduledExecutorService scheduler;
 
-    @Mock
-    private ThingHandlerCallback callback;
-
-    @Mock
-    private Bridge thing;
-
-    @Mock
-    private MqttService service;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Bridge thing;
+    private @Mock MqttService service;
 
     private MqttBrokerConnectionEx connection;
 
     private BrokerHandler handler;
 
-    @Before
+    @BeforeEach
     public void setUp() throws ConfigurationException, MqttException {
         scheduler = new ScheduledThreadPoolExecutor(1);
-        MockitoAnnotations.initMocks(this);
         when(thing.getUID()).thenReturn(MqttThingID.getThingUID("10.10.0.10", 80));
         connection = spy(new MqttBrokerConnectionEx("10.10.0.10", 80, false, "BrokerHandlerTest"));
         connection.setTimeoutExecutor(scheduler, 10);
@@ -76,17 +75,17 @@ public class BrokerHandlerTest {
         handler.setCallback(callback);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         scheduler.shutdownNow();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void handlerInitWithoutUrl()
             throws InterruptedException, IllegalArgumentException, MqttException, ConfigurationException {
         // Assume it is a real handler and not a mock as defined above
         handler = new BrokerHandler(thing);
-        assertThat(initializeHandlerWaitForTimeout(), is(true));
+        assertThrows(IllegalArgumentException.class, () -> initializeHandlerWaitForTimeout());
     }
 
     @Test
@@ -106,7 +105,7 @@ public class BrokerHandlerTest {
 
         ArgumentCaptor<ThingStatusInfo> statusInfoCaptor = ArgumentCaptor.forClass(ThingStatusInfo.class);
         verify(callback, atLeast(3)).statusUpdated(eq(thing), statusInfoCaptor.capture());
-        Assert.assertThat(statusInfoCaptor.getValue().getStatus(), is(ThingStatus.ONLINE));
+        assertThat(statusInfoCaptor.getValue().getStatus(), is(ThingStatus.ONLINE));
     }
 
     /**
index 9f5c8e4b1a1d6b7e5b2acd13ef9bcf5fea578bbe..cf342e3ddc9ea7a8d12d753e210e2ae13eb737e0 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.mqtt.internal.discovery;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -23,11 +23,14 @@ import java.util.TreeMap;
 
 import javax.naming.ConfigurationException;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.mqtt.MqttBindingConstants;
 import org.openhab.core.config.discovery.DiscoveryListener;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -39,16 +42,15 @@ import org.openhab.core.io.transport.mqtt.MqttService;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class ServiceDiscoveryServiceTest {
-    @Mock
-    private MqttService service;
 
-    @Mock
-    private DiscoveryListener discoverListener;
+    private @Mock MqttService service;
+    private @Mock DiscoveryListener discoverListener;
 
-    @Before
+    @BeforeEach
     public void initMocks() throws ConfigurationException {
-        MockitoAnnotations.initMocks(this);
         Map<String, MqttBrokerConnection> brokers = new TreeMap<>();
         brokers.put("testname", new MqttBrokerConnection("tcp://123.123.123.123", null, false, null));
         brokers.put("textual", new MqttBrokerConnection("tcp://123.123.123.123", null, true, null));
index efd8f9e4982c89e6341df8a7f5e5cdc21c20f91e..bd9f26c2fa3193785da29bcbd81a82e46849ad89 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.mqtt.internal.ssl;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -26,7 +26,7 @@ import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.util.HexUtils;
 
 /**
index d6a73caab37ab52d1a534f3759c095680cae2e0d..2ac49c913c211db2c3f9b19911c908a81288d916 100644 (file)
 package org.openhab.binding.nanoleaf.internal;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nanoleaf.internal.model.Layout;
 
 import com.google.gson.Gson;
@@ -36,7 +36,7 @@ public class LayoutTest {
     String layout1Json = "";
     String layoutInconsistentPanelNoJson = "";
 
-    @Before
+    @BeforeEach
     public void setup() {
         layout1Json = "{\"numPanels\":14,\"sideLength\":100,\"positionData\":[{\"panelId\":41451,\"x\":350,\"y\":0,\"o\":0,\"shapeType\":3},{\"panelId\":8134,\"x\":350,\"y\":150,\"o\":0,\"shapeType\":2},{\"panelId\":58086,\"x\":200,\"y\":100,\"o\":270,\"shapeType\":2},{\"panelId\":38724,\"x\":300,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":48111,\"x\":200,\"y\":200,\"o\":270,\"shapeType\":2},{\"panelId\":56093,\"x\":100,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":55836,\"x\":0,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":31413,\"x\":100,\"y\":300,\"o\":90,\"shapeType\":2},{\"panelId\":9162,\"x\":300,\"y\":300,\"o\":90,\"shapeType\":2},{\"panelId\":13276,\"x\":400,\"y\":300,\"o\":90,\"shapeType\":2},{\"panelId\":17870,\"x\":400,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":5164,\"x\":500,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":64279,\"x\":600,\"y\":200,\"o\":0,\"shapeType\":2},{\"panelId\":39755,\"x\":500,\"y\":100,\"o\":90,\"shapeType\":2}]}";
         // panel number is not consistent to returned panels in array but it should still work
index 50cb7a52f454f8d990d347dbf49e834d1935f868..15d219d46b1137eecbd16b5b9bc5e6213b615a74 100644 (file)
 package org.openhab.binding.nanoleaf.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nanoleaf.internal.model.TouchEvent;
 import org.openhab.binding.nanoleaf.internal.model.TouchEvents;
 
index 5fc4c0f247cbf6ce1b67e70344876b2dd389bc6b..168aeb9cc23b1881eca5e0f8d1377978325ed58d 100644 (file)
  */
 package org.openhab.binding.nanoleaf.internal.handler;
 
-import static java.nio.file.Files.*;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nanoleaf.internal.model.ControllerInfo;
 import org.openhab.binding.nanoleaf.internal.model.State;
 import org.openhab.core.library.types.OnOffType;
@@ -38,7 +37,7 @@ public class NanoleafControllerHandlerTest {
 
     private String controllerInfoJSON = "";
 
-    @Before
+    @BeforeEach
     public void setup() {
     }
 
index 84b7ce88a28255bc2c706d3f1be30ca8f2e755fa..e378c1388858f9aa4ed90b84ddde4d1bf94c5599 100644 (file)
  */
 package org.openhab.binding.neohub.test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.neohub.internal.NeoHubBindingConstants.*;
 
 import java.io.BufferedReader;
@@ -27,7 +22,7 @@ import java.math.BigDecimal;
 import java.time.Instant;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.neohub.internal.NeoHubAbstractDeviceData;
 import org.openhab.binding.neohub.internal.NeoHubAbstractDeviceData.AbstractRecord;
 import org.openhab.binding.neohub.internal.NeoHubGetEngineersData;
index ad77b9444cc572325f48631094810cb04c4124fe..77c56de4c578e3e632f2209702d053554940a584 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.netatmo.internal.discovery;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
@@ -21,16 +21,18 @@ import java.util.List;
 import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.binding.netatmo.internal.handler.NetatmoBridgeHandler;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.i18n.LocaleProvider;
 import org.openhab.core.i18n.TranslationProvider;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.netatmo.internal.handler.NetatmoBridgeHandler;
 
 import io.swagger.client.model.NAMain;
 import io.swagger.client.model.NAStationDataBody;
@@ -39,13 +41,14 @@ import io.swagger.client.model.NAStationModule;
 /**
  * @author Sven Strohschein - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class NetatmoModuleDiscoveryServiceTest {
 
     private NetatmoModuleDiscoveryServiceAccessible service;
     private NetatmoBridgeHandler bridgeHandlerSpy;
 
-    @Before
+    @BeforeEach
     public void before() {
         Bridge bridgeMock = mock(Bridge.class);
         when(bridgeMock.getUID()).thenReturn(new ThingUID("netatmo", "bridge"));
index 23d7a5fa68467e379cf5f05fcbc6a7e2d9ed6f84..38a393b58c3c531cb38d17ba1440044432d10840 100644 (file)
  */
 package org.openhab.binding.netatmo.internal.presence;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.binding.netatmo.internal.NetatmoBindingConstants;
 import org.openhab.core.i18n.TimeZoneProvider;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -29,29 +37,22 @@ import org.openhab.core.thing.internal.ThingImpl;
 import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.UnDefType;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.netatmo.internal.NetatmoBindingConstants;
 
 import io.swagger.client.model.NAWelcomeCamera;
 
 /**
  * @author Sven Strohschein - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class NAPresenceCameraHandlerTest {
 
     private static final String DUMMY_VPN_URL = "https://dummytestvpnaddress.net/restricted/10.255.89.96/9826069dc689e8327ac3ed2ced4ff089/MTU5MTgzMzYwMDrQ7eHHhG0_OJ4TgmPhGlnK7QQ5pZ,,";
     private static final String DUMMY_LOCAL_URL = "http://192.168.178.76/9826069dc689e8327ac3ed2ced4ff089";
     private static final Optional<String> DUMMY_PING_RESPONSE = createPingResponseContent(DUMMY_LOCAL_URL);
 
-    @Mock
-    private RequestExecutor requestExecutorMock;
-    @Mock
-    private TimeZoneProvider timeZoneProviderMock;
+    private @Mock RequestExecutor requestExecutorMock;
+    private @Mock TimeZoneProvider timeZoneProviderMock;
 
     private Thing presenceCameraThing;
     private NAWelcomeCamera presenceCamera;
@@ -60,7 +61,7 @@ public class NAPresenceCameraHandlerTest {
     private ChannelUID floodlightAutoModeChannelUID;
     private NAPresenceCameraHandlerAccessible handler;
 
-    @Before
+    @BeforeEach
     public void before() {
         presenceCameraThing = new ThingImpl(new ThingTypeUID("netatmo", "NOC"), "1");
         presenceCamera = new NAWelcomeCamera();
index c0a8e1b9ce5e09a9ff8c20d1cf37962d8382469a..53a54273e6f36fa0527c5d02dc7b4dc0d32d7353 100644 (file)
  */
 package org.openhab.binding.netatmo.internal.welcome;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.binding.netatmo.internal.NetatmoBindingConstants;
+import org.openhab.binding.netatmo.internal.handler.NetatmoBridgeHandler;
+import org.openhab.binding.netatmo.internal.webhook.NAWebhookCameraEvent;
 import org.openhab.core.i18n.TimeZoneProvider;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.internal.ThingImpl;
 import org.openhab.core.types.UnDefType;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.netatmo.internal.NetatmoBindingConstants;
-import org.openhab.binding.netatmo.internal.handler.NetatmoBridgeHandler;
-import org.openhab.binding.netatmo.internal.webhook.NAWebhookCameraEvent;
 
 import io.swagger.client.model.NAWelcomeEvent;
 import io.swagger.client.model.NAWelcomeHome;
@@ -43,18 +48,18 @@ import io.swagger.client.model.NAWelcomeSubEvent;
 /**
  * @author Sven Strohschein - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class NAWelcomeHomeHandlerTest {
 
     private static final String DUMMY_HOME_ID = "1";
 
-    @Mock
-    private TimeZoneProvider timeZoneProviderMock;
     private NAWelcomeHomeHandlerAccessible handler;
-    @Mock
-    private NetatmoBridgeHandler bridgeHandlerMock;
 
-    @Before
+    private @Mock NetatmoBridgeHandler bridgeHandlerMock;
+    private @Mock TimeZoneProvider timeZoneProviderMock;
+
+    @BeforeEach
     public void before() {
         Thing welcomeHomeThing = new ThingImpl(new ThingTypeUID("netatmo", "NAWelcomeHome"), "1");
         handler = new NAWelcomeHomeHandlerAccessible(welcomeHomeThing);
@@ -283,10 +288,9 @@ public class NAWelcomeHomeHandlerTest {
 
     @Test
     public void testMatchDetectedObjectEnums() {
-        assertArrayEquals(
-                "The detected object enums aren't equal anymore, that could lead to a bug! Please check the usages!",
-                Arrays.stream(NAWelcomeEvent.CategoryEnum.values()).map(Enum::name).toArray(),
-                Arrays.stream(NAWelcomeSubEvent.TypeEnum.values()).map(Enum::name).toArray());
+        assertArrayEquals(Arrays.stream(NAWelcomeEvent.CategoryEnum.values()).map(Enum::name).toArray(),
+                Arrays.stream(NAWelcomeSubEvent.TypeEnum.values()).map(Enum::name).toArray(),
+                "The detected object enums aren't equal anymore, that could lead to a bug! Please check the usages!");
     }
 
     private NAWelcomeHome initHome() {
index 2b98ea8d324cbb5825aec7a1169a0348822d5019..9444a38e07d62fcc61653ffe989b144f0f98279c 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.network.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
@@ -25,12 +26,15 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheAsync;
 import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheHelper;
 import org.openhab.binding.network.internal.utils.NetworkUtils;
@@ -43,26 +47,20 @@ import org.openhab.binding.network.internal.utils.PingResult;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class PresenceDetectionTest {
-    static long CACHETIME = 2000L;
-    @Mock
-    NetworkUtils networkUtils;
+    private static final long CACHETIME = 2000L;
 
-    @Mock
-    PresenceDetectionListener listener;
+    private PresenceDetection subject;
 
-    @Mock
-    ExecutorService executorService;
+    private @Mock Consumer<PresenceDetectionValue> callback;
+    private @Mock ExecutorService executorService;
+    private @Mock PresenceDetectionListener listener;
+    private @Mock NetworkUtils networkUtils;
 
-    @Mock
-    Consumer<PresenceDetectionValue> callback;
-
-    PresenceDetection subject;
-
-    @Before
+    @BeforeEach
     public void setUp() throws UnknownHostException {
-        MockitoAnnotations.initMocks(this);
-
         // Mock an interface
         when(networkUtils.getInterfaceNames()).thenReturn(Collections.singleton("TESTinterface"));
         doReturn(ArpPingUtilEnum.IPUTILS_ARPING).when(networkUtils).determineNativeARPpingMethod(anyString());
@@ -86,7 +84,7 @@ public class PresenceDetectionTest {
         assertThat(subject.pingMethod, is(IpPingMethodEnum.WINDOWS_PING));
     }
 
-    @After
+    @AfterEach
     public void shutDown() {
         subject.waitForPresenceDetection();
     }
index d1284dcc499452ac500e809ccd9423b25945f4e4..c4ddea38fba120059d076f553b4608c002837c6a 100644 (file)
 package org.openhab.binding.network.internal;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests cases for {@see PresenceDetectionValue}
index 4c76a12d0f89dc7a4c0a96a1d1767c64e0c38431..8c1f3616d5289ebda5762add0ebaccd5451240ac 100644 (file)
 package org.openhab.binding.network.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.openhab.binding.network.internal.WakeOnLanPacketSender.*;
 
 import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.openhab.core.util.HexUtils;
 
 /**
@@ -26,6 +29,7 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Wouter Born - Initial contribution
  */
+@Timeout(value = 10, unit = TimeUnit.SECONDS)
 public class WakeOnLanPacketSenderTest {
 
     private void assertValidMagicPacket(byte[] macBytes, byte[] packet) {
@@ -75,23 +79,23 @@ public class WakeOnLanPacketSenderTest {
         assertValidMagicPacket(HexUtils.hexToBytes("6f70656e4841"), actualPacket);
     }
 
-    @Test(expected = IllegalStateException.class, timeout = 10000)
+    @Test
     public void sendWithEmptyMacAddressThrowsException() {
-        new WakeOnLanPacketSender("").sendPacket();
+        assertThrows(IllegalStateException.class, () -> new WakeOnLanPacketSender("").sendPacket());
     }
 
-    @Test(expected = IllegalStateException.class, timeout = 10000)
+    @Test
     public void sendWithTooShortMacAddressThrowsException() {
-        new WakeOnLanPacketSender("6f:70:65:6e:48").sendPacket();
+        assertThrows(IllegalStateException.class, () -> new WakeOnLanPacketSender("6f:70:65:6e:48").sendPacket());
     }
 
-    @Test(expected = IllegalStateException.class, timeout = 10000)
+    @Test
     public void sendWithTooLongMacAddressThrowsException() {
-        new WakeOnLanPacketSender("6f:70:65:6e:48:41:42").sendPacket();
+        assertThrows(IllegalStateException.class, () -> new WakeOnLanPacketSender("6f:70:65:6e:48:41:42").sendPacket());
     }
 
-    @Test(expected = IllegalStateException.class, timeout = 10000)
+    @Test
     public void sendWithUnsupportedSeparatorInMacAddressThrowsException() {
-        new WakeOnLanPacketSender("6f=70=65=6e=48=41").sendPacket();
+        assertThrows(IllegalStateException.class, () -> new WakeOnLanPacketSender("6f=70=65=6e=48=41").sendPacket());
     }
 }
index 19172cbd267af4a269668ec60e6bd34d4dc76570..19a1942e3ba2014b5429325a4bc08b7157ec8008 100644 (file)
 package org.openhab.binding.network.internal.dhcp;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assume.assumeTrue;
-import static org.mockito.Matchers.eq;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.SocketException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.network.internal.dhcp.DHCPPacket.BadPacketException;
 
 /**
index 4cf253b2df43b95b822e7d0c100e9e784511dbe2..196d333c422e3e3ba807383dfd17eed76c745440 100644 (file)
 package org.openhab.binding.network.internal.discovery;
 
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.util.Collections;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.network.internal.NetworkBindingConstants;
 import org.openhab.binding.network.internal.PresenceDetectionValue;
 import org.openhab.core.config.discovery.DiscoveryListener;
@@ -34,18 +37,16 @@ import org.openhab.core.config.discovery.DiscoveryResult;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class DiscoveryTest {
     private final String ip = "127.0.0.1";
 
-    @Mock
-    PresenceDetectionValue value;
+    private @Mock PresenceDetectionValue value;
+    private @Mock DiscoveryListener listener;
 
-    @Mock
-    DiscoveryListener listener;
-
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
         when(value.getHostAddress()).thenReturn(ip);
         when(value.getLowestLatency()).thenReturn(10.0);
         when(value.isReachable()).thenReturn(true);
@@ -65,8 +66,8 @@ public class DiscoveryTest {
         d.partialDetectionResult(value);
         verify(listener).thingDiscovered(any(), result.capture());
         DiscoveryResult dresult = result.getValue();
-        Assert.assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createPingUID(ip)));
-        Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
+        assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createPingUID(ip)));
+        assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
     }
 
     @Test
@@ -83,8 +84,8 @@ public class DiscoveryTest {
         d.partialDetectionResult(value);
         verify(listener).thingDiscovered(any(), result.capture());
         DiscoveryResult dresult = result.getValue();
-        Assert.assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createServiceUID(ip, 1010)));
-        Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
-        Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_PORT), is(1010));
+        assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createServiceUID(ip, 1010)));
+        assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
+        assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_PORT), is(1010));
     }
 }
index 6905437f76cb5c682ed21acc5d288819bfd03437..12da18a70e6a82aa8e92af286dfafdde2d404324 100644 (file)
 package org.openhab.binding.network.internal.handler;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.network.internal.NetworkBindingConfiguration;
 import org.openhab.binding.network.internal.NetworkBindingConstants;
 import org.openhab.binding.network.internal.PresenceDetection;
@@ -45,17 +48,16 @@ import org.openhab.core.thing.binding.ThingHandlerCallback;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class NetworkHandlerTest extends JavaTest {
     private ThingUID thingUID = new ThingUID("network", "ttype", "ping");
-    @Mock
-    private ThingHandlerCallback callback;
 
-    @Mock
-    private Thing thing;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Thing thing;
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
         when(thing.getUID()).thenReturn(thingUID);
     }
 
@@ -91,7 +93,7 @@ public class NetworkHandlerTest extends JavaTest {
     public void tcpDeviceInitTests() {
         NetworkBindingConfiguration config = new NetworkBindingConfiguration();
         NetworkHandler handler = spy(new NetworkHandler(thing, true, config));
-        Assert.assertThat(handler.isTCPServiceDevice(), is(true));
+        assertThat(handler.isTCPServiceDevice(), is(true));
         handler.setCallback(callback);
         // Port is missing, should make the device OFFLINE
         when(thing.getConfiguration()).thenAnswer(a -> {
@@ -103,9 +105,8 @@ public class NetworkHandlerTest extends JavaTest {
         // Check that we are offline
         ArgumentCaptor<ThingStatusInfo> statusInfoCaptor = ArgumentCaptor.forClass(ThingStatusInfo.class);
         verify(callback).statusUpdated(eq(thing), statusInfoCaptor.capture());
-        Assert.assertThat(statusInfoCaptor.getValue().getStatus(), is(equalTo(ThingStatus.OFFLINE)));
-        Assert.assertThat(statusInfoCaptor.getValue().getStatusDetail(),
-                is(equalTo(ThingStatusDetail.CONFIGURATION_ERROR)));
+        assertThat(statusInfoCaptor.getValue().getStatus(), is(equalTo(ThingStatus.OFFLINE)));
+        assertThat(statusInfoCaptor.getValue().getStatusDetail(), is(equalTo(ThingStatusDetail.CONFIGURATION_ERROR)));
     }
 
     @Test
index f577e7f283daeda5d798fab619a1b0ec7eec3c0e..34dc993a126dd24afbccc1f86715525c085faad9 100644 (file)
  */
 package org.openhab.binding.network.internal.toberemoved.cache;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 import java.util.function.Consumer;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheAsync.ExpiringCacheUpdate;
 
@@ -27,18 +27,17 @@ import org.openhab.binding.network.internal.toberemoved.cache.ExpiringCacheAsync
  * @author David Graeff - Initial contribution
  */
 public class ExpiringCacheAsyncTest {
-    @SuppressWarnings("unused")
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testConstructorWrongCacheTime() {
+        assertThrows(IllegalArgumentException.class, () ->
         // Fail if cache time is <= 0
         new ExpiringCacheAsync<>(0, () -> {
-        });
+        }));
     }
 
-    @SuppressWarnings("unused")
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testConstructorNoRefrehCommand() {
-        new ExpiringCacheAsync<>(2000, null);
+        assertThrows(IllegalArgumentException.class, () -> new ExpiringCacheAsync<>(2000, null));
     }
 
     @Test
index 141f6644f94d7e5cb3dbf8b907c0ff71e6a6c035..372f77820e31310a5632fe09d7a4d2abb97eb78a 100644 (file)
  */
 package org.openhab.binding.network.internal.utils;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import java.util.Optional;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the parser which extracts latency values from the output of the ping command.
@@ -34,8 +35,8 @@ public class LatencyParserTest {
         Optional<Double> resultLatency = latencyParser.parseLatency(input);
 
         // Assert
-        Assert.assertTrue(resultLatency.isPresent());
-        Assert.assertEquals(1.225, resultLatency.get(), 0);
+        assertTrue(resultLatency.isPresent());
+        assertEquals(1.225, resultLatency.get(), 0);
     }
 
     @Test
@@ -54,7 +55,7 @@ public class LatencyParserTest {
             Optional<Double> resultLatency = latencyParser.parseLatency(inputLine);
 
             // Assert
-            Assert.assertFalse(resultLatency.isPresent());
+            assertFalse(resultLatency.isPresent());
         }
     }
 }
index 2ee527c08d43ff0dbe0bff305a1f1948427e481d..c6d985f25c7a56d55ca294ca77dcb39e2f962c3e 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.networkupstools.internal;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.io.IOException;
@@ -28,7 +29,7 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.apache.commons.io.FileUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.CoreItemFactory;
 
 /**
@@ -75,7 +76,7 @@ public class NutNameChannelsTest {
         for (final Entry<NutName, String> entry : readMeNutNames.entrySet()) {
             final Matcher matcher = README_PATTERN.matcher(entry.getValue());
 
-            assertNotNull("Could not find NutName in readme for : " + entry.getValue(), entry.getKey());
+            assertNotNull(entry.getKey(), "Could not find NutName in readme for : " + entry.getValue());
             if (matcher.find()) {
                 list.add(String.format(TEMPLATE_CHANNEL, entry.getKey().getChannelId(),
                         nutNameToChannelType(entry.getKey())));
@@ -145,10 +146,10 @@ public class NutNameChannelsTest {
 
     private NutName lineToNutName(final String line) {
         final Matcher matcher = README_PATTERN.matcher(line);
-        assertTrue("Could not match readme line: " + line, matcher.find());
+        assertTrue(matcher.find(), "Could not match readme line: " + line);
         final String name = matcher.group(1);
         final NutName channelIdToNutName = NutName.channelIdToNutName(name);
-        assertNotNull("Name should not match null: '" + name + "' ->" + line, channelIdToNutName);
+        assertNotNull(channelIdToNutName, "Name should not match null: '" + name + "' ->" + line);
         return channelIdToNutName;
     }
 
index 204abb9a39f4c76e7713bac7f5f41f67f6658e42..b683da29eca8b359a4f1ced1e1a225ce2e32c7a8 100644 (file)
  */
 package org.openhab.binding.networkupstools.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Optional;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class to check the validity of the {@link NutName} enum.
@@ -38,12 +38,12 @@ public class NutNameTest {
         for (final NutName nn : NutName.values()) {
             final Matcher matcher = CHANNEL_PATTERN.matcher(nn.getName());
 
-            assertTrue("NutName name '" + nn + "' could not be matched with expected pattern.", matcher.find());
+            assertTrue(matcher.find(), "NutName name '" + nn + "' could not be matched with expected pattern.");
             final String expectedChannelId = matcher.group(1)
                     + StringUtils.capitalize(Optional.ofNullable(matcher.group(2)).orElse(""))
                     + StringUtils.capitalize(Optional.ofNullable(matcher.group(3)).orElse(""))
                     + StringUtils.capitalize(Optional.ofNullable(matcher.group(4)).orElse(""));
-            assertEquals("Channel name not correct", expectedChannelId, nn.getChannelId());
+            assertEquals(expectedChannelId, nn.getChannelId(), "Channel name not correct");
         }
     }
 }
index b90ff77412023a84a0e03c0dd3ca65e06b7c2df4..54016409baf7a92287aeec80e27e2493a8120971 100644 (file)
  */
 package org.openhab.binding.networkupstools.internal.nut;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,24 +26,25 @@ import java.nio.file.Paths;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 
 /**
  * Unit test to test the {@link NutApi} using a mock Socket connection.
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class NutApiTest {
 
-    @Mock
-    private Socket socket;
+    private @Mock Socket socket;
     private NutConnector connector;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
-        initMocks(this);
         connector = new NutConnector("localhost", 0, "test", "pwd") {
             @Override
             protected Socket newSocket() {
index 28e6fb2db646599b8b57918b30842d9744859da3..ae82f2d294ebdbdf19eefde40422eb39cf3d75c2 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.handler;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.nibeheatpump.internal.models.PumpModel;
 import org.openhab.binding.nibeheatpump.internal.models.VariableInformation;
 import org.openhab.core.io.transport.serial.SerialPortManager;
@@ -38,7 +38,7 @@ import org.openhab.core.types.Command;
  *
  * @author Jevgeni Kiski - Initial contribution
  */
-@RunWith(Parameterized.class)
+@ExtendWith(MockitoExtension.class)
 public class NibeHeatPumpHandlerCommand2NibeTest {
     private NibeHeatPumpHandler product; // the class under test
     private Method m;
@@ -46,13 +46,8 @@ public class NibeHeatPumpHandlerCommand2NibeTest {
     private Class<?>[] parameterTypes;
     private Object[] parameters;
 
-    private int fCoilAddress;
-    private Command fCommand;
-    private int fExpected;
-
     private @Mock SerialPortManager serialPortManager;
 
-    @Parameterized.Parameters(name = "{index}: f({0}, {1})={2}")
     public static Collection<Object[]> data() {
         return Arrays.asList(new Object[][] { { 47028, new DecimalType("-1"), (byte) 0xFF },
                 { 48132, new DecimalType("0"), 0 }, { 48132, new StringType("0"), 0 },
@@ -63,16 +58,8 @@ public class NibeHeatPumpHandlerCommand2NibeTest {
                 { 47371, OnOffType.from(true), 0x1 }, { 47371, OnOffType.from(false), 0x0 }, });
     }
 
-    public NibeHeatPumpHandlerCommand2NibeTest(final int coilAddress, final Command command, final int expected) {
-        this.fCoilAddress = coilAddress;
-        this.fCommand = command;
-        this.fExpected = expected;
-    }
-
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
-        initMocks(this);
-
         product = new NibeHeatPumpHandler(null, PumpModel.F1X55, serialPortManager);
         parameterTypes = new Class[2];
         parameterTypes[0] = VariableInformation.class;
@@ -82,13 +69,15 @@ public class NibeHeatPumpHandlerCommand2NibeTest {
         parameters = new Object[2];
     }
 
-    @Test
-    public void convertNibeValueToStateTest() throws InvocationTargetException, IllegalAccessException {
-        VariableInformation varInfo = VariableInformation.getVariableInfo(PumpModel.F1X55, fCoilAddress);
+    @ParameterizedTest
+    @MethodSource("data")
+    public void convertNibeValueToStateTest(final int coilAddress, final Command command, final int expected)
+            throws InvocationTargetException, IllegalAccessException {
+        VariableInformation varInfo = VariableInformation.getVariableInfo(PumpModel.F1X55, coilAddress);
         parameters[0] = varInfo;
-        parameters[1] = fCommand;
+        parameters[1] = command;
         int value = (int) m.invoke(product, parameters);
 
-        assertEquals(fExpected, value);
+        assertEquals(expected, value);
     }
 }
index b3536841d7505ba54e67bb22d809c98191d9280c..d024ef4238f2ad4c0f8243c6e8c27dde41549d32 100644 (file)
@@ -12,8 +12,7 @@
  */
 package org.openhab.binding.nibeheatpump.internal.handler;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -21,11 +20,12 @@ import java.text.DecimalFormatSymbols;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.nibeheatpump.internal.models.PumpModel;
 import org.openhab.binding.nibeheatpump.internal.models.VariableInformation;
 import org.openhab.core.io.transport.serial.SerialPortManager;
@@ -36,7 +36,7 @@ import org.openhab.core.types.State;
  *
  * @author Jevgeni Kiski - Initial contribution
  */
-@RunWith(Parameterized.class)
+@ExtendWith(MockitoExtension.class)
 public class NibeHeatPumpHandlerNibe2StateTest {
 
     // we need to get the decimal separator of the default locale for our tests
@@ -47,15 +47,9 @@ public class NibeHeatPumpHandlerNibe2StateTest {
     private Method m;
     private Class<?>[] parameterTypes;
     private Object[] parameters;
-    private int fCoilAddress;
-    private int fValue;
-    private String fFormat;
-    private String fType;
-    private String fExpected;
 
     private @Mock SerialPortManager serialPortManager;
 
-    @Parameterized.Parameters(name = "{index}: f({0}, {1}, {3})={4}")
     public static Collection<Object[]> data() {
         return Arrays.asList(new Object[][] { //
                 { 47028, 0xFF, "%d", "Number", "-1" }, //
@@ -87,19 +81,8 @@ public class NibeHeatPumpHandlerNibe2StateTest {
         });
     }
 
-    public NibeHeatPumpHandlerNibe2StateTest(final int coilAddress, final int value, final String format,
-            final String type, final String expected) {
-        this.fCoilAddress = coilAddress;
-        this.fValue = value;
-        this.fFormat = format;
-        this.fType = type;
-        this.fExpected = expected;
-    }
-
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
-        initMocks(this);
-
         product = new NibeHeatPumpHandler(null, PumpModel.F1X55, serialPortManager);
         parameterTypes = new Class[3];
         parameterTypes[0] = VariableInformation.class;
@@ -110,14 +93,16 @@ public class NibeHeatPumpHandlerNibe2StateTest {
         parameters = new Object[3];
     }
 
-    @Test
-    public void convertNibeValueToStateTest() throws InvocationTargetException, IllegalAccessException {
-        VariableInformation varInfo = VariableInformation.getVariableInfo(PumpModel.F1X55, fCoilAddress);
+    @ParameterizedTest
+    @MethodSource("data")
+    public void convertNibeValueToStateTest(final int coilAddress, final int value, final String format,
+            final String type, final String expected) throws InvocationTargetException, IllegalAccessException {
+        VariableInformation varInfo = VariableInformation.getVariableInfo(PumpModel.F1X55, coilAddress);
         parameters[0] = varInfo;
-        parameters[1] = fValue;
-        parameters[2] = fType;
+        parameters[1] = value;
+        parameters[2] = type;
         State state = (State) m.invoke(product, parameters);
 
-        assertEquals(fExpected, state.format(fFormat));
+        assertEquals(expected, state.format(format));
     }
 }
index a38738ee8c45aa527a7f7e8831eb62c5ecf6c80d..2f8c64b18e25fceda6cf63dbab3389e5d72ee305 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 import org.openhab.core.util.HexUtils;
 
@@ -182,20 +182,20 @@ public class ModbusDataReadOutMessageTest {
         checkRegisters(message, expectedValues);
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void badCrcTest() throws NibeHeatPumpException {
+    @Test
+    public void badCrcTest() {
         final String message = "5C0020685001A81F0100A86400FDA7D003449C1E004F9CA000509C7800519C0301529C1B01879C14014E9CC601479C010115B9B0FF3AB94B00C9AF0000489C0D014C9CE7004B9C0000FFFF0000FFFF0000FFFF000044";
 
         final byte[] msg = HexUtils.hexToBytes(message);
-        MessageFactory.getMessage(msg);
+        assertThrows(NibeHeatPumpException.class, () -> MessageFactory.getMessage(msg));
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void notModbusDataReadOutMessageTest() throws NibeHeatPumpException {
+    @Test
+    public void notModbusDataReadOutMessageTest() {
         final String message = "519C0301529C1B01879C14014E9CC601479C010115B9B0FF3AB94B00C9AF0000489C0D014C9CE7004B9C0000FFFF0000FFFF0000FFFF000044";
 
         final byte[] msg = HexUtils.hexToBytes(message);
-        new ModbusDataReadOutMessage(msg);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusDataReadOutMessage(msg));
     }
 
     private void checkRegisters(final String message, final ArrayList<ModbusValue> expectedRegs)
index f543ddc8a410e40345a9e28cba3b5ec157352c07..31486abed6738376cf02eb037639c09bd98f7d65 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 import org.openhab.core.util.HexUtils;
 
@@ -42,17 +42,17 @@ public class ModbusReadRequestMessageTest {
         assertEquals(coilAddress, m.getCoilAddress());
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void badCrcTest() throws NibeHeatPumpException {
+    @Test
+    public void badCrcTest() {
         final String strMessage = "C069023930A1";
         final byte[] msg = HexUtils.hexToBytes(strMessage);
-        new ModbusReadRequestMessage(msg);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusReadRequestMessage(msg));
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void notReadRequestMessageTest() throws NibeHeatPumpException {
+    @Test
+    public void notReadRequestMessageTest() {
         final String strMessage = "C169023930A2";
         final byte[] byteMessage = HexUtils.hexToBytes(strMessage);
-        new ModbusReadRequestMessage(byteMessage);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusReadRequestMessage(byteMessage));
     }
 }
index 01b3e23d85e1d36615e7fedb312740107de529ec..ff46a8400e2c294054691c7bcda700e17fc7a798 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 import org.openhab.core.util.HexUtils;
 
@@ -45,17 +45,17 @@ public class ModbusReadResponseMessageTest {
         assertEquals(value, m.getValue());
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void badCrcTest() throws NibeHeatPumpException {
+    @Test
+    public void badCrcTest() {
         final String strMessage = "5C00206A060102030405064C";
         final byte[] byteMessage = HexUtils.hexToBytes(strMessage);
-        MessageFactory.getMessage(byteMessage);
+        assertThrows(NibeHeatPumpException.class, () -> MessageFactory.getMessage(byteMessage));
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void notReadResponseMessageTest() throws NibeHeatPumpException {
+    @Test
+    public void notReadResponseMessageTest() {
         final String strMessage = "5C00206B060102030405064A";
         final byte[] byteMessage = HexUtils.hexToBytes(strMessage);
-        new ModbusReadResponseMessage(byteMessage);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusReadResponseMessage(byteMessage));
     }
 }
index 1cd5d44a015662c788c331d02e21dd788edc6b06..f06f812e0f51d1ecb71fb80c6426e9b80ef5c613 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 import org.openhab.core.util.HexUtils;
 
@@ -26,7 +26,7 @@ import org.openhab.core.util.HexUtils;
  */
 public class ModbusWriteRequestMessageTest {
 
-    @Before
+    @BeforeEach
     public void Before() {
     }
 
@@ -50,17 +50,17 @@ public class ModbusWriteRequestMessageTest {
         assertEquals(value, m.getValue());
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void badCrcTest() throws NibeHeatPumpException {
+    @Test
+    public void badCrcTest() {
         final String strMessage = "C06B06393006120F00BA";
         final byte[] msg = HexUtils.hexToBytes(strMessage);
-        new ModbusWriteRequestMessage(msg);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusWriteRequestMessage(msg));
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void notWriteRequestMessageTest() throws NibeHeatPumpException {
+    @Test
+    public void notWriteRequestMessageTest() {
         final String strMessage = "C06A06393006120F00BF";
         final byte[] byteMessage = HexUtils.hexToBytes(strMessage);
-        new ModbusWriteRequestMessage(byteMessage);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusWriteRequestMessage(byteMessage));
     }
 }
index 4c4f9a532d1c7e1bee48a089ea979d30f6de2d75..b409c574d81fe735ca43b04a32329794e15b5767 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 import org.openhab.core.util.HexUtils;
 
@@ -26,7 +26,7 @@ import org.openhab.core.util.HexUtils;
  */
 public class ModbusWriteResponseMessageTest {
 
-    @Before
+    @BeforeEach
     public void Before() {
     }
 
@@ -62,17 +62,17 @@ public class ModbusWriteResponseMessageTest {
         assertEquals(false, m.isSuccessfull());
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void badCrcTest() throws NibeHeatPumpException {
+    @Test
+    public void badCrcTest() {
         final String strMessage = "5C00206C01004A";
         final byte[] msg = HexUtils.hexToBytes(strMessage);
-        new ModbusWriteResponseMessage(msg);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusWriteResponseMessage(msg));
     }
 
-    @Test(expected = NibeHeatPumpException.class)
-    public void notWriteResponseMessageTest() throws NibeHeatPumpException {
+    @Test
+    public void notWriteResponseMessageTest() {
         final String strMessage = "5C00206B060102030405064A";
         final byte[] byteMessage = HexUtils.hexToBytes(strMessage);
-        new ModbusWriteResponseMessage(byteMessage);
+        assertThrows(NibeHeatPumpException.class, () -> new ModbusWriteResponseMessage(byteMessage));
     }
 }
index 62f0b4e2649c45187d623b24373dc3c4d355c578..6080e2d2397b2c7c2bcfa8dea4bb80dfed109345 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.openhab.binding.nibeheatpump.internal.protocol.NibeHeatPumpProtocolContext;
 import org.openhab.binding.nibeheatpump.internal.protocol.NibeHeatPumpProtocolDefaultContext;
 import org.openhab.core.util.HexUtils;
@@ -63,7 +64,7 @@ public class NibeHeatPumpProtocolTest {
         }
     };
 
-    @Before
+    @BeforeEach
     public void Before() {
         ackRequestCount = 0;
         nakRequestCount = 0;
@@ -74,7 +75,8 @@ public class NibeHeatPumpProtocolTest {
         mockupContext.msg().clear();
     }
 
-    @Test(timeout = 1000)
+    @Test
+    @Timeout(value = 1, unit = TimeUnit.SECONDS)
     public void test() {
         //@formatter:off
         final String strTestData =
@@ -132,24 +134,24 @@ public class NibeHeatPumpProtocolTest {
         String expect;
 
         expect = "5C001962189600E1010200000000800000000000020914340001000005B8";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(0));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(0));
 
         expect = "5C00206850449C9600489C88014C9C2D014E9CCF004D9CE0014F9C3200509C0400519C8201529C6B02569C3E00C9AF000001A8F600FDA77E02FAA90F0098A9DC27FFFF0000A0A93A04FFFF00009CA9FD19FFFF000081";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(1));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(1));
 
         expect = "5C001962189600DF01020000000080000000000002091434000100000586";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(2));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(2));
 
         expect = "5C0019600079";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(3));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(3));
 
         expect = "5C00206851449C2500489CFC004C9CF1004E9CC7014D9C0B024F9C2500509C3300519C0B01529C5C5C01569C3100C9AF000001A80C01FDA716FAFAA9070098A91B1BFFFF0000A0A9CA02FFFF00009CA99212FFFF0000BE";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(4));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(4));
 
         expect = "5C00206852449C2500489CFE004C9CF2004E9CD4014D9CFB014F9C2500509C3700519C0D01529C5C5C01569C3200C9AF000001A80C01FDA712FAFAA9070098A95C5C1BFFFF0000A0A9D102FFFF00009CA9B412FFFF00007F";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(5));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(5));
 
         expect = "5C00206850449C2600489CF6004C9CF1004E9CD6014D9C0C024F9C4500509C3F00519CF100529C0401569CD500C9AF000001A80C01FDA799FAFAA9020098A91A1BFFFF0000A0A9CA02FFFF00009CA99212FFFF0000C5";
-        Assert.assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(6));
+        assertArrayEquals(HexUtils.hexToBytes(expect), receivedMsgs.get(6));
     }
 }
index f5d26dea1de55999e8f5a26c950049d5ea9c7fbf..28dfc2cca717cd902670c364d9fde052ee748ebe 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.models;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Pauli Anttila - Initial contribution
  */
 public class PumpModelTest {
 
-    @Before
+    @BeforeEach
     public void Before() {
     }
 
@@ -54,8 +54,8 @@ public class PumpModelTest {
         assertEquals(PumpModel.F470, pumpModel);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void badPumpModelTest() {
-        PumpModel.getPumpModel("XXXX");
+        assertThrows(IllegalArgumentException.class, () -> PumpModel.getPumpModel("XXXX"));
     }
 }
index e5cf957ee3c06042c366df7b0e4646db01563ba9..bc092edb2154bd1c96e5fecc43a06927d56970f7 100644 (file)
  */
 package org.openhab.binding.nibeheatpump.internal.models;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Pauli Anttila - Initial contribution
  */
 public class VariableInformationTest {
 
-    @Before
+    @BeforeEach
     public void Before() {
     }
 
index 7adc85ae7c6b09d05732961a7c9302cee7ae0a91..276124fd5d31565c13860c1622d67388786e2efa 100644 (file)
  */
 package org.openhab.binding.omnikinverter.internal.test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.omnikinverter.internal.OmnikInverterMessage;
 
 /**
@@ -29,7 +29,7 @@ public class OmnikInverterMessageTest {
 
     private OmnikInverterMessage message;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         File file = new File("src/test/resources/omnik.output");
         message = new OmnikInverterMessage(Files.readAllBytes(file.toPath()));
index 4757407ce23e98d30b5462542b3469580141ded9..b61ea851fd0ca80c546307d22e7b2ecb7c17b55e 100644 (file)
  */
 package org.openhab.binding.onewire;
 
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.onewire.internal.OwBindingConstants;
 import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.device.OwSensorType;
-import org.openhab.binding.onewire.internal.handler.*;
+import org.openhab.binding.onewire.internal.handler.AdvancedMultisensorThingHandler;
+import org.openhab.binding.onewire.internal.handler.BAE091xSensorThingHandler;
+import org.openhab.binding.onewire.internal.handler.BasicMultisensorThingHandler;
+import org.openhab.binding.onewire.internal.handler.BasicThingHandler;
+import org.openhab.binding.onewire.internal.handler.EDSSensorThingHandler;
 
 /**
  * Tests cases for binding completeness
@@ -48,7 +57,7 @@ public class CompletenessTest {
         for (OwSensorType sensorType : EnumSet.allOf(OwSensorType.class)) {
             if (!OwBindingConstants.THING_TYPE_MAP.containsKey(sensorType)
                     && !IGNORED_SENSOR_TYPES.contains(sensorType)) {
-                Assert.fail("missing thing type map for sensor type " + sensorType.name());
+                fail("missing thing type map for sensor type " + sensorType.name());
             }
         }
     }
@@ -58,7 +67,7 @@ public class CompletenessTest {
         for (OwSensorType sensorType : EnumSet.allOf(OwSensorType.class)) {
             if (!OwBindingConstants.SENSOR_TYPE_CHANNEL_MAP.containsKey(sensorType)
                     && !IGNORED_SENSOR_TYPES.contains(sensorType)) {
-                Assert.fail("missing channel configuration map for sensor type " + sensorType.name());
+                fail("missing channel configuration map for sensor type " + sensorType.name());
             }
         }
     }
@@ -67,7 +76,7 @@ public class CompletenessTest {
     public void allSensorsSupportedByThingHandlers() {
         for (OwSensorType sensorType : EnumSet.allOf(OwSensorType.class)) {
             if (!THINGHANDLER_SENSOR_TYPES.contains(sensorType) && !IGNORED_SENSOR_TYPES.contains(sensorType)) {
-                Assert.fail("missing thing handler for sensor type " + sensorType.name());
+                fail("missing thing handler for sensor type " + sensorType.name());
             }
         }
     }
@@ -77,7 +86,7 @@ public class CompletenessTest {
         for (OwSensorType sensorType : EnumSet.allOf(OwSensorType.class)) {
             if (!OwBindingConstants.THING_LABEL_MAP.containsKey(sensorType)
                     && !IGNORED_SENSOR_TYPES.contains(sensorType)) {
-                Assert.fail("missing label for sensor type " + sensorType.name());
+                fail("missing label for sensor type " + sensorType.name());
             }
         }
     }
@@ -90,14 +99,14 @@ public class CompletenessTest {
                     try {
                         return (String) f.get(null);
                     } catch (IllegalAccessException e) {
-                        Assert.fail("unexpected");
+                        fail("unexpected");
                         return null;
                     }
                 }).collect(Collectors.toList());
 
         for (String channel : channels) {
             if (!OwBindingConstants.ACCEPTED_ITEM_TYPES_MAP.containsKey(channel)) {
-                Assert.fail("missing accepted item type for channel " + channel);
+                fail("missing accepted item type for channel " + channel);
             }
         }
     }
index 9dfe7de596c57291e0ce1db80c813dcf818425d8..fd461009608cd0706c00e361c7612b45f37a7a31 100644 (file)
  */
 package org.openhab.binding.onewire;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.onewire.internal.SensorId;
 import org.openhab.binding.onewire.internal.owserver.OwserverDeviceParameter;
 
index 50fc6eb425516689f6a87813f1a1e3f894a60895..c8d7dafa77303ba47886bf9fba329d75c23a5793 100644 (file)
  */
 package org.openhab.binding.onewire;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.onewire.internal.SensorId;
 
 /**
index 12b3f9a222307a86d935d4d3c301a1772b8cdfa7..89ffbf157663f9e723e9be5707e3e15f0a55546c 100644 (file)
  */
 package org.openhab.binding.onewire;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import javax.measure.quantity.Dimensionless;
 import javax.measure.quantity.Temperature;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.onewire.internal.Util;
 import org.openhab.core.library.dimension.Density;
 import org.openhab.core.library.types.QuantityType;
index 0ae358f465802ac4fa05886af559eacf792f3d16..6e8dbdb8e5869ff29a826343783a65204686a224 100644 (file)
  */
 package org.openhab.binding.onewire.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
@@ -42,7 +44,7 @@ import org.openhab.core.types.State;
  */
 @NonNullByDefault
 public class BAE0910Test extends DeviceTestParent<BAE0910> {
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BAE091X, BAE0910.class);
     }
@@ -50,54 +52,49 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
     // pin 1: counter
 
     @Test
-    public void counter() {
+    public void counter() throws OwException {
         addChannel(CHANNEL_COUNTER, "Number");
         final BAE0910 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(
-                    mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter("/counter"))))
-                    .thenReturn(new DecimalType(34567));
-
-            testDevice.enableChannel(CHANNEL_COUNTER);
-            testDevice.configureChannels(mockBridgeHandler);
-
-            // refresh
-            ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
-            testDevice.refresh(mockBridgeHandler, true);
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter("/counter")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_COUNTER), stateArgumentCaptor.capture());
-            assertEquals(new DecimalType(34567), stateArgumentCaptor.getValue());
-
-            // write
-            assertFalse(testDevice.writeChannel(mockBridgeHandler, CHANNEL_COUNTER, new DecimalType(12345)));
-
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter("/counter"))))
+                .thenReturn(new DecimalType(34567));
+
+        testDevice.enableChannel(CHANNEL_COUNTER);
+        testDevice.configureChannels(mockBridgeHandler);
+
+        // refresh
+        ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
+        testDevice.refresh(mockBridgeHandler, true);
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
+                eq(new OwserverDeviceParameter("/counter")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_COUNTER), stateArgumentCaptor.capture());
+        assertEquals(new DecimalType(34567), stateArgumentCaptor.getValue());
+
+        // write
+        assertFalse(testDevice.writeChannel(mockBridgeHandler, CHANNEL_COUNTER, new DecimalType(12345)));
+
+        inOrder.verifyNoMoreInteractions();
     }
 
     // pin 2: digital2 or pwm1
 
     @Test
-    public void digitalOut2() {
+    public void digitalOut2() throws OwException {
         addChannel(CHANNEL_DIGITAL2, "Switch");
         digitalBaseChannel(CHANNEL_DIGITAL2, bitSet(3, 4), 0, "/out", bitSet(0), true);
     }
 
     @Test
-    public void pwm4() {
+    public void pwm4() throws OwException {
         pwmBaseChannel(CHANNEL_PWM_FREQ2, CHANNEL_PWM_DUTY4, "/period2", "/duty4", 2);
     }
 
     // pin 6: pio or pwm 3
 
     @Test
-    public void digital6PioIn() {
+    public void digital6PioIn() throws OwException {
         Map<String, Object> channelConfig = new HashMap<>();
         channelConfig.put("pulldevice", "pulldown");
         channelConfig.put("mode", "input");
@@ -106,7 +103,7 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
     }
 
     @Test
-    public void digital6PioOut() {
+    public void digital6PioOut() throws OwException {
         Map<String, Object> channelConfig = new HashMap<>();
         channelConfig.put("mode", "output");
         addChannel(CHANNEL_DIGITAL6, "Switch", new Configuration(channelConfig));
@@ -114,14 +111,14 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
     }
 
     @Test
-    public void pwm3() {
+    public void pwm3() throws OwException {
         pwmBaseChannel(CHANNEL_PWM_FREQ1, CHANNEL_PWM_DUTY3, "/period1", "/duty3", 1);
     }
 
     // pin 7: analog, output, pwm2
 
     @Test
-    public void analog() {
+    public void analog() throws OwException {
         Map<String, Object> channelConfig = new HashMap<>();
         channelConfig.put("hires", "true");
         addChannel(CHANNEL_VOLTAGE, "Number:ElectricPotential", new Configuration(channelConfig));
@@ -129,61 +126,56 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
         final BAE0910 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter("/adc"))))
-                    .thenReturn(new DecimalType(5.2));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter("/adc"))))
+                .thenReturn(new DecimalType(5.2));
 
-            testDevice.enableChannel(CHANNEL_VOLTAGE);
-            testDevice.configureChannels(mockBridgeHandler);
+        testDevice.enableChannel(CHANNEL_VOLTAGE);
+        testDevice.configureChannels(mockBridgeHandler);
 
-            // test configuration
-            assertEquals(bitSet(3, 4), checkConfiguration(2));
+        // test configuration
+        assertEquals(bitSet(3, 4), checkConfiguration(2));
 
-            // refresh
-            ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
-            testDevice.refresh(mockBridgeHandler, true);
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter("/adc")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_VOLTAGE), stateArgumentCaptor.capture());
-            assertEquals(new QuantityType<>("5.2 V"), stateArgumentCaptor.getValue());
+        // refresh
+        ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
+        testDevice.refresh(mockBridgeHandler, true);
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter("/adc")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_VOLTAGE), stateArgumentCaptor.capture());
+        assertEquals(new QuantityType<>("5.2 V"), stateArgumentCaptor.getValue());
 
-            // write (should fail)
-            assertFalse(testDevice.writeChannel(mockBridgeHandler, CHANNEL_VOLTAGE, new QuantityType<>("3 V")));
+        // write (should fail)
+        assertFalse(testDevice.writeChannel(mockBridgeHandler, CHANNEL_VOLTAGE, new QuantityType<>("3 V")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void digitalOut7() {
+    public void digitalOut7() throws OwException {
         addChannel(CHANNEL_DIGITAL7, "Switch");
         digitalBaseChannel(CHANNEL_DIGITAL7, bitSet(4), 4, "/tpm2c", bitSet(4, 7), true);
     }
 
     @Test
-    public void pwm2() {
+    public void pwm2() throws OwException {
         pwmBaseChannel(CHANNEL_PWM_FREQ2, CHANNEL_PWM_DUTY2, "/period2", "/duty2", 2);
     }
 
     // pin 8: digital in, digital out or pwm
 
     @Test
-    public void digitalIn8() {
+    public void digitalIn8() throws OwException {
         addChannel(CHANNEL_DIGITAL8, "Switch", new ChannelTypeUID(BINDING_ID, "bae-in"));
         digitalBaseChannel(CHANNEL_DIGITAL8, bitSet(4, 5), 3, "/tpm1c", bitSet(4, 5, 7), false);
     }
 
     @Test
-    public void digitalOut8() {
+    public void digitalOut8() throws OwException {
         addChannel(CHANNEL_DIGITAL8, "Switch");
         digitalBaseChannel(CHANNEL_DIGITAL8, bitSet(4), 3, "/tpm1c", bitSet(4, 7), true);
     }
 
     @Test
-    public void pwm1() {
+    public void pwm1() throws OwException {
         pwmBaseChannel(CHANNEL_PWM_FREQ1, CHANNEL_PWM_DUTY1, "/period1", "/duty1", 1);
     }
 
@@ -198,44 +190,39 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
      * @param isOutput if this channel is an output
      */
     private void digitalBaseChannel(String channel, BitSet configBitSet, int configRegister, String channelParam,
-            BitSet returnBitSet, boolean isOutput) {
+            BitSet returnBitSet, boolean isOutput) throws OwException {
         final BAE0910 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), eq(new OwserverDeviceParameter(channelParam))))
-                    .thenReturn(returnBitSet);
-
-            testDevice.enableChannel(channel);
-            testDevice.configureChannels(mockBridgeHandler);
-
-            // test configuration
-            assertEquals(configBitSet, checkConfiguration(configRegister));
-
-            // refresh
-            ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
-            testDevice.refresh(mockBridgeHandler, true);
-            inOrder.verify(mockBridgeHandler).readBitSet(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(channelParam)));
-            inOrder.verify(mockThingHandler).postUpdate(eq(channel), stateArgumentCaptor.capture());
-            assertEquals(OnOffType.ON, stateArgumentCaptor.getValue());
-
-            // write
-            if (isOutput) {
-                ArgumentCaptor<BitSet> bitSetArgumentCaptor = ArgumentCaptor.forClass(BitSet.class);
-                assertTrue(testDevice.writeChannel(mockBridgeHandler, channel, OnOffType.ON));
-                inOrder.verify(mockBridgeHandler).writeBitSet(eq(testSensorId),
-                        eq(new OwserverDeviceParameter(channelParam)), bitSetArgumentCaptor.capture());
-                assertEquals(returnBitSet, bitSetArgumentCaptor.getValue());
-            } else {
-                assertFalse(testDevice.writeChannel(mockBridgeHandler, channel, OnOffType.ON));
-            }
-
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), eq(new OwserverDeviceParameter(channelParam))))
+                .thenReturn(returnBitSet);
+
+        testDevice.enableChannel(channel);
+        testDevice.configureChannels(mockBridgeHandler);
+
+        // test configuration
+        assertEquals(configBitSet, checkConfiguration(configRegister));
+
+        // refresh
+        ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
+        testDevice.refresh(mockBridgeHandler, true);
+        inOrder.verify(mockBridgeHandler).readBitSet(eq(testSensorId), eq(new OwserverDeviceParameter(channelParam)));
+        inOrder.verify(mockThingHandler).postUpdate(eq(channel), stateArgumentCaptor.capture());
+        assertEquals(OnOffType.ON, stateArgumentCaptor.getValue());
+
+        // write
+        if (isOutput) {
+            ArgumentCaptor<BitSet> bitSetArgumentCaptor = ArgumentCaptor.forClass(BitSet.class);
+            assertTrue(testDevice.writeChannel(mockBridgeHandler, channel, OnOffType.ON));
+            inOrder.verify(mockBridgeHandler).writeBitSet(eq(testSensorId),
+                    eq(new OwserverDeviceParameter(channelParam)), bitSetArgumentCaptor.capture());
+            assertEquals(returnBitSet, bitSetArgumentCaptor.getValue());
+        } else {
+            assertFalse(testDevice.writeChannel(mockBridgeHandler, channel, OnOffType.ON));
         }
+
+        inOrder.verifyNoMoreInteractions();
     }
 
     /**
@@ -248,7 +235,7 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
      * @param registerIndex index for TPM configuration register
      */
     private void pwmBaseChannel(String freqChannel, String dutyChannel, String freqParam, String dutyParam,
-            int registerIndex) {
+            int registerIndex) throws OwException {
         Map<String, Object> channelConfig = new HashMap<>();
         channelConfig.put("prescaler", 5);
         addChannel(freqChannel, "Number:Frequency", new Configuration(channelConfig));
@@ -257,51 +244,42 @@ public class BAE0910Test extends DeviceTestParent<BAE0910> {
         final BAE0910 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(
-                    mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(freqParam))))
-                    .thenReturn(new DecimalType(32768));
-            Mockito.when(
-                    mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(dutyParam))))
-                    .thenReturn(new DecimalType(16384));
-
-            testDevice.enableChannel(freqChannel);
-            testDevice.enableChannel(dutyChannel);
-            testDevice.configureChannels(mockBridgeHandler);
-
-            // test configuration
-            assertEquals(bitSet(0, 2), checkConfiguration(registerIndex + 2));
-
-            // refresh
-            ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
-            testDevice.refresh(mockBridgeHandler, true);
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(freqParam)));
-            inOrder.verify(mockThingHandler).postUpdate(eq(freqChannel), stateArgumentCaptor.capture());
-            assertEquals(new QuantityType<>("15.2587890625 Hz"), stateArgumentCaptor.getValue());
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(dutyParam)));
-            inOrder.verify(mockThingHandler).postUpdate(eq(dutyChannel), stateArgumentCaptor.capture());
-            assertEquals(new QuantityType<>("50 %"), stateArgumentCaptor.getValue());
-
-            // write
-            ArgumentCaptor<DecimalType> decimalTypeArgumentCaptor = ArgumentCaptor.forClass(DecimalType.class);
-            assertTrue(testDevice.writeChannel(mockBridgeHandler, freqChannel, new QuantityType<>("50000 Hz")));
-            inOrder.verify(mockBridgeHandler).writeDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(freqParam)), decimalTypeArgumentCaptor.capture());
-            assertEquals(new DecimalType(10), decimalTypeArgumentCaptor.getValue());
-            testDevice.writeChannel(mockBridgeHandler, dutyChannel, new QuantityType<>("25 %"));
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(freqParam)));
-            inOrder.verify(mockBridgeHandler).writeDecimalType(eq(testSensorId),
-                    eq(new OwserverDeviceParameter(dutyParam)), decimalTypeArgumentCaptor.capture());
-            assertEquals(new DecimalType(8192), decimalTypeArgumentCaptor.getValue());
-
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(freqParam))))
+                .thenReturn(new DecimalType(32768));
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(dutyParam))))
+                .thenReturn(new DecimalType(16384));
+
+        testDevice.enableChannel(freqChannel);
+        testDevice.enableChannel(dutyChannel);
+        testDevice.configureChannels(mockBridgeHandler);
+
+        // test configuration
+        assertEquals(bitSet(0, 2), checkConfiguration(registerIndex + 2));
+
+        // refresh
+        ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
+        testDevice.refresh(mockBridgeHandler, true);
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(freqParam)));
+        inOrder.verify(mockThingHandler).postUpdate(eq(freqChannel), stateArgumentCaptor.capture());
+        assertEquals(new QuantityType<>("15.2587890625 Hz"), stateArgumentCaptor.getValue());
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(dutyParam)));
+        inOrder.verify(mockThingHandler).postUpdate(eq(dutyChannel), stateArgumentCaptor.capture());
+        assertEquals(new QuantityType<>("50 %"), stateArgumentCaptor.getValue());
+
+        // write
+        ArgumentCaptor<DecimalType> decimalTypeArgumentCaptor = ArgumentCaptor.forClass(DecimalType.class);
+        assertTrue(testDevice.writeChannel(mockBridgeHandler, freqChannel, new QuantityType<>("50000 Hz")));
+        inOrder.verify(mockBridgeHandler).writeDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(freqParam)),
+                decimalTypeArgumentCaptor.capture());
+        assertEquals(new DecimalType(10), decimalTypeArgumentCaptor.getValue());
+        testDevice.writeChannel(mockBridgeHandler, dutyChannel, new QuantityType<>("25 %"));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(freqParam)));
+        inOrder.verify(mockBridgeHandler).writeDecimalType(eq(testSensorId), eq(new OwserverDeviceParameter(dutyParam)),
+                decimalTypeArgumentCaptor.capture());
+        assertEquals(new DecimalType(8192), decimalTypeArgumentCaptor.getValue());
+
+        inOrder.verifyNoMoreInteractions();
     }
 
     /**
index 289f1a6308a882d4bb3e747a66aed35981ca201c..85f209b65c340c7fd65b8884e4a467b7909472fb 100644 (file)
@@ -12,8 +12,7 @@
  */
 package org.openhab.binding.onewire.device;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
@@ -21,9 +20,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -41,7 +39,7 @@ import org.openhab.core.library.types.QuantityType;
 @NonNullByDefault
 public class DS18x20Test extends DeviceTestParent<DS18x20> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS18x20.class);
 
@@ -51,42 +49,34 @@ public class DS18x20Test extends DeviceTestParent<DS18x20> {
     }
 
     @Test
-    public void temperatureTest() {
+    public void temperatureTest() throws OwException {
         final DS18x20 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(15.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(15.0));
 
-            testDevice.enableChannel(CHANNEL_TEMPERATURE);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_TEMPERATURE);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(1)).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("15.0 Â°C")));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verify(mockBridgeHandler, times(1)).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("15.0 Â°C")));
     }
 
     @Test
-    public void temperatureIgnorePORTest() {
+    public void temperatureIgnorePORTest() throws OwException {
         final DS18x20 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(85.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(85.0));
 
-            testDevice.enableChannel(CHANNEL_TEMPERATURE);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_TEMPERATURE);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(1)).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler, times(0)).postUpdate(eq(CHANNEL_TEMPERATURE), any());
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verify(mockBridgeHandler, times(1)).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler, times(0)).postUpdate(eq(CHANNEL_TEMPERATURE), any());
     }
 }
index 12b51081ff75d58531d780cb5b587c4d04f40a92..ad72b5e0a421f854248fcd5e1061fff33c861067 100644 (file)
@@ -17,9 +17,8 @@ import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -36,7 +35,7 @@ import org.openhab.core.library.types.QuantityType;
  */
 @NonNullByDefault
 public class DS1923Test extends DeviceTestParent<DS1923> {
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_MS_TX, DS1923.class);
 
@@ -47,52 +46,44 @@ public class DS1923Test extends DeviceTestParent<DS1923> {
     }
 
     @Test
-    public void temperatureChannel() {
+    public void temperatureChannel() throws OwException {
         final DS1923 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
 
-            testDevice.enableChannel(CHANNEL_TEMPERATURE);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_TEMPERATURE);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void humidityChannel() {
+    public void humidityChannel() throws OwException {
         final DS1923 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
 
-            testDevice.enableChannel(CHANNEL_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_DEWPOINT);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_DEWPOINT);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
-                    eq(new QuantityType<>("0.9381970824113001000 g/m³")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
-                    eq(new QuantityType<>("-20.31395053870025 Â°C")));
+        inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
+                eq(new QuantityType<>("0.9381970824113001000 g/m³")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
+                eq(new QuantityType<>("-20.31395053870025 Â°C")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 }
index e0d2733c35c7eadfa51e3c7db599050065ff543b..82e6cfd18d02a66c25d049bb1a5ce1337282de75 100644 (file)
@@ -15,8 +15,9 @@ package org.openhab.binding.onewire.device;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.THING_TYPE_BASIC;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.device.DS2401;
 import org.openhab.core.library.types.OnOffType;
 
@@ -28,18 +29,18 @@ import org.openhab.core.library.types.OnOffType;
 @NonNullByDefault
 public class DS2401Test extends DeviceTestParent<DS2401> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS2401.class);
     }
 
     @Test
-    public void presenceTestOn() {
+    public void presenceTestOn() throws OwException {
         presenceTest(OnOffType.ON);
     }
 
     @Test
-    public void presenceTestOff() {
+    public void presenceTestOff() throws OwException {
         presenceTest(OnOffType.OFF);
     }
 }
index 09b194859c6b7f1539ff7db659237c3782e55620..b6bd2a2b0bcafbef0ca108e09ec19acb2d82b132 100644 (file)
@@ -19,9 +19,8 @@ import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 import java.util.BitSet;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -36,7 +35,7 @@ import org.openhab.core.library.types.OnOffType;
 @NonNullByDefault
 public class DS2405Test extends DeviceTestParent<DS2405> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS2405.class);
 
@@ -44,12 +43,12 @@ public class DS2405Test extends DeviceTestParent<DS2405> {
     }
 
     @Test
-    public void digitalChannel() {
+    public void digitalChannel() throws OwException {
         digitalChannelTest(OnOffType.ON, 0);
         digitalChannelTest(OnOffType.OFF, 0);
     }
 
-    private void digitalChannelTest(OnOffType state, int channelNo) {
+    private void digitalChannelTest(OnOffType state, int channelNo) throws OwException {
         final DS2405 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
@@ -58,18 +57,14 @@ public class DS2405Test extends DeviceTestParent<DS2405> {
             returnValue.flip(0, 7);
         }
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
 
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
     }
 
     private String channelName(int channelNo) {
index 03b24c148261adf9b34af00d74c8e688735b60cc..a63e947d50a474e29f39a01541f8f672b48f20e2 100644 (file)
@@ -19,9 +19,8 @@ import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 import java.util.BitSet;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -36,7 +35,7 @@ import org.openhab.core.library.types.OnOffType;
 @NonNullByDefault
 public class DS2406_DS2413Test extends DeviceTestParent<DS2406_DS2413> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS2406_DS2413.class);
 
@@ -46,14 +45,14 @@ public class DS2406_DS2413Test extends DeviceTestParent<DS2406_DS2413> {
     }
 
     @Test
-    public void digitalChannel() {
+    public void digitalChannel() throws OwException {
         for (int i = 0; i < 2; i++) {
             digitalChannelTest(OnOffType.ON, i);
             digitalChannelTest(OnOffType.OFF, i);
         }
     }
 
-    private void digitalChannelTest(OnOffType state, int channelNo) {
+    private void digitalChannelTest(OnOffType state, int channelNo) throws OwException {
         final DS2406_DS2413 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
@@ -62,18 +61,14 @@ public class DS2406_DS2413Test extends DeviceTestParent<DS2406_DS2413> {
             returnValue.flip(0, 7);
         }
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
 
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
     }
 
     private String channelName(int channelNo) {
index 12f4f0e1b4b7be232040afa7886837a4d5bffe03..10be7fb96d09702bba6a57dc7d6a389b93d38d94 100644 (file)
@@ -19,9 +19,8 @@ import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 import java.util.BitSet;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -36,7 +35,7 @@ import org.openhab.core.library.types.OnOffType;
 @NonNullByDefault
 public class DS2408Test extends DeviceTestParent<DS2408> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS2408.class);
 
@@ -46,14 +45,14 @@ public class DS2408Test extends DeviceTestParent<DS2408> {
     }
 
     @Test
-    public void digitalChannel() {
+    public void digitalChannel() throws OwException {
         for (int i = 0; i < 8; i++) {
             digitalChannelTest(OnOffType.ON, i);
             digitalChannelTest(OnOffType.OFF, i);
         }
     }
 
-    private void digitalChannelTest(OnOffType state, int channelNo) {
+    private void digitalChannelTest(OnOffType state, int channelNo) throws OwException {
         final DS2408 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
@@ -62,18 +61,14 @@ public class DS2408Test extends DeviceTestParent<DS2408> {
             returnValue.flip(0, 8);
         }
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readBitSet(eq(testSensorId), any())).thenReturn(returnValue);
 
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verify(mockBridgeHandler, times(2)).readBitSet(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(channelName(channelNo)), eq(state));
     }
 
     private String channelName(int channelNo) {
index 9e3d3ce0812a400a56367b54de0e21c93bdfb341..36446fa3cb115ce6c43d030218e3012ca60b67d1 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.onewire.device;
 
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
@@ -20,9 +21,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -39,7 +39,7 @@ import org.openhab.core.types.State;
 @NonNullByDefault
 public class DS2423Test extends DeviceTestParent<DS2423> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_BASIC, DS2423.class);
 
@@ -68,7 +68,7 @@ public class DS2423Test extends DeviceTestParent<DS2423> {
             inOrder.verify(mockThingHandler).postUpdate(eq(channelName(0)), eq(returnValue.get(0)));
             inOrder.verify(mockThingHandler).postUpdate(eq(channelName(1)), eq(returnValue.get(1)));
         } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
+            fail("caught unexpected OwException");
         }
     }
 
index 90b75a2b3a8ff6f7ef03f5104008921cf069dc5c..0109dc90a7342e729cece467ba1ddce1b964e085 100644 (file)
@@ -17,9 +17,8 @@ import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -37,7 +36,7 @@ import org.openhab.core.library.types.QuantityType;
 @NonNullByDefault
 public class DS2438Test extends DeviceTestParent<DS2438> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_MS_TX, DS2438.class);
 
@@ -52,173 +51,145 @@ public class DS2438Test extends DeviceTestParent<DS2438> {
     }
 
     @Test
-    public void temperatureChannel() {
+    public void temperatureChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
 
-            testDevice.enableChannel(CHANNEL_TEMPERATURE);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_TEMPERATURE);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void humidityChannel() {
+    public void humidityChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
-
-            testDevice.enableChannel(CHANNEL_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_DEWPOINT);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
-
-            inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
-                    eq(new QuantityType<>("0.9381970824113001000 g/m³")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
-                    eq(new QuantityType<>("-20.31395053870025 Â°C")));
-
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+
+        testDevice.enableChannel(CHANNEL_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_DEWPOINT);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
+
+        inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
+                eq(new QuantityType<>("0.9381970824113001000 g/m³")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
+                eq(new QuantityType<>("-20.31395053870025 Â°C")));
+
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void voltageChannel() {
+    public void voltageChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.enableChannel(CHANNEL_VOLTAGE);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_VOLTAGE);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_VOLTAGE), eq(new QuantityType<>("2.0 V")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_VOLTAGE), eq(new QuantityType<>("2.0 V")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void currentChannel() {
+    public void currentChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
 
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.enableChannel(CHANNEL_CURRENT);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_CURRENT);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_CURRENT), eq(new QuantityType<>("2.0 mA")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_CURRENT), eq(new QuantityType<>("2.0 mA")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void lightChannel() {
+    public void lightChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(0.1));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(0.1));
 
-            testDevice.enableChannel(CHANNEL_LIGHT);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.setLightSensorType(LightSensorType.ELABNET_V1);
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_LIGHT);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.setLightSensorType(LightSensorType.ELABNET_V1);
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("97442 lx")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("97442 lx")));
 
-            testDevice.setLightSensorType(LightSensorType.ELABNET_V2);
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.setLightSensorType(LightSensorType.ELABNET_V2);
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("134 lx")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("134 lx")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void supplyVoltageChannel() {
+    public void supplyVoltageChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.enableChannel(CHANNEL_SUPPLYVOLTAGE);
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_SUPPLYVOLTAGE);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_SUPPLYVOLTAGE), eq(new QuantityType<>("2.0 V")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_SUPPLYVOLTAGE), eq(new QuantityType<>("2.0 V")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void noChannel() {
+    public void noChannel() throws OwException {
         final DS2438 testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.configureChannels();
-            inOrder.verify(mockThingHandler).getThing();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.configureChannels();
+        inOrder.verify(mockThingHandler).getThing();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 }
index e682c5c2411f1552a1db26b02b7e33c270e3add4..19c8c0cb6e5ca4d437115e737dfb30b2c8fa6c7c 100644 (file)
@@ -12,8 +12,8 @@
  */
 package org.openhab.binding.onewire.device;
 
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.CHANNEL_PRESENT;
 
 import java.lang.reflect.Constructor;
@@ -21,10 +21,13 @@ import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.SensorId;
 import org.openhab.binding.onewire.internal.device.AbstractOwDevice;
@@ -33,7 +36,11 @@ import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
 import org.openhab.binding.onewire.internal.handler.OwserverBridgeHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.thing.*;
+import org.openhab.core.thing.Channel;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
 import org.openhab.core.thing.type.ChannelTypeUID;
 
@@ -42,27 +49,20 @@ import org.openhab.core.thing.type.ChannelTypeUID;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public abstract class DeviceTestParent<T extends AbstractOwDevice> {
     private @Nullable Class<T> deviceTestClazz;
 
-    @Mock
-    @NonNullByDefault({})
-    protected OwBaseThingHandler mockThingHandler;
-
-    @Mock
-    @NonNullByDefault({})
-    protected OwserverBridgeHandler mockBridgeHandler;
-
-    @Mock
-    @NonNullByDefault({})
-    protected Thing mockThing;
+    protected @Mock @NonNullByDefault({}) OwBaseThingHandler mockThingHandler;
+    protected @Mock @NonNullByDefault({}) OwserverBridgeHandler mockBridgeHandler;
+    protected @Mock @NonNullByDefault({}) Thing mockThing;
 
     protected SensorId testSensorId = new SensorId("00.000000000000");
 
     public void setupMocks(ThingTypeUID thingTypeUID, Class<T> deviceTestClazz) {
         this.deviceTestClazz = deviceTestClazz;
-        initMocks(this);
 
         Mockito.when(mockThingHandler.getThing()).thenReturn(mockThing);
         Mockito.when(mockThing.getUID()).thenReturn(new ThingUID(thingTypeUID, "testsensor"));
@@ -95,7 +95,7 @@ public abstract class DeviceTestParent<T extends AbstractOwDevice> {
         try {
             Constructor<T> constructor = deviceTestClazz.getConstructor(SensorId.class, OwBaseThingHandler.class);
             T testDevice = constructor.newInstance(testSensorId, mockThingHandler);
-            Assert.assertNotNull(testDevice);
+            assertNotNull(testDevice);
             return testDevice;
         } catch (NoSuchMethodException | InstantiationException | IllegalAccessException
                 | InvocationTargetException e) {
@@ -112,7 +112,7 @@ public abstract class DeviceTestParent<T extends AbstractOwDevice> {
             Constructor<T> constructor = deviceTestClazz.getConstructor(SensorId.class, OwSensorType.class,
                     OwBaseThingHandler.class);
             T testDevice = constructor.newInstance(testSensorId, sensorType, mockThingHandler);
-            Assert.assertNotNull(testDevice);
+            assertNotNull(testDevice);
             return testDevice;
         } catch (NoSuchMethodException | InstantiationException | IllegalAccessException
                 | InvocationTargetException e) {
@@ -120,16 +120,13 @@ public abstract class DeviceTestParent<T extends AbstractOwDevice> {
         }
     }
 
-    public void presenceTest(OnOffType state) {
+    public void presenceTest(OnOffType state) throws OwException {
         final T testDevice = instantiateDevice();
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(state);
-            testDevice.checkPresence(mockBridgeHandler);
 
-            inOrder.verify(mockThingHandler).updatePresenceStatus(eq(state));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(state);
+        testDevice.checkPresence(mockBridgeHandler);
+
+        inOrder.verify(mockThingHandler).updatePresenceStatus(eq(state));
     }
 }
index de213f54530cb3503f793078104c1719d5c22055..a5c69973f54ba76e22755ebd73cc1391e1903321 100644 (file)
@@ -17,9 +17,8 @@ import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.openhab.binding.onewire.internal.OwException;
@@ -37,7 +36,7 @@ import org.openhab.core.library.types.QuantityType;
 @NonNullByDefault
 public class EDS006xTest extends DeviceTestParent<EDS006x> {
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         setupMocks(THING_TYPE_EDS_ENV, EDS006x.class);
 
@@ -50,114 +49,94 @@ public class EDS006xTest extends DeviceTestParent<EDS006x> {
     }
 
     @Test
-    public void temperatureChannel() {
+    public void temperatureChannel() throws OwException {
         final EDS006x testDevice = instantiateDevice(OwSensorType.EDS0068);
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
 
-            testDevice.enableChannel(CHANNEL_TEMPERATURE);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_TEMPERATURE);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_TEMPERATURE), eq(new QuantityType<>("10.0 Â°C")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void humidityChannel() {
+    public void humidityChannel() throws OwException {
         final EDS006x testDevice = instantiateDevice(OwSensorType.EDS0068);
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
-
-            testDevice.enableChannel(CHANNEL_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
-            testDevice.enableChannel(CHANNEL_DEWPOINT);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
-
-            inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
-                    eq(new QuantityType<>("0.9381970824113001000 g/m³")));
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
-                    eq(new QuantityType<>("-20.31395053870025 Â°C")));
-
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(10.0));
+
+        testDevice.enableChannel(CHANNEL_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_ABSOLUTE_HUMIDITY);
+        testDevice.enableChannel(CHANNEL_DEWPOINT);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
+
+        inOrder.verify(mockBridgeHandler, times(2)).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_HUMIDITY), eq(new QuantityType<>("10.0 %")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_ABSOLUTE_HUMIDITY),
+                eq(new QuantityType<>("0.9381970824113001000 g/m³")));
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_DEWPOINT),
+                eq(new QuantityType<>("-20.31395053870025 Â°C")));
+
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void pressureChannel() {
+    public void pressureChannel() throws OwException {
         final EDS006x testDevice = instantiateDevice(OwSensorType.EDS0068);
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.enableChannel(CHANNEL_PRESSURE);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_PRESSURE);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_PRESSURE), eq(new QuantityType<>("2.0 mbar")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_PRESSURE), eq(new QuantityType<>("2.0 mbar")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void lightChannel() {
+    public void lightChannel() throws OwException {
         final EDS006x testDevice = instantiateDevice(OwSensorType.EDS0068);
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(100));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(100));
 
-            testDevice.enableChannel(CHANNEL_LIGHT);
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.enableChannel(CHANNEL_LIGHT);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
-            inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("100 lx")));
+        inOrder.verify(mockBridgeHandler).readDecimalType(eq(testSensorId), any());
+        inOrder.verify(mockThingHandler).postUpdate(eq(CHANNEL_LIGHT), eq(new QuantityType<>("100 lx")));
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void noChannel() {
+    public void noChannel() throws OwException {
         final EDS006x testDevice = instantiateDevice(OwSensorType.EDS0068);
         final InOrder inOrder = Mockito.inOrder(mockThingHandler, mockBridgeHandler);
 
-        try {
-            Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
-            Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
+        Mockito.when(mockBridgeHandler.checkPresence(testSensorId)).thenReturn(OnOffType.ON);
+        Mockito.when(mockBridgeHandler.readDecimalType(eq(testSensorId), any())).thenReturn(new DecimalType(2.0));
 
-            testDevice.configureChannels();
-            testDevice.refresh(mockBridgeHandler, true);
+        testDevice.configureChannels();
+        testDevice.refresh(mockBridgeHandler, true);
 
-            inOrder.verifyNoMoreInteractions();
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        inOrder.verifyNoMoreInteractions();
     }
 }
index 4edb183b6ce0256c9780b4cd352513a565e388f1..67c0b87fd4288d3e95eb1c8c4dd8de9971193ed0 100644 (file)
  */
 package org.openhab.binding.onewire.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.times;
-import static org.openhab.binding.onewire.internal.OwBindingConstants.CONFIG_ID;
-import static org.openhab.binding.onewire.internal.OwBindingConstants.THING_TYPE_BASIC;
+import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
 import org.openhab.binding.onewire.internal.device.OwSensorType;
 import org.openhab.binding.onewire.internal.handler.BasicThingHandler;
 import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
@@ -47,15 +43,13 @@ import org.openhab.core.thing.binding.builder.ThingBuilder;
 public class BasicThingHandlerTest extends AbstractThingHandlerTest {
     private static final String TEST_ID = "00.000000000000";
 
-    @Before
+    @BeforeEach
     public void setup() throws OwException {
-        MockitoAnnotations.initMocks(this);
-
         initializeBridge();
 
         final Bridge bridge = this.bridge;
         if (bridge == null) {
-            Assert.fail("bridge is null");
+            fail("bridge is null");
             return;
         }
 
@@ -67,7 +61,7 @@ public class BasicThingHandlerTest extends AbstractThingHandlerTest {
 
         final Thing thing = this.thing;
         if (thing == null) {
-            Assert.fail("thing is null");
+            fail("thing is null");
             return;
         }
 
@@ -85,7 +79,7 @@ public class BasicThingHandlerTest extends AbstractThingHandlerTest {
     public void testInitializationEndsWithUnknown() throws OwException {
         final ThingHandler thingHandler = this.thingHandler;
         if (thingHandler == null) {
-            Assert.fail("thingHandler is null");
+            fail("thingHandler is null");
             return;
         }
 
@@ -103,7 +97,7 @@ public class BasicThingHandlerTest extends AbstractThingHandlerTest {
         final OwBaseThingHandler thingHandler = this.thingHandler;
         final InOrder inOrder = this.inOrder;
         if (thingHandler == null || inOrder == null) {
-            Assert.fail("prerequisite is null");
+            fail("prerequisite is null");
             return;
         }
 
@@ -127,7 +121,7 @@ public class BasicThingHandlerTest extends AbstractThingHandlerTest {
         final OwBaseThingHandler thingHandler = this.thingHandler;
         final InOrder inOrder = this.inOrder;
         if (thingHandler == null || inOrder == null) {
-            Assert.fail("prerequisite is null");
+            fail("prerequisite is null");
             return;
         }
 
index f35a5afdd5fdd7eaf274fd204b3b0418fd18a149..2fa0224701d18181cb490152a6b5fcdb499c0088 100644 (file)
  */
 package org.openhab.binding.onewire.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.times;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
 import org.openhab.binding.onewire.internal.handler.EDSSensorThingHandler;
 import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
 import org.openhab.binding.onewire.test.AbstractThingHandlerTest;
 import org.openhab.core.config.core.Configuration;
-import org.openhab.core.thing.*;
+import org.openhab.core.thing.Bridge;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
 import org.openhab.core.thing.binding.builder.ThingBuilder;
@@ -50,15 +51,13 @@ public class EDSSensorThingHandlerTest extends AbstractThingHandlerTest {
             CHANNEL_ABSOLUTE_HUMIDITY);
     private static final ChannelUID CHANNEL_UID_DEWPOINT = new ChannelUID(THING_UID, CHANNEL_DEWPOINT);
 
-    @Before
+    @BeforeEach
     public void setup() throws OwException {
-        MockitoAnnotations.initMocks(this);
-
         initializeBridge();
 
         final Bridge bridge = this.bridge;
         if (bridge == null) {
-            Assert.fail("bridge is null");
+            fail("bridge is null");
             return;
         }
 
@@ -75,7 +74,7 @@ public class EDSSensorThingHandlerTest extends AbstractThingHandlerTest {
 
         final Thing thing = this.thing;
         if (thing == null) {
-            Assert.fail("thing is null");
+            fail("thing is null");
             return;
         }
 
@@ -97,7 +96,7 @@ public class EDSSensorThingHandlerTest extends AbstractThingHandlerTest {
     public void testInitializationEndsWithUnknown() {
         final ThingHandler thingHandler = this.thingHandler;
         if (thingHandler == null) {
-            Assert.fail("thingHandler is null");
+            fail("thingHandler is null");
             return;
         }
 
@@ -111,7 +110,7 @@ public class EDSSensorThingHandlerTest extends AbstractThingHandlerTest {
         final OwBaseThingHandler thingHandler = this.thingHandler;
         final InOrder inOrder = this.inOrder;
         if (thingHandler == null || inOrder == null) {
-            Assert.fail("prerequisite is null");
+            fail("prerequisite is null");
             return;
         }
 
index 771492b41e21923836ba30b3b7f5ece8c61f7a19..b770b906b0a2355cdf7fdb0d2f2e2abfa89507a7 100644 (file)
  */
 package org.openhab.binding.onewire.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.times;
-import static org.openhab.binding.onewire.internal.OwBindingConstants.CONFIG_ID;
-import static org.openhab.binding.onewire.internal.OwBindingConstants.THING_TYPE_MS_TX;
+import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
 import org.openhab.binding.onewire.internal.device.OwSensorType;
 import org.openhab.binding.onewire.internal.handler.BasicMultisensorThingHandler;
 import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
@@ -47,15 +43,13 @@ import org.openhab.core.thing.binding.builder.ThingBuilder;
 public class MultisensorThingHandlerTest extends AbstractThingHandlerTest {
     private static final String TEST_ID = "00.000000000000";
 
-    @Before
+    @BeforeEach
     public void setup() throws OwException {
-        MockitoAnnotations.initMocks(this);
-
         initializeBridge();
 
         final Bridge bridge = this.bridge;
         if (bridge == null) {
-            Assert.fail("bridge is null");
+            fail("bridge is null");
             return;
         }
 
@@ -67,7 +61,7 @@ public class MultisensorThingHandlerTest extends AbstractThingHandlerTest {
 
         final Thing thing = this.thing;
         if (thing == null) {
-            Assert.fail("thing is null");
+            fail("thing is null");
             return;
         }
 
@@ -95,7 +89,7 @@ public class MultisensorThingHandlerTest extends AbstractThingHandlerTest {
     public void testInitializationEndsWithUnknown() {
         final ThingHandler thingHandler = this.thingHandler;
         if (thingHandler == null) {
-            Assert.fail("thingHandler is null");
+            fail("thingHandler is null");
             return;
         }
         thingHandler.initialize();
@@ -108,7 +102,7 @@ public class MultisensorThingHandlerTest extends AbstractThingHandlerTest {
         final OwBaseThingHandler thingHandler = this.thingHandler;
         final InOrder inOrder = this.inOrder;
         if (thingHandler == null || inOrder == null) {
-            Assert.fail("prerequisite is null");
+            fail("prerequisite is null");
             return;
         }
         thingHandler.initialize();
index f51defce96a2c710709bccb0451514545b05c489..fb4fc23c649043c639b8cb20fd12e2690ca9c79c 100644 (file)
 package org.openhab.binding.onewire.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
 
 import java.util.HashMap;
@@ -25,13 +24,14 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.onewire.internal.handler.OwserverBridgeHandler;
 import org.openhab.binding.onewire.internal.owserver.OwserverConnection;
 import org.openhab.binding.onewire.internal.owserver.OwserverConnectionState;
@@ -49,6 +49,7 @@ import org.openhab.core.thing.binding.builder.BridgeBuilder;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 @NonNullByDefault
 public class OwserverBridgeHandlerTest extends JavaTest {
 
@@ -56,24 +57,17 @@ public class OwserverBridgeHandlerTest extends JavaTest {
     private static final int TEST_PORT = 4711;
     Map<String, Object> bridgeProperties = new HashMap<>();
 
-    @Mock
-    @NonNullByDefault({})
-    private OwserverConnection owserverConnection;
-
-    @Mock
-    @NonNullByDefault({})
-    private ThingHandlerCallback thingHandlerCallback;
+    private @Mock @NonNullByDefault({}) OwserverConnection owserverConnection;
+    private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
 
     private @Nullable OwserverBridgeHandler bridgeHandler;
     private @Nullable Bridge bridge;
 
-    @Before
+    @BeforeEach
     public void setup() {
         bridgeProperties.put(CONFIG_ADDRESS, TEST_HOST);
         bridgeProperties.put(CONFIG_PORT, TEST_PORT);
 
-        initMocks(this);
-
         bridge = BridgeBuilder.create(THING_TYPE_OWSERVER, "owserver").withLabel("owserver")
                 .withConfiguration(new Configuration(bridgeProperties)).build();
 
@@ -85,7 +79,7 @@ public class OwserverBridgeHandlerTest extends JavaTest {
         final Bridge bridge = this.bridge;
 
         if (bridge == null) {
-            Assert.fail("bridge is null");
+            fail("bridge is null");
             return;
         }
 
@@ -95,7 +89,7 @@ public class OwserverBridgeHandlerTest extends JavaTest {
         this.bridgeHandler = bridgeHandler;
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         final OwserverBridgeHandler bridgeHandler = this.bridgeHandler;
         if (bridgeHandler != null) {
@@ -107,7 +101,7 @@ public class OwserverBridgeHandlerTest extends JavaTest {
     public void testInitializationStartsConnectionWithOptions() {
         final OwserverBridgeHandler bridgeHandler = this.bridgeHandler;
         if (bridgeHandler == null) {
-            Assert.fail("bridgeHandler is null");
+            fail("bridgeHandler is null");
             return;
         }
 
@@ -123,7 +117,7 @@ public class OwserverBridgeHandlerTest extends JavaTest {
     public void testInitializationReportsRefreshableOnSuccessfullConnection() {
         final OwserverBridgeHandler bridgeHandler = this.bridgeHandler;
         if (bridgeHandler == null) {
-            Assert.fail("bridgeHandler is null");
+            fail("bridgeHandler is null");
             return;
         }
 
@@ -148,7 +142,7 @@ public class OwserverBridgeHandlerTest extends JavaTest {
     public void testInitializationReportsNotRefreshableOnFailedConnection() {
         final OwserverBridgeHandler bridgeHandler = this.bridgeHandler;
         if (bridgeHandler == null) {
-            Assert.fail("bridgeHandler is null");
+            fail("bridgeHandler is null");
             return;
         }
 
index 16796e7ce2de57a43b8446e29a7e8181130829de..5c153ae08949ab3671f69da78284f99b4827768c 100644 (file)
@@ -12,9 +12,8 @@
  */
 package org.openhab.binding.onewire.owserver;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.IOException;
 import java.util.List;
@@ -22,12 +21,13 @@ import java.util.concurrent.CompletableFuture;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.OwPageBuffer;
 import org.openhab.binding.onewire.internal.SensorId;
@@ -46,6 +46,7 @@ import org.openhab.core.types.State;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 @NonNullByDefault
 public class OwserverConnectionTest extends JavaTest {
     private static final String TEST_HOST = "127.0.0.1";
@@ -53,15 +54,12 @@ public class OwserverConnectionTest extends JavaTest {
     private @Nullable OwserverTestServer testServer;
     private @Nullable OwserverConnection owserverConnection;
 
-    @Mock
-    private @NonNullByDefault({}) OwserverBridgeHandler bridgeHandler;
+    private @Mock @NonNullByDefault({}) OwserverBridgeHandler bridgeHandler;
 
     private int testPort;
 
-    @Before
+    @BeforeEach
     public void setup() throws Exception {
-        initMocks(this);
-
         CompletableFuture<Boolean> serverStarted = new CompletableFuture<>();
         testPort = TestPortUtil.findFreePort();
         try {
@@ -80,7 +78,7 @@ public class OwserverConnectionTest extends JavaTest {
         serverStarted.get(); // wait for the server thread to start
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         try {
             final OwserverTestServer testServer = this.testServer;
@@ -96,7 +94,7 @@ public class OwserverConnectionTest extends JavaTest {
     public void successfullConnectionReportedToBridgeHandler() {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
@@ -108,7 +106,7 @@ public class OwserverConnectionTest extends JavaTest {
     public void failedConnectionReportedToBridgeHandler() {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.setPort(1);
@@ -119,30 +117,27 @@ public class OwserverConnectionTest extends JavaTest {
     }
 
     @Test
-    public void testGetDirectory() {
+    public void testGetDirectory() throws OwException {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
-        try {
-            List<SensorId> directory = owserverConnection.getDirectory("/");
-
-            assertEquals(3, directory.size());
-            assertEquals(new SensorId("/00.0123456789ab"), directory.get(0));
-            assertEquals(new SensorId("/00.0123456789ac"), directory.get(1));
-            assertEquals(new SensorId("/00.0123456789ad"), directory.get(2));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+
+        List<SensorId> directory = owserverConnection.getDirectory("/");
+
+        assertEquals(3, directory.size());
+        assertEquals(new SensorId("/00.0123456789ab"), directory.get(0));
+        assertEquals(new SensorId("/00.0123456789ac"), directory.get(1));
+        assertEquals(new SensorId("/00.0123456789ad"), directory.get(2));
     }
 
     @Test
     public void testCheckPresence() {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
@@ -154,71 +149,58 @@ public class OwserverConnectionTest extends JavaTest {
     }
 
     @Test
-    public void testReadDecimalType() {
+    public void testReadDecimalType() throws OwException {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
-        try {
-            DecimalType number = (DecimalType) owserverConnection.readDecimalType("testsensor/decimal");
 
-            assertEquals(17.4, number.doubleValue(), 0.01);
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        DecimalType number = (DecimalType) owserverConnection.readDecimalType("testsensor/decimal");
+
+        assertEquals(17.4, number.doubleValue(), 0.01);
     }
 
     @Test
-    public void testReadDecimalTypeArray() {
+    public void testReadDecimalTypeArray() throws OwException {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
-        try {
-            List<State> numbers = owserverConnection.readDecimalTypeArray("testsensor/decimalarray");
 
-            assertEquals(3834, ((DecimalType) numbers.get(0)).intValue());
-            assertEquals(0, ((DecimalType) numbers.get(1)).intValue());
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        List<State> numbers = owserverConnection.readDecimalTypeArray("testsensor/decimalarray");
+
+        assertEquals(3834, ((DecimalType) numbers.get(0)).intValue());
+        assertEquals(0, ((DecimalType) numbers.get(1)).intValue());
     }
 
     @Test
-    public void testGetPages() {
+    public void testGetPages() throws OwException {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
-        try {
-            OwPageBuffer pageBuffer = owserverConnection.readPages("testsensor");
 
-            assertEquals(31, pageBuffer.getByte(5, 7));
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        OwPageBuffer pageBuffer = owserverConnection.readPages("testsensor");
+        assertEquals(31, pageBuffer.getByte(5, 7));
     }
 
     @Test
-    public void testWriteDecimalType() {
+    public void testWriteDecimalType() throws OwException {
         final OwserverConnection owserverConnection = this.owserverConnection;
         if (owserverConnection == null) {
-            Assert.fail("connection is null");
+            fail("connection is null");
             return;
         }
         owserverConnection.start();
-        try {
-            owserverConnection.writeDecimalType("testsensor/decimal", new DecimalType(2009));
 
-            Mockito.verify(bridgeHandler, never()).reportConnectionState(OwserverConnectionState.FAILED);
-        } catch (OwException e) {
-            Assert.fail("caught unexpected OwException");
-        }
+        owserverConnection.writeDecimalType("testsensor/decimal", new DecimalType(2009));
+
+        Mockito.verify(bridgeHandler, never()).reportConnectionState(OwserverConnectionState.FAILED);
     }
 }
index 59e8137d4a1d75c5957c4aaed7802d5b602b0681..f766070ffdcc6da5e01d4ac16e23bb5f122257ba 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.onewire.test;
 
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.openhab.binding.onewire.internal.OwBindingConstants.THING_TYPE_OWSERVER;
 
@@ -23,11 +24,14 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.After;
-import org.junit.Assert;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.onewire.internal.OwDynamicStateDescriptionProvider;
 import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
@@ -48,6 +52,8 @@ import org.openhab.core.thing.binding.builder.BridgeBuilder;
  *
  * @author Jan N. Klug - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public abstract class AbstractThingHandlerTest extends JavaTest {
 
@@ -56,25 +62,11 @@ public abstract class AbstractThingHandlerTest extends JavaTest {
     protected Map<String, Object> thingConfiguration = new HashMap<>();
     protected Map<String, Object> channelProperties = new HashMap<>();
 
-    @Mock
-    @NonNullByDefault({})
-    protected ThingHandlerCallback thingHandlerCallback;
-
-    @Mock
-    @NonNullByDefault({})
-    protected OwDynamicStateDescriptionProvider stateProvider;
-
-    @Mock
-    @NonNullByDefault({})
-    protected ThingHandlerCallback bridgeHandlerCallback;
-
-    @Mock
-    @NonNullByDefault({})
-    protected OwserverBridgeHandler bridgeHandler;
-
-    @Mock
-    @NonNullByDefault({})
-    protected OwserverBridgeHandler secondBridgeHandler;
+    protected @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
+    protected @Mock @NonNullByDefault({}) OwDynamicStateDescriptionProvider stateProvider;
+    protected @Mock @NonNullByDefault({}) ThingHandlerCallback bridgeHandlerCallback;
+    protected @Mock @NonNullByDefault({}) OwserverBridgeHandler bridgeHandler;
+    protected @Mock @NonNullByDefault({}) OwserverBridgeHandler secondBridgeHandler;
 
     protected List<Channel> channels = new ArrayList<>();
 
@@ -84,7 +76,7 @@ public abstract class AbstractThingHandlerTest extends JavaTest {
 
     protected @Nullable InOrder inOrder;
 
-    @After
+    @AfterEach
     public void tearDown() {
         final ThingHandler thingHandler = this.thingHandler;
         if (thingHandler != null) {
@@ -95,7 +87,7 @@ public abstract class AbstractThingHandlerTest extends JavaTest {
     protected void initializeHandlerMocks() {
         final ThingHandler thingHandler = this.thingHandler;
         if (thingHandler == null) {
-            Assert.fail("thingHandler is null");
+            fail("thingHandler is null");
             return;
         }
 
@@ -131,7 +123,7 @@ public abstract class AbstractThingHandlerTest extends JavaTest {
         Mockito.doAnswer(answer -> {
             final OwBaseThingHandler thingHandler = this.thingHandler;
             if (thingHandler == null) {
-                Assert.fail("thingHandler is null");
+                fail("thingHandler is null");
                 return null;
             }
 
index 78383cf01286921b19c488269e26d241ec44103c..bfe53444d7d9550a418d7f4cfe0720164153593e 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.onewire.test;
 
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -22,7 +24,6 @@ import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
 import org.openhab.binding.onewire.internal.OwException;
 import org.openhab.binding.onewire.internal.OwPageBuffer;
 import org.openhab.binding.onewire.internal.owserver.OwserverPacket;
@@ -78,7 +79,7 @@ public class OwserverTestServer {
                 } catch (IOException e) {
                     logger.error("I/O Error: {}", e.getMessage());
                 } catch (OwException e) {
-                    Assert.fail("caught unexpected OwException");
+                    fail("caught unexpected OwException");
                 }
             }
         }.start();
index 63a952dfa9f81b944846ad01d48e7d3be9e3de72..0e2c395021c38e53336efb9516fa0b99a6b25068 100644 (file)
@@ -12,8 +12,9 @@
  */
 package tests;
 
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.CommandPayload;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.PartitionCommand;
 import org.openhab.binding.paradoxalarm.internal.util.ParadoxUtil;
@@ -41,9 +42,9 @@ public class TestCreateCommandPayload {
         int payloadIndexOfByteToCheck = 6 + (partitionNumber - 1) / 2;
         byte byteValue = bytes[payloadIndexOfByteToCheck];
         if ((partitionNumber - 1) % 2 == 0) {
-            Assert.assertTrue(ParadoxUtil.getHighNibble(byteValue) == command.getCommand());
+            assertTrue(ParadoxUtil.getHighNibble(byteValue) == command.getCommand());
         } else {
-            Assert.assertTrue(ParadoxUtil.getLowNibble(byteValue) == command.getCommand());
+            assertTrue(ParadoxUtil.getLowNibble(byteValue) == command.getCommand());
         }
     }
 }
index 9d9254c6ade57c868495b76074274f10b738610d..5460b2ff4e0fcfaac6e8d7957397fd9296494553 100644 (file)
  */
 package tests;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Arrays;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.paradoxalarm.internal.communication.crypto.EncryptionHandler;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.HeaderCommand;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.ParadoxIPPacket;
@@ -70,6 +69,6 @@ public class TestEncryptionHandler {
         ParadoxUtil.printByteArray("Expected=", ENCRYPTED_EXPECTED2);
         ParadoxUtil.printByteArray("Packet=  ", packetBytes);
 
-        Assert.assertTrue(Arrays.equals(packetBytes, ENCRYPTED_EXPECTED2));
+        assertTrue(Arrays.equals(packetBytes, ENCRYPTED_EXPECTED2));
     }
 }
index 1d4d80a45661fb7862aeae6be092782ebac75a26..a44159e914285d4f088f16584e7e750e660a2d02 100644 (file)
  */
 package tests;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import java.util.Arrays;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.CommandPayload;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.EpromRequestPayload;
 import org.openhab.binding.paradoxalarm.internal.communication.messages.HeaderCommand;
@@ -57,7 +58,7 @@ public class TestGetBytes {
         ParadoxUtil.printByteArray("Expected =", EXPECTED1);
         ParadoxUtil.printByteArray("Packet   =", packetBytes);
 
-        Assert.assertTrue(Arrays.equals(packetBytes, EXPECTED1));
+        assertTrue(Arrays.equals(packetBytes, EXPECTED1));
     }
 
     private static final byte[] EXPECTED_COMMAND_PAYLOAD = { 0x40, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
@@ -71,7 +72,7 @@ public class TestGetBytes {
         ParadoxUtil.printByteArray("Expected =", EXPECTED_COMMAND_PAYLOAD);
         ParadoxUtil.printByteArray("Result   =", packetBytes);
 
-        Assert.assertTrue(Arrays.equals(packetBytes, EXPECTED_COMMAND_PAYLOAD));
+        assertTrue(Arrays.equals(packetBytes, EXPECTED_COMMAND_PAYLOAD));
     }
 
     private static final byte[] EXPECTED_MEMORY_PAYLOAD = { (byte) 0xAA, 0x0A, 0x00, 0x03, 0x08, (byte) 0xF0, 0x00,
index 0d77064447517c6ed2c1852a0f58a5753028deb3..623dcb83c228148dac94eabc7aee3e65cb0ec720 100644 (file)
@@ -12,8 +12,9 @@
  */
 package tests;
 
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.paradoxalarm.internal.util.ParadoxUtil;
 
 /**
@@ -31,7 +32,7 @@ public class TestParadoxUtil {
 
         final byte[] EXPECTED_RESULT = { 0x0A, 0x50, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x59, (byte) 0xEE, (byte) 0xEE,
                 (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE };
-        Assert.assertArrayEquals(EXPECTED_RESULT, extendedArray); //
+        assertArrayEquals(EXPECTED_RESULT, extendedArray); //
     }
 
     @Test
@@ -42,6 +43,6 @@ public class TestParadoxUtil {
         byte[] mergedArrays = ParadoxUtil.mergeByteArrays(ARR1, ARR2, ARR3);
 
         final byte[] EXPECTED_RESULT = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
-        Assert.assertArrayEquals(EXPECTED_RESULT, mergedArrays);
+        assertArrayEquals(EXPECTED_RESULT, mergedArrays);
     }
 }
index 0bc7c7e3ef05b0c88caf64944a8944e0cfc41ec4..f0aa6ce79fc34674988bf48a0f369d22bf173703 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBBQTemperatureMessage.SubType.BBQ1;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,16 +32,16 @@ public class RFXComBBQTemperatureMessageTest {
         String hexMessage = "0A4E012B2955001A002179";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComBBQTemperatureMessage msg = (RFXComBBQTemperatureMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", BBQ1, msg.subType);
-        assertEquals("Seq Number", 43, msg.seqNbr);
-        assertEquals("Sensor Id", "10581", msg.getDeviceId());
-        assertEquals("Food Temperature", 26, msg.foodTemperature, 0.1);
-        assertEquals("BBQ Temperature", 33, msg.bbqTemperature, 0.1);
-        assertEquals("Signal Level", 7, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(BBQ1, msg.subType, "SubType");
+        assertEquals(43, msg.seqNbr, "Seq Number");
+        assertEquals("10581", msg.getDeviceId(), "Sensor Id");
+        assertEquals(26, msg.foodTemperature, 0.1, "Food Temperature");
+        assertEquals(33, msg.bbqTemperature, 0.1, "BBQ Temperature");
+        assertEquals(7, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 38e02f47b228663ae5a846bc04b527cddef72b84..0bd02c87378e622e0d1211bc035b1aa5849a969c 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -24,8 +26,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
  */
 @NonNullByDefault
 public class RFXComBarometricMessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.BAROMETRIC);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.BAROMETRIC));
     }
 }
index 697588297244b7ee03dc886df9236ad6eb2a0245..692f4629bec649a178ae663c8d8a23be1be302b9 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBlinds1Message.Commands;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBlinds1Message.SubType;
@@ -32,15 +32,15 @@ public class RFXComBlinds1MessageTest {
             RFXComBlinds1Message.Commands command) throws RFXComException {
         final RFXComBlinds1Message msg = (RFXComBlinds1Message) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Command", command, msg.command);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(command, msg.command, "Command");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index ae521a5c01b1da72c340f31c982b13f5e654ae7f..dbcd82977a6e2d13ca29958911fce3bc62ce34c8 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -24,9 +26,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
  */
 @NonNullByDefault
 public class RFXComCamera1MessageTest {
-
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.CAMERA1);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.CAMERA1));
     }
 }
index 36dd7e34b3f526faffabae5f5d336ae05cb0a128..b59b4fea448fbcf1d1b7c67ed6b9c90a06589aac 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComChimeMessage.SubType;
 import org.openhab.core.util.HexUtils;
@@ -34,13 +34,13 @@ public class RFXComChimeMessageTest {
         String hexMessage = "0716020900A1F350";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComChimeMessage msg = (RFXComChimeMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", SubType.SELECTPLUS, msg.subType);
-        assertEquals("Seq Number", 9, msg.seqNbr);
-        assertEquals("Sensor Id", "41459", msg.getDeviceId());
-        assertEquals("Signal Level", 5, msg.signalLevel);
+        assertEquals(SubType.SELECTPLUS, msg.subType, "SubType");
+        assertEquals(9, msg.seqNbr, "Seq Number");
+        assertEquals("41459", msg.getDeviceId(), "Sensor Id");
+        assertEquals(5, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 504c0acab1ed8e572d1f096f57c919be9daba0af..6969789a577d264132bef9a4a11814238941b151 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -31,20 +31,20 @@ public class RFXComCurrentEnergyMessageTest {
             int batteryLevel) throws RFXComException {
         final RFXComCurrentEnergyMessage msg = (RFXComCurrentEnergyMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Count", count, msg.count);
-        assertEquals("Channel 1", channel1, msg.channel1Amps, 0.01);
-        assertEquals("Channel 2", channel2, msg.channel2Amps, 0.01);
-        assertEquals("Channel 3", channel3, msg.channel3Amps, 0.01);
-        assertEquals("Total usage", totalUsage, msg.totalUsage, 0.05);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
-        assertEquals("Battery Level", batteryLevel, msg.batteryLevel);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(count, msg.count, "Count");
+        assertEquals(channel1, msg.channel1Amps, 0.01, "Channel 1");
+        assertEquals(channel2, msg.channel2Amps, 0.01, "Channel 2");
+        assertEquals(channel3, msg.channel3Amps, 0.01, "Channel 3");
+        assertEquals(totalUsage, msg.totalUsage, 0.05, "Total usage");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
+        assertEquals(batteryLevel, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index 2a781b44ae42419b35242d7ed782c4414263d252..2c8f2f53747f3c582054e87134c650c2d078f5c4 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComCurrentMessage.SubType;
 import org.openhab.core.util.HexUtils;
@@ -34,18 +34,18 @@ public class RFXComCurrentMessageTest {
 
         final RFXComCurrentMessage msg = (RFXComCurrentMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(message));
-        assertEquals("SubType", SubType.ELEC1, msg.subType);
-        assertEquals("Seq Number", 15, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "34304", msg.getDeviceId());
-        assertEquals("Count", 4, msg.count);
-        assertEquals("Channel 1", 2.9d, msg.channel1Amps, 0.01);
-        assertEquals("Channel 2", 0d, msg.channel2Amps, 0.01);
-        assertEquals("Channel 3", 0d, msg.channel3Amps, 0.01);
-        assertEquals("Signal Level", 4, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(SubType.ELEC1, msg.subType, "SubType");
+        assertEquals(15, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("34304", msg.getDeviceId(), "Sensor Id");
+        assertEquals(4, msg.count, "Count");
+        assertEquals(2.9d, msg.channel1Amps, 0.01, "Channel 1");
+        assertEquals(0d, msg.channel2Amps, 0.01, "Channel 2");
+        assertEquals(0d, msg.channel3Amps, 0.01, "Channel 3");
+        assertEquals(4, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", message, HexUtils.bytesToHex(decoded));
+        assertEquals(message, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index a4191a2813d8bd234f93e91659224d3fbc658c3f..46496559ab5dffb249b219155d87c17a23f31a68 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.rfxcom.internal.messages;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.CURTAIN1;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 
 /**
index 5004e4ac2cb657dc458980c373b762e9e4081328..a2ccbd7d5330563d7b17ced1b272d3b5b938de60 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.util.HexUtils;
@@ -33,17 +33,17 @@ public class RFXComDateTimeMessageTest {
         String hexMessage = "0D580117B90003041D030D150A69";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComDateTimeMessage msg = (RFXComDateTimeMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RFXComDateTimeMessage.SubType.RTGR328N, msg.subType);
-        assertEquals("Seq Number", 23, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "47360", msg.getDeviceId());
-        assertEquals("Date time", "2003-04-29T13:21:10", msg.dateTime);
-        assertEquals("Signal Level", 2, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL));
+        assertEquals(RFXComDateTimeMessage.SubType.RTGR328N, msg.subType, "SubType");
+        assertEquals(23, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("47360", msg.getDeviceId(), "Sensor Id");
+        assertEquals("2003-04-29T13:21:10", msg.dateTime, "Date time");
+        assertEquals(2, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL), "Signal Level");
 
-        assertEquals("Converted value", DateTimeType.valueOf("2003-04-29T13:21:10"),
-                msg.convertToState(CHANNEL_DATE_TIME, new MockDeviceState()));
+        assertEquals(DateTimeType.valueOf("2003-04-29T13:21:10"),
+                msg.convertToState(CHANNEL_DATE_TIME, new MockDeviceState()), "Converted value");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 2e6f4cefe2a669550362012acccd4494f30850b0..85def5bfd50b2352bcab6541b217d3128e93fb49 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.EDISIO;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 
 /**
@@ -25,8 +26,8 @@ import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplemente
  */
 @NonNullByDefault
 public class RFXComEdisioTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(EDISIO);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class, () -> RFXComMessageFactory.createMessage(EDISIO));
     }
 }
index 43e240a2599386b1b517ad1aaf605aefb6b8d3e4..7b392df08546336199638fe9a6c978e65c5d1177 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComEnergyMessage.SubType.ELEC2;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,17 +32,17 @@ public class RFXComEnergyMessageTest {
         String hexMessage = "115A01071A7300000003F600000000350B89";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComEnergyMessage msg = (RFXComEnergyMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", ELEC2, msg.subType);
-        assertEquals("Seq Number", 7, msg.seqNbr);
-        assertEquals("Sensor Id", "6771", msg.getDeviceId());
-        assertEquals("Count", 0, msg.count);
-        assertEquals("Instant usage", 1014d / 230, msg.instantAmp, 0.01);
-        assertEquals("Total usage", 60.7d / 230, msg.totalAmpHour, 0.01);
-        assertEquals("Signal Level", (byte) 8, msg.signalLevel);
-        assertEquals("Battery Level", (byte) 9, msg.batteryLevel);
+        assertEquals(ELEC2, msg.subType, "SubType");
+        assertEquals(7, msg.seqNbr, "Seq Number");
+        assertEquals("6771", msg.getDeviceId(), "Sensor Id");
+        assertEquals(0, msg.count, "Count");
+        assertEquals(1014d / 230, msg.instantAmp, 0.01, "Instant usage");
+        assertEquals(60.7d / 230, msg.totalAmpHour, 0.01, "Total usage");
+        assertEquals((byte) 8, msg.signalLevel, "Signal Level");
+        assertEquals((byte) 9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index a4cfb738ecb5489dabbc30df6aa6bbac994bd2e1..750883592c122ad30fe12398e70befd913ce395a 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,8 +27,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComFS20MessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.FS20);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.FS20));
     }
 }
index 9d105d41d8b103be6386df468afa9f51825bb301..9b600b66806d321c1d25949f192f3c053fceeed4 100644 (file)
@@ -18,7 +18,7 @@ import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubT
 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessageTest.testCommand;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
index ee25692d13f74cb2723f71bad747f5e53040f9d6..7d4cb978f1502dec2e899e4fe1cc8e31daa7857b 100644 (file)
@@ -18,7 +18,7 @@ import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubT
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
index bcaf5513f36a3ce28bf854805ffe4f857f49255b..ee7a20dfca3e211ee603953578d08e24cba3d0bf 100644 (file)
@@ -18,7 +18,7 @@ import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubT
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
index c8e404085f615614b75f70dba27770826d31f2ad..91d763506a3a5a51f509d7e207a808c921885b2b 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.CASAFAN;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -55,9 +55,9 @@ public class RFXComFanMessageTest {
             @Nullable State expectedCommand, State expectedLightCommand, @Nullable State expectedFanSpeed,
             RFXComBaseMessage.PacketType packetType) throws RFXComException {
         final RFXComFanMessage msg = (RFXComFanMessage) RFXComMessageFactory.createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
 
         assertEquals(expectedCommand, msg.convertToState(CHANNEL_COMMAND, DEVICE_STATE));
         assertEquals(expectedLightCommand, msg.convertToState(CHANNEL_FAN_LIGHT, DEVICE_STATE));
@@ -67,7 +67,7 @@ public class RFXComFanMessageTest {
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index d88328d9e7cad7b1deaaf67e3e1dafcb01f58502..9f44c261bb775280f656106d5809db57ffffc9a2 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,8 +27,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComGasMessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.GAS);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.GAS));
     }
 }
index 23c225c596aab44bfa7e2b20740a6903b642a6ba..561cd50620c44f1df1e5a3415fc646c13379ebb4 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.HOME_CONFORT;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.Commands;
 import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.SubType;
index 940efddc7032d39cd417e06fde1b7037d23331ef..300d7aed2d65127393e99324226fd6a447bcfc3c 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,16 +32,16 @@ public class RFXComHumidityMessageTest {
         String hexMessage = "085101027700360189";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComHumidityMessage msg = (RFXComHumidityMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RFXComHumidityMessage.SubType.HUM1, msg.subType);
-        assertEquals("Seq Number", 2, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "30464", msg.getDeviceId());
-        assertEquals("Humidity", 54, msg.humidity);
-        assertEquals("Humidity status", RFXComHumidityMessage.HumidityStatus.COMFORT, msg.humidityStatus);
-        assertEquals("Signal Level", (byte) 8, msg.signalLevel);
-        assertEquals("Battery Level", (byte) 9, msg.batteryLevel);
+        assertEquals(RFXComHumidityMessage.SubType.HUM1, msg.subType, "SubType");
+        assertEquals(2, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("30464", msg.getDeviceId(), "Sensor Id");
+        assertEquals(54, msg.humidity, "Humidity");
+        assertEquals(RFXComHumidityMessage.HumidityStatus.COMFORT, msg.humidityStatus, "Humidity status");
+        assertEquals((byte) 8, msg.signalLevel, "Signal Level");
+        assertEquals((byte) 9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 08e69b6882999d3c45f75571973dcf2661747487..27d7daa7dbaf971a88a071815e9f866ed774b742 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,8 +27,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComIOLinesMessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.IO_LINES);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.IO_LINES));
     }
 }
index 63f6407a6c58a1d62b5668a4531c374c4e403eed..be532a823d15a7f441108cc24abb1c43344ea281 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.TransceiverType._433_92MHZ_TRANSCEIVER;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.config.RFXComBridgeConfiguration;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
@@ -31,7 +31,7 @@ import org.openhab.core.util.HexUtils;
 public class RFXComInterfaceControlMessageTest {
     private RFXComBridgeConfiguration configuration = new RFXComBridgeConfiguration();
 
-    @Before
+    @BeforeEach
     public void resetConfig() {
         configuration.transmitPower = -18;
         configuration.enableUndecoded = false;
index 04ddc676e5024f22b3b70bd6440262588f63eece..477c3a05d8286f4acf579afd45207977e2ec825c 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.Commands.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.SubType.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.SubType.START_RECEIVER;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.TransceiverType._433_92MHZ_TRANSCEIVER;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.Commands;
 import org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.SubType;
@@ -36,9 +36,9 @@ public class RFXComInterfaceMessageTest {
             throws RFXComException {
         RFXComInterfaceMessage msg = (RFXComInterfaceMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Command", command, msg.command);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(command, msg.command, "Command");
 
         return msg;
     }
@@ -48,7 +48,7 @@ public class RFXComInterfaceMessageTest {
         RFXComInterfaceMessage msg = testMessage("1401070307436F7079726967687420524658434F4D", START_RECEIVER, 3,
                 Commands.START_RECEIVER);
 
-        assertEquals("text", "Copyright RFXCOM", msg.text);
+        assertEquals("Copyright RFXCOM", msg.text, "text");
     }
 
     @Test
@@ -60,9 +60,9 @@ public class RFXComInterfaceMessageTest {
     public void testStatusMessage() throws RFXComException {
         RFXComInterfaceMessage msg = testMessage("1401000102530C0800270001031C04524658434F4D", RESPONSE, 1, GET_STATUS);
 
-        assertEquals("Command", _433_92MHZ_TRANSCEIVER, msg.transceiverType);
+        assertEquals(_433_92MHZ_TRANSCEIVER, msg.transceiverType, "Command");
 
         // TODO this is not correct, improvements for this have been made in the OH1 repo
-        assertEquals("firmwareVersion", 12, msg.firmwareVersion);
+        assertEquals(12, msg.firmwareVersion, "firmwareVersion");
     }
 }
index 4d8b0a3538140da355b9b5a171de0d6bbf0620f1..a4b5897b2c953331bd84e31f60d5c7ed8ff7ccce 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
-import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
 import org.openhab.core.util.HexUtils;
 
@@ -26,9 +27,9 @@ import org.openhab.core.util.HexUtils;
 @NonNullByDefault
 public class RFXComInvalidMessageTypeTest {
 
-    @Test(expected = RFXComUnsupportedValueException.class)
-    public void testMessage() throws RFXComException {
+    @Test
+    public void testMessage() {
         byte[] message = HexUtils.hexToBytes("07CC01271356ECC0");
-        RFXComMessageFactory.createMessage(message);
+        assertThrows(RFXComUnsupportedValueException.class, () -> RFXComMessageFactory.createMessage(message));
     }
 }
index c3f2b7c4344f0b6ec6633c9eaf0685c3130a17b3..9b1eca6e805b2b2eb4348f694955514a6b946925 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComLighting1Message.Commands;
@@ -38,17 +38,17 @@ public class RFXComLighting1MessageTest {
             byte signalLevel, Commands command, String commandString) throws RFXComException {
         final RFXComLighting1Message msg = (RFXComLighting1Message) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
-        assertEquals("Command", command, msg.command);
-        assertEquals("Command String", commandString,
-                msg.convertToState(CHANNEL_COMMAND_STRING, deviceState).toString());
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
+        assertEquals(command, msg.command, "Command");
+        assertEquals(commandString, msg.convertToState(CHANNEL_COMMAND_STRING, deviceState).toString(),
+                "Command String");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index 22a67c274d702f4464e60fde217346babf017636..e5f7c969d7317e0cc813daa4e12550993aa00ca8 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,14 +32,14 @@ public class RFXComLighting2MessageTest {
         String hexMessage = "0B11000600109B520B000080";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComLighting2Message msg = (RFXComLighting2Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RFXComLighting2Message.SubType.AC, msg.subType);
-        assertEquals("Seq Number", 6, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "1088338.11", msg.getDeviceId());
-        assertEquals("Command", RFXComLighting2Message.Commands.OFF, msg.command);
-        assertEquals("Signal Level", (byte) 8, msg.signalLevel);
+        assertEquals(RFXComLighting2Message.SubType.AC, msg.subType, "SubType");
+        assertEquals(6, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("1088338.11", msg.getDeviceId(), "Sensor Id");
+        assertEquals(RFXComLighting2Message.Commands.OFF, msg.command, "Command");
+        assertEquals((byte) 8, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index af7d262f8d41eee492480c3fa0a4326f0ebcbe7e..517ec03db06ad374c9219f4686f2409da140d8df 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,9 +27,10 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComLighting3MessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
+    @Test
+    public void checkNotImplemented() {
         // TODO Note that this message is supported in the 1.9 binding
-        RFXComMessageFactory.createMessage(PacketType.LIGHTING3);
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.LIGHTING3));
     }
 }
index e2c96c9d37b1f99a12eaaf76b1ed20dda36c4eaa..868acdb8cec1f47dc4e6d612a32215512e5938f2 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.LIGHTING4;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting4Message.Commands.*;
@@ -23,7 +23,7 @@ import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
 import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfigurationBuilder;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
@@ -49,7 +49,7 @@ public class RFXComLighting4MessageTest {
         byte[] binaryMessage = message.decodeMessage();
         RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactory.createMessage(binaryMessage);
 
-        assertEquals("Sensor Id", "90000", msg.getDeviceId());
+        assertEquals("90000", msg.getDeviceId(), "Sensor Id");
     }
 
     private void testMessage(String hexMsg, RFXComLighting4Message.SubType subType, String deviceId,
@@ -63,16 +63,16 @@ public class RFXComLighting4MessageTest {
             int onCommand) throws RFXComException {
         RFXComLighting4Message msg = (RFXComLighting4Message) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Command", commandByte, RFXComTestHelper.getActualIntValue(msg, CHANNEL_COMMAND_ID));
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(commandByte, RFXComTestHelper.getActualIntValue(msg, CHANNEL_COMMAND_ID), "Command");
         if (seqNbr != null) {
-            assertEquals("Seq Number", seqNbr.shortValue(), (short) (msg.seqNbr & 0xFF));
+            assertEquals(seqNbr.shortValue(), (short) (msg.seqNbr & 0xFF), "Seq Number");
         }
-        assertEquals("Signal Level", signalLevel, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL));
+        assertEquals(signalLevel, RFXComTestHelper.getActualIntValue(msg, CHANNEL_SIGNAL_LEVEL), "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
 
         RFXComTestHelper.checkDiscoveryResult(msg, deviceId, pulse, subType.toString(), offCommand, onCommand);
     }
index a2b2deea6cffa5b0db866b5f17fa2ec2ccb574d9..dd52c6aee975fe106e268c7f093f57c8075bec10 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.LIGHTING5;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.Commands.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.SubType.IT;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
 import org.openhab.core.library.types.OnOffType;
@@ -43,11 +43,11 @@ public class RFXComLighting5MessageTest {
         itMessageObject.convertFromState(CHANNEL_COMMAND, OnOffType.ON);
         byte[] message = itMessageObject.decodeMessage();
         String hexMessage = HexUtils.bytesToHex(message);
-        assertEquals("Message is not as expected", "0A140F0000080D01010000", hexMessage);
+        assertEquals("0A140F0000080D01010000", hexMessage, "Message is not as expected");
         RFXComLighting5Message msg = (RFXComLighting5Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", IT, msg.subType);
-        assertEquals("Sensor Id", "2061.1", msg.getDeviceId());
-        assertEquals("Command", ON, msg.command);
+        assertEquals(IT, msg.subType, "SubType");
+        assertEquals("2061.1", msg.getDeviceId(), "Sensor Id");
+        assertEquals(ON, msg.command, "Command");
     }
 
     @Test
index d8f6f5ba75ce3e453152fdb4b414fb87ea36616e..53dfd5ae7e6e87713fed425ab462c3c56a491e2b 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,17 +32,17 @@ public class RFXComLighting6MessageTest {
         String hexMessage = "0B150005D950450101011D80";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComLighting6Message msg = (RFXComLighting6Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RFXComLighting6Message.SubType.BLYSS, msg.subType);
-        assertEquals("Seq Number", 5, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "55632.E.1", msg.getDeviceId());
-        assertEquals("Command", RFXComLighting6Message.Commands.OFF, msg.command);
-        assertEquals("Signal Level", (byte) 8, msg.signalLevel);
+        assertEquals(RFXComLighting6Message.SubType.BLYSS, msg.subType, "SubType");
+        assertEquals(5, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("55632.E.1", msg.getDeviceId(), "Sensor Id");
+        assertEquals(RFXComLighting6Message.Commands.OFF, msg.command, "Command");
+        assertEquals((byte) 8, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
         // the openhab plugin is not (yet) using the cmndseqnbr & seqnbr2
         String acceptedHexMessage = "0B150005D950450101000080";
 
-        assertEquals("Message converted back", acceptedHexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(acceptedHexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 803dba8e4d6cff2d1aa9f3e3cfa30f0f5358242b..37cd6af7cefac6d9c3050143403a89f189e33092 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 
 /**
@@ -23,9 +25,10 @@ import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplemente
  */
 @NonNullByDefault
 public class RFXComPowerMessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
+    @Test
+    public void checkNotImplemented() {
         // TODO Note that this message is supported in the 1.9 binding
-        RFXComMessageFactory.createMessage(RFXComBaseMessage.PacketType.POWER);
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(RFXComBaseMessage.PacketType.POWER));
     }
 }
index 7fe843b7d2fa4d33d56260feb2bcbcc54846e352..5442c984b7b5fd1775b4f118cada49d11649142f 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,8 +27,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComRFXMeterMessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.RFXMETER);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.RFXMETER));
     }
 }
index 1dcb788676db52dfae6d60f9cc0622593a3d2fcb..5c313b5716553b06c31b3e714a8ef4a871cc7b33 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComRFXSensorMessage.SubType.*;
 
@@ -20,7 +20,7 @@ import javax.xml.bind.DatatypeConverter;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.handler.DeviceState;
 import org.openhab.core.library.types.DecimalType;
@@ -41,20 +41,20 @@ public class RFXComRFXSensorMessageTest {
             DeviceState deviceState) throws RFXComException {
         final RFXComRFXSensorMessage msg = (RFXComRFXSensorMessage) RFXComMessageFactory
                 .createMessage(DatatypeConverter.parseHexBinary(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
-        assertEquals("Temperature", temperature, getMessageTemperature(msg, deviceState));
-        assertEquals("Voltage", voltage, getChannelAsDouble(CHANNEL_VOLTAGE, msg, deviceState));
-        assertEquals("Reference Voltage", referenceVoltage,
-                getChannelAsDouble(CHANNEL_REFERENCE_VOLTAGE, msg, deviceState));
-        assertEquals("Humidity", expectedHumidity, getChannelAsDouble(CHANNEL_HUMIDITY, msg, deviceState));
-        assertEquals("Pressure", expectedPressure, getChannelAsDouble(CHANNEL_PRESSURE, msg, deviceState));
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
+        assertEquals(temperature, getMessageTemperature(msg, deviceState), "Temperature");
+        assertEquals(voltage, getChannelAsDouble(CHANNEL_VOLTAGE, msg, deviceState), "Voltage");
+        assertEquals(referenceVoltage, getChannelAsDouble(CHANNEL_REFERENCE_VOLTAGE, msg, deviceState),
+                "Reference Voltage");
+        assertEquals(expectedHumidity, getChannelAsDouble(CHANNEL_HUMIDITY, msg, deviceState), "Humidity");
+        assertEquals(expectedPressure, getChannelAsDouble(CHANNEL_PRESSURE, msg, deviceState), "Pressure");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, DatatypeConverter.printHexBinary(decoded));
+        assertEquals(hexMsg, DatatypeConverter.printHexBinary(decoded), "Message converted back");
     }
 
     @Test
index 97508cf3ea8b951c604f4c68ccc467f365e1bb32..db69d4c79e0e2108d755d6a0d28c58f7d3485115 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.RADIATOR1;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 
 /**
@@ -25,8 +26,8 @@ import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplemente
  */
 @NonNullByDefault
 public class RFXComRadiator1MessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(RADIATOR1);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class, () -> RFXComMessageFactory.createMessage(RADIATOR1));
     }
 }
index c617f5848c6cb2b826e4fbcb8ee24ae5b6665941..7d3be823ba17ef02cb80d177f6c089566bfa4ab4 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComRainMessage.SubType.RAIN2;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -33,16 +33,16 @@ public class RFXComRainMessageTest {
         String hexMessage = "0B550217B6000000004D3C69";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComRainMessage msg = (RFXComRainMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RAIN2, msg.subType);
-        assertEquals("Seq Number", 23, msg.seqNbr);
-        assertEquals("Sensor Id", "46592", msg.getDeviceId());
-        assertEquals("Rain rate", 0.0, msg.rainRate, 0.001);
-        assertEquals("Total rain", 1977.2, msg.rainTotal, 0.001);
-        assertEquals("Signal Level", 6, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(RAIN2, msg.subType, "SubType");
+        assertEquals(23, msg.seqNbr, "Seq Number");
+        assertEquals("46592", msg.getDeviceId(), "Sensor Id");
+        assertEquals(0.0, msg.rainRate, 0.001, "Rain rate");
+        assertEquals(1977.2, msg.rainTotal, 0.001, "Total rain");
+        assertEquals(6, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 42773123e80333d0cff464e80d291b1208b8144a..0992a7e54ea9bfb8460d6794435a4f2257407b4c 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -24,8 +26,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
  */
 @NonNullByDefault
 public class RFXComRemoteControlMessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.REMOTE_CONTROL);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.REMOTE_CONTROL));
     }
 }
index a8e72992fd7db5464af72857eae806b55a4baf27..89eb6ccc4142f3954fdef5b7ab5fcb707723c622 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.RFY;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.Commands;
 import org.openhab.binding.rfxcom.internal.messages.RFXComRfyMessage.SubType;
index fec775df890a298e1a7caa236d9d00b2ca8c28a9..1a6f4643b19ab58557785acff2405b81e119f054 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComSecurity1Message.SubType.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComSecurity1Message.Contact;
@@ -38,18 +38,18 @@ public class RFXComSecurity1MessageTest {
             @Nullable Status status, int signalLevel) throws RFXComException {
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComSecurity1Message msg = (RFXComSecurity1Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", sequenceNumber, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Battery level", batteryLevel, msg.batteryLevel);
-        assertEquals("Contact", contact, msg.contact);
-        assertEquals("Motion", motion, msg.motion);
-        assertEquals("Status", status, msg.status);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(sequenceNumber, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(batteryLevel, msg.batteryLevel, "Battery level");
+        assertEquals(contact, msg.contact, "Contact");
+        assertEquals(motion, msg.motion, "Motion");
+        assertEquals(status, msg.status, "Status");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
@@ -66,8 +66,9 @@ public class RFXComSecurity1MessageTest {
                 0);
     }
 
-    @Test(expected = RFXComUnsupportedValueException.class)
-    public void testSomeInvalidSecurityMessage() throws RFXComException {
-        testSomeMessages("08FF0A1F0000000650", null, 0, null, 0, null, null, null, 0);
+    @Test
+    public void testSomeInvalidSecurityMessage() {
+        assertThrows(RFXComUnsupportedValueException.class,
+                () -> testSomeMessages("08FF0A1F0000000650", null, 0, null, 0, null, null, null, 0));
     }
 }
index 33061097896ed6cc9c1071a5a514272f5c8ac1d6..0f4dc43908c0c931db2ba6a747d66eb14ff023b5 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComSecurity2Message.SubType;
 import org.openhab.core.util.HexUtils;
@@ -35,14 +35,14 @@ public class RFXComSecurity2MessageTest {
         byte[] message = HexUtils.hexToBytes(hexMessage);
 
         RFXComSecurity2Message msg = (RFXComSecurity2Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", SubType.RAW_AES_KEELOQ, msg.subType);
-        assertEquals("Seq Number", 0, msg.seqNbr);
-        assertEquals("Sensor Id", "51450387", msg.getDeviceId());
-        assertEquals("Button Status", 12, msg.buttonStatus);
-        assertEquals("Battery Level", 4, msg.batteryLevel);
-        assertEquals("Signal Level", 5, msg.signalLevel);
+        assertEquals(SubType.RAW_AES_KEELOQ, msg.subType, "SubType");
+        assertEquals(0, msg.seqNbr, "Seq Number");
+        assertEquals("51450387", msg.getDeviceId(), "Sensor Id");
+        assertEquals(12, msg.buttonStatus, "Button Status");
+        assertEquals(4, msg.batteryLevel, "Battery Level");
+        assertEquals(5, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 93f124accb2d5c497bfe830c4fba742b0a01adac..ca95d97bf4e363d2e5747995749268ffc5eebd64 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityBarometricMessage.ForecastStatus.RAIN;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityBarometricMessage.HumidityStatus.DRY;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityBarometricMessage.SubType.THB2;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -36,19 +36,19 @@ public class RFXComTemperatureHumidityBarometricMessageTest {
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComTemperatureHumidityBarometricMessage msg = (RFXComTemperatureHumidityBarometricMessage) RFXComMessageFactory
                 .createMessage(message);
-        assertEquals("SubType", THB2, msg.subType);
-        assertEquals("Seq Number", 14, msg.seqNbr);
-        assertEquals("Sensor Id", "59648", msg.getDeviceId());
-        assertEquals("Temperature", 20.1, msg.temperature, 0.01);
-        assertEquals("Humidity", 39, msg.humidity);
-        assertEquals("Humidity status", DRY, msg.humidityStatus);
-        assertEquals("Barometer", 999.0, msg.pressure, 0.001);
-        assertEquals("Forecast", RAIN, msg.forecastStatus);
-        assertEquals("Signal Level", 3, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(THB2, msg.subType, "SubType");
+        assertEquals(14, msg.seqNbr, "Seq Number");
+        assertEquals("59648", msg.getDeviceId(), "Sensor Id");
+        assertEquals(20.1, msg.temperature, 0.01, "Temperature");
+        assertEquals(39, msg.humidity, "Humidity");
+        assertEquals(DRY, msg.humidityStatus, "Humidity status");
+        assertEquals(999.0, msg.pressure, 0.001, "Barometer");
+        assertEquals(RAIN, msg.forecastStatus, "Forecast");
+        assertEquals(3, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 510414c00318239d09f969a08b6e360bee96a3de..11eb7dfbf4aefc62cb6afc22018e20e921145c4a 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityMessage.HumidityStatus.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityMessage.SubType.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureHumidityMessage.HumidityStatus;
 import org.openhab.core.util.HexUtils;
@@ -37,18 +37,18 @@ public class RFXComTemperatureHumidityMessageTest {
         byte[] binaryMessage = HexUtils.hexToBytes(hexMsg);
         final RFXComTemperatureHumidityMessage msg = (RFXComTemperatureHumidityMessage) RFXComMessageFactory
                 .createMessage(binaryMessage);
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", sensorId, msg.sensorId);
-        assertEquals("Temperature", temperature, msg.temperature, 0.01);
-        assertEquals("Humidity", humidity, msg.humidity);
-        assertEquals("Humidity Status", humidityStatus, msg.humidityStatus);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
-        assertEquals("Battery Level", batteryLevel, msg.batteryLevel);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(sensorId, msg.sensorId, "Sensor Id");
+        assertEquals(temperature, msg.temperature, 0.01, "Temperature");
+        assertEquals(humidity, msg.humidity, "Humidity");
+        assertEquals(humidityStatus, msg.humidityStatus, "Humidity Status");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
+        assertEquals(batteryLevel, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index dc754a9283970629a348de6014c5a9a0aca857a1..b36755a692683070b45c53314a1c0d43221dbbc0 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureMessage.SubType.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -31,16 +31,16 @@ public class RFXComTemperatureMessageTest {
             double temperature, int signalLevel, int bateryLevel) throws RFXComException {
         final RFXComTemperatureMessage msg = (RFXComTemperatureMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", deviceId, msg.getDeviceId());
-        assertEquals("Temperature", temperature, msg.temperature, 0.001);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
-        assertEquals("Battery", bateryLevel, msg.batteryLevel);
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(deviceId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(temperature, msg.temperature, 0.001, "Temperature");
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
+        assertEquals(bateryLevel, msg.batteryLevel, "Battery");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index 927643940d1d1e7c36efb4627a8910bea45ee90d..1c8d6c1911f8680d0a5849b6d0237032745903a3 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTemperatureRainMessage.SubType.WS1200;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,15 +32,15 @@ public class RFXComTemperatureRainMessageTest {
         String hexMessage = "0A4F01CCF001004F03B759";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComTemperatureRainMessage msg = (RFXComTemperatureRainMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", WS1200, msg.subType);
-        assertEquals("Seq Number", 204, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "61441", msg.getDeviceId());
-        assertEquals("Temperature", 7.9, msg.temperature, 0.001);
-        assertEquals("Rain total", 95.1, msg.rainTotal, 0.001);
-        assertEquals("Signal Level", (byte) 5, msg.signalLevel);
+        assertEquals(WS1200, msg.subType, "SubType");
+        assertEquals(204, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("61441", msg.getDeviceId(), "Sensor Id");
+        assertEquals(7.9, msg.temperature, 0.001, "Temperature");
+        assertEquals(95.1, msg.rainTotal, 0.001, "Rain total");
+        assertEquals((byte) 5, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 1ee2e1b171e8f11ed792cefc0f230d64a0cb32a6..6ce9a9bba6621542650bd339849e41b7c00a91ba 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Map;
 
@@ -35,8 +35,8 @@ class RFXComTestHelper {
         // This is a place where its easy to make mistakes in coding, and can result in errors, normally
         // array bounds errors
         byte[] binaryMessage = message.decodeMessage();
-        assertEquals("Wrong packet length", binaryMessage[0], binaryMessage.length - 1);
-        assertEquals("Wrong packet type", packetType.toByte(), binaryMessage[1]);
+        assertEquals(binaryMessage[0], binaryMessage.length - 1, "Wrong packet length");
+        assertEquals(packetType.toByte(), binaryMessage[1], "Wrong packet type");
     }
 
     static void checkDiscoveryResult(RFXComDeviceMessage msg, String deviceId, @Nullable Integer pulse, String subType,
@@ -48,13 +48,13 @@ class RFXComTestHelper {
         msg.addDevicePropertiesTo(builder);
 
         Map<String, Object> properties = builder.build().getProperties();
-        assertEquals("Device Id", deviceId, properties.get("deviceId"));
-        assertEquals("Sub type", subType, properties.get("subType"));
+        assertEquals(deviceId, properties.get("deviceId"), "Device Id");
+        assertEquals(subType, properties.get("subType"), "Sub type");
         if (pulse != null) {
-            assertEquals("Pulse", pulse, properties.get("pulse"));
+            assertEquals(pulse, properties.get("pulse"), "Pulse");
         }
-        assertEquals("On command", onCommand, properties.get("onCommandId"));
-        assertEquals("Off command", offCommand, properties.get("offCommandId"));
+        assertEquals(onCommand, properties.get("onCommandId"), "On command");
+        assertEquals(offCommand, properties.get("offCommandId"), "Off command");
     }
 
     static int getActualIntValue(RFXComDeviceMessage msg, String channelId) throws RFXComException {
index 04677a7bd345ddce6717221c3790114de6500149..86a4c810ce5f48f14da867c5fc228a79a9178e84 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,17 +32,17 @@ public class RFXComThermostat1MessageTest {
         String hexMessage = "0940001B6B1816150270";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComThermostat1Message msg = (RFXComThermostat1Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", RFXComThermostat1Message.SubType.DIGIMAX, msg.subType);
-        assertEquals("Seq Number", 27, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", "27416", msg.getDeviceId());
-        assertEquals("Temperature", 22, msg.temperature);
-        assertEquals("Set point", 21, msg.set);
-        assertEquals("Mode", RFXComThermostat1Message.Mode.HEATING, msg.mode);
-        assertEquals("Status", RFXComThermostat1Message.Status.NO_DEMAND, msg.status);
-        assertEquals("Signal Level", (byte) 7, msg.signalLevel);
+        assertEquals(RFXComThermostat1Message.SubType.DIGIMAX, msg.subType, "SubType");
+        assertEquals(27, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("27416", msg.getDeviceId(), "Sensor Id");
+        assertEquals(22, msg.temperature, "Temperature");
+        assertEquals(21, msg.set, "Set point");
+        assertEquals(RFXComThermostat1Message.Mode.HEATING, msg.mode, "Mode");
+        assertEquals(RFXComThermostat1Message.Status.NO_DEMAND, msg.status, "Status");
+        assertEquals((byte) 7, msg.signalLevel, "Signal Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 204bc73d8f4f2a5a493762353c19295bc9a4baf2..e4a042206dcd24f12795f8729b516300c041d300 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -24,9 +26,10 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
  */
 @NonNullByDefault
 public class RFXComThermostat2MessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
+    @Test
+    public void checkNotImplemented() {
         // TODO Note that this message is supported in the 1.9 binding
-        RFXComMessageFactory.createMessage(PacketType.THERMOSTAT2);
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.THERMOSTAT2));
     }
 }
index b65d89b98dd45499b2fc04482eb2f7e3b16b91f4..0ba3730dfb1423f366f04662ffb47a3613eeeca8 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.THERMOSTAT3;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComThermostat3Message.SubType.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
 import org.openhab.core.library.types.OnOffType;
@@ -69,11 +69,11 @@ public class RFXComThermostat3MessageTest {
             throws RFXComException {
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComThermostat3Message msg = (RFXComThermostat3Message) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", subtype, msg.subType);
-        assertEquals("Seq Number", sequenceNumber, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Sensor Id", sensorId, msg.getDeviceId());
-        assertEquals(CHANNEL_COMMAND, command, msg.command);
-        assertEquals("Signal Level", signalLevel, msg.signalLevel);
+        assertEquals(subtype, msg.subType, "SubType");
+        assertEquals(sequenceNumber, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals(sensorId, msg.getDeviceId(), "Sensor Id");
+        assertEquals(command, msg.command, CHANNEL_COMMAND);
+        assertEquals(signalLevel, msg.signalLevel, "Signal Level");
 
         assertEquals(commandChannel, msg.convertToState(CHANNEL_COMMAND, deviceState));
         assertEquals(secondCommandChannel, msg.convertToState(CHANNEL_COMMAND_SECOND, deviceState));
@@ -82,7 +82,7 @@ public class RFXComThermostat3MessageTest {
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
     // TODO please add tests for real messages
 
index 5a64e03d430386a1940f2cb10044fec8831306cb..f6fbfc15419580b6d3dbf0c0b3dd52fb97731b9d 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.THERMOSTAT4;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 
 /**
@@ -25,8 +26,8 @@ import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplemente
  */
 @NonNullByDefault
 public class RFXComThermostat4MessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(THERMOSTAT4);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class, () -> RFXComMessageFactory.createMessage(THERMOSTAT4));
     }
 }
index 5abaa43e4cab7e989f27c799f3cc7fed68062125..89cd9355b69c5d9cb73b7c2e838033fff5f415e6 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTransmitterMessage.Response.ACK;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComTransmitterMessage.SubType.RESPONSE;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComTransmitterMessage.Response;
 import org.openhab.binding.rfxcom.internal.messages.RFXComTransmitterMessage.SubType;
@@ -33,13 +33,13 @@ public class RFXComTransmitterMessageTest {
     private void testMessage(String hexMsg, Response response, SubType subType, int seqNbr) throws RFXComException {
         final RFXComTransmitterMessage msg = (RFXComTransmitterMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Response", response, msg.response);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(response, msg.response, "Response");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
index 3a2ca660e716e47ad4ea9f96f4258295df3d379d..1a8cf7d63c0b62d6dd949f513acd1e1b483a482e 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -34,19 +34,19 @@ public class RFXComUVMessageTest {
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComUVMessage msg = (RFXComUVMessage) RFXComMessageFactory.createMessage(message);
 
-        assertEquals("SubType", RFXComUVMessage.SubType.UV3, msg.subType);
-        assertEquals("Seq Number", 18, msg.seqNbr);
-        assertEquals("Sensor Id", "13345", msg.getDeviceId());
+        assertEquals(RFXComUVMessage.SubType.UV3, msg.subType, "SubType");
+        assertEquals(18, msg.seqNbr, "Seq Number");
+        assertEquals("13345", msg.getDeviceId(), "Sensor Id");
 
-        assertEquals("UV", 2.5, msg.uv, 0.001);
-        assertEquals("Temperature", 1822.5, msg.temperature, 0.001);
+        assertEquals(2.5, msg.uv, 0.001, "UV");
+        assertEquals(1822.5, msg.temperature, 0.001, "Temperature");
 
-        assertEquals("Signal Level", 14, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(14, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
@@ -56,18 +56,18 @@ public class RFXComUVMessageTest {
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComUVMessage msg = (RFXComUVMessage) RFXComMessageFactory.createMessage(message);
 
-        assertEquals("SubType", RFXComUVMessage.SubType.UV3, msg.subType);
-        assertEquals("Seq Number", 18, msg.seqNbr);
-        assertEquals("Sensor Id", "13345", msg.getDeviceId());
+        assertEquals(RFXComUVMessage.SubType.UV3, msg.subType, "SubType");
+        assertEquals(18, msg.seqNbr, "Seq Number");
+        assertEquals("13345", msg.getDeviceId(), "Sensor Id");
 
-        assertEquals("UV", 2.5, msg.uv, 0.001);
-        assertEquals("Temperature", -1822.5, msg.temperature, 0.001);
+        assertEquals(2.5, msg.uv, 0.001, "UV");
+        assertEquals(-1822.5, msg.temperature, 0.001, "Temperature");
 
-        assertEquals("Signal Level", 14, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(14, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 0bf041de82cd06248e422ef8a13d425feec9ef48..b19d814941d8955461b533ece535129c4f4de312 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageTooLongException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
@@ -34,14 +34,14 @@ public class RFXComUndecodedRFMessageTest {
             throws RFXComException {
         final RFXComUndecodedRFMessage msg = (RFXComUndecodedRFMessage) RFXComMessageFactory
                 .createMessage(HexUtils.hexToBytes(hexMsg));
-        assertEquals("SubType", subType, msg.subType);
-        assertEquals("Seq Number", seqNbr, (short) (msg.seqNbr & 0xFF));
-        assertEquals("Device Id", "UNDECODED", msg.getDeviceId());
-        assertEquals("Payload", rawPayload, HexUtils.bytesToHex(msg.rawPayload));
+        assertEquals(subType, msg.subType, "SubType");
+        assertEquals(seqNbr, (short) (msg.seqNbr & 0xFF), "Seq Number");
+        assertEquals("UNDECODED", msg.getDeviceId(), "Device Id");
+        assertEquals(rawPayload, HexUtils.bytesToHex(msg.rawPayload), "Payload");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMsg, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMsg, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 
     @Test
@@ -49,13 +49,14 @@ public class RFXComUndecodedRFMessageTest {
         testMessage("070301271356ECC0", RFXComUndecodedRFMessage.SubType.ARC, 0x27, "1356ECC0");
     }
 
-    @Test(expected = RFXComMessageTooLongException.class)
+    @Test
     public void testLongMessage() throws RFXComException {
         RFXComUndecodedRFMessage msg = (RFXComUndecodedRFMessage) RFXComMessageFactory
                 .createMessage(PacketType.UNDECODED_RF_MESSAGE);
         msg.subType = RFXComUndecodedRFMessage.SubType.ARC;
         msg.seqNbr = 1;
         msg.rawPayload = HexUtils.hexToBytes("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021");
-        msg.decodeMessage();
+
+        assertThrows(RFXComMessageTooLongException.class, () -> msg.decodeMessage());
     }
 }
index 10606749cce9285f5fb66273263d32239ca6bfb3..19e1a95dfe3a4e24e0cdbab8b79500de793f1485 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -25,8 +27,9 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
 @NonNullByDefault
 public class RFXComWaterMessageTest {
 
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
-        RFXComMessageFactory.createMessage(PacketType.WATER);
+    @Test
+    public void checkNotImplemented() {
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.WATER));
     }
 }
index 9933f3b320ca0937d27ffe3e5c93132474651ab9..d3d1391d34aa1bc60cecc36b3223eb296216f7e6 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
 import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;
 
@@ -24,9 +26,10 @@ import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType
  */
 @NonNullByDefault
 public class RFXComWeightMessageTest {
-    @Test(expected = RFXComMessageNotImplementedException.class)
-    public void checkNotImplemented() throws Exception {
+    @Test
+    public void checkNotImplemented() {
         // TODO Note that this message is supported in the 1.9 binding
-        RFXComMessageFactory.createMessage(PacketType.WEIGHT);
+        assertThrows(RFXComMessageNotImplementedException.class,
+                () -> RFXComMessageFactory.createMessage(PacketType.WEIGHT));
     }
 }
index 1ac765e83fa3c2ede25c0c808165ca949dd2ba76..08cd76dd4b355576f361925f40903a2735970a52 100644 (file)
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.rfxcom.internal.messages.RFXComWindMessage.SubType.WIND1;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.core.util.HexUtils;
 
@@ -32,17 +32,17 @@ public class RFXComWindMessageTest {
         String hexMessage = "105601122F000087000000140000000079";
         byte[] message = HexUtils.hexToBytes(hexMessage);
         RFXComWindMessage msg = (RFXComWindMessage) RFXComMessageFactory.createMessage(message);
-        assertEquals("SubType", WIND1, msg.subType);
-        assertEquals("Seq Number", 18, msg.seqNbr);
-        assertEquals("Sensor Id", "12032", msg.getDeviceId());
-        assertEquals("Direction", 135.0, msg.windDirection, 0.001);
-        // assertEquals("Average speed", 0.0, msg.w9j, 0.001);
-        assertEquals("Wind Gust", 2.0, msg.windSpeed, 0.001);
-        assertEquals("Signal Level", 7, msg.signalLevel);
-        assertEquals("Battery Level", 9, msg.batteryLevel);
+        assertEquals(WIND1, msg.subType, "SubType");
+        assertEquals(18, msg.seqNbr, "Seq Number");
+        assertEquals("12032", msg.getDeviceId(), "Sensor Id");
+        assertEquals(135.0, msg.windDirection, 0.001, "Direction");
+        // assertEquals(0.0, msg.w9j, 0.001, "Average speed");
+        assertEquals(2.0, msg.windSpeed, 0.001, "Wind Gust");
+        assertEquals(7, msg.signalLevel, "Signal Level");
+        assertEquals(9, msg.batteryLevel, "Battery Level");
 
         byte[] decoded = msg.decodeMessage();
 
-        assertEquals("Message converted back", hexMessage, HexUtils.bytesToHex(decoded));
+        assertEquals(hexMessage, HexUtils.bytesToHex(decoded), "Message converted back");
     }
 }
index 14a4717ff67b66ecd91dd8fd0304f533d50e58a0..966eed34fcbb9a44902ed3e89b4dac41b37e46ac 100644 (file)
  */
 package org.openhab.binding.robonect.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
 
 import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ExecutionException;
@@ -26,10 +24,11 @@ import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.http.HttpMethod;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.robonect.internal.model.ErrorList;
 import org.openhab.binding.robonect.internal.model.MowerInfo;
 import org.openhab.binding.robonect.internal.model.Name;
@@ -38,25 +37,20 @@ import org.openhab.binding.robonect.internal.model.VersionInfo;
 /**
  * The goal of this class is to test the functionality of the RobonectClient,
  * by mocking the module responses.
- * 
+ *
  * @author Marco Meyer - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class RobonectClientTest {
 
     private RobonectClient subject;
 
-    @Mock
-    private HttpClient httpClientMock;
-
-    @Mock
-    private ContentResponse responseMock;
-
-    @Mock
-    private Request requestMock;
+    private @Mock HttpClient httpClientMock;
+    private @Mock ContentResponse responseMock;
+    private @Mock Request requestMock;
 
-    @Before
+    @BeforeEach
     public void init() {
-        MockitoAnnotations.initMocks(this);
         RobonectEndpoint dummyEndPoint = new RobonectEndpoint("123.456.789.123", null, null);
         subject = new RobonectClient(httpClientMock, dummyEndPoint);
     }
@@ -179,33 +173,33 @@ public class RobonectClientTest {
         verify(httpClientMock, times(1)).newRequest("http://123.456.789.123/json?cmd=status");
     }
 
-    @Test(expected = RobonectCommunicationException.class)
+    @Test
     public void shouldReceiveErrorAnswerOnInterruptedException()
             throws InterruptedException, ExecutionException, TimeoutException {
         when(httpClientMock.newRequest("http://123.456.789.123/json?cmd=status")).thenReturn(requestMock);
         when(requestMock.method(HttpMethod.GET)).thenReturn(requestMock);
         when(requestMock.timeout(30000L, TimeUnit.MILLISECONDS)).thenReturn(requestMock);
         when(requestMock.send()).thenThrow(new InterruptedException("Mock Interrupted Exception"));
-        MowerInfo answer = subject.getMowerInfo();
+        assertThrows(RobonectCommunicationException.class, () -> subject.getMowerInfo());
     }
 
-    @Test(expected = RobonectCommunicationException.class)
+    @Test
     public void shouldReceiveErrorAnswerOnExecutionException()
             throws InterruptedException, ExecutionException, TimeoutException {
         when(httpClientMock.newRequest("http://123.456.789.123/json?cmd=status")).thenReturn(requestMock);
         when(requestMock.method(HttpMethod.GET)).thenReturn(requestMock);
         when(requestMock.timeout(30000L, TimeUnit.MILLISECONDS)).thenReturn(requestMock);
         when(requestMock.send()).thenThrow(new ExecutionException(new Exception("Mock Exception")));
-        MowerInfo answer = subject.getMowerInfo();
+        assertThrows(RobonectCommunicationException.class, () -> subject.getMowerInfo());
     }
 
-    @Test(expected = RobonectCommunicationException.class)
+    @Test
     public void shouldReceiveErrorAnswerOnTimeoutException()
             throws InterruptedException, ExecutionException, TimeoutException {
         when(httpClientMock.newRequest("http://123.456.789.123/json?cmd=status")).thenReturn(requestMock);
         when(requestMock.method(HttpMethod.GET)).thenReturn(requestMock);
         when(requestMock.timeout(30000L, TimeUnit.MILLISECONDS)).thenReturn(requestMock);
         when(requestMock.send()).thenThrow(new TimeoutException("Mock Timeout Exception"));
-        MowerInfo answer = subject.getMowerInfo();
+        assertThrows(RobonectCommunicationException.class, () -> subject.getMowerInfo());
     }
 }
index ec6fe820c24438f31e8602baf7c0309218405cb5..e54115f6bfd38e28b350768778c5631dd8069547 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.robonect.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
@@ -21,12 +21,15 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 
 import org.eclipse.jetty.client.HttpClient;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.robonect.internal.RobonectBindingConstants;
 import org.openhab.binding.robonect.internal.RobonectClient;
 import org.openhab.binding.robonect.internal.model.ErrorEntry;
@@ -57,28 +60,20 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Marco Meyer - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class RobonectHandlerTest {
 
     private RobonectHandler subject;
 
-    @Mock
-    private Thing robonectThingMock;
+    private @Mock Thing robonectThingMock;
+    private @Mock RobonectClient robonectClientMock;
+    private @Mock ThingHandlerCallback callbackMock;
+    private @Mock HttpClient httpClientMock;
+    private @Mock TimeZoneProvider timezoneProvider;
 
-    @Mock
-    private RobonectClient robonectClientMock;
-
-    @Mock
-    private ThingHandlerCallback callbackMock;
-
-    @Mock
-    private HttpClient httpClientMock;
-
-    @Mock
-    private TimeZoneProvider timezoneProvider;
-
-    @Before
+    @BeforeEach
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         subject = new RobonectHandler(robonectThingMock, httpClientMock, timezoneProvider);
         subject.setCallback(callbackMock);
         subject.setRobonectClient(robonectClientMock);
index 83d74c82cc3fe7b1ea3fb3c5f46a592c0ba46186..00ae3ecf39bff06d420571371e352e1b8781ea2c 100644 (file)
  */
 package org.openhab.binding.robonect.internal.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.nio.charset.StandardCharsets;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * The goal of this class is to test the model parser to make sure the structures
@@ -29,7 +29,7 @@ public class ModelParserTest {
 
     private ModelParser subject;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         subject = new ModelParser();
     }
index 4f7b403140389806583989398d5838b06b73ad08..271fe644fd21bd6553229a8ba4c4ed1f27800276 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.sensibo.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
index 4ee923552c7f8cee37a97130dc6c7f3e4024591e..51536669674c1a9b146544e8ef7709666c5de7ea 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.dto;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.time.ZonedDateTime;
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sensibo.internal.dto.poddetails.AcStateDTO;
 import org.openhab.binding.sensibo.internal.dto.poddetails.MeasurementDTO;
 import org.openhab.binding.sensibo.internal.dto.poddetails.ModeCapabilityDTO;
index b37cf8a6b7de0a175ec86b3cb6d5e27d1365fd04..6cdc5f214699f140cfda501de42618be4289f088 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.dto;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sensibo.internal.dto.pods.PodDTO;
 
 import com.google.gson.reflect.TypeToken;
index f08bb4607e0c3abc6f29904fe3028e66297f5f94..638fb60052ed78e3f55f230d10ed4cac186c0a5c 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.dto;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sensibo.internal.dto.setacstateproperty.SetAcStatePropertyRequest;
 
 /**
index 64e1907d11bb5840b0da26a532a857b98dae0a39..8330f7b358535ad416ad238b42458b3f2b2db78b 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.dto;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sensibo.internal.dto.setacstateproperty.SetAcStatePropertyReponse;
 
 /**
index 506e99a80799ab2905c651c7851f952ebcf7bac5..c8c648d59d86101b4c2999bedb47f7dbfdd7b740 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.dto;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sensibo.internal.dto.poddetails.AcStateDTO;
 import org.openhab.binding.sensibo.internal.dto.settimer.SetTimerRequest;
 
index 80f5eafa5a795a9515f59d61a0ed0b4162f45d88..7e0836d34e96c62d7ff8c764bc75ab68f5d9ffca 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.handler;
 
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.Assert.assertEquals;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
@@ -25,44 +22,49 @@ import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.eclipse.jetty.client.HttpClient;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.sensibo.internal.config.SensiboAccountConfiguration;
 import org.openhab.binding.sensibo.internal.model.SensiboSky;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingUID;
 
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.client.WireMock;
 import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
 
 /**
  * @author Arne Seime - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class SensiboAccountHandlerTest {
-    @Rule
-    public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.options().dynamicPort());
-
-    @Mock
-    private Bridge sensiboAccountMock;
+    private WireMockServer wireMockServer;
 
     private HttpClient httpClient;
-    @Mock
-    private Configuration configuration;
 
-    @Before
+    private @Mock Configuration configuration;
+    private @Mock Bridge sensiboAccountMock;
+
+    @BeforeEach
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
+        wireMockServer = new WireMockServer(WireMockConfiguration.options().dynamicPort());
+        wireMockServer.start();
+
+        int port = wireMockServer.port();
+        WireMock.configureFor("localhost", port);
+
         httpClient = new HttpClient();
         httpClient.start();
-        SensiboAccountHandler.API_ENDPOINT = "http://localhost:" + wireMockRule.port() + "/api"; // https://home.sensibo.com/api/v2
+
+        SensiboAccountHandler.API_ENDPOINT = "http://localhost:" + port + "/api"; // https://home.sensibo.com/api/v2
     }
 
-    @After
+    @AfterEach
     public void shutdown() throws Exception {
         httpClient.stop();
     }
index 80e76230be4f1692b22a3a427b410626ef774df4..751a96373131527f3f9603d4c2b7b65617669006 100644 (file)
  */
 package org.openhab.binding.sensibo.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
index e5c1118d927920e4a11b131fe3a84cee101cb44a..c043d678d600e5c4cbf2b6d0e199b4cddb61bba6 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.siemensrds.test;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.siemensrds.internal.RdsBindingConstants.*;
 
 import java.io.BufferedReader;
@@ -24,7 +24,7 @@ import java.util.Map.Entry;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.siemensrds.internal.RdsAccessToken;
 import org.openhab.binding.siemensrds.internal.RdsCloudException;
 import org.openhab.binding.siemensrds.internal.RdsDataPoints;
index 15210c1ebae9eccb50b320ea871aa22d6abb4837..597301e2f342f668ed956cc62d081ed78d451938 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.sleepiq.api.impl.typeadapters;
 
 import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link LocalTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class LocalTimeTypeAdapter extends TemporalTypeAdapter<LocalTime> {
 
-  public LocalTimeTypeAdapter() {
-    super(LocalTime::parse);
-  }
+    public LocalTimeTypeAdapter() {
+        super(LocalTime::parse);
+    }
 }
index 7272f675096b56014054c185bb1a5620e1895d13..ded37fd975c9dbcd1bb53786a4f55313f9355704 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.sleepiq.api.impl.typeadapters;
 
 import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link OffsetDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter<OffsetDateTime> {
 
-  public OffsetDateTimeTypeAdapter() {
-    super(OffsetDateTime::parse);
-  }
+    public OffsetDateTimeTypeAdapter() {
+        super(OffsetDateTime::parse);
+    }
 }
index cba1326e8517cc1cb2f396f242238e252a5e0856..e6f49e783786c1585f198298eefefac3fb0d8c85 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.sleepiq.api.impl.typeadapters;
 
 import java.time.OffsetTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link OffsetTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class OffsetTimeTypeAdapter extends TemporalTypeAdapter<OffsetTime> {
 
-  public OffsetTimeTypeAdapter() {
-    super(OffsetTime::parse);
-  }
+    public OffsetTimeTypeAdapter() {
+        super(OffsetTime::parse);
+    }
 }
index c241e090944a887951955ad8e13847e9c9ca9118..dcbde82e6fcccd4372a5d60adc46b24dfd9413a7 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.impl.typeadapters;
 
+import java.io.IOException;
+import java.util.Objects;
+import java.util.function.Function;
+
 import com.google.gson.TypeAdapter;
 import com.google.gson.stream.JsonReader;
 import com.google.gson.stream.JsonToken;
 import com.google.gson.stream.JsonWriter;
 
-import java.io.IOException;
-import java.time.temporal.TemporalAccessor;
-import java.util.Objects;
-import java.util.function.Function;
-
 /**
  * Abstract type adapter for jsr310 date-time types.
  *
@@ -37,33 +36,33 @@ import java.util.function.Function;
  */
 abstract class TemporalTypeAdapter<T> extends TypeAdapter<T> {
 
-  Function<String, T> parseFunction;
+    Function<String, T> parseFunction;
 
-  TemporalTypeAdapter(Function<String, T> parseFunction) {
-    Objects.requireNonNull(parseFunction);
-    this.parseFunction = parseFunction;
-  }
+    TemporalTypeAdapter(Function<String, T> parseFunction) {
+        Objects.requireNonNull(parseFunction);
+        this.parseFunction = parseFunction;
+    }
 
-  @Override
-  public void write(JsonWriter out, T value) throws IOException {
-    if (value == null) {
-      out.nullValue();
-    } else {
-      out.value(value.toString());
+    @Override
+    public void write(JsonWriter out, T value) throws IOException {
+        if (value == null) {
+            out.nullValue();
+        } else {
+            out.value(value.toString());
+        }
     }
-  }
 
-  @Override
-  public T read(JsonReader in) throws IOException {
-    if (in.peek() == JsonToken.NULL) {
-      in.nextNull();
-      return null;
+    @Override
+    public T read(JsonReader in) throws IOException {
+        if (in.peek() == JsonToken.NULL) {
+            in.nextNull();
+            return null;
+        }
+        String temporalString = preProcess(in.nextString());
+        return parseFunction.apply(temporalString);
     }
-    String temporalString = preProcess(in.nextString());
-    return parseFunction.apply(temporalString);
-  }
 
-  public String preProcess(String in) {
-    return in;
-  }
+    public String preProcess(String in) {
+        return in;
+    }
 }
index 53402b560f49a841acfcdf6aebd1022cea0ca67b..0d31cad1a3d03daa3a36af67c6457bef0f902f82 100644 (file)
@@ -21,7 +21,6 @@
 package org.openhab.binding.sleepiq.api.impl.typeadapters;
 
 import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
 
 /**
  * Type adapter for jsr310 {@link ZonedDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
  */
 public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter<ZonedDateTime> {
 
-  public ZonedDateTimeTypeAdapter() {
-    super(ZonedDateTime::parse);
-  }
+    public ZonedDateTimeTypeAdapter() {
+        super(ZonedDateTime::parse);
+    }
 }
index 73fe4565b5b9a047d9c7f1d05e6aef3de24db4ff..796bd5aeb30efe7587442a122b967fbf025dfdce 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.BedSideStatus;
-import org.openhab.binding.sleepiq.api.model.TimeSince;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class BedSideStatusTest extends AbstractTest
-{
+public class BedSideStatusTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        BedSideStatus bedSideStatus = new BedSideStatus().withAlertDetailedMessage("No Alert")
-                                                         .withAlertId(0L)
-                                                         .withInBed(false)
-                                                         .withLastLink(new TimeSince().withDuration(3,
-                                                                                                    5,
-                                                                                                    4,
-                                                                                                    38))
-                                                         .withPressure(573)
-                                                         .withSleepNumber(55);
+    public void testSerializeAllFields() throws Exception {
+        BedSideStatus bedSideStatus = new BedSideStatus().withAlertDetailedMessage("No Alert").withAlertId(0L)
+                .withInBed(false).withLastLink(new TimeSince().withDuration(3, 5, 4, 38)).withPressure(573)
+                .withSleepNumber(55);
         assertEquals(readJson("bed-side-status.json"), gson.toJson(bedSideStatus));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("bed-side-status.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("bed-side-status.json"))) {
             BedSideStatus bedSideStatus = gson.fromJson(reader, BedSideStatus.class);
             assertEquals("No Alert", bedSideStatus.getAlertDetailedMessage());
             assertEquals(Long.valueOf(0L), bedSideStatus.getAlertId());
index 2a335d5f3909a7ac00acf51c1962a1ab52c64c13..331675ba80fcd1d6cf342770290b1fe38a6a2fad 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.BedSideStatus;
-import org.openhab.binding.sleepiq.api.model.BedStatus;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class BedStatusTest extends AbstractTest
-{
+public class BedStatusTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
+    public void testSerializeAllFields() throws Exception {
         BedStatus bedStatus = new BedStatus().withBedId("-9999999999999999999")
-                                             .withLeftSide(new BedSideStatus().withInBed(true))
-                                             .withRightSide(new BedSideStatus().withInBed(false))
-                                             .withStatus(1L);
+                .withLeftSide(new BedSideStatus().withInBed(true)).withRightSide(new BedSideStatus().withInBed(false))
+                .withStatus(1L);
         assertEquals(readJson("bed-status.json"), gson.toJson(bedStatus));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("bed-status.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("bed-status.json"))) {
             BedStatus bedStatus = gson.fromJson(reader, BedStatus.class);
             assertEquals("-9999999999999999999", bedStatus.getBedId());
             assertEquals(Long.valueOf(1L), bedStatus.getStatus());
index 386b1c3b7a85ec3db9a1cd53204328ac994d4be7..3873351011fd241464d88c4b2518fcfc1806d91e 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.FileReader;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.Bed;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class BedTest extends AbstractTest
-{
+public class BedTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        Bed bed = new Bed().withAccountId("-8888888888888888888")
-                           .withBase("MODULAR")
-                           .withBedId("-9999999999999999999")
-                           .withDualSleep(true)
-                           .withKidsBed(false)
-                           .withMacAddress("AABBCCDDEEFF")
-                           .withModel("P5")
-                           .withName("Bed")
-                           .withPurchaseDate(ZonedDateTime.of(2017,
-                                                              2,
-                                                              2,
-                                                              0,
-                                                              0,
-                                                              1,
-                                                              0,
-                                                              ZoneId.of("Z").normalized()))
-                           .withReference("55555555555-5")
-                           .withRegistrationDate(ZonedDateTime.of(2017,
-                                                                  2,
-                                                                  17,
-                                                                  2,
-                                                                  14,
-                                                                  10,
-                                                                  0,
-                                                                  ZoneId.of("Z").normalized()))
-                           .withReturnRequestStatus(0L)
-                           .withSerial("")
-                           .withSize("QUEEN")
-                           .withSku("QP5")
-                           .withSleeperLeftId("-2222222222222222222")
-                           .withSleeperRightId("-1111111111111111111")
-                           .withStatus(1L)
-                           .withTimezone("US/Pacific")
-                           .withVersion("")
-                           .withZipCode("90210");
+    public void testSerializeAllFields() throws Exception {
+        Bed bed = new Bed().withAccountId("-8888888888888888888").withBase("MODULAR").withBedId("-9999999999999999999")
+                .withDualSleep(true).withKidsBed(false).withMacAddress("AABBCCDDEEFF").withModel("P5").withName("Bed")
+                .withPurchaseDate(ZonedDateTime.of(2017, 2, 2, 0, 0, 1, 0, ZoneId.of("Z").normalized()))
+                .withReference("55555555555-5")
+                .withRegistrationDate(ZonedDateTime.of(2017, 2, 17, 2, 14, 10, 0, ZoneId.of("Z").normalized()))
+                .withReturnRequestStatus(0L).withSerial("").withSize("QUEEN").withSku("QP5")
+                .withSleeperLeftId("-2222222222222222222").withSleeperRightId("-1111111111111111111").withStatus(1L)
+                .withTimezone("US/Pacific").withVersion("").withZipCode("90210");
         assertEquals(readJson("bed.json"), gson.toJson(bed));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("bed.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("bed.json"))) {
             Bed bed = gson.fromJson(reader, Bed.class);
             assertEquals("-8888888888888888888", bed.getAccountId());
             assertEquals("MODULAR", bed.getBase());
@@ -94,11 +61,10 @@ public class BedTest extends AbstractTest
             assertEquals("AABBCCDDEEFF", bed.getMacAddress());
             assertEquals("P5", bed.getModel());
             assertEquals("Bed", bed.getName());
-            assertEquals(ZonedDateTime.of(2017, 2, 2, 0, 0, 1, 0, ZoneId.of("Z").normalized()),
-                         bed.getPurchaseDate());
+            assertEquals(ZonedDateTime.of(2017, 2, 2, 0, 0, 1, 0, ZoneId.of("Z").normalized()), bed.getPurchaseDate());
             assertEquals("55555555555-5", bed.getReference());
             assertEquals(ZonedDateTime.of(2017, 2, 17, 2, 14, 10, 0, ZoneId.of("Z").normalized()),
-                         bed.getRegistrationDate());
+                    bed.getRegistrationDate());
             assertEquals(Long.valueOf(0L), bed.getReturnRequestStatus());
             assertEquals("", bed.getSerial());
             assertEquals("QUEEN", bed.getSize());
index 91b760b5cd057ce01f0571245452f64e4d50172c..5a1f6c4074f7d9f2bee007610b2b137a24fc398f 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.Bed;
-import org.openhab.binding.sleepiq.api.model.BedsResponse;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class BedsResponseTest extends AbstractTest
-{
+public class BedsResponseTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        BedsResponse bedsResponse = new BedsResponse().withBeds(Arrays.asList(new Bed().withName("Bed1"),
-                                                                              new Bed().withName("Bed2")));
+    public void testSerializeAllFields() throws Exception {
+        BedsResponse bedsResponse = new BedsResponse()
+                .withBeds(Arrays.asList(new Bed().withName("Bed1"), new Bed().withName("Bed2")));
         assertEquals(readJson("beds-response.json"), gson.toJson(bedsResponse));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("beds-response.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("beds-response.json"))) {
             BedsResponse bedsResponse = gson.fromJson(reader, BedsResponse.class);
 
             List<Bed> beds = bedsResponse.getBeds();
index 425e713d59535d0e2cddb0f9c7ffbb9814770274..2fa2016938b8aacadd5a8de589db7812614df333 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.BedStatus;
-import org.openhab.binding.sleepiq.api.model.FamilyStatus;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class FamilyStatusTest extends AbstractTest
-{
+public class FamilyStatusTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
+    public void testSerializeAllFields() throws Exception {
         FamilyStatus familyStatus = new FamilyStatus().withBeds(Arrays.asList(new BedStatus().withStatus(1L)));
         assertEquals(readJson("family-status.json"), gson.toJson(familyStatus));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("family-status.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("family-status.json"))) {
             FamilyStatus familyStatus = gson.fromJson(reader, FamilyStatus.class);
 
             List<BedStatus> beds = familyStatus.getBeds();
index c565b6e76519271fe6482784b51a28797f4f3e1b..d36bd3acc8b3c53eb419b2d804497f2754fc23cf 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.PauseMode;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class PauseModeTest extends AbstractTest
-{
+public class PauseModeTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        PauseMode pauseMode = new PauseMode().withAccountId("-8888888888888888888")
-                                             .withBedId("-9999999999999999999")
-                                             .withPauseMode("off");
+    public void testSerializeAllFields() throws Exception {
+        PauseMode pauseMode = new PauseMode().withAccountId("-8888888888888888888").withBedId("-9999999999999999999")
+                .withPauseMode("off");
         assertEquals(readJson("pause-mode.json"), gson.toJson(pauseMode));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("pause-mode.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("pause-mode.json"))) {
             PauseMode pauseMode = gson.fromJson(reader, PauseMode.class);
             assertEquals("-8888888888888888888", pauseMode.getAccountId());
             assertEquals("-9999999999999999999", pauseMode.getBedId());
index 9cf37252cef114625c0fab5149c282d720463cee..8b184b6c39b56cdf2965203850f393add899ec32 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.FileReader;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.Sleeper;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class SleeperTest extends AbstractTest
-{
+public class SleeperTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        Sleeper sleeper = new Sleeper().withAccountId("-5555555555555555555")
-                                       .withAccountOwner(true)
-                                       .withActive(true)
-                                       .withAvatar("")
-                                       .withBedId("-9999999999999999999")
-                                       .withBirthMonth(6)
-                                       .withBirthYear("1970")
-                                       .withChild(false)
-                                       .withDuration("")
-                                       .withEmail("alice@domain.com")
-                                       .withEmailValidated(true)
-                                       .withFirstName("Alice")
-                                       .withHeight(64)
-                                       .withLastLogin("2017-02-17 20:19:36 CST")
-                                       .withLicenseVersion(6L)
-                                       .withMale(false)
-                                       .withSide(1)
-                                       .withSleeperId("-1111111111111111111")
-                                       .withSleepGoal(450)
-                                       .withTimezone("US/Pacific")
-                                       .withUsername("alice@domain.com")
-                                       .withWeight(110)
-                                       .withZipCode("90210");
+    public void testSerializeAllFields() throws Exception {
+        Sleeper sleeper = new Sleeper().withAccountId("-5555555555555555555").withAccountOwner(true).withActive(true)
+                .withAvatar("").withBedId("-9999999999999999999").withBirthMonth(6).withBirthYear("1970")
+                .withChild(false).withDuration("").withEmail("alice@domain.com").withEmailValidated(true)
+                .withFirstName("Alice").withHeight(64).withLastLogin("2017-02-17 20:19:36 CST").withLicenseVersion(6L)
+                .withMale(false).withSide(1).withSleeperId("-1111111111111111111").withSleepGoal(450)
+                .withTimezone("US/Pacific").withUsername("alice@domain.com").withWeight(110).withZipCode("90210");
         assertEquals(readJson("sleeper.json"), gson.toJson(sleeper));
     }
 
     @Test
-    public void testSerializeLastLoginNull() throws Exception
-    {
+    public void testSerializeLastLoginNull() throws Exception {
         Sleeper sleeper = new Sleeper().withLastLogin("null");
         assertEquals(readJson("sleeper-lastlogin-null.json"), gson.toJson(sleeper));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("sleeper.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("sleeper.json"))) {
             Sleeper sleeper = gson.fromJson(reader, Sleeper.class);
             assertEquals("-5555555555555555555", sleeper.getAccountId());
             assertEquals(true, sleeper.isAccountOwner());
@@ -106,10 +82,8 @@ public class SleeperTest extends AbstractTest
     }
 
     @Test
-    public void testDeserializeLastLoginNull() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("sleeper-lastlogin-null.json")))
-        {
+    public void testDeserializeLastLoginNull() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("sleeper-lastlogin-null.json"))) {
             Sleeper sleeper = gson.fromJson(reader, Sleeper.class);
             assertEquals("null", sleeper.getLastLogin());
         }
index 62969c79367cdfb5e4bbc079e7ceb71a0200c0e1..118a24a4ccb43748d379755346c00a0cf5244f35 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.FileReader;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.sleepiq.api.impl.GsonGenerator;
-import org.openhab.binding.sleepiq.api.model.Sleeper;
-import org.openhab.binding.sleepiq.api.model.SleepersResponse;
 import org.openhab.binding.sleepiq.api.test.AbstractTest;
 
 import com.google.gson.Gson;
 
-public class SleepersResponseTest extends AbstractTest
-{
+public class SleepersResponseTest extends AbstractTest {
     private static Gson gson;
 
-    @BeforeClass
-    public static void setUpBeforeClass()
-    {
+    @BeforeAll
+    public static void setUpBeforeClass() {
         gson = GsonGenerator.create(true);
     }
 
     @Test
-    public void testSerializeAllFields() throws Exception
-    {
-        SleepersResponse sleepersResponse = new SleepersResponse().withSleepers(Arrays.asList(new Sleeper().withFirstName("Alice"),
-                                                                                              new Sleeper().withFirstName("Bob")));
+    public void testSerializeAllFields() throws Exception {
+        SleepersResponse sleepersResponse = new SleepersResponse()
+                .withSleepers(Arrays.asList(new Sleeper().withFirstName("Alice"), new Sleeper().withFirstName("Bob")));
         assertEquals(readJson("sleepers-response.json"), gson.toJson(sleepersResponse));
     }
 
     @Test
-    public void testDeserializeAllFields() throws Exception
-    {
-        try (FileReader reader = new FileReader(getTestDataFile("sleepers-response.json")))
-        {
+    public void testDeserializeAllFields() throws Exception {
+        try (FileReader reader = new FileReader(getTestDataFile("sleepers-response.json"))) {
             SleepersResponse sleepersResponse = gson.fromJson(reader, SleepersResponse.class);
 
             List<Sleeper> sleepers = sleepersResponse.getSleepers();
index 54c658cb5fbc75be447ebab5a78bc820a30150ed..3e5d3d14be03122fcf4005ad4a42f38d0a3a43c1 100644 (file)
  */
 package org.openhab.binding.sleepiq.api.model;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.time.Duration;
 
-import org.junit.Test;
-import org.openhab.binding.sleepiq.api.model.TimeSince;
+import org.junit.jupiter.api.Test;
 
-public class TimeSinceTest
-{
+public class TimeSinceTest {
     @Test
-    public void testWithDuration()
-    {
+    public void testWithDuration() {
         assertEquals(new TimeSince().withDuration(0, 0, 0, 0).getDuration(),
-                     new TimeSince().withDuration(Duration.parse("PT00H00M00S")).getDuration());
+                new TimeSince().withDuration(Duration.parse("PT00H00M00S")).getDuration());
         assertEquals(new TimeSince().withDuration(0, 2, 3, 4).getDuration(),
-                     new TimeSince().withDuration(Duration.parse("PT02H03M04S")).getDuration());
+                new TimeSince().withDuration(Duration.parse("PT02H03M04S")).getDuration());
         assertEquals(new TimeSince().withDuration(0, 12, 34, 56).getDuration(),
-                     new TimeSince().withDuration(Duration.parse("PT12H34M56S")).getDuration());
+                new TimeSince().withDuration(Duration.parse("PT12H34M56S")).getDuration());
         assertEquals(new TimeSince().withDuration(1, 2, 3, 4).getDuration(),
-                     new TimeSince().withDuration(Duration.parse("P1DT02H03M04S")).getDuration());
+                new TimeSince().withDuration(Duration.parse("P1DT02H03M04S")).getDuration());
         assertEquals(new TimeSince().withDuration(12, 23, 34, 45).getDuration(),
-                     new TimeSince().withDuration(Duration.parse("P12DT23H34M45S")).getDuration());
+                new TimeSince().withDuration(Duration.parse("P12DT23H34M45S")).getDuration());
     }
 
     @Test
-    public void testToString()
-    {
-        assertEquals("00:00:00",
-                     new TimeSince().withDuration(Duration.parse("PT00H00M00S")).toString());
-        assertEquals("02:03:04",
-                     new TimeSince().withDuration(Duration.parse("PT02H03M04S")).toString());
-        assertEquals("12:34:56",
-                     new TimeSince().withDuration(Duration.parse("PT12H34M56S")).toString());
-        assertEquals("1 d 02:03:04",
-                     new TimeSince().withDuration(Duration.parse("P1DT02H03M04S")).toString());
-        assertEquals("12 d 23:34:45",
-                     new TimeSince().withDuration(Duration.parse("P12DT23H34M45S")).toString());
+    public void testToString() {
+        assertEquals("00:00:00", new TimeSince().withDuration(Duration.parse("PT00H00M00S")).toString());
+        assertEquals("02:03:04", new TimeSince().withDuration(Duration.parse("PT02H03M04S")).toString());
+        assertEquals("12:34:56", new TimeSince().withDuration(Duration.parse("PT12H34M56S")).toString());
+        assertEquals("1 d 02:03:04", new TimeSince().withDuration(Duration.parse("P1DT02H03M04S")).toString());
+        assertEquals("12 d 23:34:45", new TimeSince().withDuration(Duration.parse("P12DT23H34M45S")).toString());
     }
 
     @Test
-    public void testParse()
-    {
+    public void testParse() {
         assertEquals(Duration.parse("PT00H00M00S"), TimeSince.parse("00:00:00").getDuration());
         assertEquals(Duration.parse("PT2H3M4S"), TimeSince.parse("02:03:04").getDuration());
         assertEquals(Duration.parse("PT12H34M56S"), TimeSince.parse("12:34:56").getDuration());
         assertEquals(Duration.parse("P1DT2H3M4S"), TimeSince.parse("1 d 02:03:04").getDuration());
-        assertEquals(Duration.parse("P12DT23H34M45S"),
-                     TimeSince.parse("12 d 23:34:45").getDuration());
+        assertEquals(Duration.parse("P12DT23H34M45S"), TimeSince.parse("12 d 23:34:45").getDuration());
     }
 }
index f22a5c05e936002265ad7880635ecd16781c1dc5..e91439307c03bda75ee723af5e14b89d451243f7 100644 (file)
@@ -24,7 +24,7 @@ import java.util.function.Supplier;
 import javax.measure.Quantity;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 import org.openhab.binding.smartmeter.connectors.ConnectorBase;
index 5e5f6e3ecf2c6d3922d5557c7588cb2656079da2..de4f3064861d68030492b498160bef6ed1ece2c6 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.binding.smartmeter;
 
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.smartmeter.internal.MeterValue;
 import org.openhab.binding.smartmeter.internal.conformity.negate.NegateBitModel;
 import org.openhab.binding.smartmeter.internal.conformity.negate.NegateBitParser;
@@ -30,9 +31,9 @@ public class TestNegateBit {
     public void testNegateBitParsing() {
         String negateProperty = "1-0_1-8-0:5:1";
         NegateBitModel parseNegateProperty = NegateBitParser.parseNegateProperty(negateProperty);
-        Assert.assertEquals("1-0_1-8-0", parseNegateProperty.getNegateChannelId());
-        Assert.assertEquals(5, parseNegateProperty.getNegatePosition());
-        Assert.assertEquals(true, parseNegateProperty.isNegateBit());
+        assertEquals("1-0_1-8-0", parseNegateProperty.getNegateChannelId());
+        assertEquals(5, parseNegateProperty.getNegatePosition());
+        assertEquals(true, parseNegateProperty.isNegateBit());
     }
 
     @Test
@@ -43,7 +44,7 @@ public class TestNegateBit {
             return new MeterValue<>(obis, "65954", null);
         });
 
-        Assert.assertTrue(negateState);
+        assertTrue(negateState);
     }
 
     @Test
@@ -54,6 +55,6 @@ public class TestNegateBit {
             return new MeterValue<>(obis, "0", null, "65922");
         });
 
-        Assert.assertFalse(negateState);
+        assertFalse(negateState);
     }
 }
index 08f86c673c65808d6705f7bb7c158748c4f4f29b..883dbc069606bb1ee95d38055ed58666a3ac5596 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.snmp.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.snmp.internal.SnmpBindingConstants.THING_TYPE_TARGET;
index 2e772d589bc7669702722b91614cdd5bc703648d..ec500d79dce181cb9a4e95fa2d0125fccf8b88cb 100644 (file)
  */
 package org.openhab.binding.snmp.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.util.Collections;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
index 39324dea9ddee0677198e59c565d40fce98cb3b7..89dac6c4956b63feaa2b7f2c10eca09ca86b4bbf 100644 (file)
  */
 package org.openhab.binding.snmp.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.util.Collections;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.StringType;
 import org.snmp4j.PDU;
index 4693bb4ebd31fc8d481a70302399d5847cc4fdd4..4ac15b5b8c30d32ab79e2d6086d9f305680716cb 100644 (file)
  */
 package org.openhab.binding.snmp.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.util.Collections;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.UnDefType;
 import org.snmp4j.PDU;
index 72ba81af646c91ad0ecdf8a240a6b2acce47ec12..9474bf485a05c5160a047900924908e5f0f6a104 100644 (file)
  */
 package org.openhab.binding.teleinfo.internal.reader.io;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 import java.io.FileInputStream;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.teleinfo.internal.dto.Frame;
 import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
 import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
@@ -42,22 +43,22 @@ public class TeleinfoInputStreamTest {
                 new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")))) {
             Frame frame = in.readNextFrame();
 
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbetmLongBaseOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbetmLongBaseOption.class, frame.getClass());
             FrameCbetmLongBaseOption frameCbetmLongBaseOption = (FrameCbetmLongBaseOption) frame;
-            Assert.assertEquals("XXXXXXXXXXXX", frameCbetmLongBaseOption.getAdco());
-            Assert.assertEquals(20, frameCbetmLongBaseOption.getIsousc());
-            Assert.assertEquals(1181243, frameCbetmLongBaseOption.getBase());
-            Assert.assertEquals(Ptec.TH, frameCbetmLongBaseOption.getPtec());
-            Assert.assertEquals(0, frameCbetmLongBaseOption.getIinst1());
-            Assert.assertEquals(2, frameCbetmLongBaseOption.getIinst2());
-            Assert.assertEquals(0, frameCbetmLongBaseOption.getIinst3());
-            Assert.assertEquals(26, frameCbetmLongBaseOption.getImax1().intValue());
-            Assert.assertEquals(18, frameCbetmLongBaseOption.getImax2().intValue());
-            Assert.assertEquals(27, frameCbetmLongBaseOption.getImax3().intValue());
-            Assert.assertEquals(7990, frameCbetmLongBaseOption.getPmax());
-            Assert.assertEquals(540, frameCbetmLongBaseOption.getPapp());
-            Assert.assertEquals("00", frameCbetmLongBaseOption.getPpot());
+            assertEquals("XXXXXXXXXXXX", frameCbetmLongBaseOption.getAdco());
+            assertEquals(20, frameCbetmLongBaseOption.getIsousc());
+            assertEquals(1181243, frameCbetmLongBaseOption.getBase());
+            assertEquals(Ptec.TH, frameCbetmLongBaseOption.getPtec());
+            assertEquals(0, frameCbetmLongBaseOption.getIinst1());
+            assertEquals(2, frameCbetmLongBaseOption.getIinst2());
+            assertEquals(0, frameCbetmLongBaseOption.getIinst3());
+            assertEquals(26, frameCbetmLongBaseOption.getImax1().intValue());
+            assertEquals(18, frameCbetmLongBaseOption.getImax2().intValue());
+            assertEquals(27, frameCbetmLongBaseOption.getImax3().intValue());
+            assertEquals(7990, frameCbetmLongBaseOption.getPmax());
+            assertEquals(540, frameCbetmLongBaseOption.getPapp());
+            assertEquals("00", frameCbetmLongBaseOption.getPpot());
         }
     }
 
@@ -67,19 +68,19 @@ public class TeleinfoInputStreamTest {
                 new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")))) {
             Frame frame = in.readNextFrame();
 
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbemmEvolutionIccHcOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbemmEvolutionIccHcOption.class, frame.getClass());
             FrameCbemmEvolutionIccHcOption frameCbemmEvolutionIccHcOption = (FrameCbemmEvolutionIccHcOption) frame;
-            Assert.assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccHcOption.getAdco());
-            Assert.assertEquals(30, frameCbemmEvolutionIccHcOption.getIsousc());
-            Assert.assertEquals(6906827, frameCbemmEvolutionIccHcOption.getHchc());
-            Assert.assertEquals(7617931, frameCbemmEvolutionIccHcOption.getHchp());
-            Assert.assertEquals(Ptec.HP, frameCbemmEvolutionIccHcOption.getPtec());
-            Assert.assertEquals(3, frameCbemmEvolutionIccHcOption.getIinst());
-            Assert.assertEquals(44, frameCbemmEvolutionIccHcOption.getImax().intValue());
-            Assert.assertEquals(680, frameCbemmEvolutionIccHcOption.getPapp());
-            Assert.assertNull(frameCbemmEvolutionIccHcOption.getAdps());
-            Assert.assertEquals(Hhphc.A, frameCbemmEvolutionIccHcOption.getHhphc());
+            assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccHcOption.getAdco());
+            assertEquals(30, frameCbemmEvolutionIccHcOption.getIsousc());
+            assertEquals(6906827, frameCbemmEvolutionIccHcOption.getHchc());
+            assertEquals(7617931, frameCbemmEvolutionIccHcOption.getHchp());
+            assertEquals(Ptec.HP, frameCbemmEvolutionIccHcOption.getPtec());
+            assertEquals(3, frameCbemmEvolutionIccHcOption.getIinst());
+            assertEquals(44, frameCbemmEvolutionIccHcOption.getImax().intValue());
+            assertEquals(680, frameCbemmEvolutionIccHcOption.getPapp());
+            assertNull(frameCbemmEvolutionIccHcOption.getAdps());
+            assertEquals(Hhphc.A, frameCbemmEvolutionIccHcOption.getHhphc());
         }
     }
 
@@ -89,24 +90,24 @@ public class TeleinfoInputStreamTest {
                 new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")))) {
             Frame frame = in.readNextFrame();
 
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbetmLongEjpOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbetmLongEjpOption.class, frame.getClass());
             FrameCbetmLongEjpOption frameCbetmLongEjpOption = (FrameCbetmLongEjpOption) frame;
-            Assert.assertEquals("XXXXXXXXXX", frameCbetmLongEjpOption.getAdco());
-            Assert.assertEquals(30, frameCbetmLongEjpOption.getIsousc());
-            Assert.assertEquals(1111111, frameCbetmLongEjpOption.getEjphn());
-            Assert.assertEquals(2222222, frameCbetmLongEjpOption.getEjphpm());
-            Assert.assertNull(frameCbetmLongEjpOption.getPejp());
-            Assert.assertEquals(Ptec.HN, frameCbetmLongEjpOption.getPtec());
-            Assert.assertEquals(10, frameCbetmLongEjpOption.getIinst1());
-            Assert.assertEquals(5, frameCbetmLongEjpOption.getIinst2());
-            Assert.assertEquals(8, frameCbetmLongEjpOption.getIinst3());
-            Assert.assertEquals(38, frameCbetmLongEjpOption.getImax1().intValue());
-            Assert.assertEquals(42, frameCbetmLongEjpOption.getImax2().intValue());
-            Assert.assertEquals(44, frameCbetmLongEjpOption.getImax3().intValue());
-            Assert.assertEquals(17480, frameCbetmLongEjpOption.getPmax());
-            Assert.assertEquals(5800, frameCbetmLongEjpOption.getPapp());
-            Assert.assertEquals("00", frameCbetmLongEjpOption.getPpot());
+            assertEquals("XXXXXXXXXX", frameCbetmLongEjpOption.getAdco());
+            assertEquals(30, frameCbetmLongEjpOption.getIsousc());
+            assertEquals(1111111, frameCbetmLongEjpOption.getEjphn());
+            assertEquals(2222222, frameCbetmLongEjpOption.getEjphpm());
+            assertNull(frameCbetmLongEjpOption.getPejp());
+            assertEquals(Ptec.HN, frameCbetmLongEjpOption.getPtec());
+            assertEquals(10, frameCbetmLongEjpOption.getIinst1());
+            assertEquals(5, frameCbetmLongEjpOption.getIinst2());
+            assertEquals(8, frameCbetmLongEjpOption.getIinst3());
+            assertEquals(38, frameCbetmLongEjpOption.getImax1().intValue());
+            assertEquals(42, frameCbetmLongEjpOption.getImax2().intValue());
+            assertEquals(44, frameCbetmLongEjpOption.getImax3().intValue());
+            assertEquals(17480, frameCbetmLongEjpOption.getPmax());
+            assertEquals(5800, frameCbetmLongEjpOption.getPapp());
+            assertEquals("00", frameCbetmLongEjpOption.getPpot());
         }
     }
 
@@ -116,26 +117,26 @@ public class TeleinfoInputStreamTest {
                 new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")))) {
             Frame frame = in.readNextFrame();
 
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbemmEvolutionIccTempoOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbemmEvolutionIccTempoOption.class, frame.getClass());
             FrameCbemmEvolutionIccTempoOption frameCbemmEvolutionIccTempoOption = (FrameCbemmEvolutionIccTempoOption) frame;
-            Assert.assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccTempoOption.getAdco());
-            Assert.assertEquals(45, frameCbemmEvolutionIccTempoOption.getIsousc());
-            Assert.assertEquals(2697099, frameCbemmEvolutionIccTempoOption.getBbrhcjb());
-            Assert.assertEquals(3494559, frameCbemmEvolutionIccTempoOption.getBbrhpjb());
-            Assert.assertEquals(41241, frameCbemmEvolutionIccTempoOption.getBbrhcjw());
-            Assert.assertEquals(194168, frameCbemmEvolutionIccTempoOption.getBbrhpjw());
-            Assert.assertEquals(0, frameCbemmEvolutionIccTempoOption.getBbrhcjr());
-            Assert.assertEquals(89736, frameCbemmEvolutionIccTempoOption.getBbrhpjr());
-            Assert.assertEquals(Ptec.HPJR, frameCbemmEvolutionIccTempoOption.getPtec());
-            Assert.assertNull(frameCbemmEvolutionIccTempoOption.getDemain());
-            Assert.assertEquals(3, frameCbemmEvolutionIccTempoOption.getIinst());
-            Assert.assertEquals(37, frameCbemmEvolutionIccTempoOption.getImax().intValue());
-            Assert.assertEquals(620, frameCbemmEvolutionIccTempoOption.getPapp());
-            Assert.assertNull(frameCbemmEvolutionIccTempoOption.getAdps());
-            Assert.assertEquals(Hhphc.Y, frameCbemmEvolutionIccTempoOption.getHhphc());
-            Assert.assertEquals(ProgrammeCircuit1.B, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit1());
-            Assert.assertEquals(ProgrammeCircuit2.P2, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit2());
+            assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccTempoOption.getAdco());
+            assertEquals(45, frameCbemmEvolutionIccTempoOption.getIsousc());
+            assertEquals(2697099, frameCbemmEvolutionIccTempoOption.getBbrhcjb());
+            assertEquals(3494559, frameCbemmEvolutionIccTempoOption.getBbrhpjb());
+            assertEquals(41241, frameCbemmEvolutionIccTempoOption.getBbrhcjw());
+            assertEquals(194168, frameCbemmEvolutionIccTempoOption.getBbrhpjw());
+            assertEquals(0, frameCbemmEvolutionIccTempoOption.getBbrhcjr());
+            assertEquals(89736, frameCbemmEvolutionIccTempoOption.getBbrhpjr());
+            assertEquals(Ptec.HPJR, frameCbemmEvolutionIccTempoOption.getPtec());
+            assertNull(frameCbemmEvolutionIccTempoOption.getDemain());
+            assertEquals(3, frameCbemmEvolutionIccTempoOption.getIinst());
+            assertEquals(37, frameCbemmEvolutionIccTempoOption.getImax().intValue());
+            assertEquals(620, frameCbemmEvolutionIccTempoOption.getPapp());
+            assertNull(frameCbemmEvolutionIccTempoOption.getAdps());
+            assertEquals(Hhphc.Y, frameCbemmEvolutionIccTempoOption.getHhphc());
+            assertEquals(ProgrammeCircuit1.B, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit1());
+            assertEquals(ProgrammeCircuit2.P2, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit2());
         }
     }
 
@@ -144,17 +145,17 @@ public class TeleinfoInputStreamTest {
         try (TeleinfoInputStream in = new TeleinfoInputStream(
                 new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")))) {
             Frame frame = in.readNextFrame();
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
             FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
-            Assert.assertEquals("031762120162", frameCbemmEvolutionIccBaseOption.getAdco());
-            Assert.assertEquals(30, frameCbemmEvolutionIccBaseOption.getIsousc());
-            Assert.assertEquals(190575, frameCbemmEvolutionIccBaseOption.getBase());
-            Assert.assertEquals(Ptec.TH, frameCbemmEvolutionIccBaseOption.getPtec());
-            Assert.assertEquals(1, frameCbemmEvolutionIccBaseOption.getIinst());
-            Assert.assertEquals(90, frameCbemmEvolutionIccBaseOption.getImax().intValue());
-            Assert.assertEquals(270, frameCbemmEvolutionIccBaseOption.getPapp());
-            Assert.assertNull(frameCbemmEvolutionIccBaseOption.getAdps());
+            assertEquals("031762120162", frameCbemmEvolutionIccBaseOption.getAdco());
+            assertEquals(30, frameCbemmEvolutionIccBaseOption.getIsousc());
+            assertEquals(190575, frameCbemmEvolutionIccBaseOption.getBase());
+            assertEquals(Ptec.TH, frameCbemmEvolutionIccBaseOption.getPtec());
+            assertEquals(1, frameCbemmEvolutionIccBaseOption.getIinst());
+            assertEquals(90, frameCbemmEvolutionIccBaseOption.getImax().intValue());
+            assertEquals(270, frameCbemmEvolutionIccBaseOption.getPapp());
+            assertNull(frameCbemmEvolutionIccBaseOption.getAdps());
         }
     }
 
@@ -164,10 +165,10 @@ public class TeleinfoInputStreamTest {
                 new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), true)) {
             Frame frame = in.readNextFrame();
 
-            Assert.assertNotNull(frame);
-            Assert.assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
+            assertNotNull(frame);
+            assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
             FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
-            Assert.assertEquals(37, frameCbemmEvolutionIccBaseOption.getAdps().intValue());
+            assertEquals(37, frameCbemmEvolutionIccBaseOption.getAdps().intValue());
         }
     }
 }
index b08bf56a1b97ba9e8f06e9673f62f317899f288e..fe37a448d66c028465e58ad30da821a3be4b4738 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for {@link CryptUtil} class.
@@ -30,13 +30,13 @@ public class CryptUtilTest {
 
     /**
      * Test round trip of encrypt and decrypt that should return the same value.
-     * 
+     *
      * @throws IOException exception in case device not reachable
      */
     @Test
     public void testCrypt() throws IOException {
-        assertEquals("Crypting should result in same string", TEST_STRING,
-                CryptUtil.decrypt(CryptUtil.encrypt(TEST_STRING), TEST_STRING.length()));
+        assertEquals(TEST_STRING, CryptUtil.decrypt(CryptUtil.encrypt(TEST_STRING), TEST_STRING.length()),
+                "Crypting should result in same string");
     }
 
     /**
@@ -47,7 +47,7 @@ public class CryptUtilTest {
     @Test
     public void testCryptWithLength() throws IOException {
         try (final ByteArrayInputStream is = new ByteArrayInputStream(CryptUtil.encryptWithLength(TEST_STRING))) {
-            assertEquals("Crypting should result in same string", TEST_STRING, CryptUtil.decryptWithLength(is));
+            assertEquals(TEST_STRING, CryptUtil.decryptWithLength(is), "Crypting should result in same string");
         }
     }
 }
index fa7f3e5eb24a1911c4e146448c54025596418892..01fdb29ea73c9bf8fae1475b6158764b2542b80e 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.tplinksmarthome.internal.model.GetSysinfo;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 
@@ -65,8 +65,8 @@ public class PropertiesCollectorTest {
         final Map<String, Object> props = PropertiesCollector.collectProperties(thingType, "localhost",
                 ModelTestUtil.jsonFromFile(responseFile, GetSysinfo.class).getSysinfo());
 
-        assertEquals("Number of properties not as expected for properties: " + props, expectedSize, props.size());
+        assertEquals(expectedSize, props.size(), "Number of properties not as expected for properties: " + props);
         props.entrySet().stream().forEach(
-                entry -> assertNotNull("Property '" + entry.getKey() + "' should not be null", entry.getValue()));
+                entry -> assertNotNull(entry.getValue(), "Property '" + entry.getKey() + "' should not be null"));
     }
 }
index d4528ed506927a19968fe338bf0c751bb5e43c8f..165c8d59a95a28d316a85b593e413fa1e7e883f1 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.IOException;
 import java.net.DatagramPacket;
@@ -25,14 +24,13 @@ import java.net.SocketTimeoutException;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.stubbing.Answer;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 import org.openhab.core.config.discovery.DiscoveryListener;
@@ -43,36 +41,22 @@ import org.openhab.core.config.discovery.DiscoveryResult;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(value = Parameterized.class)
+@ExtendWith(MockitoExtension.class)
 public class TPLinkSmartHomeDiscoveryServiceTest {
 
     private static final List<Object[]> TESTS = Arrays.asList(
             new Object[][] { { "bulb_get_sysinfo_response_on", 11 }, { "rangeextender_get_sysinfo_response", 11 } });
 
-    @Mock
-    private DatagramSocket discoverSocket;
-
-    @Mock
-    private DiscoveryListener discoveryListener;
+    private @Mock DatagramSocket discoverSocket;
+    private @Mock DiscoveryListener discoveryListener;
 
     private TPLinkSmartHomeDiscoveryService discoveryService;
 
-    private final String filename;
-    private final int propertiesSize;
-
-    public TPLinkSmartHomeDiscoveryServiceTest(String filename, int propertiesSize) {
-        this.filename = filename;
-        this.propertiesSize = propertiesSize;
-    }
-
-    @Parameters(name = "{0}")
     public static List<Object[]> data() {
         return TESTS;
     }
 
-    @Before
-    public void setUp() throws IOException {
-        initMocks(this);
+    public void setUp(String filename) throws IOException {
         discoveryService = new TPLinkSmartHomeDiscoveryService() {
             @Override
             protected DatagramSocket sendDiscoveryPacket() throws IOException {
@@ -98,16 +82,20 @@ public class TPLinkSmartHomeDiscoveryServiceTest {
 
     /**
      * Test if startScan method finds a device with expected properties.
+     *
+     * @throws IOException
      */
-    @Test
-    public void testScan() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testScan(String filename, int propertiesSize) throws IOException {
+        setUp(filename);
         discoveryService.startScan();
         ArgumentCaptor<DiscoveryResult> discoveryResultCaptor = ArgumentCaptor.forClass(DiscoveryResult.class);
         verify(discoveryListener).thingDiscovered(any(), discoveryResultCaptor.capture());
         DiscoveryResult discoveryResult = discoveryResultCaptor.getValue();
-        assertEquals("Check if correct binding id found", TPLinkSmartHomeBindingConstants.BINDING_ID,
-                discoveryResult.getBindingId());
-        assertEquals("Check if expected number of properties found", propertiesSize,
-                discoveryResult.getProperties().size());
+        assertEquals(TPLinkSmartHomeBindingConstants.BINDING_ID, discoveryResult.getBindingId(),
+                "Check if correct binding id found");
+        assertEquals(propertiesSize, discoveryResult.getProperties().size(),
+                "Check if expected number of properties found");
     }
 }
index 5937a3adf1e5bc360476b2747f7b57ae1dd85ecf..5e9ebcb905c62fca84c94c678804cfe88ede2888 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.lang.reflect.Field;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.binding.tplinksmarthome.internal.device.BulbDevice;
 import org.openhab.binding.tplinksmarthome.internal.device.DimmerDevice;
 import org.openhab.binding.tplinksmarthome.internal.device.EnergySwitchDevice;
@@ -41,7 +39,7 @@ import org.openhab.core.thing.ThingTypeUID;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(value = Parameterized.class)
+@ExtendWith(MockitoExtension.class)
 public class TPLinkSmartHomeHandlerFactoryTest {
 
     private static final String SMART_HOME_DEVICE_FIELD = "smartHomeDevice";
@@ -67,42 +65,28 @@ public class TPLinkSmartHomeHandlerFactoryTest {
     });
     // @formatter:on
 
-    @Mock
-    Thing thing;
+    private @Mock Thing thing;
 
-    private final String name;
-    private final Class<?> clazz;
-
-    public TPLinkSmartHomeHandlerFactoryTest(String name, Class<?> clazz) {
-        this.name = name;
-        this.clazz = clazz;
-    }
-
-    @Parameters(name = "{0} - {1}")
     public static List<Object[]> data() {
         return TESTS;
     }
 
-    @Before
-    public void setUp() {
-        initMocks(this);
-    }
-
-    @Test
-    public void testCorrectClass()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testCorrectClass(String name, Class<?> clazz)
             throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
         when(thing.getThingTypeUID()).thenReturn(new ThingTypeUID(TPLinkSmartHomeBindingConstants.BINDING_ID, name));
         SmartHomeHandler handler = (SmartHomeHandler) factory.createHandler(thing);
 
         if (clazz == null) {
-            assertNull(name + " should not return any handler but null", handler);
+            assertNull(handler, name + " should not return any handler but null");
         } else {
-            assertNotNull(name + " should no return null handler", handler);
+            assertNotNull(handler, name + " should no return null handler");
             Field smartHomeDeviceField = SmartHomeHandler.class.getDeclaredField(SMART_HOME_DEVICE_FIELD);
 
             smartHomeDeviceField.setAccessible(true);
-            assertSame(name + " should return expected device class", clazz,
-                    smartHomeDeviceField.get(handler).getClass());
+            assertSame(clazz, smartHomeDeviceField.get(handler).getClass(),
+                    name + " should return expected device class");
         }
     }
 }
index 9db8b0095bd5afaa14e78adc93a65bcd4939427b..91b92b7b54acc0695e6c7a36f18a6204883c0e39 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
 import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*;
 import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.LB130;
@@ -20,7 +20,8 @@ import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingT
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.HSBType;
@@ -43,6 +44,7 @@ public class BulbDeviceTest extends DeviceTestBase<BulbDevice> {
                 "bulb_get_sysinfo_response_on");
     }
 
+    @BeforeEach
     @Override
     public void setUp() throws IOException {
         super.setUp();
@@ -52,120 +54,120 @@ public class BulbDeviceTest extends DeviceTestBase<BulbDevice> {
     @Test
     public void testHandleCommandBrightness() throws IOException {
         assertInput("bulb_transition_light_state_brightness");
-        assertTrue("Brightness channel should be handled",
-                device.handleCommand(CHANNEL_UID_BRIGHTNESS, new PercentType(33)));
+        assertTrue(device.handleCommand(CHANNEL_UID_BRIGHTNESS, new PercentType(33)),
+                "Brightness channel should be handled");
     }
 
     @Test
     public void testHandleCommandBrightnessOnOff() throws IOException {
         assertInput("bulb_transition_light_state_on");
-        assertTrue("Brightness channel with OnOff state should be handled",
-                device.handleCommand(CHANNEL_UID_BRIGHTNESS, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_BRIGHTNESS, OnOffType.ON),
+                "Brightness channel with OnOff state should be handled");
     }
 
     @Test
     public void testHandleCommandColor() throws IOException {
         assertInput("bulb_transition_light_state_color");
-        assertTrue("Color channel should be handled", device.handleCommand(CHANNEL_UID_COLOR, new HSBType("55,44,33")));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR, new HSBType("55,44,33")), "Color channel should be handled");
     }
 
     public void testHandleCommandColorBrightness() throws IOException {
         assertInput("bulb_transition_light_state_brightness");
-        assertTrue("Color channel with Percentage state (=brightness) should be handled",
-                device.handleCommand(CHANNEL_UID_COLOR, new PercentType(33)));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR, new PercentType(33)),
+                "Color channel with Percentage state (=brightness) should be handled");
     }
 
     public void testHandleCommandColorOnOff() throws IOException {
         assertInput("bulb_transition_light_state_on");
-        assertTrue("Color channel with OnOff state should be handled",
-                device.handleCommand(CHANNEL_UID_COLOR, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR, OnOffType.ON),
+                "Color channel with OnOff state should be handled");
     }
 
     @Test
     public void testHandleCommandColorTemperature() throws IOException {
         assertInput("bulb_transition_light_state_color_temp");
-        assertTrue("Color temperature channel should be handled",
-                device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE, new PercentType(40)));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE, new PercentType(40)),
+                "Color temperature channel should be handled");
     }
 
     @Test
     public void testHandleCommandColorTemperatureAbs() throws IOException {
         assertInput("bulb_transition_light_state_color_temp");
-        assertTrue("Color temperature channel should be handled",
-                device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE_ABS, new DecimalType(5100)));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE_ABS, new DecimalType(5100)),
+                "Color temperature channel should be handled");
     }
 
     @Test
     public void testHandleCommandColorTemperatureOnOff() throws IOException {
         assertInput("bulb_transition_light_state_on");
-        assertTrue("Color temperature channel with OnOff state should be handled",
-                device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_COLOR_TEMPERATURE, OnOffType.ON),
+                "Color temperature channel with OnOff state should be handled");
     }
 
     @Test
     public void testHandleCommandSwitch() throws IOException {
         assertInput("bulb_transition_light_state_on");
-        assertTrue("Switch channel should be handled", device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON), "Switch channel should be handled");
     }
 
     @Test
     public void testUpdateChannelBrightnessOn() {
-        assertEquals("Brightness should be on", new PercentType(92),
-                device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState));
+        assertEquals(new PercentType(92), device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState),
+                "Brightness should be on");
     }
 
     @Test
     public void testUpdateChannelBrightnessOff() throws IOException {
         deviceState = new DeviceState(ModelTestUtil.readJson(DEVICE_OFF));
-        assertEquals("Brightness should be off", PercentType.ZERO,
-                device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState));
+        assertEquals(PercentType.ZERO, device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState),
+                "Brightness should be off");
     }
 
     @Test
     public void testUpdateChannelColorOn() {
-        assertEquals("Color should be on", new HSBType("7,44,92"),
-                device.updateChannel(CHANNEL_UID_COLOR, deviceState));
+        assertEquals(new HSBType("7,44,92"), device.updateChannel(CHANNEL_UID_COLOR, deviceState),
+                "Color should be on");
     }
 
     @Test
     public void testUpdateChannelColorOff() throws IOException {
         deviceState = new DeviceState(ModelTestUtil.readJson(DEVICE_OFF));
-        assertEquals("Color should be off", new HSBType("7,44,0"),
-                device.updateChannel(CHANNEL_UID_COLOR, deviceState));
+        assertEquals(new HSBType("7,44,0"), device.updateChannel(CHANNEL_UID_COLOR, deviceState),
+                "Color should be off");
     }
 
     @Test
     public void testUpdateChannelSwitchOn() {
-        assertSame("Switch should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState), "Switch should be on");
     }
 
     @Test
     public void testUpdateChannelSwitchOff() throws IOException {
         deviceState = new DeviceState(ModelTestUtil.readJson(DEVICE_OFF));
-        assertSame("Switch should be off", OnOffType.OFF, device.updateChannel(CHANNEL_UID_SWITCH, deviceState));
+        assertSame(OnOffType.OFF, device.updateChannel(CHANNEL_UID_SWITCH, deviceState), "Switch should be off");
     }
 
     @Test
     public void testUpdateChannelColorTemperature() {
-        assertEquals("Color temperature should be set", new PercentType(2),
-                device.updateChannel(CHANNEL_UID_COLOR_TEMPERATURE, deviceState));
+        assertEquals(new PercentType(2), device.updateChannel(CHANNEL_UID_COLOR_TEMPERATURE, deviceState),
+                "Color temperature should be set");
     }
 
     @Test
     public void testUpdateChannelColorTemperatureAbs() {
-        assertEquals("Color temperature should be set", new DecimalType(2630),
-                device.updateChannel(CHANNEL_UID_COLOR_TEMPERATURE_ABS, deviceState));
+        assertEquals(new DecimalType(2630), device.updateChannel(CHANNEL_UID_COLOR_TEMPERATURE_ABS, deviceState),
+                "Color temperature should be set");
     }
 
     @Test
     public void testUpdateChannelOther() {
-        assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
-                device.updateChannel(CHANNEL_UID_OTHER, deviceState));
+        assertSame(UnDefType.UNDEF, device.updateChannel(CHANNEL_UID_OTHER, deviceState),
+                "Unknown channel should return UNDEF");
     }
 
     @Test
     public void testUpdateChannelPower() {
-        assertEquals("Power values should be set", new DecimalType(10.8),
-                device.updateChannel(CHANNEL_UID_ENERGY_POWER, deviceState));
+        assertEquals(new DecimalType(10.8), device.updateChannel(CHANNEL_UID_ENERGY_POWER, deviceState),
+                "Power values should be set");
     }
 }
index 02a080dc27bc2ac4ddb8164e4d1fb409975297bb..5449e53005b1adc7b46e09f5995b727a9c84e27b 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -25,8 +24,12 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.tplinksmarthome.internal.Connection;
 import org.openhab.binding.tplinksmarthome.internal.CryptUtil;
 import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeConfiguration;
@@ -37,6 +40,8 @@ import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public class DeviceTestBase<T extends SmartHomeDevice> {
 
@@ -47,10 +52,8 @@ public class DeviceTestBase<T extends SmartHomeDevice> {
 
     private final String deviceStateFilename;
 
-    @Mock
-    private @NonNullByDefault({}) Socket socket;
-    @Mock
-    private @NonNullByDefault({}) OutputStream outputStream;
+    private @Mock @NonNullByDefault({}) Socket socket;
+    private @Mock @NonNullByDefault({}) OutputStream outputStream;
 
     /**
      * Constructor.
@@ -75,9 +78,8 @@ public class DeviceTestBase<T extends SmartHomeDevice> {
         device.initialize(connection, configuration);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
-        initMocks(this);
         when(socket.getOutputStream()).thenReturn(outputStream);
         deviceState = new DeviceState(ModelTestUtil.readJson(deviceStateFilename));
     }
@@ -121,7 +123,7 @@ public class DeviceTestBase<T extends SmartHomeDevice> {
             byte[] input = (byte[]) arg.getArguments()[0];
             try (ByteArrayInputStream inputStream = new ByteArrayInputStream(input)) {
                 String expectedString = expectedProcessor.apply(CryptUtil.decryptWithLength(inputStream));
-                assertEquals(filenames[index.get()], json, expectedString);
+                assertEquals(json, expectedString, filenames[index.get()]);
             }
             index.incrementAndGet();
             return null;
index 4e69f6790eb0da87d5a37022564352db2eedba3d..8aa685bcb989f1bf157a3dfc05caebe3c786b3e6 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -42,43 +42,44 @@ public class DimmerDeviceTest extends DeviceTestBase<DimmerDevice> {
     public void testHandleCommandBrightnessOnOff() throws IOException {
         assertInput("dimmer_set_switch_state_on");
         setSocketReturnAssert("dimmer_set_switch_state_on");
-        assertTrue("Brightness channel as OnOffType type should be handled",
-                device.handleCommand(CHANNEL_UID_BRIGHTNESS, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_BRIGHTNESS, OnOffType.ON),
+                "Brightness channel as OnOffType type should be handled");
     }
 
     @Test
     public void testHandleCommandBrightnessZero() throws IOException {
         assertInput("dimmer_set_switch_state_off");
         setSocketReturnAssert("dimmer_set_switch_state_response");
-        assertTrue("Brightness channel with percentage 0 should be handled",
-                device.handleCommand(CHANNEL_UID_BRIGHTNESS, PercentType.ZERO));
+        assertTrue(device.handleCommand(CHANNEL_UID_BRIGHTNESS, PercentType.ZERO),
+                "Brightness channel with percentage 0 should be handled");
     }
 
     @Test
     public void testHandleCommandBrightness() throws IOException {
         assertInput("dimmer_set_brightness", "dimmer_set_switch_state_on");
         setSocketReturnAssert("dimmer_set_brightness_response", "dimmer_set_switch_state_on");
-        assertTrue("Brightness channel should be handled",
-                device.handleCommand(CHANNEL_UID_BRIGHTNESS, new PercentType(17)));
+        assertTrue(device.handleCommand(CHANNEL_UID_BRIGHTNESS, new PercentType(17)),
+                "Brightness channel should be handled");
     }
 
     @Test
     public void testUpdateChannelSwitch() throws IOException {
         deviceState = new DeviceState(ModelTestUtil.readJson("hs220_get_sysinfo_response_off"));
 
-        assertSame("Dimmer device should be off", OnOffType.OFF,
-                ((PercentType) device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState)).as(OnOffType.class));
+        assertSame(OnOffType.OFF,
+                ((PercentType) device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState)).as(OnOffType.class),
+                "Dimmer device should be off");
     }
 
     @Test
     public void testUpdateChannelBrightness() {
-        assertEquals("Dimmer brightness should be set", BRIGHTNESS_VALUE,
-                device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState));
+        assertEquals(BRIGHTNESS_VALUE, device.updateChannel(CHANNEL_UID_BRIGHTNESS, deviceState),
+                "Dimmer brightness should be set");
     }
 
     @Test
     public void testUpdateChannelOther() {
-        assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
-                device.updateChannel(CHANNEL_UID_OTHER, deviceState));
+        assertSame(UnDefType.UNDEF, device.updateChannel(CHANNEL_UID_OTHER, deviceState),
+                "Unknown channel should return UNDEF");
     }
 }
index 7ce3f4cb61457c832c6e43acb14694fbde162f01..1f2fc7d223b84fba0d6f7b83bce033e84798600f 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class to test if text read from the device is correctly decoded to handle special characters.
index 1dc871bc622edba3307fd0952d74619e1e85c4fc..612941152f9d34a07fa4f2e911e80c9bd99ce4fa 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
 
 import java.io.IOException;
@@ -20,10 +20,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.types.State;
@@ -34,7 +32,6 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
-@RunWith(value = Parameterized.class)
 @NonNullByDefault
 public class EnergySwitchDeviceTest {
 
@@ -42,45 +39,49 @@ public class EnergySwitchDeviceTest {
             .asList(new Object[][] { { "plug_get_realtime_response", }, { "plug_get_realtime_response_v2", } });
 
     private final EnergySwitchDevice device = new EnergySwitchDevice();
-    private final DeviceState deviceState;
 
-    public EnergySwitchDeviceTest(String name) throws IOException {
-        deviceState = new DeviceState(ModelTestUtil.readJson(name));
-    }
-
-    @Parameters(name = "{0}")
     public static List<Object[]> data() {
         return TESTS;
     }
 
-    @Test
-    public void testUpdateChannelEnergyCurrent() {
-        assertEquals("Energy current should have valid state value", new QuantityType<>(1 + " A"),
-                device.updateChannel(CHANNEL_UID_ENERGY_CURRENT, deviceState));
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testUpdateChannelEnergyCurrent(String name) throws IOException {
+        DeviceState deviceState = new DeviceState(ModelTestUtil.readJson(name));
+        assertEquals(new QuantityType<>(1 + " A"), device.updateChannel(CHANNEL_UID_ENERGY_CURRENT, deviceState),
+                "Energy current should have valid state value");
     }
 
-    @Test
-    public void testUpdateChannelEnergyTotal() {
-        assertEquals("Energy total should have valid state value", new QuantityType<>(10 + " kWh"),
-                device.updateChannel(CHANNEL_UID_ENERGY_TOTAL, deviceState));
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testUpdateChannelEnergyTotal(String name) throws IOException {
+        DeviceState deviceState = new DeviceState(ModelTestUtil.readJson(name));
+        assertEquals(new QuantityType<>(10 + " kWh"), device.updateChannel(CHANNEL_UID_ENERGY_TOTAL, deviceState),
+                "Energy total should have valid state value");
     }
 
-    @Test
-    public void testUpdateChannelEnergyVoltage() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testUpdateChannelEnergyVoltage(String name) throws IOException {
+        DeviceState deviceState = new DeviceState(ModelTestUtil.readJson(name));
         State state = device.updateChannel(CHANNEL_UID_ENERGY_VOLTAGE, deviceState);
-        assertEquals("Energy voltage should have valid state value", 230, ((QuantityType<?>) state).intValue());
-        assertEquals("Channel patten to format voltage correctly", "230 V", state.format("%.0f %unit%"));
+        assertEquals(230, ((QuantityType<?>) state).intValue(), "Energy voltage should have valid state value");
+        assertEquals("230 V", state.format("%.0f %unit%"), "Channel patten to format voltage correctly");
     }
 
-    @Test
-    public void testUpdateChanneEnergyPower() {
-        assertEquals("Energy power should have valid state value", new QuantityType<>(20 + " W"),
-                device.updateChannel(CHANNEL_UID_ENERGY_POWER, deviceState));
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testUpdateChanneEnergyPower(String name) throws IOException {
+        DeviceState deviceState = new DeviceState(ModelTestUtil.readJson(name));
+        assertEquals(new QuantityType<>(20 + " W"), device.updateChannel(CHANNEL_UID_ENERGY_POWER, deviceState),
+                "Energy power should have valid state value");
     }
 
-    @Test
-    public void testUpdateChannelOther() {
-        assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
-                device.updateChannel(CHANNEL_UID_OTHER, deviceState));
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testUpdateChannelOther(String name) throws IOException {
+        DeviceState deviceState = new DeviceState(ModelTestUtil.readJson(name));
+        assertSame(UnDefType.UNDEF, device.updateChannel(CHANNEL_UID_OTHER, deviceState),
+                "Unknown channel should return UNDEF");
     }
 }
index c614eb5ef8fa7a2ffac051d6e2eaaa25897f63d2..f21246f34530763def3b172894f9a66fc38e3eae 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*;
 import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.HS300;
 
@@ -23,8 +23,8 @@ import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants;
 import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
 import org.openhab.binding.tplinksmarthome.internal.model.SetRelayState;
@@ -56,7 +56,7 @@ public class PowerStripDeviceTest extends DeviceTestBase<PowerStripDevice> {
     }
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         super.setUp();
         final AtomicInteger inputCounter = new AtomicInteger(0);
@@ -73,22 +73,23 @@ public class PowerStripDeviceTest extends DeviceTestBase<PowerStripDevice> {
                 .toJson(ModelTestUtil.GSON.fromJson(s, SetRelayState.class));
         assertInput(normalize, normalize, "hs300_set_relay_state");
         setSocketReturnAssert("hs300_set_relay_state_response");
-        assertTrue("Outlet channel 2 should be handled", device.handleCommand(CHANNEL_OUTLET_2, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_OUTLET_2, OnOffType.ON), "Outlet channel 2 should be handled");
     }
 
     @Test
     public void testUpdateChannelOutlet1() {
-        assertSame("Outlet 1 should be on", OnOffType.ON, device.updateChannel(CHANNEL_OUTLET_1, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_OUTLET_1, deviceState), "Outlet 1 should be on");
     }
 
     @Test
     public void testUpdateChannelOutlet2() {
-        assertSame("Outlet 2 should be off", OnOffType.OFF, device.updateChannel(CHANNEL_OUTLET_2, deviceState));
+        assertSame(OnOffType.OFF, device.updateChannel(CHANNEL_OUTLET_2, deviceState), "Outlet 2 should be off");
     }
 
     @Test
     public void testUpdateChannelEnergyCurrent() {
-        assertEquals("Energy current should have valid state value", 1,
-                ((QuantityType<?>) device.updateChannel(CHANNEL_ENERGY_CURRENT_OUTLET_2, deviceState)).intValue());
+        assertEquals(1,
+                ((QuantityType<?>) device.updateChannel(CHANNEL_ENERGY_CURRENT_OUTLET_2, deviceState)).intValue(),
+                "Energy current should have valid state value");
     }
 }
index 2a77cb09fd2e4e509dfab11e037d3fc7d4825292..6b202bf4e260be89dd0ff606b6328d4a738894f6 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.UnDefType;
 
@@ -36,23 +36,23 @@ public class RangeExtenderDeviceTest extends DeviceTestBase<RangeExtenderDevice>
 
     @Test
     public void testHandleCommandSwitch() throws IOException {
-        assertFalse("Switch channel not yet supported so should not be handled",
-                device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON));
+        assertFalse(device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON),
+                "Switch channel not yet supported so should not be handled");
     }
 
     @Test
     public void testUpdateChannelSwitch() {
-        assertSame("Switch should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState), "Switch should be on");
     }
 
     @Test
     public void testUpdateChannelLed() {
-        assertSame("Led should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_LED, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_UID_LED, deviceState), "Led should be on");
     }
 
     @Test
     public void testUpdateChannelOther() {
-        assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
-                device.updateChannel(CHANNEL_UID_OTHER, deviceState));
+        assertSame(UnDefType.UNDEF, device.updateChannel(CHANNEL_UID_OTHER, deviceState),
+                "Unknown channel should return UNDEF");
     }
 }
index 4c0255176b803fe0d3d6d245b698a755a3120d0c..100b55c582e3a35c8e8d538de6af603cce03afbe 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.device;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.*;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.UnDefType;
 
@@ -38,29 +38,29 @@ public class SwitchDeviceTest extends DeviceTestBase<SwitchDevice> {
     public void testHandleCommandSwitch() throws IOException {
         assertInput("plug_set_relay_state_on");
         setSocketReturnAssert("plug_set_relay_state_on");
-        assertTrue("Switch channel should be handled", device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_SWITCH, OnOffType.ON), "Switch channel should be handled");
     }
 
     @Test
     public void testHandleCommandLed() throws IOException {
         assertInput("plug_set_led_on");
         setSocketReturnAssert("plug_set_led_on");
-        assertTrue("Led channel should be handled", device.handleCommand(CHANNEL_UID_LED, OnOffType.ON));
+        assertTrue(device.handleCommand(CHANNEL_UID_LED, OnOffType.ON), "Led channel should be handled");
     }
 
     @Test
     public void testUpdateChannelSwitch() {
-        assertSame("Switch should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_UID_SWITCH, deviceState), "Switch should be on");
     }
 
     @Test
     public void testUpdateChannelLed() {
-        assertSame("Led should be on", OnOffType.ON, device.updateChannel(CHANNEL_UID_LED, deviceState));
+        assertSame(OnOffType.ON, device.updateChannel(CHANNEL_UID_LED, deviceState), "Led should be on");
     }
 
     @Test
     public void testUpdateChannelOther() {
-        assertSame("Unknown channel should return UNDEF", UnDefType.UNDEF,
-                device.updateChannel(CHANNEL_UID_OTHER, deviceState));
+        assertSame(UnDefType.UNDEF, device.updateChannel(CHANNEL_UID_OTHER, deviceState),
+                "Unknown channel should return UNDEF");
     }
 }
index f58d921ac5f5225f886b2b489682a6e2df207b05..604b4d74480aa0807483081bf38f43bd91c3700e 100644 (file)
  */
 package org.openhab.binding.tplinksmarthome.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants.CHANNEL_UID_SWITCH;
 import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*;
 
 import java.io.IOException;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.tplinksmarthome.internal.ChannelUIDConstants;
 import org.openhab.binding.tplinksmarthome.internal.Commands;
 import org.openhab.binding.tplinksmarthome.internal.Connection;
@@ -52,27 +55,23 @@ import org.openhab.core.types.State;
  *
  * @author Hilbrand Bouwkamp - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public class SmartHomeHandlerTest {
 
     private @NonNullByDefault({}) SmartHomeHandler handler;
 
-    @Mock
-    private @NonNullByDefault({}) Connection connection;
-    @Mock
-    private @NonNullByDefault({}) ThingHandlerCallback callback;
-    @Mock
-    private @NonNullByDefault({}) Thing thing;
-    @Mock
-    private @NonNullByDefault({}) SmartHomeDevice smartHomeDevice;
-    @Mock
-    private @NonNullByDefault({}) TPLinkSmartHomeDiscoveryService discoveryService;
+    private @Mock @NonNullByDefault({}) Connection connection;
+    private @Mock @NonNullByDefault({}) ThingHandlerCallback callback;
+    private @Mock @NonNullByDefault({}) Thing thing;
+    private @Mock @NonNullByDefault({}) SmartHomeDevice smartHomeDevice;
+    private @Mock @NonNullByDefault({}) TPLinkSmartHomeDiscoveryService discoveryService;
 
     private final Configuration configuration = new Configuration();
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
-        initMocks(this);
         configuration.put(CONFIG_IP, "localhost");
         configuration.put(CONFIG_REFRESH, 1);
         when(thing.getConfiguration()).thenReturn(configuration);
@@ -90,7 +89,7 @@ public class SmartHomeHandlerTest {
         handler.setCallback(callback);
     }
 
-    @After
+    @AfterEach
     public void after() {
         handler.dispose();
     }
@@ -102,7 +101,7 @@ public class SmartHomeHandlerTest {
 
         verify(callback).statusUpdated(eq(thing), statusInfoCaptor.capture());
         ThingStatusInfo thingStatusInfo = statusInfoCaptor.getValue();
-        assertEquals("Device should be unknown", ThingStatus.UNKNOWN, thingStatusInfo.getStatus());
+        assertEquals(ThingStatus.UNKNOWN, thingStatusInfo.getStatus(), "Device should be unknown");
     }
 
     @Test
@@ -125,8 +124,8 @@ public class SmartHomeHandlerTest {
         handler.handleCommand(channelUID, RefreshType.REFRESH);
         ArgumentCaptor<State> stateCaptor = ArgumentCaptor.forClass(State.class);
         verify(callback).stateUpdated(eq(channelUID), stateCaptor.capture());
-        assertEquals("State of RSSI channel should be set", new QuantityType<>(expectedRssi + " dBm"),
-                stateCaptor.getValue());
+        assertEquals(new QuantityType<>(expectedRssi + " dBm"), stateCaptor.getValue(),
+                "State of RSSI channel should be set");
     }
 
     @Test
@@ -137,7 +136,7 @@ public class SmartHomeHandlerTest {
         handler.handleCommand(channelUID, RefreshType.REFRESH);
         ArgumentCaptor<State> stateCaptor = ArgumentCaptor.forClass(State.class);
         verify(callback).stateUpdated(eq(channelUID), stateCaptor.capture());
-        assertSame("State of channel switch should be set", OnOffType.ON, stateCaptor.getValue());
+        assertSame(OnOffType.ON, stateCaptor.getValue(), "State of channel switch should be set");
     }
 
     @Test
index 8a8e3c6728dcc009a29e2177cf1bcc08bc5b67d4..a6ea99ac650ad70f0566d0266e168a73355a0ba5 100644 (file)
  */
 package org.openhab.binding.tradfri.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.HSBType;
 import org.openhab.core.library.types.PercentType;
 
index 5fc80d96c589bf8ad5050f39b55af72f040a267d..4a59a05de9f6fc7057b1a514305bc6aff89e9d62 100644 (file)
 package org.openhab.binding.tradfri.internal.discovery;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
 import static org.openhab.binding.tradfri.internal.config.TradfriDeviceConfig.CONFIG_ID;
 
 import java.util.Collection;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.binding.tradfri.internal.handler.TradfriGatewayHandler;
 import org.openhab.core.config.discovery.DiscoveryListener;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -43,12 +47,13 @@ import com.google.gson.JsonParser;
  * @author Kai Kreuzer - Initial contribution
  * @author Christoph Weitkamp - Added support for remote controller and motion sensor devices (read-only battery level)
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class TradfriDiscoveryServiceTest {
 
     private static final ThingUID GATEWAY_THING_UID = new ThingUID("tradfri:gateway:1");
 
-    @Mock
-    private TradfriGatewayHandler handler;
+    private @Mock TradfriGatewayHandler handler;
 
     private final DiscoveryListener listener = new DiscoveryListener() {
         @Override
@@ -71,10 +76,8 @@ public class TradfriDiscoveryServiceTest {
 
     private TradfriDiscoveryService discovery;
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
-
         when(handler.getThing()).thenReturn(BridgeBuilder.create(GATEWAY_TYPE_UID, "1").build());
 
         discovery = new TradfriDiscoveryService();
@@ -82,7 +85,7 @@ public class TradfriDiscoveryServiceTest {
         discovery.addDiscoveryListener(listener);
     }
 
-    @After
+    @AfterEach
     public void cleanUp() {
         discoveryResult = null;
     }
index bc76b29e06fe3cf9edbad0992e76a41818607910..11e3bbfd70c34b7ab0704bded2b9bd88ab2697ff 100644 (file)
  */
 package org.openhab.binding.tradfri.internal.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Arrays;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link TradfriVersion}.
@@ -34,9 +34,9 @@ public class TradfriVersionTest {
     private static final String VERSION_STRING = "1.2.42";
     private static final TradfriVersion VERSION = new TradfriVersion(VERSION_STRING);
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testIllegalArgumentException() throws IllegalArgumentException {
-        new TradfriVersion("FAILURE");
+        assertThrows(IllegalArgumentException.class, () -> new TradfriVersion("FAILURE"));
     }
 
     @Test
index ed80e222169ef549d7c503f78e6b026299dd1e4f..713be465bc0105104279085479ab713678c8425e 100644 (file)
  */
 package org.openhab.binding.upb.internal.message;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Marcus Better - Initial contribution
index 1eab99599fe2e0f18a103fcac13d93c9edcb0e35..4a8786184cc33d6f10c612d775d35617f1bd303c 100644 (file)
@@ -13,9 +13,9 @@
 package org.openhab.binding.wifiled.internal.handler;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for LEDStateDTO
index b821a8e2bc28e769f977cac0b2ee5a1e238310d2..e2dff70ef7f619f9ec2fde93eb41a03e964279b7 100644 (file)
 package org.openhab.binding.yamahareceiver.internal;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import java.util.List;
 import java.util.Optional;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openhab.binding.yamahareceiver.internal.config.YamahaBridgeConfig;
@@ -48,33 +47,18 @@ public class YamahaReceiverHandlerTest extends AbstractXMLProtocolTest {
 
     private YamahaBridgeHandler subject;
 
-    @Mock
-    private YamahaBridgeConfig bridgeConfig;
-
-    @Mock
-    private Configuration configuration;
-
-    @Mock
-    private ProtocolFactory protocolFactory;
-
-    @Mock
-    private DeviceInformation deviceInformation;
-
-    @Mock
-    private SystemControl systemControl;
-
-    @Mock
-    private ThingHandlerCallback callback;
-
-    @Mock
-    private Bridge bridge;
+    private @Mock YamahaBridgeConfig bridgeConfig;
+    private @Mock Configuration configuration;
+    private @Mock ProtocolFactory protocolFactory;
+    private @Mock DeviceInformation deviceInformation;
+    private @Mock SystemControl systemControl;
+    private @Mock ThingHandlerCallback callback;
+    private @Mock Bridge bridge;
 
     @Override
     protected void onSetUp() throws Exception {
         super.onSetUp();
 
-        initMocks(this);
-
         ctx.prepareForModel(TestModels.RX_S601D);
         ctx.respondWith("<Main_Zone><Input><Input_Sel_Item>GetParam</Input_Sel_Item></Input></Main_Zone>",
                 "Main_Zone_Input_Input_Sel.xml");
index fd3ef99d8e91cd81748f8a72de4c667328f5e099..350ff5019d9a4ead191432976b6dd87e51285bf3 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone.Zone_2;
 
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.openhab.binding.yamahareceiver.internal.config.YamahaZoneConfig;
 import org.openhab.binding.yamahareceiver.internal.protocol.xml.AbstractXMLProtocolTest;
@@ -37,11 +37,8 @@ import org.openhab.binding.yamahareceiver.internal.state.ZoneControlStateListene
  */
 public class XMLProtocolFactoryTest extends AbstractXMLProtocolTest {
 
-    @Mock
-    private YamahaZoneConfig zoneConfig;
-
-    @Mock
-    private ZoneControlStateListener zoneControlStateListener;
+    private @Mock YamahaZoneConfig zoneConfig;
+    private @Mock ZoneControlStateListener zoneControlStateListener;
 
     private DeviceInformationState state = new DeviceInformationState();
 
@@ -70,7 +67,7 @@ public class XMLProtocolFactoryTest extends AbstractXMLProtocolTest {
         ZoneControl zoneControl = subject.ZoneControl(con, zoneConfig, zoneControlStateListener, () -> null, state);
 
         // assert
-        assertTrue("Created ZoneB control", zoneControl instanceof ZoneBControlXML);
+        assertTrue(zoneControl instanceof ZoneBControlXML, "Created ZoneB control");
     }
 
     @Test
@@ -86,6 +83,6 @@ public class XMLProtocolFactoryTest extends AbstractXMLProtocolTest {
         ZoneControl zoneControl = subject.ZoneControl(con, zoneConfig, zoneControlStateListener, () -> null, state);
 
         // assert
-        assertTrue("Created Zone control", zoneControl instanceof ZoneControlXML);
+        assertTrue(zoneControl instanceof ZoneControlXML, "Created Zone control");
     }
 }
index bfdab8d1dd1494970ed55765d817e07123735017..d67ed6c9d8f16f8e98a53ef1464196a559c77b71 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 
 /**
  * Baseline for tests for the XML protocol implementation.
  *
  * @author Tomasz Maruszak - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public abstract class AbstractXMLProtocolTest {
 
-    @Mock
-    protected XMLConnection con;
+    protected @Mock XMLConnection con;
 
     protected ModelContext ctx;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
-        initMocks(this);
         ctx = new ModelContext(con);
 
         onSetUp();
index e2517d43d7ef9329052b2f8a1804dcc9c6039bee..4958729ec02e469daf345231eed5b9ac139fe8df 100644 (file)
@@ -28,16 +28,11 @@ import org.openhab.binding.yamahareceiver.internal.state.ZoneControlStateListene
  */
 public abstract class AbstractZoneControlXMLTest extends AbstractXMLProtocolTest {
 
-    @Mock
-    protected YamahaZoneConfig zoneConfig;
-
-    @Mock
-    protected ZoneControlStateListener zoneControlStateListener;
-
     protected DeviceInformationState deviceInformationState;
 
-    @Mock
-    protected InputConverter inputConverter;
+    protected @Mock InputConverter inputConverter;
+    protected @Mock ZoneControlStateListener zoneControlStateListener;
+    protected @Mock YamahaZoneConfig zoneConfig;
 
     @Override
     protected void onSetUp() throws Exception {
index 67badb6fb91659c5b8020655a880c8d92849a89f..9b2a7aba5e7147adcafc66ed352ba89c66e8d5ab 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone.*;
 
@@ -21,7 +21,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants;
 
 /**
@@ -87,15 +87,15 @@ public class DeviceDescriptorXMLTest extends AbstractXMLProtocolTest {
         assertCommands(subject.system, systemCommandsSpec);
 
         assertNotNull(subject.features);
-        assertTrue("Desired features present", subject.features.keySet().containsAll(features));
+        assertTrue(subject.features.keySet().containsAll(features), "Desired features present");
 
         assertNotNull(subject.zones);
-        assertEquals("Number of zones match", zones.size(), subject.zones.size());
+        assertEquals(zones.size(), subject.zones.size(), "Number of zones match");
 
         for (int i = 0; i < zones.size(); i++) {
             YamahaReceiverBindingConstants.Zone zone = zones.get(i);
 
-            assertTrue("Desired zone is present", subject.zones.containsKey(zone));
+            assertTrue(subject.zones.containsKey(zone), "Desired zone is present");
 
             DeviceDescriptorXML.ZoneDescriptor zoneDesc = subject.zones.get(zone);
             CommandsSpec zoneSpec = zonesCommandsSpec[i];
@@ -104,9 +104,9 @@ public class DeviceDescriptorXMLTest extends AbstractXMLProtocolTest {
     }
 
     private void assertCommands(DeviceDescriptorXML.HasCommands descWithCommands, CommandsSpec spec) {
-        assertNotNull("Descriptor commands are present", descWithCommands);
-        assertEquals("Expected number of commands", spec.expectedNumber, descWithCommands.commands.size());
-        assertTrue("Expected commands are present", descWithCommands.commands.containsAll(spec.expected));
+        assertNotNull(descWithCommands, "Descriptor commands are present");
+        assertEquals(spec.expectedNumber, descWithCommands.commands.size(), "Expected number of commands");
+        assertTrue(descWithCommands.commands.containsAll(spec.expected), "Expected commands are present");
     }
 
     private static class CommandsSpec {
index f16b45de4fb63173f51e108771d57c864650912c..94a8069cc8fe6daefbee74deed0aaf4b8296002e 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone.*;
 
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.yamahareceiver.internal.protocol.ReceivedMessageParseException;
 import org.openhab.binding.yamahareceiver.internal.state.DeviceInformationState;
 
@@ -50,8 +50,8 @@ public class DeviceInformationXMLTest extends AbstractXMLProtocolTest {
         subject.update();
 
         // assert
-        assertTrue("ZONE_B detected", state.features.contains(ZONE_B));
-        assertTrue("Zone_2 added", state.zones.contains(Zone_2));
+        assertTrue(state.features.contains(ZONE_B), "ZONE_B detected");
+        assertTrue(state.zones.contains(Zone_2), "Zone_2 added");
     }
 
     @Test
@@ -64,7 +64,7 @@ public class DeviceInformationXMLTest extends AbstractXMLProtocolTest {
         subject.update();
 
         // assert
-        assertTrue("Zones detected", state.zones.containsAll(Arrays.asList(Main_Zone, Zone_2, Zone_3)));
-        assertTrue("Features detected", state.features.containsAll(Arrays.asList(TUNER, BLUETOOTH)));
+        assertTrue(state.zones.containsAll(Arrays.asList(Main_Zone, Zone_2, Zone_3)), "Zones detected");
+        assertTrue(state.features.containsAll(Arrays.asList(TUNER, BLUETOOTH)), "Features detected");
     }
 }
index e81af18f0791c9074169c8249604fe71e88ed5de..00b860f3d2a065241499b5a9909f6073070b4c42 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Inputs.*;
 import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLConstants.Commands.ZONE_INPUT_QUERY;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link InputConverterXML}.
index cac736be8045ff61a07d9603b4e05c117ec19e9d..a10e2a8662585b34fe68bd19d1114a1ead50f59f 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 import static org.openhab.binding.yamahareceiver.internal.TestModels.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Inputs.*;
 
 import java.util.function.Consumer;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
@@ -31,21 +30,16 @@ import org.openhab.binding.yamahareceiver.internal.state.PlayInfoStateListener;
 
 /**
  * Unit test for {@link InputWithPlayControlXML}.
- * 
+ *
  * @author Tomasz Maruszak - Initial contribution
  */
 public class InputWithPlayControlXMLTest extends AbstractZoneControlXMLTest {
 
     private InputWithPlayControlXML subject;
 
-    @Mock
-    private PlayInfoStateListener playInfoStateListener;
-
-    @Captor
-    private ArgumentCaptor<PlayInfoState> playInfoStateArg;
-
-    @Mock
-    private YamahaBridgeConfig bridgeConfig;
+    private @Mock PlayInfoStateListener playInfoStateListener;
+    private @Captor ArgumentCaptor<PlayInfoState> playInfoStateArg;
+    private @Mock YamahaBridgeConfig bridgeConfig;
 
     private String albumUrl;
 
index 8514cb29d943e4299eeebf93888d2ca55b95d4d9..800de512859773d9dbe9ced4507769bf9be2c360 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 import static org.openhab.binding.yamahareceiver.internal.TestModels.*;
@@ -20,7 +20,7 @@ import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingC
 
 import java.util.function.Consumer;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
@@ -36,11 +36,8 @@ public class InputWithPresetControlXMLTest extends AbstractZoneControlXMLTest {
 
     private InputWithPresetControlXML subject;
 
-    @Mock
-    private PresetInfoStateListener presetInfoStateListener;
-
-    @Captor
-    private ArgumentCaptor<PresetInfoState> presetInfoStateArg;
+    private @Mock PresetInfoStateListener presetInfoStateListener;
+    private @Captor ArgumentCaptor<PresetInfoState> presetInfoStateArg;
 
     private void given(String model, String input, Consumer<ModelContext> setup) throws Exception {
         ctx.prepareForModel(model);
index ea82c52499a2c6b0d56f533b742cfe4901681c90..bc38a8a912a9af0a28b01595680df5441c823e20 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openhab.binding.yamahareceiver.internal.TestModels;
@@ -35,8 +35,7 @@ public class SystemControlXMLTest extends AbstractXMLProtocolTest {
 
     private DeviceInformationState deviceInformationState;
 
-    @Mock
-    private SystemControlStateListener systemControlStateListener;
+    private @Mock SystemControlStateListener systemControlStateListener;
 
     protected void setupFor(String model) throws Exception {
         ctx.prepareForModel(model);
index 9a2ce3acaa29ea547065543824c1027ea6f07dc7..2a8cdde63e69ba83c02711218da32cd741179c77 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 import static org.openhab.binding.yamahareceiver.internal.TestModels.HTR_4069;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.yamahareceiver.internal.state.ZoneControlState;
 
index 140b36166a17296ad1678842b174a7f382076997..b56599a621566c0e8b037bbf34f933ffcb5ea846 100644 (file)
  */
 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 import static org.openhab.binding.yamahareceiver.internal.TestModels.*;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone.Main_Zone;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.openhab.binding.yamahareceiver.internal.state.ZoneControlState;
 
index 6d9e7def3e957d0f8a1c74821905b217814cbd59..43ecff9c15f88f76199a782369a31cd2bd1354a4 100644 (file)
  */
 package org.openhab.binding.yeelight.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
 import static org.openhab.binding.yeelight.internal.YeelightBindingConstants.PARAMETER_DEVICE_ID;
 
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
-import org.openhab.binding.yeelight.internal.handler.*;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.binding.yeelight.internal.handler.YeelightCeilingHandler;
+import org.openhab.binding.yeelight.internal.handler.YeelightCeilingWithAmbientHandler;
+import org.openhab.binding.yeelight.internal.handler.YeelightCeilingWithNightHandler;
+import org.openhab.binding.yeelight.internal.handler.YeelightColorHandler;
+import org.openhab.binding.yeelight.internal.handler.YeelightStripeHandler;
+import org.openhab.binding.yeelight.internal.handler.YeelightWhiteHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
@@ -40,7 +44,8 @@ import org.openhab.core.thing.binding.ThingHandler;
  * @author Viktor Koop - Initial contribution
  * @author Nikita Pogudalov - Added YeelightCeilingWithNightHandler for Ceiling 1
  */
-@RunWith(value = Parameterized.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class YeelightHandlerFactoryTest {
 
     private static final List<Object[]> TESTS = Arrays.asList(
@@ -52,41 +57,31 @@ public class YeelightHandlerFactoryTest {
 
     private final YeelightHandlerFactory factory = new YeelightHandlerFactory();
 
-    @Mock
-    private Thing thing;
+    private @Mock Thing thing;
 
-    private final String name;
-    private final Class<?> clazz;
-
-    public YeelightHandlerFactoryTest(String name, Class<?> clazz) {
-        this.name = name;
-        this.clazz = clazz;
-    }
-
-    @Parameters(name = "{0} - {1}")
     public static List<Object[]> data() {
         return TESTS;
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        initMocks(this);
         Configuration configuration = new Configuration();
         configuration.put(PARAMETER_DEVICE_ID, "");
 
         when(thing.getConfiguration()).thenReturn(configuration);
     }
 
-    @Test
-    public void testCorrectClass() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testCorrectClass(String name, Class<?> clazz) {
         when(thing.getThingTypeUID()).thenReturn(new ThingTypeUID(YeelightBindingConstants.BINDING_ID, name));
         ThingHandler handler = factory.createHandler(thing);
 
         if (null == clazz) {
-            assertNull(name + " should not return any handler but null", handler);
+            assertNull(handler, name + " should not return any handler but null");
         } else {
-            assertNotNull(name + " should no return null handler", handler);
-            assertEquals(" should be correct matcher", clazz, handler.getClass());
+            assertNotNull(handler, name + " should no return null handler");
+            assertEquals(clazz, handler.getClass(), " should be correct matcher");
 
             assertEquals(thing, handler.getThing());
         }
index dadf5ad1f91f64c33fd01a9586bf5015f6627250..b4be1df6c4eca8ed35a3abbd5b7f9ede03d1650b 100644 (file)
  */
 package org.openhab.binding.yeelight.internal.lib.device;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.yeelight.internal.lib.enums.ActiveMode;
 
 /**
@@ -27,7 +27,7 @@ public class DeviceBaseTest {
 
     private DeviceBase deviceBase;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         deviceBase = new DeviceBase("myid") {
         };
index 146a5ce80c802902167cfb3a9c1c0dbcf7b79d9a..7761f33f16052a465c5afbba8cc99bc52652d60a 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.automation;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.time.LocalDateTime;
 import java.util.Collections;
@@ -22,6 +23,11 @@ import java.util.Random;
 import java.util.TreeMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.core.automation.Condition;
+import org.openhab.core.automation.util.ConditionBuilder;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.items.GroupItem;
 import org.openhab.core.library.items.ContactItem;
@@ -30,11 +36,6 @@ import org.openhab.core.library.items.SwitchItem;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.core.automation.Condition;
-import org.openhab.core.automation.util.ConditionBuilder;
 import org.openhab.io.hueemulation.internal.DeviceType;
 import org.openhab.io.hueemulation.internal.RuleUtils;
 import org.openhab.io.hueemulation.internal.dto.HueDataStore;
@@ -64,7 +65,7 @@ public class RuleConditionHandlerTests {
         }
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         ds = new HueDataStore();
 
@@ -76,12 +77,12 @@ public class RuleConditionHandlerTests {
                 new HueGroupEntry("name", new GroupItem("white", new NumberItem("number")), DeviceType.SwitchType));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         RuleUtils.random = new Random();
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void itemNotExisting() {
         Configuration configuration = new Configuration();
         configuration.put("address", "/groups/9/action");
@@ -89,7 +90,7 @@ public class RuleConditionHandlerTests {
         configuration.put("value", "");
         Condition c = ConditionBuilder.create().withId("a").withTypeUID(HueRuleConditionHandler.MODULE_TYPE_ID)
                 .withConfiguration(configuration).build();
-        new HueRuleConditionHandler(c, ds);
+        assertThrows(IllegalStateException.class, () -> new HueRuleConditionHandler(c, ds));
     }
 
     @Test
index 40b3e3526fdf56b607f95254ea6a309d654c3b2a..761749291d8bf7820b8fd076091663b3d0a275c6 100644 (file)
@@ -29,19 +29,22 @@ import java.util.logging.Logger;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 
-import org.openhab.core.events.EventPublisher;
-import org.openhab.core.items.MetadataRegistry;
-import org.openhab.core.net.NetworkAddressService;
-import org.openhab.core.storage.Storage;
-import org.openhab.core.storage.StorageService;
 import org.glassfish.grizzly.http.server.HttpServer;
 import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
 import org.glassfish.jersey.logging.LoggingFeature;
 import org.glassfish.jersey.logging.LoggingFeature.Verbosity;
 import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.core.events.EventPublisher;
+import org.openhab.core.items.MetadataRegistry;
+import org.openhab.core.net.NetworkAddressService;
+import org.openhab.core.storage.Storage;
+import org.openhab.core.storage.StorageService;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.rest.mocks.ConfigStoreWithoutMetadata;
 import org.openhab.io.hueemulation.internal.rest.mocks.DummyMetadataRegistry;
@@ -58,12 +61,13 @@ import org.osgi.service.cm.ConfigurationAdmin;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class CommonSetup {
 
     public UserManagement userManagement;
 
-    @Mock
-    public EventPublisher eventPublisher;
+    public @Mock EventPublisher eventPublisher;
 
     public ConfigStore cs;
 
@@ -102,7 +106,6 @@ public class CommonSetup {
     public String basePath;
 
     public CommonSetup(boolean withMetadata) throws IOException {
-        MockitoAnnotations.initMocks(this);
         when(configAdmin.getConfiguration(anyString())).thenReturn(configAdminConfig);
         when(configAdmin.getConfiguration(anyString(), any())).thenReturn(configAdminConfig);
         Dictionary<String, Object> mockProperties = new Hashtable<>();
index 3d4548485328e95702fb397c12f889b2c4a6de73..cc41b1909a2a989ed11648b102018441ad2db062 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.Mockito.mock;
 
 import java.io.IOException;
@@ -21,15 +21,15 @@ import java.util.Collections;
 import java.util.concurrent.ScheduledExecutorService;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.hamcrest.CoreMatchers;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.items.Metadata;
 import org.openhab.core.items.MetadataKey;
 import org.openhab.core.library.items.SwitchItem;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.hamcrest.CoreMatchers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.dto.HueLightEntry;
 import org.openhab.io.hueemulation.internal.dto.HueStatePlug;
@@ -47,7 +47,7 @@ public class ItemUIDtoHueIDMappingTests {
 
     LightsAndGroups lightsAndGroups = new LightsAndGroups();
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(true);
         commonSetup.start(new ResourceConfig());
@@ -61,7 +61,7 @@ public class ItemUIDtoHueIDMappingTests {
         lightsAndGroups.activate();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         commonSetup.dispose();
     }
index 4a2b0c1b671a9f176dd32745ec821f0fb5ff35ba..c8a70e6a6a3dbf39dcfac1eca71eb768488275d8 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.Mockito.verify;
 
@@ -23,6 +24,10 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.events.Event;
 import org.openhab.core.items.GroupItem;
 import org.openhab.core.items.ItemRegistry;
@@ -31,10 +36,6 @@ import org.openhab.core.library.items.ColorItem;
 import org.openhab.core.library.items.SwitchItem;
 import org.openhab.core.library.types.HSBType;
 import org.openhab.core.library.types.OnOffType;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.DeviceType;
 import org.openhab.io.hueemulation.internal.dto.HueGroupEntry;
@@ -56,7 +57,7 @@ public class LightsAndGroupsTests {
 
     LightsAndGroups subject = new LightsAndGroups();
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
         itemRegistry = new DummyItemRegistry();
@@ -81,7 +82,7 @@ public class LightsAndGroupsTests {
         commonSetup.start(new ResourceConfig().registerInstances(subject));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         commonSetup.dispose();
     }
index 7a8aaad1d442035c4f1b6a6546f0a61aae28047a..1dae91e749aa91b15fd8da880fb6c62ac022a4ad 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
@@ -25,6 +26,15 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.core.automation.Condition;
+import org.openhab.core.automation.Rule;
+import org.openhab.core.automation.RuleRegistry;
+import org.openhab.core.automation.Trigger;
+import org.openhab.core.automation.util.RuleBuilder;
 import org.openhab.core.items.GenericItem;
 import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.library.items.ColorItem;
@@ -32,15 +42,6 @@ import org.openhab.core.library.items.SwitchItem;
 import org.openhab.core.library.types.HSBType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.State;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.core.automation.Condition;
-import org.openhab.core.automation.Rule;
-import org.openhab.core.automation.RuleRegistry;
-import org.openhab.core.automation.Trigger;
-import org.openhab.core.automation.util.RuleBuilder;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.RuleUtils;
 import org.openhab.io.hueemulation.internal.dto.HueRuleEntry;
@@ -75,7 +76,7 @@ public class RulesTests {
         itemRegistry.add(item);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
         this.cs = commonSetup.cs;
@@ -104,7 +105,7 @@ public class RulesTests {
         commonSetup.start(new ResourceConfig().registerInstances(subject));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         RuleUtils.random = new Random();
         commonSetup.dispose();
index 3399e17668c344a3176475375005872c4e360c31..68c223c46c44ccfe7d2123e048aa44905dca0dfb 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
@@ -24,6 +25,14 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.hamcrest.CoreMatchers;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.core.automation.Rule;
+import org.openhab.core.automation.RuleRegistry;
+import org.openhab.core.automation.util.RuleBuilder;
 import org.openhab.core.items.GenericItem;
 import org.openhab.core.items.GroupItem;
 import org.openhab.core.items.ItemRegistry;
@@ -36,14 +45,6 @@ import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
 import org.openhab.core.types.Command;
 import org.openhab.core.types.State;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.hamcrest.CoreMatchers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.core.automation.Rule;
-import org.openhab.core.automation.RuleRegistry;
-import org.openhab.core.automation.util.RuleBuilder;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.dto.HueSceneEntry;
 import org.openhab.io.hueemulation.internal.rest.mocks.DummyItemRegistry;
@@ -72,7 +73,7 @@ public class SceneTests {
         itemRegistry.add(item);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
         this.cs = commonSetup.cs;
@@ -97,7 +98,7 @@ public class SceneTests {
         commonSetup.start(new ResourceConfig().registerInstances(subject));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         commonSetup.dispose();
     }
index e67b47b9c7b8f09dad32f9704d3b8650c26443d9..bf809af33130fc33ddab824653058bd3e05ab027 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
@@ -28,19 +29,19 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.core.config.core.Configuration;
-import org.openhab.core.library.items.ColorItem;
-import org.openhab.core.library.items.SwitchItem;
 import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.automation.Rule;
 import org.openhab.core.automation.RuleManager;
 import org.openhab.core.automation.RuleRegistry;
 import org.openhab.core.automation.Trigger;
 import org.openhab.core.automation.util.RuleBuilder;
 import org.openhab.core.automation.util.TriggerBuilder;
+import org.openhab.core.config.core.Configuration;
+import org.openhab.core.library.items.ColorItem;
+import org.openhab.core.library.items.SwitchItem;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.DeviceType;
 import org.openhab.io.hueemulation.internal.RuleUtils;
@@ -66,7 +67,7 @@ public class ScheduleTests {
 
     Schedules subject = new Schedules();
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
         this.cs = commonSetup.cs;
@@ -97,7 +98,7 @@ public class ScheduleTests {
         RuleUtils.random = random;
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         RuleUtils.random = new Random();
         commonSetup.dispose();
index 368bebd4d704fe5d7e3ba171b3dc9f7e26d8bcd7..5c4a3b2c9eec6277a56dae8a0bc91de79bb42704 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
@@ -21,6 +22,10 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.items.GenericItem;
 import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.library.items.ColorItem;
@@ -35,10 +40,6 @@ import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.OpenClosedType;
 import org.openhab.core.library.types.PercentType;
 import org.openhab.core.types.State;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.rest.mocks.DummyItemRegistry;
 
@@ -61,7 +62,7 @@ public class SensorTests {
         itemRegistry.add(item);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
         itemRegistry = new DummyItemRegistry();
@@ -84,7 +85,7 @@ public class SensorTests {
         commonSetup.start(new ResourceConfig().registerInstances(subject));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         commonSetup.dispose();
     }
index 642cc6141383c96de47ea739b08de2c4a4589b9d..d8d711eddc63c8dd5d1be4235a83097565af474f 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.rest;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -23,9 +24,9 @@ import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Response;
 
 import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openhab.io.hueemulation.internal.ConfigStore;
 import org.openhab.io.hueemulation.internal.HueEmulationConfig;
@@ -49,7 +50,7 @@ public class UsersAndConfigTests {
 
     CommonSetup commonSetup;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         commonSetup = new CommonSetup(false);
 
@@ -60,7 +61,7 @@ public class UsersAndConfigTests {
         commonSetup.start(new ResourceConfig().registerInstances(configurationAccess));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         commonSetup.dispose();
     }
index 668723322e246c40ed3c7ea7d00afbf59a4bc81e..2193f1f21aacdf903ea52f35f239865273935d5b 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.hueemulation.internal.upnp;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 
 import java.io.IOException;
@@ -31,11 +32,11 @@ import org.glassfish.grizzly.osgi.httpservice.OSGiMainHandler;
 import org.glassfish.grizzly.osgi.httpservice.util.Logger;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.hamcrest.CoreMatchers;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 import org.openhab.io.hueemulation.internal.rest.CommonSetup;
@@ -57,7 +58,7 @@ public class UpnpTests {
 
     LightsAndGroups lightsAndGroups = new LightsAndGroups();
 
-    @BeforeClass
+    @BeforeAll
     public static void setupHttpParts() throws IOException {
         commonSetup = new CommonSetup(true);
         commonSetup.start(new ResourceConfig());
@@ -72,7 +73,7 @@ public class UpnpTests {
         httpServiceImpl = new HttpServiceImpl(mock(Bundle.class), logger);
     }
 
-    @Before
+    @BeforeEach
     public void setup() {
         Executor executor = mock(Executor.class);
         Mockito.doAnswer(a -> {
@@ -87,12 +88,12 @@ public class UpnpTests {
         subject.overwriteReadyToFalse = false;
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         subject.deactivate();
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownHttp() {
         mainHttpHandler.unregisterAll();
         commonSetup.dispose();
index 005ddc3af3e0e4228923486476fede59a3b28f95..9a742771b6f7d0c412fa4221e7377e412c73642c 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.mqttembeddedbroker.internal;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.verify;
 
@@ -33,11 +34,12 @@ import javax.naming.ConfigurationException;
 import org.apache.commons.io.FileUtils;
 import org.h2.mvstore.MVMap;
 import org.h2.mvstore.MVStore;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.core.config.core.ConfigConstants;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection.Protocol;
@@ -56,16 +58,15 @@ import io.moquette.broker.subscriptions.Topic;
  *
  * @author David Graeff - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
 public class MqttEmbeddedBrokerServiceTest extends JavaTest {
 
     private EmbeddedBrokerService subject;
     private Map<String, Object> config = new HashMap<>();
     private @Mock MqttService service;
 
-    @Before
+    @BeforeEach
     public void setUp() throws ConfigurationException, MqttException, GeneralSecurityException, IOException {
-        MockitoAnnotations.initMocks(this);
-
         config.put("username", "username");
         config.put("password", "password");
         config.put("port", 12345);
@@ -75,7 +76,7 @@ public class MqttEmbeddedBrokerServiceTest extends JavaTest {
         subject = new EmbeddedBrokerService(service, config);
     }
 
-    @After
+    @AfterEach
     public void cleanUp() {
         subject.deactivate();
     }
index a8bffbfb27b520a25038b97250690df32ec64eff..2d65dce319f67c22e680415dd5561f9f8778a24d 100644 (file)
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.io.transport.modbus.BitArray;
 
 /**
@@ -60,27 +61,27 @@ public class BasicBitArrayTest {
         assertThat(data1.getBit(2), is(equalTo(false)));
     }
 
-    @Test(expected = IndexOutOfBoundsException.class)
+    @Test
     public void testOutOfBounds() {
         BitArray data1 = new BitArray(true, false, true);
-        data1.getBit(3);
+        assertThrows(IndexOutOfBoundsException.class, () -> data1.getBit(3));
     }
 
-    @Test(expected = IndexOutOfBoundsException.class)
+    @Test
     public void testOutOfBounds2() {
         BitArray data1 = new BitArray(true, false, true);
-        data1.getBit(-1);
+        assertThrows(IndexOutOfBoundsException.class, () -> data1.getBit(-1));
     }
 
-    @Test(expected = IndexOutOfBoundsException.class)
+    @Test
     public void testOutOfBounds3() {
         BitArray data1 = new BitArray(3);
-        data1.getBit(3);
+        assertThrows(IndexOutOfBoundsException.class, () -> data1.getBit(3));
     }
 
-    @Test(expected = IndexOutOfBoundsException.class)
+    @Test
     public void testOutOfBounds4() {
         BitArray data1 = new BitArray(3);
-        data1.getBit(-1);
+        assertThrows(IndexOutOfBoundsException.class, () -> data1.getBit(-1));
     }
 }
index e2794923a5272e3fffa847f285d52754f859365b..e5b0819b5fc402f0b7867177d0c38e6077f2b19a 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -21,12 +22,8 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.apache.commons.lang.NotImplementedException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.OnOffType;
@@ -39,22 +36,8 @@ import org.openhab.io.transport.modbus.ModbusRegisterArray;
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(Parameterized.class)
 public class BitUtilitiesCommandToRegistersTest {
 
-    private final Command command;
-    private final ValueType type;
-    private final Object expectedResult;
-
-    @Rule
-    public final ExpectedException shouldThrow = ExpectedException.none();
-
-    public BitUtilitiesCommandToRegistersTest(Command command, ValueType type, Object expectedResult) {
-        this.command = command;
-        this.type = type;
-        this.expectedResult = expectedResult; // Exception or array of 16bit integers
-    }
-
     private static short[] shorts(int... ints) {
         short[] shorts = new short[ints.length];
         for (int i = 0; i < ints.length; i++) {
@@ -64,7 +47,6 @@ public class BitUtilitiesCommandToRegistersTest {
         return shorts;
     }
 
-    @Parameters
     public static Collection<Object[]> data() {
         return Collections.unmodifiableList(Stream
                 .of(new Object[] { new DecimalType("1.0"), ValueType.BIT, IllegalArgumentException.class },
@@ -325,13 +307,15 @@ public class BitUtilitiesCommandToRegistersTest {
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
-    @Test
-    public void testCommandToRegisters() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testCommandToRegisters(Command command, ValueType type, Object expectedResult) {
         if (expectedResult instanceof Class && Exception.class.isAssignableFrom((Class) expectedResult)) {
-            shouldThrow.expect((Class) expectedResult);
+            assertThrows((Class) expectedResult, () -> ModbusBitUtilities.commandToRegisters(command, type));
+            return;
         }
 
-        ModbusRegisterArray registers = ModbusBitUtilities.commandToRegisters(this.command, this.type);
+        ModbusRegisterArray registers = ModbusBitUtilities.commandToRegisters(command, type);
         short[] expectedRegisters = (short[]) expectedResult;
 
         assertThat(String.format("register index command=%s, type=%s", command, type), registers.size(),
index 1221d8c320de78c6a6609776ffa4ba7fff85b7b8..8647903b24e63cebaad94d971711371b22e1adf2 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.nio.ByteBuffer;
 import java.util.Collection;
@@ -24,12 +25,8 @@ import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.io.transport.modbus.ModbusBitUtilities;
 import org.openhab.io.transport.modbus.ModbusConstants.ValueType;
@@ -39,25 +36,8 @@ import org.openhab.io.transport.modbus.ModbusRegisterArray;
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(Parameterized.class)
 public class BitUtilitiesExtractStateFromRegistersTest {
 
-    final ModbusRegisterArray registers;
-    final ValueType type;
-    final int index;
-    final Object expectedResult;
-
-    @Rule
-    public final ExpectedException shouldThrow = ExpectedException.none();
-
-    public BitUtilitiesExtractStateFromRegistersTest(Object expectedResult, ValueType type,
-            ModbusRegisterArray registers, int index) {
-        this.registers = registers;
-        this.index = index;
-        this.type = type;
-        this.expectedResult = expectedResult; // Exception or DecimalType
-    }
-
     private static ModbusRegisterArray shortArrayToRegisterArray(int... arr) {
         ModbusRegister[] tmp = new ModbusRegister[0];
         return new ModbusRegisterArray(IntStream.of(arr).mapToObj(val -> {
@@ -67,7 +47,6 @@ public class BitUtilitiesExtractStateFromRegistersTest {
         }).collect(Collectors.toList()).toArray(tmp));
     }
 
-    @Parameters
     public static Collection<Object[]> data() {
         return Collections.unmodifiableList(Stream.of(
                 //
@@ -383,14 +362,18 @@ public class BitUtilitiesExtractStateFromRegistersTest {
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
-    @Test
-    public void testCommandToRegisters() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testCommandToRegisters(Object expectedResult, ValueType type, ModbusRegisterArray registers,
+            int index) {
         if (expectedResult instanceof Class && Exception.class.isAssignableFrom((Class) expectedResult)) {
-            shouldThrow.expect((Class) expectedResult);
+            assertThrows((Class) expectedResult,
+                    () -> ModbusBitUtilities.extractStateFromRegisters(registers, index, type));
+            return;
         }
 
-        Optional<@NonNull DecimalType> actualState = ModbusBitUtilities.extractStateFromRegisters(this.registers,
-                this.index, this.type);
+        Optional<@NonNull DecimalType> actualState = ModbusBitUtilities.extractStateFromRegisters(registers, index,
+                type);
         // Wrap given expectedResult to Optional, if necessary
         Optional<@NonNull DecimalType> expectedStateWrapped = expectedResult instanceof DecimalType
                 ? Optional.of((DecimalType) expectedResult)
index bcea73431e9af12422a288cc9bd19e76d0c84ccc..59b94885a284c3678cbe92950054f019591db744 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -24,41 +25,20 @@ import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.core.library.types.StringType;
 import org.openhab.io.transport.modbus.ModbusBitUtilities;
 import org.openhab.io.transport.modbus.ModbusRegister;
 import org.openhab.io.transport.modbus.ModbusRegisterArray;
 
+import io.swagger.v3.oas.annotations.Parameters;
+
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(Parameterized.class)
 public class BitUtilitiesExtractStringFromRegistersTest {
 
-    final ModbusRegisterArray registers;
-    final int index;
-    final int length;
-    final Object expectedResult;
-    final Charset charset;
-
-    @Rule
-    public final ExpectedException shouldThrow = ExpectedException.none();
-
-    public BitUtilitiesExtractStringFromRegistersTest(Object expectedResult, ModbusRegisterArray registers, int index,
-            int length, Charset charset) {
-        this.registers = registers;
-        this.index = index;
-        this.length = length;
-        this.charset = charset;
-        this.expectedResult = expectedResult;
-    }
-
     private static ModbusRegisterArray shortArrayToRegisterArray(int... arr) {
         ModbusRegister[] tmp = new ModbusRegister[0];
         return new ModbusRegisterArray(IntStream.of(arr).mapToObj(val -> {
@@ -99,14 +79,17 @@ public class BitUtilitiesExtractStringFromRegistersTest {
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
-    @Test
-    public void testExtractStringFromRegisters() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testExtractStringFromRegisters(Object expectedResult, ModbusRegisterArray registers, int index,
+            int length, Charset charset) {
         if (expectedResult instanceof Class && Exception.class.isAssignableFrom((Class) expectedResult)) {
-            shouldThrow.expect((Class) expectedResult);
+            assertThrows((Class) expectedResult,
+                    () -> ModbusBitUtilities.extractStringFromRegisters(registers, index, length, charset));
+            return;
         }
 
-        StringType actualState = ModbusBitUtilities.extractStringFromRegisters(this.registers, this.index, this.length,
-                this.charset);
+        StringType actualState = ModbusBitUtilities.extractStringFromRegisters(registers, index, length, charset);
         assertThat(String.format("registers=%s, index=%d, length=%d", registers, index, length), actualState,
                 is(equalTo(expectedResult)));
     }
index 7e4f14819dce1c861ee82bc79126fe446ab4b8cb..1c211f00c12ad071b28c22c327ac65671845ce4b 100644 (file)
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Optional;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.OnOffType;
index 428ed46325974b615ae51652704b1d86bb65eeab..ae573be3041efd8152be4ca86837cc928cbd14ce 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -27,11 +28,13 @@ import java.util.HashMap;
 import java.util.function.LongSupplier;
 
 import org.apache.commons.lang.NotImplementedException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.mockito.MockitoAnnotations;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.openhab.core.test.java.JavaTest;
 import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
 import org.openhab.io.transport.modbus.endpoint.ModbusTCPSlaveEndpoint;
@@ -62,6 +65,8 @@ import net.wimpi.modbus.util.SerialParameters;
 /**
  * @author Sami Salonen - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 public class IntegrationTestSupport extends JavaTest {
 
     public enum ServerType {
@@ -113,14 +118,9 @@ public class IntegrationTestSupport extends JavaTest {
 
     private static AtomicCounter udpServerIndex = new AtomicCounter(0);
 
-    @Spy
-    protected TCPSlaveConnectionFactory tcpConnectionFactory = new TCPSlaveConnectionFactoryImpl();
-
-    @Spy
-    protected UDPSlaveTerminalFactory udpTerminalFactory = new UDPSlaveTerminalFactoryImpl();
-
-    @Spy
-    protected SerialConnectionFactory serialConnectionFactory = new SerialConnectionFactoryImpl();
+    protected @Spy TCPSlaveConnectionFactory tcpConnectionFactory = new TCPSlaveConnectionFactoryImpl();
+    protected @Spy UDPSlaveTerminalFactory udpTerminalFactory = new UDPSlaveTerminalFactoryImpl();
+    protected @Spy SerialConnectionFactory serialConnectionFactory = new SerialConnectionFactoryImpl();
 
     protected ResultCaptor<ModbusRequest> modbustRequestCaptor;
 
@@ -146,7 +146,7 @@ public class IntegrationTestSupport extends JavaTest {
         return InetAddress.getByName("127.0.0.1");
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         modbustRequestCaptor = new ResultCaptor<>(new LongSupplier() {
 
@@ -155,12 +155,11 @@ public class IntegrationTestSupport extends JavaTest {
                 return artificialServerWait;
             }
         });
-        MockitoAnnotations.initMocks(this);
         modbusManager = new NonOSGIModbusManager();
         startServer();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         stopServer();
         modbusManager.close();
@@ -238,8 +237,8 @@ public class IntegrationTestSupport extends JavaTest {
 
         udpListener.start();
         waitForUDPServerStartup();
-        Assert.assertNotSame(-1, udpModbusPort);
-        Assert.assertNotSame(0, udpModbusPort);
+        assertNotSame(-1, udpModbusPort);
+        assertNotSame(0, udpModbusPort);
     }
 
     private void waitForUDPServerStartup() throws InterruptedException {
@@ -256,8 +255,8 @@ public class IntegrationTestSupport extends JavaTest {
         tcpListener.start();
         // Query server port. It seems to take time (probably due to thread starting)
         waitForTCPServerStartup();
-        Assert.assertNotSame(-1, tcpModbusPort);
-        Assert.assertNotSame(0, tcpModbusPort);
+        assertNotSame(-1, tcpModbusPort);
+        assertNotSame(0, tcpModbusPort);
     }
 
     private void waitForTCPServerStartup() throws InterruptedException {
index 70ea4dbfe413a0f6ac42c8469179c89132cf93d2..35a7eb02f63c0d06b6900ae7d9699e0014e8c00b 100644 (file)
@@ -12,8 +12,9 @@
  */
 package org.openhab.io.transport.modbus.test;
 
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
 import org.openhab.io.transport.modbus.endpoint.ModbusSerialSlaveEndpoint;
 import org.openhab.io.transport.modbus.endpoint.ModbusTCPSlaveEndpoint;
 import org.openhab.io.transport.modbus.endpoint.ModbusUDPSlaveEndpoint;
@@ -30,7 +31,7 @@ public class ModbusSlaveEndpointTestCase {
     public void testEqualsSameTcp() {
         ModbusTCPSlaveEndpoint e1 = new ModbusTCPSlaveEndpoint("127.0.0.1", 500);
         ModbusTCPSlaveEndpoint e2 = new ModbusTCPSlaveEndpoint("127.0.0.1", 500);
-        Assert.assertEquals(e1, e2);
+        assertEquals(e1, e2);
     }
 
     @Test
@@ -41,7 +42,7 @@ public class ModbusSlaveEndpointTestCase {
         ModbusSerialSlaveEndpoint e2 = new ModbusSerialSlaveEndpoint("port1", 9600, SerialPort.FLOWCONTROL_NONE,
                 SerialPort.FLOWCONTROL_NONE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE,
                 Modbus.DEFAULT_SERIAL_ENCODING, true, 500);
-        Assert.assertEquals(e1, e2);
+        assertEquals(e1, e2);
     }
 
     /**
@@ -55,8 +56,8 @@ public class ModbusSlaveEndpointTestCase {
         ModbusSerialSlaveEndpoint e2 = new ModbusSerialSlaveEndpoint("port1", 9600, SerialPort.FLOWCONTROL_NONE,
                 SerialPort.FLOWCONTROL_NONE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE,
                 Modbus.DEFAULT_SERIAL_ENCODING, false, 500);
-        Assert.assertEquals(e1, e2);
-        Assert.assertEquals(e1.hashCode(), e2.hashCode());
+        assertEquals(e1, e2);
+        assertEquals(e1.hashCode(), e2.hashCode());
     }
 
     @Test
@@ -67,32 +68,32 @@ public class ModbusSlaveEndpointTestCase {
         ModbusSerialSlaveEndpoint e2 = new ModbusSerialSlaveEndpoint("port2", 9600, SerialPort.FLOWCONTROL_NONE,
                 SerialPort.FLOWCONTROL_NONE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE,
                 Modbus.DEFAULT_SERIAL_ENCODING, true, 500);
-        Assert.assertNotEquals(e1, e2);
-        Assert.assertNotEquals(e1.hashCode(), e2.hashCode());
+        assertNotEquals(e1, e2);
+        assertNotEquals(e1.hashCode(), e2.hashCode());
     }
 
     @Test
     public void testEqualsDifferentTCPPort() {
         ModbusTCPSlaveEndpoint e1 = new ModbusTCPSlaveEndpoint("127.0.0.1", 500);
         ModbusTCPSlaveEndpoint e2 = new ModbusTCPSlaveEndpoint("127.0.0.1", 501);
-        Assert.assertNotEquals(e1, e2);
-        Assert.assertNotEquals(e1.hashCode(), e2.hashCode());
+        assertNotEquals(e1, e2);
+        assertNotEquals(e1.hashCode(), e2.hashCode());
     }
 
     @Test
     public void testEqualsDifferentTCPHost() {
         ModbusTCPSlaveEndpoint e1 = new ModbusTCPSlaveEndpoint("127.0.0.1", 500);
         ModbusTCPSlaveEndpoint e2 = new ModbusTCPSlaveEndpoint("127.0.0.2", 501);
-        Assert.assertNotEquals(e1, e2);
-        Assert.assertNotEquals(e1.hashCode(), e2.hashCode());
+        assertNotEquals(e1, e2);
+        assertNotEquals(e1.hashCode(), e2.hashCode());
     }
 
     @Test
     public void testEqualsDifferentProtocol() {
         ModbusTCPSlaveEndpoint e1 = new ModbusTCPSlaveEndpoint("127.0.0.1", 500);
         ModbusUDPSlaveEndpoint e2 = new ModbusUDPSlaveEndpoint("127.0.0.1", 500);
-        Assert.assertNotEquals(e1, e2);
-        Assert.assertNotEquals(e1.hashCode(), e2.hashCode());
+        assertNotEquals(e1, e2);
+        assertNotEquals(e1.hashCode(), e2.hashCode());
     }
 
     @Test
@@ -101,7 +102,7 @@ public class ModbusSlaveEndpointTestCase {
         ModbusSerialSlaveEndpoint e2 = new ModbusSerialSlaveEndpoint("port2", 9600, SerialPort.FLOWCONTROL_NONE,
                 SerialPort.FLOWCONTROL_NONE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE,
                 Modbus.DEFAULT_SERIAL_ENCODING, true, 500);
-        Assert.assertNotEquals(e1, e2);
-        Assert.assertNotEquals(e1.hashCode(), e2.hashCode());
+        assertNotEquals(e1, e2);
+        assertNotEquals(e1.hashCode(), e2.hashCode());
     }
 }
index c0c886d49276f26862df4d2b7efa65d4de46d078..912175e4d5d6e355b0638e588b2002369ae7164c 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assumptions.*;
 
 import java.io.IOException;
 import java.lang.reflect.Constructor;
@@ -35,8 +36,8 @@ import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.io.transport.modbus.BitArray;
 import org.openhab.io.transport.modbus.ModbusCommunicationInterface;
 import org.openhab.io.transport.modbus.ModbusReadFunctionCode;
@@ -132,7 +133,7 @@ public class SmokeTest extends IntegrationTestSupport {
         }
     }
 
-    @Before
+    @BeforeEach
     public void setUpSocketSpy() throws IOException {
         socketSpy.sockets.clear();
     }
@@ -164,7 +165,7 @@ public class SmokeTest extends IntegrationTestSupport {
 
             assertThat(okCount.get(), is(equalTo(0)));
             assertThat(errorCount.get(), is(equalTo(1)));
-            assertTrue(lastError.toString(), lastError.get() instanceof ModbusSlaveErrorResponseException);
+            assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
         }
     }
 
@@ -201,7 +202,7 @@ public class SmokeTest extends IntegrationTestSupport {
 
             assertThat(okCount.get(), is(equalTo(0)));
             assertThat(errorCount.get(), is(equalTo(1)));
-            assertTrue(lastError.toString(), lastError.get() instanceof ModbusConnectionException);
+            assertTrue(lastError.get() instanceof ModbusConnectionException, lastError.toString());
         }
     }
 
@@ -234,7 +235,7 @@ public class SmokeTest extends IntegrationTestSupport {
             assertTrue(callbackCalled.await(15, TimeUnit.SECONDS));
             assertThat(okCount.get(), is(equalTo(0)));
             assertThat(lastError.toString(), errorCount.get(), is(equalTo(1)));
-            assertTrue(lastError.toString(), lastError.get() instanceof ModbusSlaveIOException);
+            assertTrue(lastError.get() instanceof ModbusSlaveIOException, lastError.toString());
         }
     }
 
@@ -473,7 +474,7 @@ public class SmokeTest extends IntegrationTestSupport {
             assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
 
             assertThat(unexpectedCount.get(), is(equalTo(0)));
-            assertTrue(lastError.toString(), lastError.get() instanceof ModbusSlaveErrorResponseException);
+            assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
 
             assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
             ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
@@ -550,7 +551,7 @@ public class SmokeTest extends IntegrationTestSupport {
             assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
 
             assertThat(unexpectedCount.get(), is(equalTo(0)));
-            assertTrue(lastError.toString(), lastError.get() instanceof ModbusSlaveErrorResponseException);
+            assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
 
             assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
             ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
@@ -705,13 +706,13 @@ public class SmokeTest extends IntegrationTestSupport {
         assertTrue(responses > 1);
 
         // Rest of the (timing-sensitive) assertions are not run in CI
-        assumeFalse("Running in CI! Will not test timing-sensitive details", isRunningInCI());
+        assumeFalse(isRunningInCI(), "Running in CI! Will not test timing-sensitive details");
         float averagePollPeriodMillis = ((float) (pollEndMillis - pollStartMillis)) / (responses - 1);
-        assertTrue(String.format(
-                "Measured avarage poll period %f ms (%d responses in %d ms) is not withing expected limits [%d, %d]",
-                averagePollPeriodMillis, responses, pollEndMillis - pollStartMillis, expectedPollAverageMin,
-                expectedPollAverageMax),
-                averagePollPeriodMillis > expectedPollAverageMin && averagePollPeriodMillis < expectedPollAverageMax);
+        assertTrue(averagePollPeriodMillis > expectedPollAverageMin && averagePollPeriodMillis < expectedPollAverageMax,
+                String.format(
+                        "Measured avarage poll period %f ms (%d responses in %d ms) is not withing expected limits [%d, %d]",
+                        averagePollPeriodMillis, responses, pollEndMillis - pollStartMillis, expectedPollAverageMin,
+                        expectedPollAverageMax));
     }
 
     @Test
@@ -828,10 +829,10 @@ public class SmokeTest extends IntegrationTestSupport {
 
     @Test
     public void testConnectionCloseAfterLastCommunicationInterfaceClosed() throws IllegalArgumentException, Exception {
-        assumeFalse("Running in CI! Will not test timing-sensitive details", isRunningInCI());
+        assumeFalse(isRunningInCI(), "Running in CI! Will not test timing-sensitive details");
         ModbusSlaveEndpoint endpoint = getEndpoint();
-        assumeTrue("Connection closing test supported only with TCP slaves",
-                endpoint instanceof ModbusTCPSlaveEndpoint);
+        assumeTrue(endpoint instanceof ModbusTCPSlaveEndpoint,
+                "Connection closing test supported only with TCP slaves");
 
         // Generate server data
         generateData();
@@ -893,10 +894,10 @@ public class SmokeTest extends IntegrationTestSupport {
 
     @Test
     public void testConnectionCloseAfterOneOffPoll() throws IllegalArgumentException, Exception {
-        assumeFalse("Running in CI! Will not test timing-sensitive details", isRunningInCI());
+        assumeFalse(isRunningInCI(), "Running in CI! Will not test timing-sensitive details");
         ModbusSlaveEndpoint endpoint = getEndpoint();
-        assumeTrue("Connection closing test supported only with TCP slaves",
-                endpoint instanceof ModbusTCPSlaveEndpoint);
+        assumeTrue(endpoint instanceof ModbusTCPSlaveEndpoint,
+                "Connection closing test supported only with TCP slaves");
 
         // Generate server data
         generateData();
index 241ec405821bcd17bb89bb0fd3b117d7d05fe494..22fa4023097ad92fa44a3beef9d9a4a300d8f993 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.io.transport.modbus.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.collection.IsArrayContainingInOrder.arrayContaining;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.ArrayMatching.arrayContaining;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.openhab.io.transport.modbus.ModbusConstants.*;
 
 import java.util.Collection;
@@ -24,7 +25,7 @@ import java.util.stream.IntStream;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.hamcrest.Matcher;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.io.transport.modbus.ModbusWriteFunctionCode;
 import org.openhab.io.transport.modbus.ModbusWriteRequestBlueprint;
 import org.openhab.io.transport.modbus.json.WriteRequestJsonUtilities;
@@ -49,13 +50,13 @@ public class WriteRequestJsonUtilitiesTest {
         assertThat(WriteRequestJsonUtilities.fromJson(3, "[]").size(), is(equalTo(0)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC6NoRegister() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 6,"//
                 + "\"address\": 5412,"//
                 + "\"value\": []"//
-                + "}]");
+                + "}]"));
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -83,22 +84,22 @@ public class WriteRequestJsonUtilitiesTest {
                         (Matcher) new RegisterMatcher(55, 5412, 99, ModbusWriteFunctionCode.WRITE_SINGLE_REGISTER, 3)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC6MultipleRegisters() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 6,"//
                 + "\"address\": 5412,"//
                 + "\"value\": [3, 4]"//
-                + "}]");
+                + "}]"));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC16NoRegister() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 16,"//
                 + "\"address\": 5412,"//
                 + "\"value\": []"//
-                + "}]");
+                + "}]"));
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -135,13 +136,13 @@ public class WriteRequestJsonUtilitiesTest {
         assertThat(writes.size(), is(equalTo(1)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC16MultipleRegistersTooManyRegisters() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 16,"//
                 + "\"address\": 5412,"//
                 + "\"value\": [" + String.join(",", OVER_MAX_REGISTERS) + "]"//
-                + "}]");
+                + "}]"));
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -156,13 +157,13 @@ public class WriteRequestJsonUtilitiesTest {
                         ModbusWriteFunctionCode.WRITE_COIL, true)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC5MultipleCoils() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 5,"//
                 + "\"address\": 5412,"//
                 + "\"value\": [3, 4]"//
-                + "}]");
+                + "}]"));
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -199,25 +200,25 @@ public class WriteRequestJsonUtilitiesTest {
         assertThat(writes.size(), is(equalTo(1)));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testFC15MultipleCoilsTooManyCoils() {
-        WriteRequestJsonUtilities.fromJson(55, "[{"//
+        assertThrows(IllegalArgumentException.class, () -> WriteRequestJsonUtilities.fromJson(55, "[{"//
                 + "\"functionCode\": 15,"//
                 + "\"address\": 5412,"//
                 + "\"value\": [" + String.join(",", OVER_MAX_COILS) + "]"//
-                + "}]");
+                + "}]"));
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void testEmptyObject() {
         // we are expecting list, not object -> error
-        WriteRequestJsonUtilities.fromJson(3, "{}");
+        assertThrows(IllegalStateException.class, () -> WriteRequestJsonUtilities.fromJson(3, "{}"));
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void testNumber() {
         // we are expecting list, not primitive (number) -> error
-        WriteRequestJsonUtilities.fromJson(3, "3");
+        assertThrows(IllegalStateException.class, () -> WriteRequestJsonUtilities.fromJson(3, "3"));
     }
 
     @Test
index c47545a199c1925977fa38f3043b53e18dcff9c9..d409ea24385435a48c15968a2ba7497fabad0768 100644 (file)
@@ -33,7 +33,7 @@ import org.openhab.core.types.State;
  * against actual dynamo db database.
  *
  *
- * Inheritor of this base class needs to store two states of one item in a static method annotated with @BeforeClass.
+ * Inheritor of this base class needs to store two states of one item in a static method annotated with @BeforeAll.
  * This
  * static
  * class should update the private static fields
index d668ac047ea7255d006d27a23e03b21e5c468071..e4c0ee280d9eadad9ff4bc6538873b037b9a34fe 100644 (file)
  */
 package org.openhab.transform.jinja.internal;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.transform.TransformationException;
 
 /**
@@ -24,7 +25,7 @@ public class JinjaTransformationServiceTest {
 
     private JinjaTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new JinjaTransformationService();
     }
@@ -36,7 +37,7 @@ public class JinjaTransformationServiceTest {
         String transformedResponse = processor.transform("{{value_json['AM2301'].Temperature}}", json);
 
         // Asserts
-        Assert.assertEquals("4.7", transformedResponse);
+        assertEquals("4.7", transformedResponse);
     }
 
     @Test
@@ -46,7 +47,7 @@ public class JinjaTransformationServiceTest {
         String transformedResponse = processor.transform("Hello {{ value }}!", value);
 
         // Asserts
-        Assert.assertEquals("Hello world!", transformedResponse);
+        assertEquals("Hello world!", transformedResponse);
     }
 
     @Test
@@ -56,6 +57,6 @@ public class JinjaTransformationServiceTest {
         String transformedResponse = processor.transform("Hello {{ value_json }}!", value);
 
         // Asserts
-        Assert.assertEquals("Hello world!", transformedResponse);
+        assertEquals("Hello world!", transformedResponse);
     }
 }
index 3d48ce7facc51d2f90b6873c296763e8f6cc47fa..4569cfc769b5db417c3a4980f422519038869c86 100644 (file)
  */
 package org.openhab.transform.jsonpath.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.transform.TransformationException;
 
 /**
@@ -26,7 +25,7 @@ public class JSonPathTransformationServiceTest {
 
     private JSonPathTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new JSonPathTransformationService();
     }
@@ -38,7 +37,7 @@ public class JSonPathTransformationServiceTest {
         String transformedResponse = processor.transform("$.store.book[0].author", json);
 
         // Asserts
-        Assert.assertEquals("Nigel Rees", transformedResponse);
+        assertEquals("Nigel Rees", transformedResponse);
     }
 
     private static final String jsonArray = "[" + //
@@ -58,19 +57,19 @@ public class JSonPathTransformationServiceTest {
         assertEquals("2", transformedResponse);
     }
 
-    @Test(expected = TransformationException.class)
-    public void testInvalidPathThrowsException() throws TransformationException {
-        processor.transform("$$", jsonArray);
+    @Test
+    public void testInvalidPathThrowsException() {
+        assertThrows(TransformationException.class, () -> processor.transform("$$", jsonArray));
     }
 
-    @Test(expected = TransformationException.class)
-    public void testPathMismatchReturnNull() throws TransformationException {
-        processor.transform("$[5].id", jsonArray);
+    @Test
+    public void testPathMismatchReturnNull() {
+        assertThrows(TransformationException.class, () -> processor.transform("$[5].id", jsonArray));
     }
 
-    @Test(expected = TransformationException.class)
+    @Test
     public void testInvalidJsonReturnNull() throws TransformationException {
-        processor.transform("$", "{id:");
+        assertThrows(TransformationException.class, () -> processor.transform("$", "{id:"));
     }
 
     @Test
index 0552a64a9f07d6e05dc3d06fb4f839df277f407c..e1974b2006d9a9f9bedfca8afbab6b88064f7a8f 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.transform.map.internal;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.io.FileReader;
@@ -23,17 +23,23 @@ import java.util.Properties;
 import java.util.concurrent.Callable;
 
 import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
 import org.osgi.framework.BundleContext;
 
 /**
  * @author Gaël L'hopital - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
+@Disabled("Needs to be updated for OH3")
 public class MapTransformationServiceTest {
 
     private static final String SOURCE_CLOSED = "CLOSED";
@@ -47,8 +53,7 @@ public class MapTransformationServiceTest {
     private static final String CONFIG_FOLDER = BASE_FOLDER + File.separator + SRC_FOLDER;
     private static final String USED_FILENAME = CONFIG_FOLDER + File.separator + "transform/" + EXISTING_FILENAME_DE;
 
-    @Mock
-    private BundleContext bundleContext;
+    private @Mock BundleContext bundleContext;
 
     private TestableMapTransformationService processor;
 
@@ -74,16 +79,14 @@ public class MapTransformationServiceTest {
         }
     };
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
-        MockitoAnnotations.initMocks(this);
-
         processor = new TestableMapTransformationService();
         processor.activate(bundleContext);
         FileUtils.copyDirectory(new File(SRC_FOLDER), new File(CONFIG_FOLDER));
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws IOException {
         processor.deactivate();
         FileUtils.deleteDirectory(new File(CONFIG_FOLDER));
@@ -93,7 +96,7 @@ public class MapTransformationServiceTest {
     public void testTransformByMap() throws Exception {
         // Test that we find a translation in an existing file
         String transformedResponse = processor.transform(EXISTING_FILENAME_DE, SOURCE_CLOSED);
-        Assert.assertEquals("zu", transformedResponse);
+        assertEquals("zu", transformedResponse);
 
         Properties properties = new Properties();
         try (FileReader reader = new FileReader(USED_FILENAME); FileWriter writer = new FileWriter(USED_FILENAME)) {
@@ -107,7 +110,7 @@ public class MapTransformationServiceTest {
                 @Override
                 public Void call() throws Exception {
                     final String transformedResponse = processor.transform(EXISTING_FILENAME_DE, SOURCE_CLOSED);
-                    Assert.assertEquals("changevalue", transformedResponse);
+                    assertEquals("changevalue", transformedResponse);
                     return null;
                 }
             }, 10000, 100);
@@ -119,7 +122,7 @@ public class MapTransformationServiceTest {
                 @Override
                 public Void call() throws Exception {
                     final String transformedResponse = processor.transform(EXISTING_FILENAME_DE, SOURCE_CLOSED);
-                    Assert.assertEquals("zu", transformedResponse);
+                    assertEquals("zu", transformedResponse);
                     return null;
                 }
             }, 10000, 100);
@@ -130,7 +133,7 @@ public class MapTransformationServiceTest {
         // Checks that an unknown input in an existing file give the expected
         // transformed response that shall be empty string (Issue #1107) if not found in the file
         transformedResponse = processor.transform(EXISTING_FILENAME_DE, SOURCE_UNKNOWN);
-        Assert.assertEquals("", transformedResponse);
+        assertEquals("", transformedResponse);
 
         // Test that an inexisting file raises correct exception as expected
         try {
@@ -144,19 +147,19 @@ public class MapTransformationServiceTest {
         transformedResponse = processor.transform(SHOULD_BE_LOCALIZED_FILENAME, SOURCE_CLOSED);
         // as we don't know the real locale at the moment the
         // test is run, we test that the string has actually been transformed
-        Assert.assertNotEquals(SOURCE_CLOSED, transformedResponse);
+        assertNotEquals(SOURCE_CLOSED, transformedResponse);
         transformedResponse = processor.transform(SHOULD_BE_LOCALIZED_FILENAME, SOURCE_CLOSED);
-        Assert.assertNotEquals(SOURCE_CLOSED, transformedResponse);
+        assertNotEquals(SOURCE_CLOSED, transformedResponse);
     }
 
     @Test
     public void testTransformByMapWithDefault() throws Exception {
         // Standard behaviour with no default value
         String transformedResponse = processor.transform(SHOULD_BE_LOCALIZED_FILENAME, "toBeDefaulted");
-        Assert.assertEquals("", transformedResponse);
+        assertEquals("", transformedResponse);
         // Modified behaviour with a file containing default value definition
         transformedResponse = processor.transform(DEFAULTED_FILENAME, "toBeDefaulted");
-        Assert.assertEquals("Default Value", transformedResponse);
+        assertEquals("Default Value", transformedResponse);
     }
 
     protected void waitForAssert(Callable<Void> assertion, int timeout, int sleepTime) throws Exception {
index 5c44e827d7b1844f1cf293674be762046a68f9a2..b8a12de94116a355a5f6bf6b30f1dede838c49bc 100644 (file)
  */
 package org.openhab.transform.regex.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.transform.TransformationException;
 
 /**
@@ -25,7 +25,7 @@ public class RegExTransformationServiceTest extends AbstractTransformationServic
 
     private RegExTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new RegExTransformationService();
     }
index 33f5234543dbecc043aca14d40a6b82d67e2de0d..ac5341ea5e5a171a36c2ea601819925e8758d4ee 100644 (file)
  */
 package org.openhab.transform.scale.internal;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Locale;
 
 import javax.measure.quantity.Dimensionless;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.transform.TransformationException;
 
@@ -30,7 +29,7 @@ import org.openhab.core.transform.TransformationException;
 public class ScaleTransformServiceTest {
     private ScaleTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new ScaleTransformationService() {
             @Override
@@ -46,12 +45,12 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/humidex_de.scale";
         String source = "10";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("nicht wesentlich", transformedResponse);
+        assertEquals("nicht wesentlich", transformedResponse);
 
         existingscale = "scale/limits.scale";
         source = "10";
         transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("middle", transformedResponse);
+        assertEquals("middle", transformedResponse);
     }
 
     @Test
@@ -61,18 +60,18 @@ public class ScaleTransformServiceTest {
         // Testing upper bound opened range
         String source = "500";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("extreme", transformedResponse);
+        assertEquals("extreme", transformedResponse);
 
         // Testing lower bound opened range
         source = "-10";
         transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("low", transformedResponse);
+        assertEquals("low", transformedResponse);
 
         // Testing unfinite up and down range
         existingscale = "scale/catchall.scale";
         source = "-10";
         transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("catchall", transformedResponse);
+        assertEquals("catchall", transformedResponse);
     }
 
     @Test
@@ -82,7 +81,7 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/humidex_fr.scale";
         String source = "-";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("", transformedResponse);
+        assertEquals("", transformedResponse);
     }
 
     @Test
@@ -106,7 +105,7 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/evaluationorder.scale";
         String source = "azerty";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("", transformedResponse);
+        assertEquals("", transformedResponse);
     }
 
     @Test
@@ -117,7 +116,7 @@ public class ScaleTransformServiceTest {
         String source = "12";
 
         String transformedResponse = processor.transform(evaluationOrder, source);
-        Assert.assertEquals("first", transformedResponse);
+        assertEquals("first", transformedResponse);
     }
 
     @Test
@@ -127,7 +126,7 @@ public class ScaleTransformServiceTest {
         String expected = "Correcte (992 ppm) !";
 
         String transformedResponse = processor.transform(aqScaleFile, airQuality.toString());
-        Assert.assertEquals(expected, transformedResponse);
+        assertEquals(expected, transformedResponse);
     }
 
     @Test
@@ -136,7 +135,7 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/catchnonnumeric.scale";
         String source = "azerty";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("Non Numeric", transformedResponse);
+        assertEquals("Non Numeric", transformedResponse);
     }
 
     @Test
@@ -144,7 +143,7 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/netatmo_aq.scale";
         String source = "992";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("Correcte (992) !", transformedResponse);
+        assertEquals("Correcte (992) !", transformedResponse);
     }
 
     @Test
@@ -152,6 +151,6 @@ public class ScaleTransformServiceTest {
         String existingscale = "scale/humidex.scale";
         String source = "200";
         String transformedResponse = processor.transform(existingscale, source);
-        Assert.assertEquals("", transformedResponse);
+        assertEquals("", transformedResponse);
     }
 }
index edbd1dfa5272acb8dbf920d4d78c4cdedba3031b..c5c0a9a6eab2333ec45112ed7671daa12c56417c 100644 (file)
  */
 package org.openhab.transform.xpath.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.transform.TransformationException;
 
 /**
@@ -25,7 +25,7 @@ public class XPathTransformationServiceTest extends AbstractTransformationServic
 
     private XPathTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new XPathTransformationService();
     }
index 33504143dab81813bf4e9789c6e37d7819a9dd9f..5f0ae560de3d9bbf2f00ca9171492a18e6fe440b 100644 (file)
  */
 package org.openhab.transform.xslt.internal;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.transform.TransformationException;
 
 /**
@@ -25,7 +25,7 @@ public class XsltTransformationServiceTest extends AbstractTransformationService
 
     private XsltTransformationService processor;
 
-    @Before
+    @BeforeEach
     public void init() {
         processor = new XsltTransformationService();
     }
index 3d40103b4efd24aa2216f6887ac79f8a7bdaa4f6..0f6540b3ed7fb4087874121f2e58c6688c3421a2 100644 (file)
  */
 package org.openhab.voice.mactts.internal;
 
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 
 import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,8 +37,8 @@ public class MacTTSVoiceTest {
      * Test MacTTSVoice(String) constructor
      */
     @Test
-    public void testConstructor() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+    public void testConstructor() throws IOException {
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
         BufferedReader bufferedReader = null;
         try {
             Process process = Runtime.getRuntime().exec("say -v ?");
@@ -46,9 +47,7 @@ public class MacTTSVoiceTest {
 
             String nextLine = bufferedReader.readLine();
             MacTTSVoice voiceMacOS = new MacTTSVoice(nextLine);
-            Assert.assertNotNull("The MacTTSVoice(String) constructor failed", voiceMacOS);
-        } catch (IOException e) {
-            Assert.fail("testConstructor() failed with IOException: " + e.getMessage());
+            assertNotNull(voiceMacOS, "The MacTTSVoice(String) constructor failed");
         } finally {
             IOUtils.closeQuietly(bufferedReader);
         }
@@ -58,8 +57,8 @@ public class MacTTSVoiceTest {
      * Test VoiceMacOS.getUID()
      */
     @Test
-    public void getUIDTest() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+    public void getUIDTest() throws IOException {
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
         BufferedReader bufferedReader = null;
         try {
             Process process = Runtime.getRuntime().exec("say -v ?");
@@ -68,10 +67,7 @@ public class MacTTSVoiceTest {
 
             String nextLine = bufferedReader.readLine();
             MacTTSVoice macTTSVoice = new MacTTSVoice(nextLine);
-            Assert.assertTrue("The VoiceMacOS UID has an incorrect format",
-                    (0 == macTTSVoice.getUID().indexOf("mactts:")));
-        } catch (IOException e) {
-            Assert.fail("getUIDTest() failed with IOException: " + e.getMessage());
+            assertTrue(0 == macTTSVoice.getUID().indexOf("mactts:"), "The VoiceMacOS UID has an incorrect format");
         } finally {
             IOUtils.closeQuietly(bufferedReader);
         }
@@ -81,8 +77,8 @@ public class MacTTSVoiceTest {
      * Test MacTTSVoice.getLabel()
      */
     @Test
-    public void getLabelTest() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+    public void getLabelTest() throws IOException {
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
         BufferedReader bufferedReader = null;
         try {
             Process process = Runtime.getRuntime().exec("say -v ?");
@@ -91,9 +87,7 @@ public class MacTTSVoiceTest {
 
             String nextLine = bufferedReader.readLine();
             MacTTSVoice voiceMacOS = new MacTTSVoice(nextLine);
-            Assert.assertNotNull("The MacTTSVoice label has an incorrect format", voiceMacOS.getLabel());
-        } catch (IOException e) {
-            Assert.fail("getLabelTest() failed with IOException: " + e.getMessage());
+            assertNotNull(voiceMacOS.getLabel(), "The MacTTSVoice label has an incorrect format");
         } finally {
             IOUtils.closeQuietly(bufferedReader);
         }
@@ -103,8 +97,8 @@ public class MacTTSVoiceTest {
      * Test MacTTSVoice.getLocale()
      */
     @Test
-    public void getLocaleTest() {
-        Assume.assumeTrue("Mac OS X" == System.getProperty("os.name"));
+    public void getLocaleTest() throws IOException {
+        assumeTrue("Mac OS X" == System.getProperty("os.name"));
         BufferedReader bufferedReader = null;
         try {
             Process process = Runtime.getRuntime().exec("say -v ?");
@@ -113,9 +107,7 @@ public class MacTTSVoiceTest {
 
             String nextLine = bufferedReader.readLine();
             MacTTSVoice voiceMacOS = new MacTTSVoice(nextLine);
-            Assert.assertNotNull("The MacTTSVoice locale has an incorrect format", voiceMacOS.getLocale());
-        } catch (IOException e) {
-            Assert.fail("getLocaleTest() failed with IOException: " + e.getMessage());
+            assertNotNull(voiceMacOS.getLocale(), "The MacTTSVoice locale has an incorrect format");
         } finally {
             IOUtils.closeQuietly(bufferedReader);
         }
index 2e2d3c4833ae9020804998f37aa0336b978d54e5..ff1418263008ca7096f5fbee21777dcc2e1b888d 100644 (file)
  */
 package org.openhab.voice.mactts.internal;
 
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
 import java.io.IOException;
 import java.util.Set;
 
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.audio.AudioFormat;
 import org.openhab.core.audio.AudioStream;
 import org.openhab.core.voice.TTSException;
@@ -35,10 +36,10 @@ public class TTSServiceMacOSTest {
      */
     @Test
     public void getAvailableVoicesTest() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
 
         MacTTSService ttsServiceMacOS = new MacTTSService();
-        Assert.assertFalse("The getAvailableVoicesTest() failed", ttsServiceMacOS.getAvailableVoices().isEmpty());
+        assertFalse(ttsServiceMacOS.getAvailableVoices().isEmpty());
     }
 
     /**
@@ -46,34 +47,28 @@ public class TTSServiceMacOSTest {
      */
     @Test
     public void getSupportedFormatsTest() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
 
         MacTTSService ttsServiceMacOS = new MacTTSService();
-        Assert.assertFalse("The getSupportedFormatsTest() failed", ttsServiceMacOS.getSupportedFormats().isEmpty());
+        assertFalse(ttsServiceMacOS.getSupportedFormats().isEmpty());
     }
 
     /**
      * Test TTSServiceMacOS.synthesize(String,Voice,AudioFormat)
      */
     @Test
-    public void synthesizeTest() {
-        Assume.assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
+    public void synthesizeTest() throws IOException, TTSException {
+        assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
 
         MacTTSService ttsServiceMacOS = new MacTTSService();
         Set<Voice> voices = ttsServiceMacOS.getAvailableVoices();
         Set<AudioFormat> audioFormats = ttsServiceMacOS.getSupportedFormats();
         try (AudioStream audioStream = ttsServiceMacOS.synthesize("Hello", voices.iterator().next(),
                 audioFormats.iterator().next())) {
-            Assert.assertNotNull("The test synthesizeTest() created null AudioSource", audioStream);
-            Assert.assertNotNull("The test synthesizeTest() created an AudioSource w/o AudioFormat",
-                    audioStream.getFormat());
-            Assert.assertNotNull("The test synthesizeTest() created an AudioSource w/o InputStream", audioStream);
-            Assert.assertTrue("The test synthesizeTest() returned an AudioSource with no data",
-                    (-1 != audioStream.read(new byte[2])));
-        } catch (TTSException e) {
-            Assert.fail("synthesizeTest() failed with TTSException: " + e.getMessage());
-        } catch (IOException e) {
-            Assert.fail("synthesizeTest() failed with IOException: " + e.getMessage());
+            assertNotNull(audioStream, "created null AudioSource");
+            assertNotNull(audioStream.getFormat(), "created an AudioSource w/o AudioFormat");
+            assertNotNull(audioStream, "created an AudioSource w/o InputStream");
+            assertTrue(-1 != audioStream.read(new byte[2]), "returned an AudioSource with no data");
         }
     }
 }
index cc19a2e5bf558aa730f398794fe71fab56a7b0a2..d094622c86e67850b5c710aaa21b229fa7dc35ba 100644 (file)
@@ -30,7 +30,7 @@ import org.openhab.core.thing.binding.ThingHandlerCallback;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
 import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.astro.internal.handler.AstroThingHandler;
 import org.openhab.binding.astro.internal.handler.SunHandler;
 import org.openhab.binding.astro.internal.model.Sun;
index bfa15949e4148a2bd5442084e71babbdcf4ed4f1..44093468f89dc4ad14e533b47661271fee32ad28 100644 (file)
@@ -28,7 +28,7 @@ import org.openhab.core.thing.ThingStatusInfo;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.thing.binding.ThingHandlerCallback;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.astro.internal.handler.AstroThingHandler;
 import org.openhab.binding.astro.internal.handler.SunHandler;
 
index f8db754dba792c8097e767b332d068c623a9482a..69d9e0a155e03b4dc6552769d0494edd36ba064a 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.astro.test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.openhab.binding.astro.internal.AstroBindingConstants.*;
 import static org.openhab.binding.astro.test.cases.AstroBindingTestsData.*;
 import static org.openhab.binding.astro.test.cases.AstroParametrizedTestCases.*;
@@ -24,19 +24,17 @@ import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.List;
 
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.types.State;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.openhab.binding.astro.internal.calc.MoonCalc;
 import org.openhab.binding.astro.internal.calc.SunCalc;
 import org.openhab.binding.astro.internal.config.AstroChannelConfig;
 import org.openhab.binding.astro.internal.model.Planet;
 import org.openhab.binding.astro.internal.util.PropertyUtils;
 import org.openhab.binding.astro.test.cases.AstroParametrizedTestCases;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.ThingUID;
+import org.openhab.core.types.State;
 
 /**
  * Tests for the Astro Channels state
@@ -47,30 +45,19 @@ import org.openhab.binding.astro.test.cases.AstroParametrizedTestCases;
  * @author Erdoan Hadzhiyusein - Adapted the class to work with the new DateTimeType
  * @author Christoph Weitkamp - Migrated tests to pure Java
  */
-@RunWith(Parameterized.class)
 public class AstroStateTest {
 
-    private String thingID;
-    private String channelId;
-    private State expectedState;
-
     // These test result timestamps are adapted for the +03:00 time zone
     private static final ZoneId ZONE_ID = ZoneId.of("+03:00");
 
-    public AstroStateTest(String thingID, String channelId, State expectedState) {
-        this.thingID = thingID;
-        this.channelId = channelId;
-        this.expectedState = expectedState;
-    }
-
-    @Parameters
     public static List<Object[]> data() {
         AstroParametrizedTestCases cases = new AstroParametrizedTestCases();
         return cases.getCases();
     }
 
-    @Test
-    public void testParametrized() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testParametrized(String thingID, String channelId, State expectedState) {
         try {
             assertStateUpdate(thingID, channelId, expectedState);
         } catch (Exception e) {
index af0287ee18f343addde6c9eba63994933c680a7c..9ada1136c97ea52c5ffd1c8b701bf3b25c54f4a8 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.avmfritz.internal.discovery;
 
 import static org.openhab.core.thing.Thing.*;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
 
 import java.io.StringReader;
@@ -31,9 +31,9 @@ import org.openhab.core.config.discovery.DiscoveryResultFlag;
 import org.openhab.core.config.discovery.DiscoveryService;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.binding.avmfritz.internal.dto.AVMFritzBaseModel;
 import org.openhab.binding.avmfritz.internal.dto.DeviceListModel;
 import org.openhab.binding.avmfritz.internal.handler.AVMFritzThingHandlerOSGiTest;
@@ -71,7 +71,7 @@ public class AVMFritzDiscoveryServiceOSGiTest extends AVMFritzThingHandlerOSGiTe
     };
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
         discovery = new AVMFritzDiscoveryService();
@@ -79,7 +79,7 @@ public class AVMFritzDiscoveryServiceOSGiTest extends AVMFritzThingHandlerOSGiTe
         discovery.addDiscoveryListener(listener);
     }
 
-    @After
+    @AfterEach
     public void cleanUp() {
         discoveryResult = null;
     }
index ae7f9e9d9ebf69e0febac571dd5516afc708f49d..185be36dd7d1306f9804c39ffa330a03df32b2ef 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.avmfritz.internal.handler;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.mock;
 import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
 
@@ -21,19 +21,19 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jetty.client.HttpClient;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.openhab.binding.avmfritz.internal.AVMFritzDynamicCommandDescriptionProvider;
 import org.openhab.core.config.core.Configuration;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ManagedThingProvider;
 import org.openhab.core.thing.ThingProvider;
 import org.openhab.core.thing.binding.ThingHandlerCallback;
 import org.openhab.core.thing.binding.builder.BridgeBuilder;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.openhab.binding.avmfritz.internal.AVMFritzDynamicCommandDescriptionProvider;
 
 /**
  * Tests for {@link AVMFritzThingHandlerOSGiTest}.
@@ -51,17 +51,17 @@ public abstract class AVMFritzThingHandlerOSGiTest extends JavaOSGiTest {
     protected @NonNullByDefault({}) Bridge bridge;
     protected @NonNullByDefault({}) BoxHandler bridgeHandler;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() throws Exception {
         httpClient.start();
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerService(volatileStorageService);
 
         managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
-        assertNotNull("Could not get ManagedThingProvider", managedThingProvider);
+        assertNotNull(managedThingProvider, "Could not get ManagedThingProvider");
 
         bridge = buildBridge();
         assertNotNull(bridge.getConfiguration());
@@ -82,7 +82,7 @@ public abstract class AVMFritzThingHandlerOSGiTest extends JavaOSGiTest {
         bridgeHandler.initialize();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         if (bridge != null) {
             managedThingProvider.remove(bridge.getUID());
@@ -91,7 +91,7 @@ public abstract class AVMFritzThingHandlerOSGiTest extends JavaOSGiTest {
         unregisterService(volatileStorageService);
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownClass() throws Exception {
         httpClient.stop();
     }
index 4a09b3d7a6e364ef47cb0816f31b392b6e9a44a2..87b7283b43b6b1a8750c20dca45aa5cbb1eaa45a 100644 (file)
@@ -13,9 +13,9 @@
 package org.openhab.binding.feed.test;
 
 import static java.lang.Thread.sleep;
-import static org.openhab.core.thing.ThingStatus.*;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.openhab.core.thing.ThingStatus.*;
 
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -27,12 +27,19 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
 import org.eclipse.jetty.http.HttpStatus;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.feed.internal.FeedBindingConstants;
+import org.openhab.binding.feed.internal.handler.FeedHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.items.Item;
 import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.items.StateChangeListener;
 import org.openhab.core.library.items.StringItem;
 import org.openhab.core.library.types.StringType;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.ManagedThingProvider;
@@ -47,14 +54,6 @@ import org.openhab.core.thing.link.ItemChannelLink;
 import org.openhab.core.thing.link.ManagedItemChannelLinkProvider;
 import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.openhab.binding.feed.internal.FeedBindingConstants;
-import org.openhab.binding.feed.internal.handler.FeedHandler;
 import org.osgi.service.http.HttpService;
 import org.osgi.service.http.NamespaceException;
 
@@ -143,7 +142,7 @@ public class FeedHandlerTest extends JavaOSGiTest {
         }
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         volatileStorageService = new VolatileStorageService();
         registerService(volatileStorageService);
@@ -157,7 +156,7 @@ public class FeedHandlerTest extends JavaOSGiTest {
         registerFeedTestServlet();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         currentItemState = null;
         if (feedThing != null) {
@@ -315,7 +314,6 @@ public class FeedHandlerTest extends JavaOSGiTest {
     }
 
     @Test
-    @Category(SlowTests.class)
     public void assertThatItemsStateIsNotUpdatedOnAutoRefreshIfContentIsNotChanged()
             throws IOException, InterruptedException {
         boolean commandReceived = false;
@@ -324,7 +322,6 @@ public class FeedHandlerTest extends JavaOSGiTest {
     }
 
     @Test
-    @Category(SlowTests.class)
     public void assertThatItemsStateIsUpdatedOnAutoRefreshIfContentChanged() throws IOException, InterruptedException {
         boolean commandReceived = false;
         boolean contentChanged = true;
index 5012bdd67628ffb755f996efc141e551e811b2ce..f52701fccea77ec915dddf97fa719c8cbbc6733d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.hue.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.binding.ThingHandler;
index 3e45b1e95436367d53cd066cc84845c90a09b7ce..4f12f297b41df0858126952b2f046d969ed59d75 100644 (file)
  */
 package org.openhab.binding.hue.internal;
 
-import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.hue.internal.HueBindingConstants.*;
+import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -23,6 +24,11 @@ import java.util.Collection;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.hue.internal.discovery.HueLightDiscoveryService;
+import org.openhab.binding.hue.internal.handler.HueBridgeHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.config.discovery.DiscoveryListener;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -36,12 +42,6 @@ import org.openhab.core.thing.ThingStatusInfo;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.builder.ThingStatusInfoBuilder;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.binding.hue.internal.discovery.HueLightDiscoveryService;
-import org.openhab.binding.hue.internal.handler.HueBridgeHandler;
 
 /**
  * Tests for {@link HueLightDiscoveryService}.
@@ -64,7 +64,7 @@ public class HueLightDiscoveryServiceOSGiTest extends AbstractHueOSGiTestParent
     protected final ThingTypeUID BRIDGE_THING_TYPE_UID = new ThingTypeUID("hue", "bridge");
     protected final ThingUID BRIDGE_THING_UID = new ThingUID(BRIDGE_THING_TYPE_UID, "testBridge");
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerVolatileStorageService();
 
@@ -89,7 +89,7 @@ public class HueLightDiscoveryServiceOSGiTest extends AbstractHueOSGiTestParent
         assertThat(discoveryService, is(notNullValue()));
     }
 
-    @After
+    @AfterEach
     public void cleanUp() {
         thingRegistry.remove(BRIDGE_THING_UID);
         waitForAssert(() -> {
@@ -217,7 +217,7 @@ public class HueLightDiscoveryServiceOSGiTest extends AbstractHueOSGiTestParent
                 usernameField.setAccessible(true);
                 usernameField.set(hueBridgeValue, hueBridgeHandler.getThing().getConfiguration().get(USER_NAME));
             } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
-                Assert.fail("Reflection usage error");
+                fail("Reflection usage error");
             }
         });
         hueBridgeHandler.initialize();
index 4a2714269a6a07f05fb866f5ba858d25202d06bc..71fc7632fa2faf4074fd576ad0596bcf92dad67e 100644 (file)
  */
 package org.openhab.binding.hue.internal.discovery;
 
-import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.openhab.binding.hue.internal.HueBindingConstants.*;
+import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.openhab.core.config.discovery.DiscoveryResult;
-import org.openhab.core.config.discovery.DiscoveryResultFlag;
-import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.jupnp.model.meta.DeviceDetails;
 import org.jupnp.model.meta.ManufacturerDetails;
@@ -38,6 +33,11 @@ import org.jupnp.model.meta.RemoteDeviceIdentity;
 import org.jupnp.model.meta.RemoteService;
 import org.jupnp.model.types.DeviceType;
 import org.jupnp.model.types.UDN;
+import org.openhab.core.config.discovery.DiscoveryResult;
+import org.openhab.core.config.discovery.DiscoveryResultFlag;
+import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.thing.ThingUID;
 
 /**
  * Tests for {@link org.openhab.binding.hue.internal.discovery.HueBridgeDiscoveryParticipant}.
@@ -53,7 +53,7 @@ public class HueBridgeDiscoveryParticipantOSGITest extends JavaOSGiTest {
     RemoteDevice hueDevice;
     RemoteDevice otherDevice;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         discoveryParticipant = getService(UpnpDiscoveryParticipant.class, HueBridgeDiscoveryParticipant.class);
         assertThat(discoveryParticipant, is(notNullValue()));
@@ -74,11 +74,11 @@ public class HueBridgeDiscoveryParticipantOSGITest extends JavaOSGiTest {
                             new ManufacturerDetails("Taiwan"), new ModelDetails("$%&/"), "serial567", "upc"),
                     remoteService);
         } catch (final ValidationException | MalformedURLException ex) {
-            Assert.fail("Internal test error.");
+            fail("Internal test error.");
         }
     }
 
-    @After
+    @AfterEach
     public void cleanUp() {
     }
 
index bb86628c87f80b7cba7002350ffcfb6d31504463..79d1297238a889c007fe665498a6960d237e1554 100644 (file)
  */
 package org.openhab.binding.hue.internal.discovery;
 
-import static org.openhab.core.config.discovery.inbox.InboxPredicates.forThingTypeUID;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.openhab.binding.hue.internal.HueBindingConstants.THING_TYPE_BRIDGE;
+import static org.openhab.core.config.discovery.inbox.InboxPredicates.forThingTypeUID;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -24,16 +25,16 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.discovery.DiscoveryListener;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.config.discovery.DiscoveryService;
 import org.openhab.core.config.discovery.inbox.Inbox;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.thing.ThingUID;
 import org.openhab.core.test.java.JavaOSGiTest;
 import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.Before;
-import org.junit.Test;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
 
 /**
  *
@@ -139,7 +140,7 @@ public class HueBridgeNupnpDiscoveryOSGITest extends JavaOSGiTest {
         }
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerService(volatileStorageService);
 
index d2ddbfb43e99ba670fd6b4f77543909efe2e2d96..5a76b1deb60f1d6518dab9367227a21f4ebef15e 100644 (file)
  */
 package org.openhab.binding.hue.internal.handler;
 
-import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.openhab.binding.hue.internal.HueBindingConstants.*;
 import static org.openhab.binding.hue.internal.config.HueBridgeConfig.HTTP;
+import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.hue.internal.AbstractHueOSGiTestParent;
+import org.openhab.binding.hue.internal.HueBridge;
+import org.openhab.binding.hue.internal.HueConfigStatusMessage;
+import org.openhab.binding.hue.internal.exceptions.ApiException;
+import org.openhab.binding.hue.internal.exceptions.LinkButtonException;
+import org.openhab.binding.hue.internal.exceptions.UnauthorizedException;
+import org.openhab.core.common.ThreadPoolManager;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.config.core.status.ConfigStatusMessage;
-import org.openhab.core.common.ThreadPoolManager;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingRegistry;
 import org.openhab.core.thing.ThingStatus;
 import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.binding.hue.internal.AbstractHueOSGiTestParent;
-import org.openhab.binding.hue.internal.HueBridge;
-import org.openhab.binding.hue.internal.HueConfigStatusMessage;
-import org.openhab.binding.hue.internal.exceptions.ApiException;
-import org.openhab.binding.hue.internal.exceptions.LinkButtonException;
-import org.openhab.binding.hue.internal.exceptions.UnauthorizedException;
 
 /**
  * Tests for {@link HueBridgeHandler}.
@@ -57,7 +58,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
 
     private ScheduledExecutorService scheduler;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerVolatileStorageService();
         thingRegistry = getService(ThingRegistry.class, ThingRegistry.class);
index 3724f7b76874df721188f643af42b6defd23cc7b..1dde4412614d9d4f8d159c959327381e6ff10bc9 100644 (file)
 package org.openhab.binding.max.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.openhab.binding.max.internal.MaxBindingConstants.*;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.max.internal.MaxBindingConstants;
+import org.openhab.binding.max.internal.handler.MaxCubeBridgeHandler;
 import org.openhab.core.config.core.Configuration;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingRegistry;
@@ -24,13 +31,6 @@ import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.thing.binding.builder.BridgeBuilder;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.binding.max.internal.MaxBindingConstants;
-import org.openhab.binding.max.internal.handler.MaxCubeBridgeHandler;
 
 /**
  * Tests for {@link MaxCubeBridgeHandler}.
@@ -47,7 +47,7 @@ public class MaxCubeBridgeHandlerOSGiTest extends JavaOSGiTest {
 
     private Bridge maxBridge;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerService(volatileStorageService);
 
@@ -55,7 +55,7 @@ public class MaxCubeBridgeHandlerOSGiTest extends JavaOSGiTest {
         assertThat(thingRegistry, is(notNullValue()));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         if (maxBridge != null) {
             thingRegistry.remove(maxBridge.getUID());
index a8cabbd6becd4d5ac2491e314e03b9d3552595b2..43c3c4d2dbf30b7a9820aa3fd5fe3989e1768756 100644 (file)
 package org.openhab.binding.modbus.tests;
 
 import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -32,6 +33,15 @@ import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.openhab.binding.modbus.internal.ModbusHandlerFactory;
 import org.openhab.core.events.Event;
 import org.openhab.core.events.EventFilter;
 import org.openhab.core.events.EventSubscriber;
@@ -41,6 +51,7 @@ import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.items.ManagedItemProvider;
 import org.openhab.core.items.events.ItemStateEvent;
 import org.openhab.core.library.CoreItemFactory;
+import org.openhab.core.test.java.JavaOSGiTest;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.ManagedThingProvider;
 import org.openhab.core.thing.Thing;
@@ -52,12 +63,6 @@ import org.openhab.core.thing.link.ItemChannelLinkProvider;
 import org.openhab.core.thing.link.ManagedItemChannelLinkProvider;
 import org.openhab.core.transform.TransformationService;
 import org.openhab.core.types.State;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.After;
-import org.junit.Before;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openhab.binding.modbus.internal.ModbusHandlerFactory;
 import org.openhab.io.transport.modbus.ModbusCommunicationInterface;
 import org.openhab.io.transport.modbus.ModbusManager;
 import org.slf4j.Logger;
@@ -66,6 +71,8 @@ import org.slf4j.LoggerFactory;
 /**
  * @author Sami Salonen - Initial contribution
  */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
 public abstract class AbstractModbusOSGiTest extends JavaOSGiTest {
 
@@ -99,8 +106,7 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest {
 
     private final Logger logger = LoggerFactory.getLogger(AbstractModbusOSGiTest.class);
 
-    @Mock
-    protected @NonNullByDefault({}) ModbusManager mockedModbusManager;
+    protected @Mock @NonNullByDefault({}) ModbusManager mockedModbusManager;
     protected @NonNullByDefault({}) ManagedThingProvider thingProvider;
     protected @NonNullByDefault({}) ManagedItemProvider itemProvider;
     protected @NonNullByDefault({}) ManagedItemChannelLinkProvider itemChannelLinkProvider;
@@ -113,8 +119,7 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest {
     private Set<ItemChannelLink> addedLinks = new HashSet<>();
     private StateSubscriber stateSubscriber = new StateSubscriber();
 
-    @Mock
-    protected @NonNullByDefault({}) ModbusCommunicationInterface comms;
+    protected @Mock @NonNullByDefault({}) ModbusCommunicationInterface comms;
 
     public AbstractModbusOSGiTest() {
         super();
@@ -123,7 +128,7 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest {
     /**
      * Before each test, configure mocked services
      */
-    @Before
+    @BeforeEach
     public void setUpAbstractModbusOSGiTest() {
         logger.debug("setUpAbstractModbusOSGiTest BEGIN");
         registerVolatileStorageService();
@@ -150,7 +155,7 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest {
         logger.debug("setUpAbstractModbusOSGiTest END");
     }
 
-    @After
+    @AfterEach
     public void tearDownAbstractModbusOSGiTest() {
         logger.debug("tearDownAbstractModbusOSGiTest BEGIN");
         swapModbusManagerToReal();
index 105cb032f9bccfff0c563862f2b61c7ba316e1cc..2b9397f0d291e29da38ec66ee8645380bcadd24a 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.modbus.tests;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
@@ -30,6 +31,14 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 
 import org.apache.commons.lang.StringUtils;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.openhab.binding.modbus.handler.EndpointNotInitializedException;
+import org.openhab.binding.modbus.handler.ModbusPollerThingHandler;
+import org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler;
+import org.openhab.binding.modbus.internal.handler.ModbusTcpThingHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.items.GenericItem;
 import org.openhab.core.items.Item;
@@ -55,16 +64,6 @@ import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
 import org.openhab.core.types.UnDefType;
-import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.modbus.handler.EndpointNotInitializedException;
-import org.openhab.binding.modbus.handler.ModbusPollerThingHandler;
-import org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler;
-import org.openhab.binding.modbus.internal.handler.ModbusTcpThingHandler;
 import org.openhab.io.transport.modbus.AsyncModbusFailure;
 import org.openhab.io.transport.modbus.AsyncModbusReadResult;
 import org.openhab.io.transport.modbus.AsyncModbusWriteResult;
@@ -89,7 +88,6 @@ import org.osgi.framework.InvalidSyntaxException;
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
 public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
 
     private final class MultiplyTransformation implements TransformationService {
@@ -115,7 +113,7 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
     }
     private List<ModbusWriteRequestBlueprint> writeRequests = new ArrayList<>();
 
-    @After
+    @AfterEach
     public void tearDown() {
         writeRequests.clear();
     }
index c016023df7ff66eabb4cb70f394c70bdd6dd7b71..e527b0a9af635a3d182b8da3e23d7954f4205835 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.binding.modbus.tests;
 
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.mockito.hamcrest.MockitoHamcrest.argThat;
@@ -22,6 +23,17 @@ import static org.mockito.hamcrest.MockitoHamcrest.argThat;
 import java.lang.reflect.Field;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.openhab.binding.modbus.handler.ModbusPollerThingHandler;
+import org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal;
+import org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Thing;
@@ -31,19 +43,6 @@ import org.openhab.core.thing.ThingStatusInfo;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandlerCallback;
 import org.openhab.core.thing.binding.builder.BridgeBuilder;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.modbus.handler.ModbusPollerThingHandler;
-import org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal;
-import org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler;
 import org.openhab.io.transport.modbus.AsyncModbusFailure;
 import org.openhab.io.transport.modbus.AsyncModbusReadResult;
 import org.openhab.io.transport.modbus.BitArray;
@@ -62,7 +61,6 @@ import org.slf4j.LoggerFactory;
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
 public class ModbusPollerThingHandlerTest extends AbstractModbusOSGiTest {
 
     private static final String HOST = "thisishost";
@@ -73,8 +71,7 @@ public class ModbusPollerThingHandlerTest extends AbstractModbusOSGiTest {
     private Bridge endpoint;
     private Bridge poller;
 
-    @Mock
-    private ThingHandlerCallback thingCallback;
+    private @Mock ThingHandlerCallback thingCallback;
 
     public static BridgeBuilder createTcpThingBuilder(String id) {
         return BridgeBuilder
@@ -114,7 +111,7 @@ public class ModbusPollerThingHandlerTest extends AbstractModbusOSGiTest {
     /**
      * Before each test, setup TCP endpoint thing, configure mocked item registry
      */
-    @Before
+    @BeforeEach
     public void setUp() {
         mockCommsToModbusManager();
         Configuration tcpConfig = new Configuration();
@@ -127,7 +124,7 @@ public class ModbusPollerThingHandlerTest extends AbstractModbusOSGiTest {
         assertThat(endpoint.getStatus(), is(equalTo(ThingStatus.ONLINE)));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         if (endpoint != null) {
             thingProvider.remove(endpoint.getUID());
index e9a854efd30d4f1d5000572ce2d2e53bf34c85b6..7f765e6072d9515b2556a0c6b79a458927f329da 100644 (file)
 package org.openhab.binding.modbus.tests;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Objects;
 
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+import org.mockito.Mockito;
+import org.openhab.binding.modbus.handler.EndpointNotInitializedException;
+import org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal;
+import org.openhab.binding.modbus.internal.handler.ModbusTcpThingHandler;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingStatus;
 import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.builder.BridgeBuilder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InOrder;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openhab.binding.modbus.handler.EndpointNotInitializedException;
-import org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal;
-import org.openhab.binding.modbus.internal.handler.ModbusTcpThingHandler;
 import org.openhab.io.transport.modbus.endpoint.EndpointPoolConfiguration;
 import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
 import org.openhab.io.transport.modbus.endpoint.ModbusTCPSlaveEndpoint;
@@ -38,7 +37,6 @@ import org.openhab.io.transport.modbus.endpoint.ModbusTCPSlaveEndpoint;
 /**
  * @author Sami Salonen - Initial contribution
  */
-@RunWith(MockitoJUnitRunner.class)
 public class ModbusTcpThingHandlerTest extends AbstractModbusOSGiTest {
 
     private static BridgeBuilder createTcpThingBuilder(String id) {
index 8f61eb49020518f5fa89af4be7df89a3a98152bd..54778eb4e6530c7ffb5e862486f88376a3166f48 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.openhab.addons.itests</groupId>
     <artifactId>org.openhab.addons.reactor.itests</artifactId>
-    <version>2.5.9-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>org.openhab.binding.mqtt.homeassistant.tests</artifactId>
index e59f9fbc575903ccafebdfcff094a7a1f0211918..5780d8e757b2c8946e803d35e91726fc0775835d 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.mqtt;
 
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.mockito.MockitoAnnotations.openMocks;
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -26,10 +26,9 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.openhab.binding.mqtt.generic.AvailabilityTracker;
 import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener;
@@ -39,6 +38,8 @@ import org.openhab.binding.mqtt.homeassistant.internal.DiscoverComponents;
 import org.openhab.binding.mqtt.homeassistant.internal.DiscoverComponents.ComponentDiscovered;
 import org.openhab.binding.mqtt.homeassistant.internal.HaID;
 import org.openhab.binding.mqtt.homeassistant.internal.HandlerConfiguration;
+import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
+import org.openhab.core.test.java.JavaOSGiTest;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
@@ -49,24 +50,19 @@ import com.google.gson.GsonBuilder;
  * @author David Graeff - Initial contribution
  */
 public class DiscoverComponentsTest extends JavaOSGiTest {
-    @Mock
-    MqttBrokerConnection connection;
 
-    @Mock
-    ComponentDiscovered discovered;
+    private AutoCloseable mocksCloseable;
 
-    @Mock
-    TransformationServiceProvider transformationServiceProvider;
+    private @Mock MqttBrokerConnection connection;
+    private @Mock ComponentDiscovered discovered;
+    private @Mock TransformationServiceProvider transformationServiceProvider;
+    private @Mock ChannelStateUpdateListener channelStateUpdateListener;
+    private @Mock AvailabilityTracker availabilityTracker;
 
-    @Mock
-    ChannelStateUpdateListener channelStateUpdateListener;
+    @BeforeEach
+    public void beforeEach() {
+        mocksCloseable = openMocks(this);
 
-    @Mock
-    AvailabilityTracker availabilityTracker;
-
-    @Before
-    public void setUp() {
-        initMocks(this);
         CompletableFuture<Void> voidFutureComplete = new CompletableFuture<>();
         voidFutureComplete.complete(null);
         doReturn(voidFutureComplete).when(connection).unsubscribeAll();
@@ -78,6 +74,11 @@ public class DiscoverComponentsTest extends JavaOSGiTest {
         doReturn(null).when(transformationServiceProvider).getTransformationService(any());
     }
 
+    @AfterEach
+    public void afterEach() throws Exception {
+        mocksCloseable.close();
+    }
+
     @Test
     public void discoveryTimeTest() throws InterruptedException, ExecutionException, TimeoutException {
         // Create a scheduler
index fb4c189026a816db63a2172a27539a5ed8ca3edc..647b3a31c5b0df03805c1c731bc288ad3d851cfa 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.mqtt;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -63,7 +63,7 @@ public class EmbeddedBrokerTools {
 
             };
             mqttService.addBrokersListener(observer);
-            assertTrue("Wait for embedded connection client failed", semaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
+            assertTrue(semaphore.tryAcquire(1000, TimeUnit.MILLISECONDS), "Wait for embedded connection client failed");
         }
         MqttBrokerConnection embeddedConnection = this.embeddedConnection;
         if (embeddedConnection == null) {
@@ -81,8 +81,8 @@ public class EmbeddedBrokerTools {
         if (embeddedConnection.connectionState() == MqttConnectionState.CONNECTED) {
             semaphore.release();
         }
-        assertTrue("Connection " + embeddedConnection.getClientId() + " failed. State: "
-                + embeddedConnection.connectionState(), semaphore.tryAcquire(500, TimeUnit.MILLISECONDS));
+        assertTrue(semaphore.tryAcquire(500, TimeUnit.MILLISECONDS), "Connection " + embeddedConnection.getClientId()
+                + " failed. State: " + embeddedConnection.connectionState());
         return embeddedConnection;
     }
 
index 0dfd246dc5b785f9638674cd8d404d43d95ee027..dd07a6962e8ecbbdcfcd0ddebd3f5e5f1b9e1b51 100644 (file)
 package org.openhab.binding.mqtt;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.mockito.MockitoAnnotations.openMocks;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -32,18 +32,9 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.types.State;
-import org.openhab.core.types.UnDefType;
-import org.openhab.core.util.UIDUtils;
-import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
-import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
-import org.openhab.core.io.transport.mqtt.MqttConnectionState;
-import org.openhab.core.io.transport.mqtt.MqttService;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.openhab.binding.mqtt.generic.AvailabilityTracker;
 import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener;
@@ -55,6 +46,15 @@ import org.openhab.binding.mqtt.homeassistant.internal.ComponentSwitch;
 import org.openhab.binding.mqtt.homeassistant.internal.DiscoverComponents;
 import org.openhab.binding.mqtt.homeassistant.internal.DiscoverComponents.ComponentDiscovered;
 import org.openhab.binding.mqtt.homeassistant.internal.HaID;
+import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
+import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
+import org.openhab.core.io.transport.mqtt.MqttConnectionState;
+import org.openhab.core.io.transport.mqtt.MqttService;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.types.State;
+import org.openhab.core.types.UnDefType;
+import org.openhab.core.util.UIDUtils;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
@@ -72,14 +72,11 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest {
     private int registeredTopics = 100;
     private Throwable failure = null;
 
-    @Mock
-    ChannelStateUpdateListener channelStateUpdateListener;
+    private AutoCloseable mocksCloseable;
 
-    @Mock
-    AvailabilityTracker availabilityTracker;
-
-    @Mock
-    TransformationServiceProvider transformationServiceProvider;
+    private @Mock ChannelStateUpdateListener channelStateUpdateListener;
+    private @Mock AvailabilityTracker availabilityTracker;
+    private @Mock TransformationServiceProvider transformationServiceProvider;
 
     /**
      * Create an observer that fails the test as soon as the broker client connection changes its connection state
@@ -89,10 +86,10 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest {
             is(MqttConnectionState.CONNECTED));
     private String testObjectTopic;
 
-    @Before
-    public void setUp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
+    @BeforeEach
+    public void beforeEach() throws Exception {
         registerVolatileStorageService();
-        initMocks(this);
+        mocksCloseable = openMocks(this);
         mqttService = getService(MqttService.class);
 
         // Wait for the EmbeddedBrokerService internal connection to be connected
@@ -124,12 +121,14 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest {
         doReturn(null).when(transformationServiceProvider).getTransformationService(any());
     }
 
-    @After
-    public void tearDown() throws InterruptedException, ExecutionException, TimeoutException {
+    @AfterEach
+    public void afterEach() throws Exception {
         if (connection != null) {
             connection.removeConnectionObserver(failIfChange);
             connection.stop().get(1000, TimeUnit.MILLISECONDS);
         }
+
+        mocksCloseable.close();
     }
 
     @Test
@@ -146,8 +145,8 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest {
         CountDownLatch c = new CountDownLatch(registeredTopics);
         connection.subscribe("homeassistant/+/+/" + ThingChannelConstants.testHomeAssistantThing.getId() + "/#",
                 (topic, payload) -> c.countDown()).get(1000, TimeUnit.MILLISECONDS);
-        assertTrue("Connection " + connection.getClientId() + " not retrieving all topics",
-                c.await(1000, TimeUnit.MILLISECONDS));
+        assertTrue(c.await(1000, TimeUnit.MILLISECONDS),
+                "Connection " + connection.getClientId() + " not retrieving all topics");
     }
 
     @Test
index 673f0cccdf3ef7074009d908836599e2deb5ff70..90f6b77ece5ad47345d2bd47068cced83c1d5d8d 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.openhab.addons.itests</groupId>
     <artifactId>org.openhab.addons.reactor.itests</artifactId>
-    <version>2.5.9-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>org.openhab.binding.mqtt.homie.tests</artifactId>
index bc54edc38ae7e12419940bd301aa2bf12af4ac91..08410ccaabeb60bac1204b77373b50d50756d19d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.mqtt;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -65,7 +65,7 @@ public class EmbeddedBrokerTools {
                 }
             };
             mqttService.addBrokersListener(observer);
-            assertTrue("Wait for embedded connection client failed", semaphore.tryAcquire(700, TimeUnit.MILLISECONDS));
+            assertTrue(semaphore.tryAcquire(700, TimeUnit.MILLISECONDS), "Wait for embedded connection client failed");
         }
         MqttBrokerConnection embeddedConnection = this.embeddedConnection;
         if (embeddedConnection == null) {
@@ -84,8 +84,8 @@ public class EmbeddedBrokerTools {
         if (embeddedConnection.connectionState() == MqttConnectionState.CONNECTED) {
             semaphore.release();
         }
-        assertTrue("Connection " + embeddedConnection.getClientId() + " failed. State: "
-                + embeddedConnection.connectionState(), semaphore.tryAcquire(500, TimeUnit.MILLISECONDS));
+        assertTrue(semaphore.tryAcquire(500, TimeUnit.MILLISECONDS), "Connection " + embeddedConnection.getClientId()
+                + " failed. State: " + embeddedConnection.connectionState());
         return embeddedConnection;
     }
 }
index 24dc2be667e3c3fa6ed566e7a081d2d52055c651..b5f580e3969f20ee710055118902fc7e0eaff40b 100644 (file)
 package org.openhab.binding.mqtt;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.mockito.MockitoAnnotations.openMocks;
 
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
@@ -31,17 +32,9 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.openhab.core.library.types.DecimalType;
-import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.types.UnDefType;
-import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
-import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
-import org.openhab.core.io.transport.mqtt.MqttConnectionState;
-import org.openhab.core.io.transport.mqtt.MqttService;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.invocation.InvocationOnMock;
 import org.openhab.binding.mqtt.generic.ChannelState;
@@ -58,6 +51,14 @@ import org.openhab.binding.mqtt.homie.internal.homie300.Property;
 import org.openhab.binding.mqtt.homie.internal.homie300.PropertyAttributes;
 import org.openhab.binding.mqtt.homie.internal.homie300.PropertyAttributes.DataTypeEnum;
 import org.openhab.binding.mqtt.homie.internal.homie300.PropertyHelper;
+import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
+import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
+import org.openhab.core.io.transport.mqtt.MqttConnectionState;
+import org.openhab.core.io.transport.mqtt.MqttService;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.types.UnDefType;
 
 /**
  * A full implementation test, that starts the embedded MQTT broker and publishes a homie device tree.
@@ -74,13 +75,13 @@ public class HomieImplementationTest extends JavaOSGiTest {
     private MqttBrokerConnection connection;
     private int registeredTopics = 100;
 
+    private AutoCloseable mocksCloseable;
+
     // The handler is not tested here, so just mock the callback
-    @Mock
-    DeviceCallback callback;
+    private @Mock DeviceCallback callback;
 
     // A handler mock is required to verify that channel value changes have been received
-    @Mock
-    HomieThingHandler handler;
+    private @Mock HomieThingHandler handler;
 
     private ScheduledExecutorService scheduler;
 
@@ -93,10 +94,10 @@ public class HomieImplementationTest extends JavaOSGiTest {
 
     private String propertyTestTopic;
 
-    @Before
-    public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
+    @BeforeEach
+    public void beforeEach() throws Exception {
         registerVolatileStorageService();
-        initMocks(this);
+        mocksCloseable = openMocks(this);
         mqttService = getService(MqttService.class);
 
         embeddedConnection = new EmbeddedBrokerTools().waitForConnection(mqttService);
@@ -152,13 +153,14 @@ public class HomieImplementationTest extends JavaOSGiTest {
         scheduler = new ScheduledThreadPoolExecutor(6);
     }
 
-    @After
-    public void tearDown() throws InterruptedException, ExecutionException, TimeoutException {
+    @AfterEach
+    public void afterEach() throws Exception {
         if (connection != null) {
             connection.removeConnectionObserver(failIfChange);
             connection.stop().get(500, TimeUnit.MILLISECONDS);
         }
         scheduler.shutdownNow();
+        mocksCloseable.close();
     }
 
     @Test
@@ -167,8 +169,8 @@ public class HomieImplementationTest extends JavaOSGiTest {
         CountDownLatch c = new CountDownLatch(registeredTopics - 4);
         connection.subscribe(DEVICE_TOPIC + "/testnode/#", (topic, payload) -> c.countDown()).get(5000,
                 TimeUnit.MILLISECONDS);
-        assertTrue("Connection " + connection.getClientId() + " not retrieving all topics ",
-                c.await(5000, TimeUnit.MILLISECONDS));
+        assertTrue(c.await(5000, TimeUnit.MILLISECONDS),
+                "Connection " + connection.getClientId() + " not retrieving all topics ");
     }
 
     @Test
@@ -311,11 +313,8 @@ public class HomieImplementationTest extends JavaOSGiTest {
         property.getChannelState().publishValue(OnOffType.ON).get();
         // No value is expected to be retained on this MQTT topic
         waitForAssert(() -> {
-            try {
-                WaitForTopicValue w = new WaitForTopicValue(embeddedConnection, propertyTestTopic + "/set");
-                assertNull(w.waitForTopicValue(50));
-            } catch (InterruptedException | ExecutionException e) {
-            }
+            WaitForTopicValue w = new WaitForTopicValue(embeddedConnection, propertyTestTopic + "/set");
+            assertNull(w.waitForTopicValue(50));
         }, 500, 100);
     }
 }
index 405e9cc4dd6972687c5f6cc0a701ece6e9480584..7d3ca1fbd8b27c9f9272078672c8b32dac607948 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.ntp.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -26,6 +27,16 @@ import java.util.Locale;
 import java.util.TimeZone;
 
 import org.apache.commons.lang.StringUtils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentMatchers;
+import org.openhab.binding.ntp.internal.NtpBindingConstants;
+import org.openhab.binding.ntp.internal.handler.NtpHandler;
+import org.openhab.binding.ntp.server.SimpleNTPServer;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.events.Event;
 import org.openhab.core.events.EventSubscriber;
@@ -39,6 +50,8 @@ import org.openhab.core.library.items.DateTimeItem;
 import org.openhab.core.library.items.StringItem;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.StringType;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.ManagedThingProvider;
@@ -57,18 +70,6 @@ import org.openhab.core.thing.type.ChannelTypeBuilder;
 import org.openhab.core.thing.type.ChannelTypeProvider;
 import org.openhab.core.thing.type.ChannelTypeUID;
 import org.openhab.core.types.State;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.ArgumentMatchers;
-import org.openhab.binding.ntp.internal.NtpBindingConstants;
-import org.openhab.binding.ntp.internal.handler.NtpHandler;
-import org.openhab.binding.ntp.server.SimpleNTPServer;
 
 /**
  * OSGi tests for the {@link NtpHandler}
@@ -122,7 +123,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         // Initializing a new local server on this port
         timeServer = new SimpleNTPServer(TEST_PORT);
@@ -144,7 +145,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
         Locale.setDefault(Locale.US);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         VolatileStorageService volatileStorageService = new VolatileStorageService();
         registerService(volatileStorageService);
@@ -165,7 +166,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
         registerService(channelTypeProvider);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         if (ntpThing != null) {
             Thing removedThing = thingRegistry.forceRemove(ntpThing.getUID());
@@ -177,7 +178,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
         }
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownClass() {
         // Stopping the local time server
         timeServer.stopServer();
@@ -274,7 +275,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
     }
 
     @Test
-    @Ignore("https://github.com/eclipse/smarthome/issues/5224")
+    @Disabled("https://github.com/eclipse/smarthome/issues/5224")
     public void testDateTimeChannelCalendarDefaultTimeZoneUpdate() {
         Configuration configuration = new Configuration();
         // Initialize with configuration with no time zone property set.
index 241f01cc7ba2d277148f0c48b3e59514a007c795..64fc5dfa25ba64dd646b37599136a73a87abe124 100644 (file)
@@ -15,7 +15,8 @@ package org.openhab.binding.systeminfo.test;
 import static java.lang.Thread.sleep;
 import static java.util.stream.Collectors.toList;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.mockito.Mockito.*;
 
 import java.math.BigDecimal;
@@ -23,6 +24,16 @@ import java.net.UnknownHostException;
 import java.util.Hashtable;
 import java.util.List;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants;
+import org.openhab.binding.systeminfo.internal.SysteminfoHandlerFactory;
+import org.openhab.binding.systeminfo.internal.discovery.SysteminfoDiscoveryService;
+import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler;
+import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException;
+import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.config.discovery.DiscoveryService;
@@ -35,6 +46,8 @@ import org.openhab.core.library.items.NumberItem;
 import org.openhab.core.library.items.StringItem;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.StringType;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.ManagedThingProvider;
@@ -55,18 +68,6 @@ import org.openhab.core.thing.type.ChannelKind;
 import org.openhab.core.thing.type.ChannelTypeUID;
 import org.openhab.core.types.State;
 import org.openhab.core.types.UnDefType;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants;
-import org.openhab.binding.systeminfo.internal.SysteminfoHandlerFactory;
-import org.openhab.binding.systeminfo.internal.discovery.SysteminfoDiscoveryService;
-import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler;
-import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException;
-import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface;
 
 /**
  * OSGi tests for the {@link SysteminfoHandler}
@@ -105,7 +106,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     private ItemRegistry itemRegistry;
     private SysteminfoHandlerFactory systeminfoHandlerFactory;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         VolatileStorageService volatileStorageService = new VolatileStorageService();
         registerService(volatileStorageService);
@@ -138,7 +139,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         assertThat(itemRegistry, is(notNullValue()));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         if (systemInfoThing != null) {
             // Remove the systeminfo thing. The handler will be also disposed automatically
@@ -658,7 +659,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
                 mockedDriveSerialNumber);
     }
 
-    @Ignore
+    @Disabled
     // There is a bug opened for this issue - https://github.com/dblock/oshi/issues/185
     @Test
     public void assertChannelSensorsCpuTempIsUpdated() {
@@ -927,7 +928,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         waitForAssert(() -> {
             List<DiscoveryResult> results = inbox.stream().filter(InboxPredicates.forThingUID(computerUID))
                     .collect(toList());
-            assertFalse("No Thing with UID " + computerUID.getAsString() + " in inbox", results.isEmpty());
+            assertFalse(results.isEmpty(), "No Thing with UID " + computerUID.getAsString() + " in inbox");
         });
 
         inbox.approve(computerUID, SysteminfoDiscoveryService.DEFAULT_THING_LABEL);
index 28b3fe9e938bb5700156eb9edca7307a328efc9c..f586e917fbdfa979a83972d33987268de46bd846 100644 (file)
 package org.openhab.binding.tradfri.internal.discovery;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.mockito.MockitoAnnotations.openMocks;
 import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
 
 import javax.jmdns.ServiceInfo;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.config.discovery.DiscoveryResultFlag;
 import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
+import org.openhab.core.test.java.JavaOSGiTest;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingUID;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
 
 /**
  * Tests for {@link TradfriDiscoveryParticipant}.
@@ -39,15 +41,15 @@ public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest {
 
     private MDNSDiscoveryParticipant discoveryParticipant;
 
-    @Mock
-    private ServiceInfo tradfriGateway;
+    private AutoCloseable mocksCloseable;
 
-    @Mock
-    private ServiceInfo otherDevice;
+    private @Mock ServiceInfo tradfriGateway;
+    private @Mock ServiceInfo otherDevice;
+
+    @BeforeEach
+    public void beforeEach() {
+        mocksCloseable = openMocks(this);
 
-    @Before
-    public void setUp() {
-        initMocks(this);
         discoveryParticipant = getService(MDNSDiscoveryParticipant.class, TradfriDiscoveryParticipant.class);
 
         when(tradfriGateway.getType()).thenReturn("_coap._udp.local.");
@@ -63,6 +65,11 @@ public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest {
         when(otherDevice.getPropertyString("version")).thenReturn("1.1");
     }
 
+    @AfterEach
+    public void afterEach() throws Exception {
+        mocksCloseable.close();
+    }
+
     @Test
     public void correctSupportedTypes() {
         assertThat(discoveryParticipant.getSupportedThingTypeUIDs().size(), is(1));
index adc08301358b3e076aee79f5e60487bb0e99b5b3..75cdee860980c745c38a966a57beb3c1f3de6bcc 100644 (file)
 package org.openhab.binding.tradfri.internal.handler;
 
 import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
 import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
 import static org.openhab.binding.tradfri.internal.config.TradfriDeviceConfig.CONFIG_ID;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.config.core.Configuration;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ManagedThingProvider;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingProvider;
 import org.openhab.core.thing.binding.builder.BridgeBuilder;
 import org.openhab.core.thing.binding.builder.ThingBuilder;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 
 /**
  * Tests cases for {@link TradfriGatewayHandler}.
@@ -46,7 +46,7 @@ public class TradfriHandlerOSGiTest extends JavaOSGiTest {
     private Bridge bridge;
     private Thing thing;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         registerService(volatileStorageService);
         managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
@@ -64,7 +64,7 @@ public class TradfriHandlerOSGiTest extends JavaOSGiTest {
                 .withConfiguration(new Configuration(properties)).build();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         managedThingProvider.remove(thing.getUID());
         managedThingProvider.remove(bridge.getUID());
index b801d8c9546c544c3c3a83da0f862191a636dad6..abdf05ec229d8216b7cb11070d4a509789945c4a 100644 (file)
  */
 package org.openhab.binding.wemo.internal.discovery.test;
 
-import static org.openhab.core.config.discovery.inbox.InboxPredicates.forThingUID;
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.openhab.core.config.discovery.inbox.InboxPredicates.forThingUID;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -23,19 +24,19 @@ import java.util.Collection;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.core.config.discovery.DiscoveryResult;
-import org.openhab.core.config.discovery.inbox.Inbox;
-import org.openhab.core.thing.Thing;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.thing.ThingUID;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.jupnp.model.meta.Device;
 import org.openhab.binding.wemo.internal.WemoBindingConstants;
 import org.openhab.binding.wemo.internal.discovery.WemoDiscoveryService;
 import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
+import org.openhab.core.config.discovery.DiscoveryResult;
+import org.openhab.core.config.discovery.inbox.Inbox;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
 
 /**
  * Tests for {@link WemoDiscoveryService}.
@@ -52,7 +53,7 @@ public class WemoDiscoveryOSGiTest extends GenericWemoOSGiTest {
 
     private @NonNullByDefault({}) Inbox inbox;
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         setUpServices();
 
@@ -60,7 +61,7 @@ public class WemoDiscoveryOSGiTest extends GenericWemoOSGiTest {
         assertThat(inbox, is(notNullValue()));
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         List<DiscoveryResult> results = inbox.getAll();
         assertThat(results.size(), is(0));
index f6a179399a22b7917445f966dc18a93b2adc4a0d..b71e49d1bef86d3f0c71f12d701d22450f9a7f08 100644 (file)
 package org.openhab.binding.wemo.internal.discovery.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 
-import org.openhab.core.config.discovery.DiscoveryResult;
-import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.thing.ThingUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.jupnp.model.meta.DeviceDetails;
 import org.jupnp.model.meta.ManufacturerDetails;
@@ -37,6 +34,10 @@ import org.jupnp.model.types.UDN;
 import org.openhab.binding.wemo.internal.WemoBindingConstants;
 import org.openhab.binding.wemo.internal.discovery.WemoDiscoveryParticipant;
 import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
+import org.openhab.core.config.discovery.DiscoveryResult;
+import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
 
 /**
  * Tests for {@link WemoDiscoveryParticipant}.
index 8a4853e6159c1ee3bf59322014c324e34ac86319..ee35247dc040d5acf3df890187711af4fe7ecffd 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.wemo.internal.discovery.test;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -23,8 +23,8 @@ import java.util.List;
 
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
@@ -43,7 +43,7 @@ import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
  */
 public class WemoLinkDiscoveryServiceOSGiTest extends GenericWemoLightOSGiTestParent {
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         setUpServices();
     }
index d12d24db850fec7b2bc1f0e4b77b204677b793a6..bb300acc2ab2b1eb4d548653940dd56d6e61babb 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.wemo.internal.handler.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -22,16 +23,9 @@ import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.List;
 
-import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.Thing;
-import org.openhab.core.thing.ThingStatus;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.types.Command;
-import org.openhab.core.types.RefreshType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jupnp.model.ValidationException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
@@ -39,6 +33,13 @@ import org.openhab.binding.wemo.internal.WemoBindingConstants;
 import org.openhab.binding.wemo.internal.handler.WemoHandler;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.types.Command;
+import org.openhab.core.types.RefreshType;
 
 /**
  * Tests for {@link WemoHandler}.
@@ -58,12 +59,12 @@ public class WemoHandlerOSGiTest extends GenericWemoOSGiTest {
     private final String SERVICE_ID = "basicevent";
     private final String SERVICE_NUMBER = "1";
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         setUpServices();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         removeThing();
     }
index 82cae0061945ed21caa793422382e557b0765244..8990c0eb350d0faf2f6677be4dd41e2d887c6484 100644 (file)
 package org.openhab.binding.wemo.internal.handler.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.wemo.internal.WemoBindingConstants;
+import org.openhab.binding.wemo.internal.handler.WemoHandler;
+import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.thing.Thing;
@@ -25,12 +31,6 @@ import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.types.State;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openhab.binding.wemo.internal.WemoBindingConstants;
-import org.openhab.binding.wemo.internal.handler.WemoHandler;
-import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 
 /**
  * Tests for {@link WemoHandler}.
@@ -60,7 +60,7 @@ public class WemoHandlerTest {
 
     private final Thing thing = mock(Thing.class);
 
-    @Before
+    @BeforeEach
     public void setUp() {
         insightParams = new WemoInsightParams();
         when(thing.getUID()).thenReturn(new ThingUID(THING_TYPE, THING_ID));
@@ -68,7 +68,7 @@ public class WemoHandlerTest {
         when(thing.getStatus()).thenReturn(ThingStatus.ONLINE);
     }
 
-    @After
+    @AfterEach
     public void clear() {
         handler.channelState = null;
         handler.channelToWatch = null;
index 3dda05a41c768b585ca2265e73f536cad4fbe703..13fdcffbf80504ca0b8607cef46f9ab56dda589a 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.wemo.internal.handler.test;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -22,6 +23,16 @@ import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.List;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.jupnp.model.ValidationException;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.openhab.binding.wemo.internal.WemoBindingConstants;
+import org.openhab.binding.wemo.internal.handler.WemoLightHandler;
+import org.openhab.binding.wemo.internal.http.WemoHttpCall;
+import org.openhab.binding.wemo.internal.test.GenericWemoLightOSGiTestParent;
 import org.openhab.core.library.types.IncreaseDecreaseType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -32,16 +43,6 @@ import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.jupnp.model.ValidationException;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.openhab.binding.wemo.internal.WemoBindingConstants;
-import org.openhab.binding.wemo.internal.handler.WemoLightHandler;
-import org.openhab.binding.wemo.internal.http.WemoHttpCall;
-import org.openhab.binding.wemo.internal.test.GenericWemoLightOSGiTestParent;
 
 /**
  * Tests for {@link WemoLightHandler}.
@@ -54,12 +55,12 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
     private static final String GET_ACTION = "GetDeviceStatus";
     private static final String SET_ACTION = "SetDeviceStatus";
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         setUpServices();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         removeThing();
     }
index 0836e0d4533976262eb7c35c15d7afdaf03f01b8..3b8a774034e9692b8164be74ce3dba956fc68ee1 100644 (file)
@@ -13,7 +13,8 @@
 package org.openhab.binding.wemo.internal.handler.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -22,6 +23,16 @@ import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.List;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.jupnp.model.ValidationException;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.openhab.binding.wemo.internal.WemoBindingConstants;
+import org.openhab.binding.wemo.internal.handler.WemoMakerHandler;
+import org.openhab.binding.wemo.internal.http.WemoHttpCall;
+import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
@@ -30,16 +41,6 @@ import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.jupnp.model.ValidationException;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.openhab.binding.wemo.internal.WemoBindingConstants;
-import org.openhab.binding.wemo.internal.handler.WemoMakerHandler;
-import org.openhab.binding.wemo.internal.http.WemoHttpCall;
-import org.openhab.binding.wemo.internal.test.GenericWemoOSGiTest;
 
 /**
  * Tests for {@link WemoMakerHandler}.
@@ -59,12 +60,12 @@ public class WemoMakerHandlerOSGiTest extends GenericWemoOSGiTest {
     private final String BASIC_EVENT_SERVICE_ID = "basicevent";
     private final String SERVICE_NUMBER = "1";
 
-    @Before
+    @BeforeEach
     public void setUp() throws IOException {
         setUpServices();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         removeThing();
     }
index 6837247908550ac2110a983c84c678a129f4f193..24226b8ff781b663ca8dcf9a573d5f8303d71209 100644 (file)
 package org.openhab.binding.wemo.internal.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
+import org.openhab.binding.wemo.internal.WemoBindingConstants;
+import org.openhab.binding.wemo.internal.handler.AbstractWemoHandler;
+import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Channel;
@@ -28,9 +31,6 @@ import org.openhab.core.thing.binding.builder.BridgeBuilder;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
 import org.openhab.core.thing.binding.builder.ThingBuilder;
 import org.openhab.core.thing.type.ChannelKind;
-import org.openhab.binding.wemo.internal.WemoBindingConstants;
-import org.openhab.binding.wemo.internal.handler.AbstractWemoHandler;
-import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 
 /**
  * Generic test class for all WemoLight related tests that contains methods and constants used across the different test
index 7ef44d4af6de9d969c3d13b6b54d70de05424ffe..171463887968f6d3dbb685d084fbbf77b4d4dbe0 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.wemo.internal.test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
@@ -24,25 +24,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Locale;
 
-import org.openhab.core.config.core.Configuration;
-import org.openhab.core.library.CoreItemFactory;
-import org.openhab.core.thing.Channel;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ManagedThingProvider;
-import org.openhab.core.thing.Thing;
-import org.openhab.core.thing.ThingRegistry;
-import org.openhab.core.thing.ThingTypeUID;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.thing.binding.ThingHandler;
-import org.openhab.core.thing.binding.builder.ChannelBuilder;
-import org.openhab.core.thing.binding.builder.ThingBuilder;
-import org.openhab.core.thing.type.ChannelKind;
-import org.openhab.core.thing.type.ChannelTypeBuilder;
-import org.openhab.core.thing.type.ChannelTypeProvider;
-import org.openhab.core.thing.type.ChannelTypeUID;
-import org.openhab.core.io.transport.upnp.UpnpIOService;
-import org.openhab.core.test.java.JavaOSGiTest;
-import org.openhab.core.test.storage.VolatileStorageService;
 import org.jupnp.UpnpService;
 import org.jupnp.mock.MockUpnpService;
 import org.jupnp.model.ValidationException;
@@ -59,6 +40,25 @@ import org.jupnp.model.types.UDN;
 import org.openhab.binding.wemo.internal.WemoBindingConstants;
 import org.openhab.binding.wemo.internal.handler.AbstractWemoHandler;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
+import org.openhab.core.config.core.Configuration;
+import org.openhab.core.io.transport.upnp.UpnpIOService;
+import org.openhab.core.library.CoreItemFactory;
+import org.openhab.core.test.java.JavaOSGiTest;
+import org.openhab.core.test.storage.VolatileStorageService;
+import org.openhab.core.thing.Channel;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.ManagedThingProvider;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingRegistry;
+import org.openhab.core.thing.ThingTypeUID;
+import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.binding.ThingHandler;
+import org.openhab.core.thing.binding.builder.ChannelBuilder;
+import org.openhab.core.thing.binding.builder.ThingBuilder;
+import org.openhab.core.thing.type.ChannelKind;
+import org.openhab.core.thing.type.ChannelTypeBuilder;
+import org.openhab.core.thing.type.ChannelTypeProvider;
+import org.openhab.core.thing.type.ChannelTypeUID;
 
 /**
  * Generic test class for all Wemo related tests that contains methods and constants used across the different test
index 0e46a454d44d982b1614cd9fd0fed33f3fe770fd..1de271b094e0555e30da6c25db59363e4cba32d6 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.openhab.addons.itests</groupId>
     <artifactId>org.openhab.addons.reactor.itests</artifactId>
-    <version>2.5.9-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>org.openhab.io.mqttembeddedbroker.tests</artifactId>
index 9a459ad7c498604f49aa173fbe4f1eadd91e7dc8..baf16cc2010519d4f495a86510337d3d289d2733 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.io.mqttembeddedbroker;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -25,7 +25,6 @@ import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
 import org.openhab.core.io.transport.mqtt.MqttConnectionState;
 import org.openhab.core.io.transport.mqtt.MqttService;
 import org.openhab.core.io.transport.mqtt.MqttServiceObserver;
-import org.openhab.io.mqttembeddedbroker.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,7 +65,7 @@ public class EmbeddedBrokerTools {
 
             };
             mqttService.addBrokersListener(observer);
-            assertTrue("Wait for embedded connection client failed", semaphore.tryAcquire(700, TimeUnit.MILLISECONDS));
+            assertTrue(semaphore.tryAcquire(700, TimeUnit.MILLISECONDS), "Wait for embedded connection client failed");
         }
         MqttBrokerConnection embeddedConnection = this.embeddedConnection;
         if (embeddedConnection == null) {
@@ -85,8 +84,8 @@ public class EmbeddedBrokerTools {
         if (embeddedConnection.connectionState() == MqttConnectionState.CONNECTED) {
             semaphore.release();
         }
-        assertTrue("Connection " + embeddedConnection.getClientId() + " failed. State: "
-                + embeddedConnection.connectionState(), semaphore.tryAcquire(500, TimeUnit.MILLISECONDS));
+        assertTrue(semaphore.tryAcquire(500, TimeUnit.MILLISECONDS), "Connection " + embeddedConnection.getClientId()
+                + " failed. State: " + embeddedConnection.connectionState());
         return embeddedConnection;
     }
 
index 1da3d3f29e78844482bbd4bb1cf4d0064bf20b49..516e0a862de360b7288cd4e86c6a1a39209b1992 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.io.mqttembeddedbroker;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.MockitoAnnotations.openMocks;
 
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -25,14 +26,14 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
 import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
 import org.openhab.core.io.transport.mqtt.MqttConnectionState;
 import org.openhab.core.io.transport.mqtt.MqttService;
 import org.openhab.core.test.java.JavaOSGiTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 
 /**
  * Moquette test
@@ -42,6 +43,8 @@ import org.junit.Test;
 public class MoquetteTest extends JavaOSGiTest {
     private static final String TEST_TOPIC = "testtopic";
 
+    private AutoCloseable mocksCloseable;
+
     private MqttService mqttService;
     private MqttBrokerConnection embeddedConnection;
     private MqttBrokerConnection clientConnection;
@@ -53,10 +56,10 @@ public class MoquetteTest extends JavaOSGiTest {
     private MqttConnectionObserver failIfChange = (state, error) -> assertThat(state,
             is(MqttConnectionState.CONNECTED));
 
-    @Before
-    public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
+    @BeforeEach
+    public void beforeEach() throws Exception {
         registerVolatileStorageService();
-        initMocks(this);
+        mocksCloseable = openMocks(this);
         mqttService = getService(MqttService.class);
 
         // Wait for the EmbeddedBrokerService internal connection to be connected
@@ -72,12 +75,13 @@ public class MoquetteTest extends JavaOSGiTest {
         clientConnection.addConnectionObserver(failIfChange);
     }
 
-    @After
-    public void tearDown() throws InterruptedException, ExecutionException, TimeoutException {
+    @AfterEach
+    public void afterEach() throws Exception {
         if (clientConnection != null) {
             clientConnection.removeConnectionObserver(failIfChange);
             clientConnection.stop().get(500, TimeUnit.MILLISECONDS);
         }
+        mocksCloseable.close();
     }
 
     @Test
@@ -101,8 +105,10 @@ public class MoquetteTest extends JavaOSGiTest {
             throws InterruptedException, ExecutionException, TimeoutException {
         List<CompletableFuture<Boolean>> futures = new ArrayList<>();
 
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1, true));
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1, true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1,
+                true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1,
+                true));
 
         CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(1000, TimeUnit.MILLISECONDS);
 
@@ -120,8 +126,10 @@ public class MoquetteTest extends JavaOSGiTest {
             throws InterruptedException, ExecutionException, TimeoutException {
         List<CompletableFuture<Boolean>> futures = new ArrayList<>();
 
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1, true));
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1, true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1,
+                true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1,
+                true));
 
         CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(1000, TimeUnit.MILLISECONDS);
 
@@ -138,8 +146,10 @@ public class MoquetteTest extends JavaOSGiTest {
             throws InterruptedException, ExecutionException, TimeoutException {
         List<CompletableFuture<Boolean>> futures = new ArrayList<>();
 
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1, true));
-        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1, true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/1", "testPayload1".getBytes(StandardCharsets.UTF_8), 1,
+                true));
+        futures.add(embeddedConnection.publish(TEST_TOPIC + "/2", "testPayload2".getBytes(StandardCharsets.UTF_8), 1,
+                true));
 
         CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(1000, TimeUnit.MILLISECONDS);