2 * Copyright (c) 2016 Cisco Systems, Inc. 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.mdsal.dom.spi;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertNull;
14 import java.util.List;
15 import java.util.stream.Collectors;
16 import org.junit.AfterClass;
17 import org.junit.BeforeClass;
18 import org.junit.Test;
19 import org.opendaylight.yang.svc.v1.urn.opendaylight.yang.extension.yang.ext.rev130709.YangModuleInfoImpl;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
22 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
24 import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
25 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
26 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
28 public class ContentRoutedRpcContextTest {
29 private static List<RpcEffectiveStatement> RPCS;
32 public static void beforeClass() {
33 final var ctx = YangParserTestUtils.parseYangSources(YangParserConfiguration.DEFAULT, null,
34 new DelegatedYangTextSource(new SourceIdentifier("yang-ext.yang"),
35 YangModuleInfoImpl.getInstance().getYangTextCharSource()),
36 new URLYangTextSource(ContentRoutedRpcContext.class.getResource("/rpc-routing-strategy.yang")));
38 RPCS = ctx.findModuleStatements("foo").iterator().next()
39 .streamEffectiveSubstatements(RpcEffectiveStatement.class)
40 .collect(Collectors.toUnmodifiableList());
44 public static void afterClass() {
49 public void unroutedRpcStrategyTest() {
50 assertNull(ContentRoutedRpcContext.forRpc(RPCS.get(1)));
54 public void routedRpcStrategyTest() {
55 final var context = ContentRoutedRpcContext.forRpc(RPCS.get(0));
56 assertNotNull(context);
58 assertEquals(QName.create("foo", "identity"), context.identity());
59 assertEquals(QName.create("foo", "ctx"), context.leaf());