2 * Copyright 2016 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.mockito.Mockito;
22 import org.openo.sfc.entity.portpair.PortPairReq4N;
23 import org.openo.sfc.resources.DriverResource;
24 import org.openo.sfc.service.ISdnControllerService;
25 import org.openo.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;
31 import javax.ws.rs.core.*;
32 import java.lang.annotation.Annotation;
34 import java.util.Date;
35 import java.util.Locale;
39 @RunWith(PowerMockRunner.class)
40 @PrepareForTest(ISdnControllerService.class)
41 @PowerMockIgnore({"javax.net.ssl.*"})
42 public class TestPortPair {
44 DriverResource resource = new DriverResource();
46 public void test_createportpair() throws Exception {
47 PortPairReq4N portpair =new PortPairReq4N();
48 portpair.setUrl("http://127.0.0.1:80");
49 N2sReqWrapper.convertPortPair(portpair);
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() {
57 // public MsbRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, MsbRegisterEntity entity) throws Exception {
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() {
67 public int getStatus() {
68 return 0; //To change body of implemented methods use File | Settings | File Templates.
72 public StatusType getStatusInfo() {
73 return null; //To change body of implemented methods use File | Settings | File Templates.
77 public Object getEntity() {
78 return null; //To change body of implemented methods use File | Settings | File Templates.
82 public <T> T readEntity(Class<T> tClass) {
83 return null; //To change body of implemented methods use File | Settings | File Templates.
87 public <T> T readEntity(GenericType<T> tGenericType) {
88 return null; //To change body of implemented methods use File | Settings | File Templates.
92 public <T> T readEntity(Class<T> tClass, Annotation[] annotations) {
93 return null; //To change body of implemented methods use File | Settings | File Templates.
97 public <T> T readEntity(GenericType<T> tGenericType, Annotation[] annotations) {
98 return null; //To change body of implemented methods use File | Settings | File Templates.
102 public boolean hasEntity() {
103 return false; //To change body of implemented methods use File | Settings | File Templates.
107 public boolean bufferEntity() {
108 return false; //To change body of implemented methods use File | Settings | File Templates.
112 public void close() {
113 //To change body of implemented methods use File | Settings | File Templates.
117 public MediaType getMediaType() {
118 return null; //To change body of implemented methods use File | Settings | File Templates.
122 public Locale getLanguage() {
123 return null; //To change body of implemented methods use File | Settings | File Templates.
127 public int getLength() {
128 return 0; //To change body of implemented methods use File | Settings | File Templates.
132 public Set<String> getAllowedMethods() {
133 return null; //To change body of implemented methods use File | Settings | File Templates.
137 public Map<String, NewCookie> getCookies() {
138 return null; //To change body of implemented methods use File | Settings | File Templates.
142 public EntityTag getEntityTag() {
143 return null; //To change body of implemented methods use File | Settings | File Templates.
147 public Date getDate() {
148 return null; //To change body of implemented methods use File | Settings | File Templates.
152 public Date getLastModified() {
153 return null; //To change body of implemented methods use File | Settings | File Templates.
157 public URI getLocation() {
158 return null; //To change body of implemented methods use File | Settings | File Templates.
162 public Set<Link> getLinks() {
163 return null; //To change body of implemented methods use File | Settings | File Templates.
167 public boolean hasLink(String s) {
168 return false; //To change body of implemented methods use File | Settings | File Templates.
172 public Link getLink(String s) {
173 return null; //To change body of implemented methods use File | Settings | File Templates.
177 public Link.Builder getLinkBuilder(String s) {
178 return null; //To change body of implemented methods use File | Settings | File Templates.
182 public MultivaluedMap<String, Object> getMetadata() {
183 return null; //To change body of implemented methods use File | Settings | File Templates.
187 public MultivaluedMap<String, String> getStringHeaders() {
188 return null; //To change body of implemented methods use File | Settings | File Templates.
192 public String getHeaderString(String s) {
193 return null; //To change body of implemented methods use File | Settings | File Templates.