Added case with Choice-case to instance identifier building
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / RestconfImplTest.java
1 package org.opendaylight.controller.sal.restconf.impl.test;
2
3 import static org.mockito.Mockito.*;
4 import static org.junit.Assert.*;
5
6 import java.io.FileNotFoundException;
7 import java.io.InputStream;
8 import java.util.Set;
9
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
13 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
14 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
15 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
16 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19
20 public class RestconfImplTest {
21
22     private static final RestconfImpl restconfImpl = new RestconfImpl();
23
24     @BeforeClass
25     public static void init() throws FileNotFoundException {
26         Set<Module> allModules = TestUtils.loadModules(RestconfImplTest.class.getResource("/full-versions/yangs").getPath());
27         SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
28         ControllerContext controllerContext = new ControllerContext();
29         controllerContext.setSchemas(schemaContext);
30         restconfImpl.setControllerContext(controllerContext);
31     }
32
33     @Test
34     public void testExample() throws FileNotFoundException {
35         InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
36         CompositeNode loadedCompositeNode = TestUtils.loadCompositeNode(xmlStream);
37         BrokerFacade brokerFacade = mock(BrokerFacade.class);
38         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
39         assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));
40     }
41
42 }