Realize the PNF registration API
[aai/esr-server.git] / esr-mgr / src / test / java / org / onap / aai / esr / wrapper / PnfManagerWrapperTest.java
1 /**
2  * Copyright 2018 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.aai.esr.wrapper;
17
18 import javax.ws.rs.core.Response;
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.mockito.Mockito;
22 import org.onap.aai.esr.common.MsbConfig;
23 import org.onap.aai.esr.entity.aai.Pnf;
24 import org.onap.aai.esr.entity.rest.PnfRegisterInfo;
25 import org.onap.aai.esr.exception.ExtsysException;
26 import org.onap.aai.esr.externalservice.aai.NetworkProxy;
27
28 public class PnfManagerWrapperTest {
29
30     static {
31         MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
32     }
33
34     @Test
35     public void test_registerPnf() throws ExtsysException {
36         PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
37         pnfRegisterInfo.setPnfId("pnf1");
38         pnfRegisterInfo.setUserLabel("PNF-test");
39         pnfRegisterInfo.setSubnetId("subnetId1");
40         pnfRegisterInfo.setNeId("neId1");
41         pnfRegisterInfo.setManagementType("Test");
42         pnfRegisterInfo.setVendor("ZTE");
43         pnfRegisterInfo.setPnfdId("pnfdId1");
44         pnfRegisterInfo.setEmsId("emsId1");
45         pnfRegisterInfo.setLattitude("121.546");
46         pnfRegisterInfo.setLongitude("14.22");
47         NetworkProxy mockNetworkProxy = Mockito.mock(NetworkProxy.class);
48         Mockito.doNothing().when(mockNetworkProxy).registerPnf(Mockito.anyString(), (Pnf)Mockito.anyObject());
49         PnfManagerWrapper pnfManagerWrapper = new PnfManagerWrapper(mockNetworkProxy);
50         Response response = pnfManagerWrapper.registerPnf(pnfRegisterInfo);
51         if (response != null) {
52             Assert.assertTrue(response.getStatus() == 200);
53         }
54     }
55 }