Development of NETCONF RPCs for tr-069 adapter to
[oam/tr069-adapter.git] / netconf-server / src / test / java / org / commscope / tr069adapter / netconf / error / ServerPortAllocationExceptionTest.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : tr-069-adapter
4  * =================================================================================================
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.
6  * =================================================================================================
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9  * may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ===============LICENSE_END=======================================================================
17  */
18
19 package org.commscope.tr069adapter.netconf.error;
20
21 import static org.junit.jupiter.api.Assertions.*;
22
23 import org.commscope.tr069adapter.mapper.model.NetconfServerManagementError;
24 import org.junit.jupiter.api.Test;
25
26 class ServerPortAllocationExceptionTest {
27
28   @Test
29   void testServerPortAllocationException() {
30     try {
31       throw new ServerPortAllocationException(NetconfServerManagementError.PORT_IN_USE);
32
33     } catch (ServerPortAllocationException e) {
34       assertTrue(true);
35     }
36   }
37
38   @Test
39   void testGetError() {
40     try {
41       throw new ServerPortAllocationException(NetconfServerManagementError.PORT_IN_USE);
42
43     } catch (ServerPortAllocationException e) {
44       assertEquals(NetconfServerManagementError.PORT_IN_USE, e.getError());
45     }
46   }
47
48   @Test
49   void testSetError() {
50     try {
51       ServerPortAllocationException se =
52           new ServerPortAllocationException(NetconfServerManagementError.INTERNAL_ERROR);
53       throw se;
54
55     } catch (ServerPortAllocationException e) {
56       assertEquals(NetconfServerManagementError.INTERNAL_ERROR, e.getError());
57     }
58   }
59
60 }