Add RestconfServer.dataDELETE()
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / Netconf822Test.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, 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.restconf.nb.rfc8040.rests.services.impl;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertNotNull;
12
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.junit.jupiter.api.Test;
15 import org.junit.jupiter.api.extension.ExtendWith;
16 import org.mockito.junit.jupiter.MockitoExtension;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
18 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
19
20 @ExtendWith(MockitoExtension.class)
21 class Netconf822Test extends AbstractRestconfTest {
22     private static final @NonNull EffectiveModelContext MODEL_CONTEXT =
23         YangParserTestUtils.parseYangResourceDirectory("/nc822");
24
25     @Override
26     @NonNull EffectiveModelContext modelContext() {
27         return MODEL_CONTEXT;
28     }
29
30     @Test
31     void testOperationsContent() {
32         final var content = server.operationsGET();
33         assertEquals("""
34             {
35               "ietf-restconf:operations" : {
36                 "foo:new" : [null],
37                 "foo:new1" : [null]
38               }
39             }""", content.toJSON());
40         assertEquals("""
41             <operations xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
42               <new xmlns="foo"/>
43               <new1 xmlns="foo"/>
44             </operations>""", content.toXML());
45     }
46
47     @Test
48     void testOperationsContentByIdentifier() {
49         final var content = server.operationsGET("foo:new1");
50         assertNotNull(content);
51         assertEquals("""
52             { "foo:new1" : [null] }""", content.toJSON());
53         assertEquals("""
54             <new1 xmlns="foo"/>""", content.toXML());
55     }
56 }