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
9 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
18 package org.onap.dcae.runtime.core.helm;
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;
32 import java.nio.file.Files;
34 import static org.mockito.ArgumentMatchers.any;
36 @RunWith(MockitoJUnitRunner.class)
37 public class HelmChartGeneratorClientImplTest {
40 private ChartBuilder chartBuilder;
43 private ChartDistributor distributor;
45 private HelmChartGeneratorClientImpl client;
47 private File mockChartFile;
50 public void setUp() throws Exception {
51 client = new HelmChartGeneratorClientImpl(chartBuilder, distributor);
52 mockChartFile = Files.createTempFile("chart", ".tgz").toFile();
56 public void testGenerateHelmChart() throws Exception{
57 client.generateHelmChart("someSpec");
58 Mockito.verify(chartBuilder, Mockito.times(1)).build(any(), any(), any(), any());
62 public void testDistribute() throws Exception{
63 client.distribute(mockChartFile);
64 Mockito.verify(distributor, Mockito.times(1)).distribute(mockChartFile);