Catalog-be dead code removal
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / GroupBusinessLogicTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.be.components;
22
23 import org.junit.Before;
24 import org.junit.BeforeClass;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mockito;
27 import org.mockito.MockitoAnnotations;
28 import org.openecomp.sdc.be.auditing.impl.AuditingManager;
29 import org.openecomp.sdc.be.components.impl.GroupBusinessLogic;
30 import org.openecomp.sdc.be.config.ConfigurationManager;
31 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
32 import org.openecomp.sdc.be.impl.ComponentsUtils;
33 import org.openecomp.sdc.be.model.User;
34 import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
35 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
36 import org.openecomp.sdc.common.api.ConfigurationSource;
37 import org.openecomp.sdc.common.api.Constants;
38 import org.openecomp.sdc.common.impl.ExternalConfiguration;
39 import org.openecomp.sdc.common.impl.FSConfigurationSource;
40
41 import javax.servlet.ServletContext;
42
43 import static org.mockito.Mockito.when;
44 /**
45  * tests GroupBusinessLogic class
46  * @author ns019t
47  *
48  */
49 public class GroupBusinessLogicTest {
50
51     ComponentsUtils componentsUtils;
52     final ServletContext servletContext = Mockito.mock(ServletContext.class);
53     private static IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
54     private static User user = Mockito.mock(User.class);
55     private static String componentId = "vfUniqueId-xxxx";
56     @InjectMocks
57     static GroupBusinessLogic bl = new GroupBusinessLogic();
58
59
60     @Before
61     public void setupBeforeMethod() {
62         MockitoAnnotations.initMocks(this);
63         ExternalConfiguration.setAppName("catalog-be");
64         String appConfigDir = "src/test/resources/config/catalog-be";
65         ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
66         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
67         componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
68         when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
69
70         bl.setComponentsUtils(componentsUtils);
71     }
72     @BeforeClass
73     public static void setupBeforeClass() {
74         when(graphLockOperation.lockComponent(componentId, ComponentTypeEnum.RESOURCE.getNodeType())).thenReturn(StorageOperationStatus.OK);
75     }
76 }