From 0fc60d82c673e2bc5bd3ca8f07089724971daf97 Mon Sep 17 00:00:00 2001 From: Hilbrand Bouwkamp Date: Thu, 21 Jan 2021 16:41:36 +0100 Subject: [PATCH] [dsmr] Fix test after openhab-core change #2126 (#9900) PortInUseException interface changed. Signed-off-by: Hilbrand Bouwkamp --- .../dsmr/internal/device/DSMRSerialAutoDeviceTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDeviceTest.java b/bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDeviceTest.java index 8738c1d0b..33d635c85 100644 --- a/bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDeviceTest.java +++ b/bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/DSMRSerialAutoDeviceTest.java @@ -132,9 +132,8 @@ public class DSMRSerialAutoDeviceTest { try (InputStream inputStream = new ByteArrayInputStream(new byte[] {})) { when(mockSerialPort.getInputStream()).thenReturn(inputStream); // Trigger device to go into error stage with port in use. - doAnswer(a -> { - throw new PortInUseException(); - }).when(mockIdentifier).open(eq(DSMRBindingConstants.DSMR_PORT_NAME), anyInt()); + doThrow(new PortInUseException(new Exception())).when(mockIdentifier) + .open(eq(DSMRBindingConstants.DSMR_PORT_NAME), anyInt()); DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, new DSMRTelegramListener(), scheduler, 1); device.start();