Add tool to measure southbound notification performance
[netconf.git] / netconf / tools / netconf-test-perf / src / main / java / org / opendaylight / netconf / test / perf / utils / TestUtils.java
1 /*
2  * Copyright (c) 2021 Pantheon Technologies, s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.test.perf.utils;
9
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;
15
16 public final class TestUtils {
17
18     private static final QName NODE_QNAME = QName.create(Node.QNAME, "node-id").intern();
19
20     private TestUtils() {
21     }
22
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));
27         } else {
28             return Optional.empty();
29         }
30     }
31 }