unit test for DriverResource
[vfc/nfvo/driver/sfc.git] / zte / sfc-driver / sfc-driver / src / test / java / org / onap / sfc / resources / DriverResourceTest.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.sfc.resources;
17
18 import org.junit.Test;
19 import org.onap.sfc.entity.DelReqInfo;
20 import org.onap.sfc.entity.FlowClassfierReq4N;
21 import org.onap.sfc.entity.PortChainReq4N;
22 import org.onap.sfc.entity.PortPairGroupReq4N;
23 import org.onap.sfc.entity.portpair.PortPairReq4N;
24
25 import javax.ws.rs.ProcessingException;
26
27 public class DriverResourceTest {
28     public static final String URL = "http://0.0.0.0:8080";
29     private DriverResource driverResource = new DriverResource();
30
31     @Test
32     public void createPortPair() throws Exception {
33         try {
34             PortPairReq4N portPairReq4N = new PortPairReq4N();
35             portPairReq4N.setUrl(URL);
36             driverResource.createPortPair(portPairReq4N);
37         } catch (ProcessingException ex) {
38             String message = ex.getMessage();
39             assert message.contains(" Connection refused");
40         }
41     }
42
43     @Test
44     public void createPortPairGroup() throws Exception {
45         try {
46             PortPairGroupReq4N portPairGroupReq4N = new PortPairGroupReq4N();
47             portPairGroupReq4N.setUrl(URL);
48             driverResource.createPortPairGroup(portPairGroupReq4N);
49         } catch (ProcessingException ex) {
50             String message = ex.getMessage();
51             assert message.contains(" Connection refused");
52         }
53     }
54
55     @Test
56     public void createFlowClassfier() throws Exception {
57         try {
58             FlowClassfierReq4N flowClassfierReq4N = new FlowClassfierReq4N();
59             flowClassfierReq4N.setUrl(URL);
60             driverResource.createFlowClassfier(flowClassfierReq4N);
61         } catch (ProcessingException ex) {
62             String message = ex.getMessage();
63             assert message.contains(" Connection refused");
64         }
65     }
66
67     @Test
68     public void creatPortChain() throws Exception {
69         try {
70             PortChainReq4N portChainReq4N = new PortChainReq4N();
71             portChainReq4N.setUrl(URL);
72             driverResource.creatPortChain(portChainReq4N);
73         } catch (ProcessingException ex) {
74             String message = ex.getMessage();
75             assert message.contains(" Connection refused");
76         }
77     }
78
79     @Test
80     public void delPortPair() throws Exception {
81         try {
82             DelReqInfo delReqInfo = new DelReqInfo();
83             delReqInfo.setUrl(URL);
84             delReqInfo.setId("123-456-789");
85             driverResource.delPortPair(delReqInfo);
86         } catch (ProcessingException ex) {
87             String message = ex.getMessage();
88             assert message.contains(" Connection refused");
89         }
90     }
91
92     @Test
93     public void delPortPairGroup() throws Exception {
94         try {
95             DelReqInfo delReqInfo = new DelReqInfo();
96             delReqInfo.setUrl(URL);
97             delReqInfo.setId("123-456-789");
98             driverResource.delPortPairGroup(delReqInfo);
99         } catch (ProcessingException ex) {
100             String message = ex.getMessage();
101             assert message.contains(" Connection refused");
102         }
103     }
104
105     @Test
106     public void delFlowClassfier() throws Exception {
107         try {
108             DelReqInfo delReqInfo = new DelReqInfo();
109             delReqInfo.setUrl(URL);
110             delReqInfo.setId("123-456-789");
111             driverResource.delFlowClassfier(delReqInfo);
112         } catch (ProcessingException ex) {
113             String message = ex.getMessage();
114             assert message.contains(" Connection refused");
115         }
116     }
117
118     @Test
119     public void delPortChain() throws Exception {
120         try {
121             DelReqInfo delReqInfo = new DelReqInfo();
122             delReqInfo.setUrl(URL);
123             delReqInfo.setId("123-456-789");
124             driverResource.delPortChain(delReqInfo);
125         } catch (ProcessingException ex) {
126             String message = ex.getMessage();
127             assert message.contains(" Connection refused");
128         }
129     }
130
131 }