@Override
    public List<PortDescription> discoverPortDetails() {
        log.info("Adding ports for Waveserver Ai device");
        List<PortDescription> ports = new ArrayList<>();

        Device device = getDevice(handler().data().deviceId());
        NetconfSession session = getNetconfSession();

        try {
            XPath xp = XPathFactory.newInstance().newXPath();
            Node nodeListItem;

            Node node = TEMPLATE_MANAGER.doRequest(session, "discoverPortDetails");
            NodeList nodeList = (NodeList) xp.evaluate("waveserver-ports/ports", node, XPathConstants.NODESET);
            int count = nodeList.getLength();
            for (int i = 0; i < count; ++i) {
                nodeListItem = nodeList.item(i);
                DefaultAnnotations annotationPort = DefaultAnnotations.builder()
                        .set(AnnotationKeys.PORT_NAME, xp.evaluate("port-id/text()", nodeListItem))
                        .set(AnnotationKeys.PROTOCOL, xp.evaluate("id/type/text()", nodeListItem))
                        .build();
                String port = xp.evaluate("port-id/text()", nodeListItem);
                ports.add(DefaultPortDescription.builder()
                          .withPortNumber(PortNumber.portNumber(
                                  portIdConvert(port), port))
                          .isEnabled(portStateConvert(
                                  xp.evaluate("state/operational-state/text()", nodeListItem)))
                          .portSpeed(portSpeedToLong(xp.evaluate("id/speed/text()", nodeListItem)))
                          .type(Port.Type.PACKET)
                          .annotations(annotationPort)
                          .build());
            }
        } catch (NetconfException | XPathExpressionException e) {
            log.error("Unable to retrieve port information for device {}, {}", device.chassisId(), e);
        }
        return ImmutableList.copyOf(ports);
    }
@Test
    public void testDiscoverPortDetails() {
        List<PortDescription> result = new ArrayList<>();
        List<PortDescription> expectResult = getExpectedPorts();

        try {
            XPath xp = XPathFactory.newInstance().newXPath();
            Node nodeListItem;

            Node node = doRequest("/response/discoverPortDetails.xml", "/rpc-reply/data");
            NodeList nodeList = (NodeList) xp.evaluate("waveserver-ports/ports", node, XPathConstants.NODESET);
            int count = nodeList.getLength();
            for (int i = 0; i < count; ++i) {
                nodeListItem = nodeList.item(i);
                DefaultAnnotations annotationPort = DefaultAnnotations.builder()
                        .set(AnnotationKeys.PORT_NAME, xp.evaluate("port-id/text()", nodeListItem))
                        .set(AnnotationKeys.PROTOCOL, xp.evaluate("id/type/text()", nodeListItem))
                        .build();
                String port = xp.evaluate("port-id/text()", nodeListItem);
                result.add(DefaultPortDescription.builder()
                                  .withPortNumber(PortNumber.portNumber(
                                          portIdConvert(port), port))
                                  .isEnabled(portStateConvert(xp.evaluate(
                                          "state/operational-state/text()", nodeListItem)))
                                  .portSpeed(portSpeedToLong(xp.evaluate(
                                          "id/speed/text()", nodeListItem)))
                                  .type(Port.Type.PACKET)
                                  .annotations(annotationPort)
                                  .build());
            }
        } catch (XPathExpressionException e) {
            e.printStackTrace();
        }
         assertEquals(expectResult, result);
    }