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=========================================================
21 package com.onap.sdnc.reports.service;
23 import java.util.ArrayList;
24 import java.util.List;
25 import org.apache.log4j.Logger;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
28 import org.springframework.boot.autoconfigure.domain.EntityScan;
29 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
30 import org.springframework.stereotype.Service;
31 import com.onap.sdnc.reports.model.CertificationInputs;
32 import com.onap.sdnc.reports.model.Input;
33 import com.onap.sdnc.reports.model.PreTestResponse;
34 import com.onap.sdnc.reports.model.Request;
35 import com.onap.sdnc.reports.model.Response;
36 import com.onap.sdnc.reports.model.ValidationTestType;
37 import com.onap.sdnc.reports.model.VnfList;
38 import com.onap.sdnc.reports.repository.DeviceRepository;
39 import com.onap.sdnc.reports.repository.PreTestConfigRepository;
42 @EnableJpaRepositories("com.onap.sdnc.reports.repository")
43 @EntityScan("com.onap.sdnc.*")
44 @EnableAutoConfiguration
46 public class LayerTestServiceImpl implements LayerTestService {
48 private static final Logger logger = Logger.getLogger(CertificationClientService.class);
51 CertificationClientService certificationClientservice;
54 DeviceRepository deviceRepository;
57 PreTestConfigRepository preTestRepo;
60 public Response networkCertification(Request restReq) {
62 String testType = "network";
64 VnfList[] vnf = restReq.getVnfList();
66 ValidationTestType[] validationType = restReq.getValidationTestType();
68 CertificationInputs vnfRequestParams = new CertificationInputs();
70 Response resOutput = new Response();
72 Input input = new Input();
74 List<PreTestResponse> preTestNew = new ArrayList<PreTestResponse>();
75 for (ValidationTestType validationTestType : validationType) {
76 if (validationTestType.getValidationType().equalsIgnoreCase("Network Layer")) {
79 if (validationTestType.getValidationType().equalsIgnoreCase("Protocol Layer")) {
80 testType = "protocol";
82 for (VnfList vnfList : vnf) {
83 input.setIpaddress(vnfList.getIpAddress());
84 input.setHostname(vnfList.getHostName());
85 vnfRequestParams.setInput(input);
86 certificationClientservice.restClient(vnfRequestParams, preTestNew, testType);
89 resOutput.setPreTestResponse(preTestNew);