2 * Copyright (c) 2021 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.test.perf.utils;
10 import java.util.Optional;
11 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
16 public final class TestUtils {
18 private static final QName NODE_QNAME = QName.create(Node.QNAME, "node-id").intern();
23 public static Optional<String> getNodeId(final YangInstanceIdentifier path) {
24 if (path.getLastPathArgument() instanceof NodeIdentifierWithPredicates) {
25 final NodeIdentifierWithPredicates nodeIId = ((NodeIdentifierWithPredicates) path.getLastPathArgument());
26 return Optional.ofNullable(nodeIId.getValue(NODE_QNAME, String.class));
28 return Optional.empty();