protected List<DeviceId> getDeviceAndPopulatePowerMap(JsonNode connectivityReply,
                                                          Map<DeviceId, Double> deviceAtoBPowerMap,
                                                          Map<DeviceId, Double> deviceBtoAPowerMap,
                                                          String name) {
        List<DeviceId> deviceIds = new ArrayList<>();
        if (connectivityReply.has("result")
                && connectivityReply.get("result").has("response")) {
            JsonNode response = connectivityReply.get("result").get("response");
            //getting the a-b path.
            Iterator<JsonNode> paths = connectivityReply.get("result").get("response")
                    .elements();
            while (paths.hasNext()) {
                JsonNode path = paths.next();
                if (path.get("response-id").asText().equals(name)) {
                    Iterator<JsonNode> elements = path.get("path-properties")
                            .get("reversed-path-route-objects").elements();
                    Iterable<JsonNode> iterable = () -> elements;
                    List<JsonNode> elementsList = StreamSupport
                            .stream(iterable.spliterator(), false)
                            .collect(Collectors.toList());
                    Iterator<JsonNode> reversePathRoute = path.get("path-properties")
                            .get("reversed-path-route-objects").elements();
                    Iterable<JsonNode> reversedIterable = () -> reversePathRoute;
                    List<JsonNode> reversedElementsList = StreamSupport
                            .stream(reversedIterable.spliterator(), false)
                            .collect(Collectors.toList());
                    for (int i = 0; i < elementsList.size() - 1; i++) {
                        if (elementsList.get(i).get("path-route-object").has("num-unnum-hop")) {
                            String elementId = elementsList.get(i).get("path-route-object")
                                    .get("num-unnum-hop").get("node-id")
                                    .asText();
                            //TODO this is a workaround until we understand better the
                            // topology mapping between ONOS and GNPy
                            if (elementId.startsWith("netconf:")) {
                                double power = -99;
                                if (!elementsList.get(i).get("path-route-object")
                                        .get("num-unnum-hop").get("gnpy-node-type")
                                        .asText().equals("transceiver")) {
                                    power = getPerHopPower(elementsList.get(i + 2));
                                }
                                deviceAtoBPowerMap.put(DeviceId.deviceId(elementId), power);
                                for (int j = 0; j < reversedElementsList.size() - 1; j++) {
                                    if (reversedElementsList.get(j).get("path-route-object").has("num-unnum-hop")) {
                                        String reversedElementId = reversedElementsList.get(j).get("path-route-object")
                                                .get("num-unnum-hop").get("node-id")
                                                .asText();
                                        double reversePower = -99;
                                        if (reversedElementId.equals(elementId)) {
                                            reversePower = getPerHopPower(reversedElementsList.get(j + 2));
                                            deviceBtoAPowerMap.put(DeviceId.deviceId(elementId), reversePower);
                                        }
                                    }
                                }
                                deviceIds.add(DeviceId.deviceId(elementId));
                            }
                        }
                    }
                    break;
                }
            }
        } else {
            log.warn("Can't retrieve devices {}", connectivityReply);
        }
        return deviceIds;
    }
@Test
    public void testgetDevicePowerMap() throws IOException {
        Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
        Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
        manager.getDeviceAndPopulatePowerMap(reply, deviceAtoBPowerMap, deviceBtoAPowerMap, "second");
        assertEquals(-25.0, deviceAtoBPowerMap.get(DeviceId.deviceId("netconf:10.0.254.107:830")));
        assertEquals(-12.0, deviceAtoBPowerMap.get(DeviceId.deviceId("netconf:10.0.254.225:830")));
        assertEquals(-12.0, deviceBtoAPowerMap.get(DeviceId.deviceId("netconf:10.0.254.225:830")));
        assertEquals(-25.0, deviceBtoAPowerMap.get(DeviceId.deviceId("netconf:10.0.254.107:830")));
    }