1 /** # ============LICENSE_START=======================================================
2 * # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
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
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.
15 * # ============LICENSE_END=========================================================
18 package org.onap.dcaegen2.platform.helmchartgenerator;
20 import org.apache.commons.io.FileUtils;
21 import org.junit.jupiter.api.AfterEach;
22 import org.junit.jupiter.api.Assertions;
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.Test;
25 import org.junit.jupiter.api.extension.ExtendWith;
26 import org.mockito.Mock;
27 import org.mockito.junit.jupiter.MockitoExtension;
28 import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.AddOnsManager;
29 import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.Auxilary;
30 import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.ComponentSpec;
31 import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.TlsInfo;
34 import java.nio.file.Files;
35 import java.nio.file.Path;
37 import static org.mockito.Mockito.when;
39 @ExtendWith(MockitoExtension.class)
40 class AddOnsManagerTest {
42 private AddOnsManager manager;
49 manager = new AddOnsManager(utils);
53 void testIncludeCertificationYamlAddOn() throws Exception {
54 final String specFileLocation = "src/test/input/specs/ves.json";
55 when(utils.deserializeJsonFileToModel(specFileLocation, ComponentSpec.class)).thenReturn(getMockCs());
56 manager.includeAddons(specFileLocation,
57 new File("src/test/dcae-ves-collector"),
58 "src/test/input/blueprint");
59 Assertions.assertTrue(Files.exists(Path.of("src/test/dcae-ves-collector/templates/certificates.yaml")));
62 private ComponentSpec getMockCs() {
63 ComponentSpec cs = new ComponentSpec();
64 Auxilary auxilary = new Auxilary();
65 TlsInfo tlsInfo = new TlsInfo();
66 tlsInfo.setUseExternalTls(true);
67 tlsInfo.setUseTls(true);
68 auxilary.setTlsInfo(tlsInfo);
69 cs.setAuxilary(auxilary);
74 void tearDown() throws Exception{
75 FileUtils.deleteDirectory(new File("src/test/dcae-ves-collector"));