Add cmpv2Certificate flag, removed hyphens from config under postgres and enhanced...
[dcaegen2/platform.git] / mod2 / helm-generator / helmchartgenerator-core / src / test / java / org / onap / dcaegen2 / platform / helmchartgenerator / AddOnsManagerTest.java
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
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  * # ============LICENSE_END=========================================================
16  */
17
18 package org.onap.dcaegen2.platform.helmchartgenerator;
19
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;
32
33 import java.io.File;
34 import java.nio.file.Files;
35 import java.nio.file.Path;
36
37 import static org.mockito.Mockito.when;
38
39 @ExtendWith(MockitoExtension.class)
40 class AddOnsManagerTest {
41
42     private AddOnsManager manager;
43
44     @Mock
45     private Utils utils;
46
47     @BeforeEach
48     void setUp() {
49         manager = new AddOnsManager(utils);
50     }
51
52     @Test
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")));
60     }
61
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);
70         return cs;
71     }
72
73     @AfterEach
74     void tearDown() throws Exception{
75         FileUtils.deleteDirectory(new File("src/test/dcae-ves-collector"));
76     }
77 }