Test SchemaExportContentYangBodyWriter 94/93394/2
authorJakub Toth <jatoth@cisco.com>
Thu, 13 Apr 2017 12:44:20 +0000 (14:44 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 2 Nov 2020 09:35:54 +0000 (09:35 +0000)
Change-Id: Ib40451621d5f20731186003ab88f4054e98546e7
Signed-off-by: Jakub Toth <jatoth@cisco.com>
(cherry picked from commit 0ce9ec3dcc59f1cef3c896b8e2573f711aa25a39)

restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriterTest.java [new file with mode: 0644]

index c377650c294cb0de290896c48a492e01a630b200..130c61ede7c3ee887b3cf140ee0f98264efa52a8 100644 (file)
@@ -39,6 +39,7 @@ public class SchemaExportContentYangBodyWriter implements MessageBodyWriter<Sche
         return -1;
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public void writeTo(final SchemaExportContext context, final Class<?> 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 (file)
index 0000000..9767c2c
--- /dev/null
@@ -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);
+    }
+
+}