Merge "Cleanup: Remove passing around of DataPersistenceProvider"
[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.spy;
15 import static org.mockito.Mockito.when;
16
17 import java.io.FileNotFoundException;
18 import java.text.ParseException;
19 import java.util.Set;
20 import org.junit.Before;
21 import org.junit.BeforeClass;
22 import org.junit.Test;
23 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
24 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
25 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
26 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
27 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
28 import org.opendaylight.yangtools.yang.model.api.Module;
29 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
30
31 /**
32  * @See {@link InvokeRpcMethodTest}
33  *
34  */
35 public class RestconfImplTest {
36
37     private RestconfImpl restconfImpl = null;
38     private static ControllerContext controllerContext = null;
39
40     @BeforeClass
41     public static void init() throws FileNotFoundException {
42         final Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
43         assertNotNull(allModules);
44         final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
45         controllerContext = spy(ControllerContext.getInstance());
46         controllerContext.setSchemas(schemaContext);
47
48     }
49
50     @Before
51     public void initMethod() {
52         restconfImpl = RestconfImpl.getInstance();
53         restconfImpl.setControllerContext(controllerContext);
54     }
55
56     @SuppressWarnings("unchecked")
57     @Test
58     public void testExample() throws FileNotFoundException, ParseException {
59         @SuppressWarnings("rawtypes")
60         final
61         NormalizedNode normalizedNodeData = TestUtils.prepareNormalizedNodeWithIetfInterfacesInterfacesData();
62         final BrokerFacade brokerFacade = mock(BrokerFacade.class);
63         when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(normalizedNodeData);
64         assertEquals(normalizedNodeData,
65                 brokerFacade.readOperationalData(null));
66     }
67
68 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.