Take advantage of MultipartTransactionAware
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / RestconfImplTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.sal.restconf.impl.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.when;
15
16 import java.io.FileNotFoundException;
17 import java.util.Set;
18
19 import org.junit.BeforeClass;
20 import org.junit.Test;
21 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
22 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
23 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
24 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
25 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
26 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
27 import org.opendaylight.yangtools.yang.model.api.Module;
28 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
29
30 public class RestconfImplTest {
31
32     private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
33
34     @BeforeClass
35     public static void init() throws FileNotFoundException {
36         Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
37         assertNotNull(allModules);
38         SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
39         ControllerContext controllerContext = ControllerContext.getInstance();
40         controllerContext.setSchemas(schemaContext);
41         restconfImpl.setControllerContext(controllerContext);
42     }
43
44     @Test
45     public void testExample() throws FileNotFoundException {
46         CompositeNode loadedCompositeNode = TestUtils.readInputToCnSn("/parts/ietf-interfaces_interfaces.xml", XmlToCompositeNodeProvider.INSTANCE);
47         BrokerFacade brokerFacade = mock(BrokerFacade.class);
48         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
49         assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));
50     }
51
52 }