1 package com.onap.sdnc.reports.service;
3 import static org.junit.Assert.*;
5 import java.util.ArrayList;
8 import org.junit.Before;
10 import org.mockito.Mock;
11 import org.mockito.Mockito;
12 import org.mockito.MockitoAnnotations;
13 import com.onap.sdnc.reports.model.CertificationInputs;
14 import com.onap.sdnc.reports.model.Input;
15 import com.onap.sdnc.reports.model.PreTestResponse;
16 import com.onap.sdnc.reports.model.Request;
17 import com.onap.sdnc.reports.model.Response;
18 import com.onap.sdnc.reports.model.ValidationTestType;
19 import com.onap.sdnc.reports.model.VnfList;
21 public class LayerTestServiceImplTest {
24 CertificationClientService cService;
27 LayerTestServiceImpl layerTestServiceImpl;
30 public void setUp() throws Exception {
31 MockitoAnnotations.initMocks(this);
35 public void networkCertificationTest() {
37 Request restReq = new Request();
38 Input input = new Input();
39 CertificationInputs vnfinfo = new CertificationInputs();
40 ValidationTestType vType = new ValidationTestType();
42 List<ValidationTestType> lVtype = new ArrayList<ValidationTestType>();
44 vType.setValidationType("Network Layer");
47 ValidationTestType[] validationTestType = new ValidationTestType[lVtype.size()];
48 lVtype.toArray(validationTestType);
49 restReq.setValidationTestType(validationTestType);
51 VnfList vnfList = new VnfList();
52 vnfList.setHostName("hostname");
53 vnfList.setIpAddress("0.0.0.0");
54 vnfList.setPortNo("0");
56 List<VnfList> vnfListArray = new ArrayList<VnfList>();
57 vnfListArray.add(vnfList);
59 VnfList[] vnfInputArray = new VnfList[vnfListArray.size()];
60 vnfListArray.toArray(vnfInputArray);
61 restReq.setVnfList(vnfInputArray);
62 input.setHostname("hostname");
63 input.setIpaddress("10.20.30.50");
64 input.setNetwork("network");
65 vnfinfo.setInput(input);
67 Response res = new Response();
69 PreTestResponse preTestRes = new PreTestResponse();
70 preTestRes.setIpaddress("0.0.0.0");
72 List<PreTestResponse> preList = new ArrayList<PreTestResponse>();
73 preList.add(preTestRes);
75 res.setPreTestResponse(preList);
77 Mockito.when(layerTestServiceImpl.networkCertification(restReq)).thenReturn(res);
79 Response actualRes = layerTestServiceImpl.networkCertification(restReq);
81 assertEquals(actualRes.getPreTestResponse().get(0).getIpaddress(), vnfList.getIpAddress());