From 0ce9ec3dcc59f1cef3c896b8e2573f711aa25a39 Mon Sep 17 00:00:00 2001 From: Jakub Toth Date: Thu, 13 Apr 2017 14:44:20 +0200 Subject: [PATCH] Test SchemaExportContentYangBodyWriter Change-Id: Ib40451621d5f20731186003ab88f4054e98546e7 Signed-off-by: Jakub Toth --- .../SchemaExportContentYangBodyWriter.java | 1 + ...SchemaExportContentYangBodyWriterTest.java | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriterTest.java diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java index c377650c29..130c61ede7 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java @@ -39,6 +39,7 @@ public class SchemaExportContentYangBodyWriter implements MessageBodyWriter type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriterTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriterTest.java new file mode 100644 index 0000000000..9767c2c905 --- /dev/null +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriterTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.netconf.md.sal.rest.schema; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import org.junit.Test; +import org.opendaylight.yangtools.yang.model.api.Module; + +public class SchemaExportContentYangBodyWriterTest { + + @Test + public void secybwInitTest() { + final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter(); + assertNotNull(secybw); + } + + @Test + public void isWriteableTest() { + final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter(); + assertNotNull(secybw); + Class type = SchemaExportContext.class; + boolean writeable = secybw.isWriteable(type, null, null, null); + assertTrue(writeable); + + type = Class.class; + writeable = secybw.isWriteable(type, null, null, null); + assertTrue(!writeable); + } + + @Test + public void getSizeTest() { + final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter(); + assertNotNull(secybw); + final long size = secybw.getSize(null, null, null, null, null); + assertEquals(-1, size); + } + + @Test + public void writeToTest() throws Exception { + final SchemaExportContentYangBodyWriter secybw = new SchemaExportContentYangBodyWriter(); + final SchemaExportContext schemaExportContext = mock(SchemaExportContext.class); + final Module module = mock(Module.class); + final String source = "source"; + when(module.getSource()).thenReturn(source); + when(schemaExportContext.getModule()).thenReturn(module); + final OutputStream stream = new ByteArrayOutputStream(); + secybw.writeTo(schemaExportContext, null, null, null, null, null, stream); + assertNotNull(secybw); + } + +} -- 2.36.6