Initial source code
[oam/tr069-adapter.git] / netconf-server / src / test / java / org / commscope / tr069adapter / netconf / server / RestartNetconfServerHandlerTest.java
1 /*\r
2  * ============LICENSE_START========================================================================\r
3  * ONAP : tr-069-adapter\r
4  * =================================================================================================\r
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
6  * =================================================================================================\r
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
9  * may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
14  * either express or implied. See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  * ===============LICENSE_END=======================================================================\r
17  */\r
18 \r
19 package org.commscope.tr069adapter.netconf.server;\r
20 \r
21 import static org.junit.Assert.assertTrue;\r
22 import static org.junit.Assert.fail;\r
23 \r
24 import java.util.ArrayList;\r
25 import java.util.List;\r
26 \r
27 import org.commscope.tr069adapter.netconf.boot.NetConfServiceBooter;\r
28 import org.commscope.tr069adapter.netconf.entity.NetConfServerDetailsEntity;\r
29 import org.commscope.tr069adapter.netconf.error.RetryFailedException;\r
30 import org.junit.FixMethodOrder;\r
31 import org.junit.jupiter.api.Test;\r
32 import org.junit.jupiter.api.extension.ExtendWith;\r
33 import org.junit.runners.MethodSorters;\r
34 import org.springframework.beans.factory.annotation.Autowired;\r
35 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;\r
36 import org.springframework.boot.test.context.SpringBootTest;\r
37 import org.springframework.boot.test.mock.mockito.MockBean;\r
38 import org.springframework.test.context.junit.jupiter.SpringExtension;\r
39 \r
40 \r
41 @FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
42 @ExtendWith(SpringExtension.class)\r
43 @SpringBootTest(classes = {NetConfServiceBooter.class},\r
44     args = "--schemas-dir test-schemas --debug true --starting-port 17830")\r
45 @AutoConfigureMockMvc\r
46 class RestartNetconfServerHandlerTest {\r
47 \r
48   @MockBean\r
49   NetConfServerManagerImpl manager;\r
50 \r
51   @Autowired\r
52   RestartNetconfServerHandler restartHandler;\r
53 \r
54   @Test\r
55   void testRestart() {\r
56     List<NetConfServerDetailsEntity> sList = new ArrayList<NetConfServerDetailsEntity>();\r
57     try {\r
58       restartHandler.restart(sList);\r
59     } catch (RetryFailedException e) {\r
60       fail("Exception while retry.");\r
61     }\r
62     assertTrue(true);\r
63   }\r
64 \r
65   @Test\r
66   void testRecover() {\r
67     List<NetConfServerDetailsEntity> sList = new ArrayList<NetConfServerDetailsEntity>();\r
68     restartHandler.recover(sList);\r
69     assertTrue(true);\r
70   }\r
71 \r
72 }\r