64c4bee3a68d332073ee46d20e236bf4f55743a8
[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.junit.Assert.assertEquals;
4 import static org.mockito.Matchers.any;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.when;
7
8 import java.io.FileNotFoundException;
9 import java.util.Set;
10
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import org.opendaylight.controller.sal.restconf.impl.*;
14 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
15 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18
19 public class RestconfImplTest {
20
21     private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
22
23     @BeforeClass
24     public static void init() throws FileNotFoundException {
25         Set<Module> allModules = TestUtils.loadModules(RestconfImplTest.class.getResource("/full-versions/yangs")
26                 .getPath());
27         SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
28         ControllerContext controllerContext = ControllerContext.getInstance();
29         controllerContext.setSchemas(schemaContext);
30         restconfImpl.setControllerContext(controllerContext);
31     }
32
33     @Test
34     public void testExample() throws FileNotFoundException {
35         CompositeNode loadedCompositeNode = TestUtils.loadCompositeNode("/parts/ietf-interfaces_interfaces.xml");
36         BrokerFacade brokerFacade = mock(BrokerFacade.class);
37         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
38         assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));
39     }
40
41 }