0732b3f7b4de304f1d85eef35091089b82779e71
[vnfsdk/refrepo.git] /
1 /**
2  * Copyright 2018 Huawei Technologies Co., Ltd.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
17
18 import mockit.Mock;
19 import mockit.MockUp;
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;
30
31 import static org.mockito.Mockito.mock;
32
33 public class LifecycleTestExceutorTest {
34    private LifecycleTestExceutor lifecycleTestExceutor;
35     private OnBoradingRequest onBoradingRequest;
36     LifeCycleTestReq lifeCycleTestReq;
37     @Before
38     public void setUp()
39     {
40        // lifecycleTestExceutor = new LifecycleTestExceutor();
41         lifeCycleTestReq = mock(LifeCycleTestReq.class);
42     }
43
44     @Test
45     public void testupLoadPackageToCatalougeForGson()
46     {
47         new MockUp<FileUtil>(){
48             @Mock
49             public boolean validatePath(String path) {
50                 return true;
51             }
52         };
53         new MockUp<LifecycleTestExceutor>(){
54             @Mock
55             private boolean checkValidResponse(RestResponse rsp) {
56                 return true;
57             }
58         };
59         new MockUp<RestResponse>(){
60             @Mock
61             public String getResult() {
62                 return "{\"csarId\":\"huawei\"}";
63             }
64         };
65         new MockUp<MsbDetails>(){
66             @Mock
67             public MsbServer getDefaultServer() {
68                 MsbServer msbServer = new MsbServer();
69                 msbServer.setHost("0.0.0.0");
70                 msbServer.setPort("5005");
71                 return msbServer;
72             }
73         };
74         new MockUp<RestfulClient>(){
75             @Mock
76             public RestResponse post(String ip, int port, String url, HttpEntity requestBody) {
77                 RestResponse rsp = new RestResponse();
78                 rsp.setStatusCode(200);
79                 rsp.setResult("OK");
80                 return rsp;
81             }
82         };
83         new MockUp<MsbServer>(){
84             @Mock
85             public String getHost() {
86                 return "0.0.0.0";
87             }
88             @Mock
89             public String getPort() {
90                 return "5005";
91             }
92         };
93         new MockUp<MsbDetailsHolder>(){
94             @Mock
95             public synchronized MsbDetails getMsbDetails(){
96                 MsbDetails msbDetails = new MsbDetails();
97                 return msbDetails;
98             }
99         };
100         onBoradingRequest = new OnBoradingRequest();
101         onBoradingRequest.setCsarId("huawei");
102         onBoradingRequest.setPackagePath("");
103         onBoradingRequest.setPackageName("huawei");
104         onBoradingRequest.setCsarIdCatalouge("catalog");
105         LifecycleTestExceutor.uploadPackageToCatalouge(onBoradingRequest);
106     }
107     public void testExeclifecycleTest()
108     {
109         LifecycleTestExceutor.execlifecycleTest(onBoradingRequest,lifeCycleTestReq);
110
111     }
112
113
114 }