sal-rest-connector test refactoring
[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.junit.Assert.assertNotNull;
5 import static org.mockito.Matchers.any;
6 import static org.mockito.Mockito.mock;
7 import static org.mockito.Mockito.when;
8
9 import java.io.FileNotFoundException;
10 import java.util.Set;
11
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;
22
23 public class RestconfImplTest {
24
25     private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
26
27     @BeforeClass
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);
35     }
36
37     @Test
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));
43     }
44
45 }