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.components.impl.ServiceBusinessLogicTest;
31 import org.openecomp.sdc.be.config.ConfigurationManager;
32 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
33 import org.openecomp.sdc.be.impl.ComponentsUtils;
34 import org.openecomp.sdc.be.model.User;
35 import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
36 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
37 import org.openecomp.sdc.common.api.ConfigurationSource;
38 import org.openecomp.sdc.common.api.Constants;
39 import org.openecomp.sdc.common.impl.ExternalConfiguration;
40 import org.openecomp.sdc.common.impl.FSConfigurationSource;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
44 import javax.servlet.ServletContext;
46 import static org.mockito.Mockito.when;
48 * tests GroupBusinessLogic class
52 public class GroupBusinessLogicTest {
54 ComponentsUtils componentsUtils;
55 final ServletContext servletContext = Mockito.mock(ServletContext.class);
56 private static IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
57 private static User user = Mockito.mock(User.class);
58 private static String componentId = "vfUniqueId-xxxx";
60 static GroupBusinessLogic bl = new GroupBusinessLogic();
64 public void setupBeforeMethod() {
65 MockitoAnnotations.initMocks(this);
66 ExternalConfiguration.setAppName("catalog-be");
67 String appConfigDir = "src/test/resources/config/catalog-be";
68 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
69 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
70 componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
71 when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
73 bl.setComponentsUtils(componentsUtils);
76 public static void setupBeforeClass() {
77 when(graphLockOperation.lockComponent(componentId, ComponentTypeEnum.RESOURCE.getNodeType())).thenReturn(StorageOperationStatus.OK);