1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.mockito.Matchers.any;
6 import static org.mockito.Mockito.mock;
7 import static org.mockito.Mockito.when;
9 import java.io.FileNotFoundException;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
15 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
16 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
17 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
18 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
19 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
23 public class RestconfImplTest {
25 private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
28 public static void init() throws FileNotFoundException {
29 Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
30 assertNotNull(allModules);
31 SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
32 ControllerContext controllerContext = ControllerContext.getInstance();
33 controllerContext.setSchemas(schemaContext);
34 restconfImpl.setControllerContext(controllerContext);
38 public void testExample() throws FileNotFoundException {
39 CompositeNode loadedCompositeNode = TestUtils.readInputToCnSn("/parts/ietf-interfaces_interfaces.xml", XmlToCompositeNodeProvider.INSTANCE);
40 BrokerFacade brokerFacade = mock(BrokerFacade.class);
41 when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
42 assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));