Changed $Yang* generation package and name
[mdsal.git] / dom / mdsal-dom-spi / src / test / java / org / opendaylight / mdsal / dom / spi / ContentRoutedRpcContextTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.mdsal.dom.spi;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertNull;
13
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;
27
28 public class ContentRoutedRpcContextTest {
29     private static List<RpcEffectiveStatement> RPCS;
30
31     @BeforeClass
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")));
37
38         RPCS = ctx.findModuleStatements("foo").iterator().next()
39             .streamEffectiveSubstatements(RpcEffectiveStatement.class)
40             .collect(Collectors.toUnmodifiableList());
41     }
42
43     @AfterClass
44     public static void afterClass() {
45         RPCS = null;
46     }
47
48     @Test
49     public void unroutedRpcStrategyTest() {
50         assertNull(ContentRoutedRpcContext.forRpc(RPCS.get(1)));
51     }
52
53     @Test
54     public void routedRpcStrategyTest() {
55         final var context = ContentRoutedRpcContext.forRpc(RPCS.get(0));
56         assertNotNull(context);
57
58         assertEquals(QName.create("foo", "identity"), context.identity());
59         assertEquals(QName.create("foo", "ctx"), context.leaf());
60     }
61 }