blob: fcafa1c9713058554d61c2f63f29125d63d7accb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
package com.onap.sdnc.testapi.service;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import com.onap.sdnc.testapi.model.Response;
import com.onap.sdnc.testapi.model.CertificationInputs;
import com.onap.sdnc.testapi.model.Input;
import com.onap.sdnc.testapi.model.ODLClientResponse;
import com.onap.sdnc.testapi.model.Output;
import com.onap.sdnc.testapi.model.PreTestResponse;
import com.onap.sdnc.testapi.model.Request;
import com.onap.sdnc.testapi.model.ValidationTestType;
import com.onap.sdnc.testapi.model.VnfList;
public class LayerTestServiceImplTest {
@Mock
CertificationClientService cService;
@Mock
LayerTestServiceImpl layerTestServiceImpl;
private String hostname = "host";
private String ipaddress = "0.0.0.0";
private String statistics = "0% loss";
private String avgTime = "Minimum = 0ms";
private String testresult="testresult";
private String reason="Check your input";
private String testtype = "network";
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void networkCertificationTest() {
Request restReq = new Request();
Input input = new Input();
CertificationInputs vnfinfo = new CertificationInputs();
ValidationTestType vType = new ValidationTestType();
List<ValidationTestType> lVtype = new ArrayList<ValidationTestType>();
vType.setTypeId("1");
vType.setValidationType("Network Layer");
lVtype.add(vType);
ValidationTestType[] validationTestType = new ValidationTestType[lVtype.size()];
lVtype.toArray(validationTestType);
restReq.setValidationTestType(validationTestType);
VnfList vnfList = new VnfList();
vnfList.setHostName("hostname");
vnfList.setIpAddress("0.0.0.0");
vnfList.setPortNo("0");
List<VnfList> vnfListArray = new ArrayList<VnfList>();
vnfListArray.add(vnfList);
VnfList[] vnfInputArray = new VnfList[vnfListArray.size()];
vnfListArray.toArray(vnfInputArray);
restReq.setVnfList(vnfInputArray);
input.setHostname("hostname");
input.setIpaddress("10.20.30.50");
input.setNetwork("network");
vnfinfo.setInput(input);
Response res = new Response();
PreTestResponse preTestRes = new PreTestResponse();
preTestRes.setIpaddress("0.0.0.0");
List<PreTestResponse> preList = new ArrayList<PreTestResponse>();
preList.add(preTestRes);
res.setPreTestResponse(preList);
Mockito.when(layerTestServiceImpl.networkCertification(restReq)).thenReturn(res);
Response actualRes = layerTestServiceImpl.networkCertification(restReq);
assertEquals(actualRes.getPreTestResponse().get(0).getIpaddress(), vnfList.getIpAddress());
}
@Test
public void TestSaveResult() {
PreTestResponse preTestResponse = new PreTestResponse();
ODLClientResponse odlClientResponse=new ODLClientResponse();
Output output=new Output();
output.setAvgTime(avgTime);
output.setHostname(hostname);
output.setIpaddress(ipaddress);
output.setReason(reason);
output.setStatistics(statistics);
output.setStatus("reachable");
output.setTestresult(testresult);
odlClientResponse.setOutput(output);
preTestResponse.setAvgTime(avgTime);
preTestResponse.setIpaddress(ipaddress);
preTestResponse.setStatistics(statistics);
preTestResponse.setStatus("reachable");
preTestResponse.setTesttype(testtype);
Mockito.doNothing().when(layerTestServiceImpl).testSaveResults(preTestResponse, odlClientResponse);
layerTestServiceImpl.testSaveResults(preTestResponse, odlClientResponse);
assertTrue(true);
}
}
|