import java.io.StringReader;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@Override
public @Nullable Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp,
@Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) {
- return Collections.emptyList();
+ return List.of();
}
};
assertTrue(discovery.getSupportedThingTypes().contains(GROUP_SWITCH_THING_TYPE));
}
+ @SuppressWarnings("null")
@Test
- public void invalidDiscoveryResult() throws JAXBException {
+ public void invalidDiscoveryResult() throws JAXBException, XMLStreamException {
// attribute productname is important for a valid discovery result
//@formatter:off
String xml =
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertNull(discoveryResult);
}
+ @SuppressWarnings("null")
@Test
- public void validDECTRepeater100Result() throws JAXBException {
+ public void validDECTRepeater100Result() throws JAXBException, XMLStreamException {
//@formatter:off
final String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
- final Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
+ Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertNull(discoveryResult);
}
+ @SuppressWarnings("null")
@Test
- public void validDECT200DiscoveryResult() throws JAXBException {
+ public void validDECT200DiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validDECT210DiscoveryResult() throws JAXBException {
+ public void validDECT210DiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validCometDECTDiscoveryResult() throws JAXBException {
+ public void validCometDECTDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validDECT300DiscoveryResult() throws JAXBException {
+ public void validDECT300DiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validDECT301DiscoveryResult() throws JAXBException {
+ public void validDECT301DiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validPowerline546EDiscoveryResult() throws JAXBException {
+ public void validPowerline546EDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void invalidHANFUNContactDiscoveryResult() throws JAXBException {
+ public void invalidHANFUNContactDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertNull(discoveryResult);
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNMagneticContactDiscoveryResult() throws JAXBException {
+ public void validHANFUNMagneticContactDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNOpticalContactDiscoveryResult() throws JAXBException {
+ public void validHANFUNOpticalContactDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNMotionSensorDiscoveryResult() throws JAXBException {
+ public void validHANFUNMotionSensorDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNMSmokeDetectorDiscoveryResult() throws JAXBException {
+ public void validHANFUNMSmokeDetectorDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNSwitchtDiscoveryResult() throws JAXBException {
+ public void validHANFUNSwitchtDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHANFUNBlindDiscoveryResult() throws JAXBException {
+ public void validHANFUNBlindDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validHeatingGroupDiscoveryResult() throws JAXBException {
+ public void validHeatingGroupDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());
assertEquals(CONFIG_AIN, discoveryResult.getRepresentationProperty());
}
+ @SuppressWarnings("null")
@Test
- public void validSwitchGroupDiscoveryResult() throws JAXBException {
+ public void validSwitchGroupDiscoveryResult() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<devicelist version=\"1\">" +
"</devicelist>";
//@formatter:on
+ XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
- DeviceListModel devices = (DeviceListModel) u.unmarshal(new StringReader(xml));
+ DeviceListModel devices = u.unmarshal(xsr, DeviceListModel.class).getValue();
+
assertNotNull(devices);
assertEquals(1, devices.getDevicelist().size());