integrate helm-chart-generator to runtime api
[dcaegen2/platform.git] / mod / runtimeapi / runtime-core / src / test / java / org / onap / dcae / runtime / core / helm / HelmChartGeneratorClientImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18 package org.onap.dcae.runtime.core.helm;
19
20 import org.apache.commons.io.FileUtils;
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.mockito.junit.MockitoJUnitRunner;
28 import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.ChartBuilder;
29 import org.onap.dcaegen2.platform.helmchartgenerator.distribution.ChartDistributor;
30
31 import java.io.File;
32 import java.nio.file.Files;
33
34 import static org.mockito.ArgumentMatchers.any;
35
36 @RunWith(MockitoJUnitRunner.class)
37 public class HelmChartGeneratorClientImplTest {
38
39     @Mock
40     private ChartBuilder chartBuilder;
41
42     @Mock
43     private ChartDistributor distributor;
44
45     private HelmChartGeneratorClientImpl client;
46
47     private File mockChartFile;
48
49     @Before
50     public void setUp() throws Exception {
51         client = new HelmChartGeneratorClientImpl(chartBuilder, distributor);
52         mockChartFile = Files.createTempFile("chart", ".tgz").toFile();
53     }
54
55     @Test
56     public void testGenerateHelmChart() throws Exception{
57         client.generateHelmChart("someSpec");
58         Mockito.verify(chartBuilder, Mockito.times(1)).build(any(), any(), any(), any());
59     }
60
61     @Test
62     public void testDistribute() throws Exception{
63         client.distribute(mockChartFile);
64         Mockito.verify(distributor, Mockito.times(1)).distribute(mockChartFile);
65     }
66
67 }