b118c569df7472d43e878361ce717ea49983e181
[so.git] / adapters / mso-adapter-utils / src / test / java / org / openecomp / mso / adapter_utils / tests / MsoHeatUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.adapter_utils.tests;
22
23 import java.util.HashMap;
24
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27
28 import org.openecomp.mso.cloud.CloudConfigFactory;
29 import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
30 import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
31 import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
32 import org.openecomp.mso.openstack.exceptions.MsoException;
33 import org.openecomp.mso.openstack.exceptions.MsoIOException;
34 import org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists;
35 import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound;
36 import org.openecomp.mso.openstack.utils.MsoCommonUtils;
37 import org.openecomp.mso.openstack.utils.MsoHeatUtils;
38 import org.openecomp.mso.properties.MsoPropertiesFactory;
39
40
41
42 /**
43  * This class implements test methods of the MsoHeatUtils
44  *
45  *
46  */
47 public class MsoHeatUtilsTest extends MsoCommonUtils {
48         public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
49         public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
50         public static MsoHeatUtils msoHeatUtils;
51
52         @BeforeClass
53         public static final void loadClasses() throws MsoCloudIdentityNotFound {
54                 ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
55                 String config = classLoader.getResource("cloud_config.json").toString().substring(5);
56                 cloudConfigFactory.initializeCloudConfig(config, 1);
57                 msoHeatUtils = new MsoHeatUtils("NO_PROP",msoPropertiesFactory,cloudConfigFactory);
58         }
59
60         @Test
61         public final void testCreateStackBadCloudConfig () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
62                 try {
63                         msoHeatUtils.createStack ("DOESNOTEXIST", "test", "stackName", "test",  new HashMap<String,Object> (), Boolean.TRUE, 10);
64                 } catch (MsoCloudSiteNotFound e) {
65
66                 } catch (java.lang.NullPointerException npe) {
67                         
68                 }
69
70         }
71
72         @Test
73     public final void testCreateStackFailedConnectionHeatClient () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
74                 try {
75                         msoHeatUtils.createStack ("MT", "test", "stackName", "test",  new HashMap<String,Object> (), Boolean.TRUE, 10);
76                 } catch (MsoIOException e) {
77
78                 }
79
80         }
81
82         @Test
83     public final void testCreateStackFailedConnection () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
84                 try {
85                         msoHeatUtils.createStack ("MT", "test", "stackName", "test",  new HashMap<String,Object> (), Boolean.TRUE, 10);
86                 } catch (MsoIOException e) {
87
88                 }
89
90         }
91
92
93
94 }