2 * ============LICENSE_START=======================================================
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
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=========================================================
20 package org.openecomp.mso.adapters.tenant;
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;
31 import javax.validation.constraints.Null;
32 import javax.xml.ws.Holder;
33 import java.util.HashMap;
35 public class MsoTenantAdapterImplTest {
38 private static MsoTenantAdapterImpl msoTenantAdapter;
41 private static CloudConfigFactory cloudConfigFactory;
43 // TODO: following test case is done for coverage
44 // later it should be modified for proper test.
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);
56 public void healthCheck() throws Exception {
57 msoTenantAdapter.healthCheck();
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());
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<>());
72 @Test(expected = NullPointerException.class)
73 public void deleteTenant() throws Exception {
74 msoTenantAdapter.deleteTenant("cloud", "tenant", new MsoRequest(), new Holder());
78 public void rollbackTenant() throws Exception {
79 msoTenantAdapter.rollbackTenant(new TenantRollback());