Fix checkstyle warnings in netconf-impl.
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultGetSchemaTest.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
9 package org.opendaylight.controller.netconf.impl.mapping.operations;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Matchers.anyString;
14 import static org.mockito.Mockito.doReturn;
15 import static org.mockito.Mockito.doThrow;
16 import static org.mockito.Mockito.mock;
17
18 import com.google.common.base.Optional;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
22 import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
23 import org.opendaylight.controller.netconf.util.xml.XmlElement;
24 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
25 import org.w3c.dom.Document;
26
27 public class DefaultGetSchemaTest {
28
29     private CapabilityProvider cap;
30     private Document doc;
31     private String getSchema;
32
33     @Before
34     public void setUp() throws Exception {
35         cap = mock(CapabilityProvider.class);
36         doc = XmlUtil.newDocument();
37         getSchema = "<get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n" +
38                 "        <identifier>threadpool-api</identifier>\n" +
39                 "        <version>2010-09-24</version>\n" +
40                 "        <format\n" +
41                 "                xmlns:ncm=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">ncm:yang\n" +
42                 "        </format>\n" +
43                 "    </get-schema>";
44     }
45
46     @Test(expected = NetconfDocumentedException.class)
47     public void testDefaultGetSchema() throws Exception {
48         DefaultGetSchema schema = new DefaultGetSchema(cap, "");
49         doThrow(IllegalStateException.class).when(cap).getSchemaForCapability(anyString(), any(Optional.class));
50         schema.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema)));
51     }
52
53     @Test
54     public void handleWithNoSubsequentOperations() throws Exception {
55         DefaultGetSchema schema = new DefaultGetSchema(cap, "");
56         doReturn("").when(cap).getSchemaForCapability(anyString(), any(Optional.class));
57         assertNotNull(schema.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema))));
58     }
59 }