Merge "Reorder modifiers"
[so.git] / adapters / mso-tenant-adapter / src / test / java / org / openecomp / mso / adapters / tenant / MsoTenantAdapterImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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 package org.openecomp.mso.adapters.tenant;
21
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.mockito.Mock;
25 import org.mockito.Mockito;
26 import org.openecomp.mso.adapters.tenantrest.TenantRollback;
27 import org.openecomp.mso.cloud.CloudConfig;
28 import org.openecomp.mso.cloud.CloudConfigFactory;
29 import org.openecomp.mso.entity.MsoRequest;
30
31 import javax.validation.constraints.Null;
32 import javax.xml.ws.Holder;
33 import java.util.HashMap;
34
35 public class MsoTenantAdapterImplTest {
36         
37     @Mock
38     private static MsoTenantAdapterImpl msoTenantAdapter;
39
40     @Mock
41         private static CloudConfigFactory cloudConfigFactory;
42     
43     // TODO: following test case is done for coverage
44     // later it should be modified for proper test.
45     
46     @BeforeClass
47     public static final void prepare () {
48         msoTenantAdapter = Mockito.spy (new MsoTenantAdapterImpl());
49         cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
50         CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
51         Mockito.when(cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
52         msoTenantAdapter.getTenantUtilsFactory().setCloudConfigFactory(cloudConfigFactory);
53     }
54
55     @Test
56     public void healthCheck() throws Exception {
57         msoTenantAdapter.healthCheck();
58     }
59
60     @Test(expected = NullPointerException.class)
61     public void createTenant() throws Exception {
62         msoTenantAdapter.createTenant("site", "tenant", new HashMap<>(),
63                 true, true, new MsoRequest(), new Holder(), new Holder());
64     }
65
66     @Test(expected = NullPointerException.class)
67     public void queryTenant() throws Exception {
68         msoTenantAdapter.queryTenant("site", "tenant", new MsoRequest(),
69                 new Holder<>(), new Holder<>(), new Holder<>());
70     }
71
72     @Test(expected = NullPointerException.class)
73     public void deleteTenant() throws Exception {
74         msoTenantAdapter.deleteTenant("cloud", "tenant", new MsoRequest(), new Holder());
75     }
76
77     @Test
78     public void rollbackTenant() throws Exception {
79         msoTenantAdapter.rollbackTenant(new TenantRollback());
80     }
81
82 }