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.openecomp.sdc.be.components;
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;
41 import javax.servlet.ServletContext;
43 import static org.mockito.Mockito.when;
45 * tests GroupBusinessLogic class
49 public class GroupBusinessLogicTest {
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";
57 static GroupBusinessLogic bl = new GroupBusinessLogic();
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);
70 bl.setComponentsUtils(componentsUtils);
73 public static void setupBeforeClass() {
74 when(graphLockOperation.lockComponent(componentId, ComponentTypeEnum.RESOURCE.getNodeType())).thenReturn(StorageOperationStatus.OK);