2 * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.md.sal.rest.schema;
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;
16 import java.io.ByteArrayOutputStream;
17 import java.io.OutputStream;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Module;
21 public class SchemaExportContentYangBodyWriterTest {
24 public void secybwInitTest() {
25 final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter();
26 assertNotNull(secybw);
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);
38 writeable = secybw.isWriteable(type, null, null, null);
39 assertTrue(!writeable);
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);
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);