Initial source code
[oam/tr069-adapter.git] / netconf-server / src / test / java / org / commscope / tr069adapter / netconf / server / RestartNetconfServerHandlerTest.java
diff --git a/netconf-server/src/test/java/org/commscope/tr069adapter/netconf/server/RestartNetconfServerHandlerTest.java b/netconf-server/src/test/java/org/commscope/tr069adapter/netconf/server/RestartNetconfServerHandlerTest.java
new file mode 100644 (file)
index 0000000..97f4ed2
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.netconf.server;\r
+\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.fail;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.commscope.tr069adapter.netconf.boot.NetConfServiceBooter;\r
+import org.commscope.tr069adapter.netconf.entity.NetConfServerDetailsEntity;\r
+import org.commscope.tr069adapter.netconf.error.RetryFailedException;\r
+import org.junit.FixMethodOrder;\r
+import org.junit.jupiter.api.Test;\r
+import org.junit.jupiter.api.extension.ExtendWith;\r
+import org.junit.runners.MethodSorters;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
+import org.springframework.boot.test.mock.mockito.MockBean;\r
+import org.springframework.test.context.junit.jupiter.SpringExtension;\r
+\r
+\r
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
+@ExtendWith(SpringExtension.class)\r
+@SpringBootTest(classes = {NetConfServiceBooter.class},\r
+    args = "--schemas-dir test-schemas --debug true --starting-port 17830")\r
+@AutoConfigureMockMvc\r
+class RestartNetconfServerHandlerTest {\r
+\r
+  @MockBean\r
+  NetConfServerManagerImpl manager;\r
+\r
+  @Autowired\r
+  RestartNetconfServerHandler restartHandler;\r
+\r
+  @Test\r
+  void testRestart() {\r
+    List<NetConfServerDetailsEntity> sList = new ArrayList<NetConfServerDetailsEntity>();\r
+    try {\r
+      restartHandler.restart(sList);\r
+    } catch (RetryFailedException e) {\r
+      fail("Exception while retry.");\r
+    }\r
+    assertTrue(true);\r
+  }\r
+\r
+  @Test\r
+  void testRecover() {\r
+    List<NetConfServerDetailsEntity> sList = new ArrayList<NetConfServerDetailsEntity>();\r
+    restartHandler.recover(sList);\r
+    assertTrue(true);\r
+  }\r
+\r
+}\r