2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package com.onap.sdnc.reports.service;
24 import static org.junit.Assert.assertEquals;
25 import java.util.ArrayList;
26 import java.util.List;
27 import org.junit.Test;
28 import org.mockito.Mock;
29 import com.onap.sdnc.reports.model.CertificationInputs;
30 import com.onap.sdnc.reports.model.Input;
31 import com.onap.sdnc.reports.model.Output;
32 import com.onap.sdnc.reports.model.PreTestResponse;
34 public class CertificationClientServiceTest {
37 CertificationClientService cService;
39 private String hostname = "host";
40 private String ipaddress = "10.53.122.25";
41 private String statistics = "0% loss";
42 private String avgTime = "Minimum = 0ms";
43 private String testType = "network";
45 @Test(expected = NullPointerException.class)
46 public void TestRestClient() {
48 PreTestResponse pretestResponse = new PreTestResponse();
49 pretestResponse.setIpaddress(ipaddress);
50 pretestResponse.setAvgTime(avgTime);
51 pretestResponse.setHostname(hostname);
52 pretestResponse.setStatus("successs");
53 pretestResponse.setStatistics(statistics);
54 pretestResponse.setTesttype(testType);
56 List<PreTestResponse> preTestNew = new ArrayList<PreTestResponse>();
57 preTestNew.add(pretestResponse);
59 Input input = new Input();
60 input.setIpaddress(ipaddress);
61 input.setHostname(hostname);
62 input.setNetwork(testType);
64 CertificationInputs certificationInputs = new CertificationInputs();
65 certificationInputs.setInput(input);
66 CertificationClientService certificationClientservice = new CertificationClientService();
67 certificationClientservice.restClient(certificationInputs, preTestNew, testType);
72 public void pingServiceTest() {
73 CertificationInputs vnfinfo = new CertificationInputs();
74 Input input = new Input();
75 input.setIpaddress("10.53.122.25");
76 input.setHostname("hostname");
77 vnfinfo.setInput(input);
78 Output mockOutput = new Output();
79 mockOutput.setIpaddress("10.53.122.25");
80 Output output = CertificationClientService.pingTest(vnfinfo);
81 assertEquals(output.getIpaddress(), input.getIpaddress());
85 public void protocolTest() {
86 CertificationInputs vnfinfo = new CertificationInputs();
87 Input input = new Input();
88 input.setIpaddress(ipaddress);
89 input.setHostname("hostname");
90 vnfinfo.setInput(input);
91 Output mockOutput = new Output();
92 mockOutput.setIpaddress(ipaddress);