2 * Copyright 2018 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
20 import org.apache.http.HttpEntity;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.onap.vnfsdk.marketplace.common.FileUtil;
24 import org.onap.vnfsdk.marketplace.msb.MsbDetails;
25 import org.onap.vnfsdk.marketplace.msb.MsbDetailsHolder;
26 import org.onap.vnfsdk.marketplace.msb.MsbServer;
27 import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest;
28 import org.onap.vnfsdk.marketplace.rest.RestResponse;
29 import org.onap.vnfsdk.marketplace.rest.RestfulClient;
31 import static org.mockito.Mockito.mock;
32 import static org.junit.Assert.assertNotNull;
34 public class LifecycleTestExceutorTest {
35 private LifecycleTestExceutor lifecycleTestExceutor;
36 private OnBoradingRequest onBoradingRequest;
37 LifeCycleTestReq lifeCycleTestReq;
41 // lifecycleTestExceutor = new LifecycleTestExceutor();
42 lifeCycleTestReq = mock(LifeCycleTestReq.class);
46 public void testupLoadPackageToCatalougeForGson()
48 new MockUp<FileUtil>(){
50 public boolean validatePath(String path) {
54 new MockUp<LifecycleTestExceutor>(){
56 private boolean checkValidResponse(RestResponse rsp) {
60 new MockUp<RestResponse>(){
62 public String getResult() {
63 return "{\"csarId\":\"huawei\"}";
66 new MockUp<MsbDetails>(){
68 public MsbServer getDefaultServer() {
69 MsbServer msbServer = new MsbServer();
70 msbServer.setHost("0.0.0.0");
71 msbServer.setPort("5005");
75 new MockUp<RestfulClient>(){
77 public RestResponse post(String ip, int port, String url, HttpEntity requestBody) {
78 RestResponse rsp = new RestResponse();
79 rsp.setStatusCode(200);
84 new MockUp<MsbServer>(){
86 public String getHost() {
90 public String getPort() {
94 new MockUp<MsbDetailsHolder>(){
96 public synchronized MsbDetails getMsbDetails(){
97 MsbDetails msbDetails = new MsbDetails();
101 onBoradingRequest = new OnBoradingRequest();
102 onBoradingRequest.setCsarId("huawei");
103 onBoradingRequest.setPackagePath("");
104 onBoradingRequest.setPackageName("huawei");
105 onBoradingRequest.setCsarIdCatalouge("catalog");
106 assertNotNull(LifecycleTestExceutor.uploadPackageToCatalouge(onBoradingRequest));
108 public void testExeclifecycleTest()
110 LifecycleTestExceutor.execlifecycleTest(onBoradingRequest,lifeCycleTestReq);