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;
23 import static org.junit.Assert.assertEquals;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.ArgumentCaptor;
29 import org.mockito.Captor;
30 import org.mockito.Mock;
31 import org.mockito.Mockito;
32 import org.mockito.MockitoAnnotations;
33 /*import com.onap.sdnc.testapi.model.ODLClientResponse;
34 import com.onap.sdnc.testapi.model.PreTestResponse;
35 import com.onap.sdnc.testapi.model.Request;
36 import com.onap.sdnc.testapi.model.Response;
37 import com.onap.sdnc.testapi.model.ValidationTestType;
38 import com.onap.sdnc.testapi.model.Vnf;
39 import com.onap.sdnc.testapi.model.VnfList;
40 import com.onap.sdnc.testapi.service.LayerTestServiceImpl;*/
42 import com.onap.sdnc.reports.model.ODLClientResponse;
43 import com.onap.sdnc.reports.model.PreTestResponse;
44 import com.onap.sdnc.reports.model.Request;
45 import com.onap.sdnc.reports.model.Response;
46 import com.onap.sdnc.reports.model.ValidationTestType;
47 import com.onap.sdnc.reports.model.Vnf;
48 import com.onap.sdnc.reports.model.VnfList;
50 public class NetworkCertificationTest {
53 LayerTestServiceImpl layerTestServiceImpl;
56 ArgumentCaptor<LayerTestServiceImpl> captor;
58 private String hostname = "host";
59 private String ipaddress = "0.0.0.0";
60 private String network = "Network Layer";
61 private String statistics = "0% loss";
62 private String avgTime = "Minimum = 0ms";
63 private String testtype = "network";
64 private String typeId = "1";
66 Response response = new Response();
67 PreTestResponse preTestResponse = new PreTestResponse();
68 ODLClientResponse odlClientResponse = new ODLClientResponse();
69 Request restReq = new Request();
72 public void setUp() throws Exception {
73 MockitoAnnotations.initMocks(this);
77 public void TestNetworkClient() {
79 preTestResponse.setAvgTime(avgTime);
80 preTestResponse.setIpaddress(ipaddress);
81 preTestResponse.setStatistics(statistics);
82 preTestResponse.setStatus("reachable");
83 preTestResponse.setTesttype(testtype);
85 List<PreTestResponse> listPreTestResponse = new ArrayList<PreTestResponse>();
86 listPreTestResponse.add(preTestResponse);
87 response.setPreTestResponse(listPreTestResponse);
89 ValidationTestType validationTestType = new ValidationTestType();
90 validationTestType.setTypeId(typeId);
91 validationTestType.setValidationType(network);
93 VnfList<List> vnflistt = new VnfList<List>();
94 vnflistt.setHostName(hostname);
95 vnflistt.setIpAddress(ipaddress);
96 vnflistt.setPortNo(null);
98 VnfList[] vnflist = restReq.getVnfList();
99 ValidationTestType[] validationTestTypee = restReq.getValidationTestType();
102 vnf.setValidationTestType(validationTestTypee);
103 vnf.setVnfList(vnflist);
104 Mockito.when(layerTestServiceImpl.networkCertification(restReq)).thenReturn(response);
105 Response res = layerTestServiceImpl.networkCertification(restReq);
107 assertEquals(res.getPreTestResponse(), response.getPreTestResponse());