rename openo to onap
[vfc/nfvo/driver/sfc.git] / zte / sfc-driver / sfc-driver / src / test / java / org / onap / sfc / TestPortPair.java
1 /**
2  * Copyright 2017 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.sfc;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.mockito.Mockito;
22 import org.onap.sfc.entity.portpair.PortPairReq4N;
23 import org.onap.sfc.resources.DriverResource;
24 import org.onap.sfc.service.ISdnControllerService;
25 import org.onap.sfc.wrapper.N2sReqWrapper;
26 import org.powermock.api.mockito.PowerMockito;
27 import org.powermock.core.classloader.annotations.PowerMockIgnore;
28 import org.powermock.core.classloader.annotations.PrepareForTest;
29 import org.powermock.modules.junit4.PowerMockRunner;
30
31 import javax.ws.rs.core.*;
32 import java.lang.annotation.Annotation;
33 import java.net.URI;
34 import java.util.Date;
35 import java.util.Locale;
36 import java.util.Map;
37 import java.util.Set;
38
39 @RunWith(PowerMockRunner.class)
40 @PrepareForTest(ISdnControllerService.class)
41 @PowerMockIgnore({"javax.net.ssl.*"})
42 public class TestPortPair {
43
44     DriverResource resource = new DriverResource();
45     @Test
46     public void test_createportpair() throws Exception {
47         PortPairReq4N portpair =new PortPairReq4N();
48         portpair.setUrl("http://127.0.0.1:8181");
49         N2sReqWrapper.convertPortPair(portpair);
50     }
51
52     @Before
53     public void setupBeforeTest() throws Exception {
54 //        SdnServiceConsumer consumer = PowerMockito.mock(SdnServiceConsumer.class);
55 //        PowerMockito.when(consumer.getMsbRegisterService("http://127.0.0.1:80")).thenReturn(new MsbService() {
56 //            @Override
57 //            public MsbRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, MsbRegisterEntity entity) throws Exception {
58 //                return null;
59 //            }
60 //        }) ;
61
62         PowerMockito.mockStatic(ISdnControllerService.class);
63         ISdnControllerService service = PowerMockito.mock(ISdnControllerService.class);
64 //        PowerMockito.doNothing().when(service).createPortPair(Mockito.anyString(),Mockito.anyString());
65         PowerMockito.when(service.createPortPair(Mockito.anyString(),Mockito.anyString())).thenReturn(new Response() {
66             @Override
67             public int getStatus() {
68                 return 0;  //To change body of implemented methods use File | Settings | File Templates.
69             }
70
71             @Override
72             public StatusType getStatusInfo() {
73                 return null;  //To change body of implemented methods use File | Settings | File Templates.
74             }
75
76             @Override
77             public Object getEntity() {
78                 return null;  //To change body of implemented methods use File | Settings | File Templates.
79             }
80
81             @Override
82             public <T> T readEntity(Class<T> tClass) {
83                 return null;  //To change body of implemented methods use File | Settings | File Templates.
84             }
85
86             @Override
87             public <T> T readEntity(GenericType<T> tGenericType) {
88                 return null;  //To change body of implemented methods use File | Settings | File Templates.
89             }
90
91             @Override
92             public <T> T readEntity(Class<T> tClass, Annotation[] annotations) {
93                 return null;  //To change body of implemented methods use File | Settings | File Templates.
94             }
95
96             @Override
97             public <T> T readEntity(GenericType<T> tGenericType, Annotation[] annotations) {
98                 return null;  //To change body of implemented methods use File | Settings | File Templates.
99             }
100
101             @Override
102             public boolean hasEntity() {
103                 return false;  //To change body of implemented methods use File | Settings | File Templates.
104             }
105
106             @Override
107             public boolean bufferEntity() {
108                 return false;  //To change body of implemented methods use File | Settings | File Templates.
109             }
110
111             @Override
112             public void close() {
113                 //To change body of implemented methods use File | Settings | File Templates.
114             }
115
116             @Override
117             public MediaType getMediaType() {
118                 return null;  //To change body of implemented methods use File | Settings | File Templates.
119             }
120
121             @Override
122             public Locale getLanguage() {
123                 return null;  //To change body of implemented methods use File | Settings | File Templates.
124             }
125
126             @Override
127             public int getLength() {
128                 return 0;  //To change body of implemented methods use File | Settings | File Templates.
129             }
130
131             @Override
132             public Set<String> getAllowedMethods() {
133                 return null;  //To change body of implemented methods use File | Settings | File Templates.
134             }
135
136             @Override
137             public Map<String, NewCookie> getCookies() {
138                 return null;  //To change body of implemented methods use File | Settings | File Templates.
139             }
140
141             @Override
142             public EntityTag getEntityTag() {
143                 return null;  //To change body of implemented methods use File | Settings | File Templates.
144             }
145
146             @Override
147             public Date getDate() {
148                 return null;  //To change body of implemented methods use File | Settings | File Templates.
149             }
150
151             @Override
152             public Date getLastModified() {
153                 return null;  //To change body of implemented methods use File | Settings | File Templates.
154             }
155
156             @Override
157             public URI getLocation() {
158                 return null;  //To change body of implemented methods use File | Settings | File Templates.
159             }
160
161             @Override
162             public Set<Link> getLinks() {
163                 return null;  //To change body of implemented methods use File | Settings | File Templates.
164             }
165
166             @Override
167             public boolean hasLink(String s) {
168                 return false;  //To change body of implemented methods use File | Settings | File Templates.
169             }
170
171             @Override
172             public Link getLink(String s) {
173                 return null;  //To change body of implemented methods use File | Settings | File Templates.
174             }
175
176             @Override
177             public Link.Builder getLinkBuilder(String s) {
178                 return null;  //To change body of implemented methods use File | Settings | File Templates.
179             }
180
181             @Override
182             public MultivaluedMap<String, Object> getMetadata() {
183                 return null;  //To change body of implemented methods use File | Settings | File Templates.
184             }
185
186             @Override
187             public MultivaluedMap<String, String> getStringHeaders() {
188                 return null;  //To change body of implemented methods use File | Settings | File Templates.
189             }
190
191             @Override
192             public String getHeaderString(String s) {
193                 return null;  //To change body of implemented methods use File | Settings | File Templates.
194             }
195         }) ;
196     }
197
198 }