2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapter_utils.tests;
23 import java.util.HashMap;
25 import org.junit.Ignore;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.onap.so.TestApplication;
29 import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
30 import org.onap.so.openstack.exceptions.MsoException;
31 import org.onap.so.openstack.exceptions.MsoIOException;
32 import org.onap.so.openstack.exceptions.MsoStackAlreadyExists;
33 import org.onap.so.openstack.exceptions.MsoTenantNotFound;
34 import org.onap.so.openstack.utils.MsoCommonUtils;
35 import org.onap.so.openstack.utils.MsoHeatUtils;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.boot.test.context.SpringBootTest;
38 import org.springframework.test.context.ActiveProfiles;
39 import org.springframework.test.context.junit4.SpringRunner;
41 import com.woorea.openstack.heat.model.CreateStackParam;
44 * This class implements test methods of the MsoHeatUtils
48 @RunWith(SpringRunner.class)
49 @SpringBootTest(classes = TestApplication.class)
50 @ActiveProfiles("test")
52 public class MsoHeatUtilsTest extends MsoCommonUtils {
54 private MsoHeatUtils msoHeatUtils;
57 public final void testCreateStackBadCloudConfig()
58 throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
60 msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String, Object>(),
62 } catch (MsoCloudSiteNotFound e) {
64 } catch (java.lang.NullPointerException npe) {
71 public final void testCreateStackFailedConnectionHeatClient()
72 throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
74 msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE,
76 } catch (MsoIOException e) {
83 public final void testCreateStackFailedConnection()
84 throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
86 msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE,
88 } catch (MsoIOException e) {
95 public final void createStackSuccessWithEnvironment() throws MsoException {
97 msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
99 } catch (MsoIOException e) {
106 public final void createStackSuccessWithFiles() throws MsoException {
108 msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
109 "environment", new HashMap<String, Object>());
110 } catch (MsoIOException e) {
117 public final void createStackSuccessWithHeatFiles() throws MsoException {
119 msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
120 "environment", new HashMap<String, Object>(), new HashMap<String, Object>());
121 } catch (MsoIOException e) {
127 public final void requestToStringBuilderTest() {
128 CreateStackParam param = new CreateStackParam();
129 param.setDisableRollback(false);
130 param.setEnvironment("environment");
131 param.setFiles(new HashMap<String, Object>());
132 param.setParameters(new HashMap<>());
133 param.setStackName("stackName");
134 param.setTemplate("template");
135 param.setTemplateUrl("http://templateUrl");
136 param.setTimeoutMinutes(1);
138 msoHeatUtils.requestToStringBuilder(param);