Introduce asynchronous RestconfServer.readData()
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / RootResourceDiscoveryServiceImplTest.java
1 /*
2  * Copyright (c) 2020 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.Assert.assertEquals;
11
12 import org.junit.Test;
13
14 public class RootResourceDiscoveryServiceImplTest {
15     private final RootResourceDiscoveryServiceImpl svc = new RootResourceDiscoveryServiceImpl("fooBarBaz");
16
17     @Test
18     public void testJsonData() {
19         final var response = svc.readJsonData();
20         assertEquals(200, response.getStatus());
21         assertEquals("""
22             {
23               "links" : {
24                 "rel" : "restconf",
25                 "href" : "/fooBarBaz"
26               }
27             }""", response.getEntity());
28     }
29
30     @Test
31     public void testXrdData() {
32         final var response = svc.readXrdData();
33         assertEquals(200, response.getStatus());
34         assertEquals("""
35             <?xml version='1.0' encoding='UTF-8'?>
36             <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
37               <Link rel='restconf' href='/fooBarBaz'/>
38             </XRD>""", response.getEntity());
39     }
40 }