3 * Copyright © 2017-2018 European Support Limited
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.
20 package org.openecomp.sdc.heat.services.tree;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
27 import java.util.List;
28 import org.junit.Assert;
29 import org.junit.Test;
30 import org.openecomp.core.utilities.file.FileUtils;
31 import org.openecomp.sdc.common.utils.SdcCommon;
32 import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
34 public class HeatTreeManagerTest {
37 public void testCreateTree() throws IOException {
38 HeatTreeManager heatTreeManager = new HeatTreeManager();
39 addFile(heatTreeManager, "mock/model/MANIFEST.json", SdcCommon.MANIFEST_NAME);
40 addFile(heatTreeManager, "mock/model/first.yaml", "first.yaml");
41 addFile(heatTreeManager, "mock/model/second.yaml", "second.yaml");
42 addFile(heatTreeManager, "mock/model/first.env", "first.env");
43 addFile(heatTreeManager, "mock/model/base_cscf_volume.yaml", "base_cscf_volume.yaml");
44 addFile(heatTreeManager, "mock/model/network.yml", "network.yml");
45 addFile(heatTreeManager, "mock/model/testHeat.yml", "testHeat.yml");
46 addFile(heatTreeManager, "mock/model/nested.yml", "nested.yml");
47 addFile(heatTreeManager, "mock/model/base_cscf_volume.env", "base_cscf_volume.env");
49 heatTreeManager.createTree();
51 HeatStructureTree heatStructureTree = heatTreeManager.getTree();
52 Assert.assertNotNull(heatStructureTree);
53 Assert.assertEquals(1, heatStructureTree.getHeat().size());
54 Assert.assertEquals(1, heatStructureTree.getNetwork().size());
57 private void addFile(HeatTreeManager heatTreeManager, String fileLocation, String fileName)
60 List<URL> urlList = FileUtils.getAllLocations(fileLocation);
61 try (InputStream inputStream = new FileInputStream(new File(urlList.get(0).getPath()))) {
62 heatTreeManager.addFile(fileName, inputStream);