Test SchemaExportContentYangBodyWriter
[netconf.git] / restconf / sal-rest-connector / src / test / java / org / opendaylight / netconf / md / sal / rest / schema / SchemaExportContentYangBodyWriterTest.java
1 /*
2  * Copyright (c) 2017 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.netconf.md.sal.rest.schema;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.when;
15
16 import java.io.ByteArrayOutputStream;
17 import java.io.OutputStream;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20
21 public class SchemaExportContentYangBodyWriterTest {
22
23     @Test
24     public void secybwInitTest() {
25         final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter();
26         assertNotNull(secybw);
27     }
28
29     @Test
30     public void isWriteableTest() {
31         final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter();
32         assertNotNull(secybw);
33         Class<?> type = SchemaExportContext.class;
34         boolean writeable = secybw.isWriteable(type, null, null, null);
35         assertTrue(writeable);
36
37         type = Class.class;
38         writeable = secybw.isWriteable(type, null, null, null);
39         assertTrue(!writeable);
40     }
41
42     @Test
43     public void getSizeTest() {
44         final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter();
45         assertNotNull(secybw);
46         final long size = secybw.getSize(null, null, null, null, null);
47         assertEquals(-1, size);
48     }
49
50     @Test
51     public void writeToTest() throws Exception {
52         final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter();
53         final SchemaExportContext schemaExportContext = mock(SchemaExportContext.class);
54         final Module module = mock(Module.class);
55         final String source = "source";
56         when(module.getSource()).thenReturn(source);
57         when(schemaExportContext.getModule()).thenReturn(module);
58         final OutputStream stream = new ByteArrayOutputStream();
59         secybw.writeTo(schemaExportContext, null, null, null, null, null, stream);
60         assertNotNull(secybw);
61     }
62
63 }