Rename restconf-nb-rfc8040 to restconf-nb
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / RestconfOperationsServiceTest.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.restconf.nb.rfc8040.rests.services.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Mockito.mock;
12
13 import java.io.IOException;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.junit.MockitoJUnitRunner;
17 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
18 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
19 import org.opendaylight.restconf.nb.rfc8040.TestUtils;
20 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
21
22 @RunWith(MockitoJUnitRunner.StrictStubs.class)
23 public class RestconfOperationsServiceTest {
24     @Test
25     public void getOperationsTest() throws IOException {
26         final var oper = new RestconfOperationsServiceImpl(
27             TestUtils.newSchemaContextHandler(
28                 YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"))),
29             mock(DOMMountPointService.class));
30
31         assertEquals("{\n"
32             + "  \"ietf-restconf:operations\" : {\n"
33             + "    \"module1:dummy-rpc1-module1\": [null],\n"
34             + "    \"module1:dummy-rpc2-module1\": [null],\n"
35             + "    \"module2:dummy-rpc1-module2\": [null],\n"
36             + "    \"module2:dummy-rpc2-module2\": [null]\n"
37             + "  }\n"
38             + "}", oper.getOperationsJSON());
39         assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
40             + "<operations xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\"\n"
41             + "            xmlns:ns0=\"module:1\"\n"
42             + "            xmlns:ns1=\"module:2\" >\n"
43             + "  <ns0:dummy-rpc1-module1/>\n"
44             + "  <ns0:dummy-rpc2-module1/>\n"
45             + "  <ns1:dummy-rpc1-module2/>\n"
46             + "  <ns1:dummy-rpc2-module2/>\n"
47             + "</operations>", oper.getOperationsXML());
48     }
49 }