summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorTomasz Golabek <tomasz.golabek@nokia.com>2019-06-28 12:17:09 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-24 08:50:23 +0000
commit79827ecb068e1e33ce28701f5dc59b37ee309b51 (patch)
treed6115d41cd37d2e82fa5b9f7bc43457bee69de9c /catalog-be/src/test
parent8b6d4ee2ffbfb11a1f9d494b2de403aab112cf93 (diff)
Autowired annotation for catalog-be
Injection of the properties moved to the constructors/setters replacing field annotations. Change-Id: I766ff67e466bec5a91db1035f29e7f919d32e0ea Issue-ID: SDC-2400 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java70
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogicTest.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java67
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java80
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogicMock.java40
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogicTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java15
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogicTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogicTest.java15
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogicTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogicTest.java21
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java72
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java51
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java34
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java18
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java27
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java17
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java9
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogicTest.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBusinessLogicMock.java30
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java31
-rw-r--r--catalog-be/src/test/resources/paths/path-context.xml21
44 files changed, 685 insertions, 306 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
index e569499f82..97bde02794 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
@@ -2,22 +2,23 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components;
import com.google.common.collect.Sets;
@@ -26,14 +27,21 @@ import org.junit.Before;
import org.mockito.Mockito;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.distribution.engine.IDistributionEngine;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
+import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
+import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
+import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -43,10 +51,15 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ForwardingPathOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
@@ -67,23 +80,30 @@ import java.util.Map;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-public abstract class BaseServiceBusinessLogicTest {
+public abstract class BaseServiceBusinessLogicTest extends ComponentBusinessLogicMock {
private static final String SERVICE_CATEGORY = "Mobility";
- final ServletContext servletContext = Mockito.mock(ServletContext.class);
- UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
- WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
- WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
- ServiceBusinessLogic bl = new ServiceBusinessLogic();
- ResponseFormatManager responseManager = null;
- IElementOperation mockElementDao;
- ComponentsUtils componentsUtils;
- AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
- ArtifactsBusinessLogic artifactBl = Mockito.mock(ArtifactsBusinessLogic.class);
- GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
- JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
- ForwardingPathOperation forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
+ private final ServletContext servletContext = Mockito.mock(ServletContext.class);
+ private UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
+ private WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+ private WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
+ private final IDistributionEngine distributionEngine = Mockito.mock(IDistributionEngine.class);
+ private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
+ private final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
+ private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ private final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
+ private final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
+ private ServiceBusinessLogic bl;
+ private ResponseFormatManager responseManager = null;
+ private IElementOperation mockElementDao;
+ private ComponentsUtils componentsUtils;
+ private AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
+ private ArtifactsBusinessLogic artifactBl = Mockito.mock(ArtifactsBusinessLogic.class);
+ private GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
+ private JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
+ private ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
+ private ForwardingPathOperation forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
User user = null;
Service serviceResponse = null;
@@ -150,12 +170,14 @@ public abstract class BaseServiceBusinessLogicTest {
when(forwardingPathOperation.deleteForwardingPath(any(),any())).thenReturn(Either.left(Sets.newHashSet("Wow-It-Works")));
when(toscaOperationFacade.getToscaElement("delete_forward_test")).thenReturn(Either.left(createServiceObject(true)));
- bl = new ServiceBusinessLogic();
- bl.setElementDao(mockElementDao);
+ bl = new ServiceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
+ artifactsBusinessLogic, distributionEngine, componentInstanceBusinessLogic,
+ serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter,
+ serviceFilterOperation, serviceFilterValidator, artifactToscaOperation);
bl.setUserAdmin(mockUserAdmin);
- bl.setArtifactBl(artifactBl);
bl.setGraphLockOperation(graphLockOperation);
- bl.setJanusGraphGenericDao(mockJanusGraphDao);
+ bl.setJanusGraphDao(mockJanusGraphDao);
bl.setToscaOperationFacade(toscaOperationFacade);
bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
bl.setComponentsUtils(componentsUtils);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java
index 7d127dfcbc..5f72b0a65b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components;
@@ -31,6 +33,7 @@ import org.openecomp.sdc.be.DummyConfigurationManager;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -50,14 +53,15 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public class ComponentBusinessLogicTest {
+public class ComponentBusinessLogicTest extends ComponentBusinessLogicMock {
private static final User USER = new User();
private static final String ARTIFACT_LABEL = "toscaArtifact1";
private static final String ARTIFACT_LABEL2 = "toscaArtifact2";
- @InjectMocks
- private ComponentBusinessLogic testInstance = new ComponentBusinessLogic() {
+ private ComponentBusinessLogic testInstance = new ComponentBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic,
+ artifactToscaOperation) {
@Override
public Either<List<String>, ResponseFormat> deleteMarkedComponents() {
return null;
@@ -79,9 +83,6 @@ public class ComponentBusinessLogicTest {
}
};
- @Mock
- private ArtifactsBusinessLogic artifactsBusinessLogic;
-
@BeforeClass
public static void setUp() throws Exception {
new DummyConfigurationManager();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
index 000de2cd4b..8d73b9e855 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
@@ -16,12 +16,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components;
import org.junit.Test;
+import org.mockito.Mockito;
import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
+import org.openecomp.sdc.be.switchover.detector.SwitchoverDetector;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.HealthCheckInfo;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
@@ -33,7 +37,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class HealthCheckBusinessLogicTest {
- HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
+ private final SwitchoverDetector switchoverDetector = Mockito.mock(SwitchoverDetector.class);
+
+ HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic(switchoverDetector);
@Test
public void checkStausUpdated() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java
index 971f7b8f20..95e6cceb78 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components;
@@ -27,6 +29,8 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.impl.BaseBusinessLogic;
+import org.openecomp.sdc.be.components.impl.BaseBusinessLogicMock;
import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -59,7 +63,7 @@ import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
-public class PropertyBusinessLogicTest {
+public class PropertyBusinessLogicTest extends BaseBusinessLogicMock {
private static final Logger log = LoggerFactory.getLogger(PropertyBusinessLogicTest.class);
@Mock
@@ -84,14 +88,14 @@ public class PropertyBusinessLogicTest {
JanusGraphDao janusGraphDao;
@InjectMocks
- private PropertyBusinessLogic bl = new PropertyBusinessLogic();
+ private PropertyBusinessLogic bl = new PropertyBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
private User user = null;
private String resourceId = "resourceforproperty.0.1";
private String serviceId = "serviceForProperty.0.1";
private static final String interfaceType = "interfaceType";
private static final String operationType = "operationType";
private static final String operationId = "operationId";
- private static final String operationId2 = "operationId2";
@Before
public void setup() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index 00e3f03074..02b2e74f7f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components;
@@ -34,8 +36,10 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.user.UserBusinessLogic;
@@ -67,9 +71,12 @@ public class ResourceImportManagerTest {
static UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
static ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ protected static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+ private static final CapabilityTypeOperation capabilityTypeOperation = Mockito.mock(CapabilityTypeOperation.class);
+
@BeforeClass
- public static void beforeClass() throws IOException {
- importManager = new ResourceImportManager();
+ public static void beforeClass() {
+ importManager = new ResourceImportManager(componentsUtils, capabilityTypeOperation);
importManager.setAuditingManager(auditingManager);
when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString())).thenReturn(Either.left(null));
importManager.setResponseFormatManager(responseFormatManager);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
index eff9c77614..ce7b846934 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
@@ -2,29 +2,29 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components;
import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
@@ -33,16 +33,22 @@ import org.openecomp.sdc.be.components.distribution.engine.INotificationData;
import org.openecomp.sdc.be.components.distribution.engine.NotificationDataImpl;
import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
import org.openecomp.sdc.be.components.impl.ActivationRequestInformation;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
+import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
+import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceDistributionReqInfo;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
@@ -59,25 +65,27 @@ import static org.mockito.Mockito.when;
/**
* Created by chaya on 10/26/2017.
*/
-public class ServiceDistributionBLTest {
+public class ServiceDistributionBLTest extends ComponentBusinessLogicMock {
+
+ private final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
+ private final DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class);
+ private final HealthCheckBusinessLogic healthCheckBusinessLogic = Mockito.mock(HealthCheckBusinessLogic.class);
+ private final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
+ private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ private final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
+ private final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
@InjectMocks
- ServiceBusinessLogic bl = new ServiceBusinessLogic();
-
- @Mock
- ServiceDistributionValidation serviceDistributionValidation;
-
- @Mock
- HealthCheckBusinessLogic healthCheckBusinessLogic;
-
- @Mock
- ToscaOperationFacade toscaOperationFacade;
+ ServiceBusinessLogic bl = new ServiceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
+ artifactsBusinessLogic, distributionEngine, componentInstanceBusinessLogic,
+ serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter,
+ serviceFilterOperation, serviceFilterValidator, artifactToscaOperation);
ComponentsUtils componentsUtils;
- @Mock
- DistributionEngine distributionEngine;
-
private Service serviceToActivate;
private ActivationRequestInformation activationRequestInformation;
private String WORKLOAD_CONTEXT = "vnfContext";
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogicTest.java
index c4b76a2a37..2f7f5aab17 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogicTest.java
@@ -48,12 +48,15 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.impl.BaseBusinessLogicMock;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -66,23 +69,16 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.common.util.ZipUtil;
import org.openecomp.sdc.exception.ResponseFormat;
-@RunWith(MockitoJUnitRunner.class)
-public class CsarBusinessLogicTest {
+public class CsarBusinessLogicTest extends BaseBusinessLogicMock {
- @InjectMocks
- private CsarBusinessLogic test;
+ private CsarOperation csarOperation = Mockito.mock(CsarOperation.class);
+ private ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+ private User user = Mockito.mock(User.class);
+ private YamlTemplateParsingHandler yamlHandler = Mockito.mock(YamlTemplateParsingHandler.class);
- @Mock
- private CsarOperation csarOperation;
-
- @Mock
- private ToscaOperationFacade toscaOperationFacade;
-
- @Mock
- private ComponentsUtils componentsUtils;
-
- @Mock
- private User user;
+ private CsarBusinessLogic test = new CsarBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, yamlHandler, artifactToscaOperation);
private static final String CSAR_UUID = "csarUUID";
private static final String CSAR_ENTRY = "Definitions/tosca_mock_vf.yaml";
@@ -96,6 +92,13 @@ public class CsarBusinessLogicTest {
private static final String RESOURCE_NAME = "resourceName";
private static final String PAYLOAD_NAME = "mock_vf.csar";
+ @Before
+ public void setUp() throws Exception {
+ test.setCsarOperation(csarOperation);
+ test.setToscaOperationFacade(toscaOperationFacade);
+ test.setComponentsUtils(componentsUtils);
+ }
+
@Test()
public void testGetCsarInfo() {
// given
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java
index dd6ad9fe30..b8d016c589 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java
@@ -29,7 +29,7 @@ import java.util.function.Consumer;
public class DmaapConsumerTest extends BeConfDependentTest{
private DmaapConsumer createTestSubject() {
- return new DmaapConsumer(new ExecutorFactory(), new DmaapClientFactory());
+ return new DmaapConsumer(new ExecutorFactory(), new DmaapClientFactory(), new DmaapHealth());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java
index f7d7be413a..a05184fc78 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java
@@ -24,6 +24,7 @@ import mockit.Deencapsulation;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Mockito;
import org.openecomp.sdc.be.components.BeConfDependentTest;
import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth;
import org.openecomp.sdc.be.components.distribution.engine.DmaapHealth;
@@ -36,8 +37,10 @@ import java.util.List;
public class HealthCheckBusinessLogicTest extends BeConfDependentTest{
+ private final SwitchoverDetector switchoverDetector = Mockito.mock(SwitchoverDetector.class);
+
private HealthCheckBusinessLogic createTestSubject() {
- HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
+ HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic(switchoverDetector);
DmaapHealth dmaapHealth = new DmaapHealth();
ReflectionTestUtils.setField(healthCheckBusinessLogic, "dmaapHealth", dmaapHealth);
DistributionEngineClusterHealth distributionEngineClusterHealth = new DistributionEngineClusterHealth();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java
index 1cdd089539..f560129ace 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java
@@ -31,6 +31,7 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
@@ -86,6 +87,15 @@ public class AdditionalInformationBusinessLogicTest {
NodeTypeEnum nodeType = NodeTypeEnum.Resource;
static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+ @Before
+ public void setUp() throws Exception {
+ additionalInformationBusinessLogic.setUserValidations(userValidations);
+ additionalInformationBusinessLogic.setJanusGraphDao(janusGraphDao);
+ additionalInformationBusinessLogic.setComponentsUtils(componentsUtils);
+ additionalInformationBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ additionalInformationBusinessLogic.setGraphLockOperation(graphLockOperation);
+ }
+
@Test
public void testCreateAdditionalInformation() {
Either<AdditionalInfoParameterInfo, ResponseFormat> result;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index 65718630da..ffa62ed855 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -30,10 +30,14 @@ import com.google.gson.JsonElement;
import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.ArtifactsResolver;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.utils.ArtifactBuilder;
import org.openecomp.sdc.be.components.utils.ObjectGenerator;
import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
@@ -49,13 +53,18 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.model.operations.api.*;
import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
import org.openecomp.sdc.be.servlets.RepresentationUtils;
+import org.openecomp.sdc.be.tosca.CsarUtils;
+import org.openecomp.sdc.be.tosca.ToscaExportHandler;
+import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -76,7 +85,8 @@ import static org.mockito.Mockito.*;
import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME;
import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME;
-public class ArtifactBusinessLogicTest {
+@RunWith(MockitoJUnitRunner.class)
+public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
public static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis());
private final static String RESOURCE_INSTANCE_NAME = "Service-111";
@@ -91,7 +101,7 @@ public class ArtifactBusinessLogicTest {
static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
@InjectMocks
- private static ArtifactsBusinessLogic artifactBL;
+ private ArtifactsBusinessLogic artifactBL;
@Mock
private ArtifactOperation artifactOperation;
@Mock
@@ -111,8 +121,6 @@ public class ArtifactBusinessLogicTest {
@Mock
private NodeTemplateOperation nodeTemplateOperation;
@Mock
- private ArtifactsOperations artifactsOperations;
- @Mock
private IGraphLockOperation graphLockOperation;
@Mock
JanusGraphDao janusGraphDao;
@@ -122,6 +130,14 @@ public class ArtifactBusinessLogicTest {
private ResponseFormat responseFormat;
@Mock
private User user;
+ @Mock
+ private ToscaExportHandler toscaExportHandler;
+ @Mock
+ private CsarUtils csarUtils;
+ @Mock
+ private LifecycleBusinessLogic lifecycleBusinessLogic;
+ @Mock
+ private ArtifactsResolver artifactsResolver;
public static final Resource resource = Mockito.mock(Resource.class);
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
@@ -140,22 +156,14 @@ public class ArtifactBusinessLogicTest {
@Before
public void initMocks() {
- MockitoAnnotations.initMocks(this);
+// MockitoAnnotations.initMocks(this);
Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either.right(StorageOperationStatus.NOT_FOUND);
- when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Service), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
- when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Resource), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
-
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> notFoundInterfaces = Either.right(StorageOperationStatus.NOT_FOUND);
- when(lifecycleOperation.getAllInterfacesOfResource(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(notFoundInterfaces);
-
Either<User, ActionStatus> getUserResult = Either.left(USER);
- when(userOperation.getUserData("jh0003", false)).thenReturn(getUserResult);
-
Either<List<ArtifactType>, ActionStatus> getType = Either.left(getAllTypes());
- when(elementOperation.getAllArtifactTypes()).thenReturn(getType);
when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC);
}
@@ -269,7 +277,7 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put("DeploymentArtifact", deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
Resource parent = new Resource();
parent.setUniqueId("uniqueId");
@@ -292,7 +300,7 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put("DeploymentArtifact", deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getArtifacts(anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getArtifacts(anyString())).thenReturn(artifacts);
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> allInterfacesOfResource =
@@ -322,13 +330,11 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put(deploymentArtifactDefinition2.getArtifactLabel(), deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getArtifacts(anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getArtifacts(anyString())).thenReturn(artifacts);
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> allInterfacesOfResource =
Either.left(createInterfaceDefinitionMap("artifactName3.yml"));
- when(interfaceLifecycleOperation.getAllInterfacesOfResource("componentId", true, true))
- .thenReturn(allInterfacesOfResource);
Resource parent = new Resource();
parent.setUniqueId("uniqueId");
@@ -339,7 +345,6 @@ public class ArtifactBusinessLogicTest {
@Test
public void validateArtifactNameUniqueness_updateName() {
-
//artifacts with the same name have the same label
ArtifactDefinition artifactInfo = createArtifactDef("artifactName2.yml", ArtifactGroupTypeEnum.DEPLOYMENT);
ArtifactDefinition informationArtifactDefinition1 = createArtifactDef("artifactName1.yml",
@@ -354,7 +359,7 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put(deploymentArtifactDefinition2.getArtifactLabel(), deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
Resource parent = new Resource();
parent.setUniqueId("uniqueId");
@@ -377,7 +382,7 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put("DeploymentArtifact", deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
Resource parent = new Resource();
parent.setUniqueId("uniqueId");
@@ -401,7 +406,7 @@ public class ArtifactBusinessLogicTest {
artifactDefinitionMap.put("DeploymentArtifact", deploymentArtifactDefinition2);
Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap);
- when(artifactsOperations.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
+ when(artifactToscaOperation.getAllInstanceArtifacts(anyString(), anyString())).thenReturn(artifacts);
Resource parent = new Resource();
parent.setUniqueId("uniqueId");
@@ -487,7 +492,7 @@ public class ArtifactBusinessLogicTest {
Resource component = new Resource();
when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
- when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
+ when(artifactToscaOperation.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
.thenReturn(Either.left(new ArtifactDefinition()));
Either<ArtifactDefinition, ResponseFormat> heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder(heatArtifact, HEAT_VF_ENV_NAME, "parentId", NodeTypeEnum.Resource, "parentName", USER, component, Collections.emptyMap());
assertThat(heatEnvPlaceHolder.isLeft()).isTrue();
@@ -508,8 +513,6 @@ public class ArtifactBusinessLogicTest {
Resource component = new Resource();
when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
- when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
- .thenReturn(Either.left(new ArtifactDefinition()));
Either<ArtifactDefinition, ResponseFormat> heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder(heatArtifact, HEAT_ENV_NAME, "parentId", NodeTypeEnum.ResourceInstance, "parentName", USER, component, Collections.emptyMap());
@@ -534,7 +537,7 @@ public class ArtifactBusinessLogicTest {
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
//TODO Remove if passes
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class)
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class)
, any(String.class))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
@@ -542,6 +545,16 @@ public class ArtifactBusinessLogicTest {
USER, INSTANCE_ID, true, true);
}
+ private ArtifactsBusinessLogic getArtifactsBusinessLogic() {
+ ArtifactsBusinessLogic artifactsBusinessLogic = new ArtifactsBusinessLogic(artifactCassandraDao,
+ toscaExportHandler, csarUtils, lifecycleBusinessLogic,
+ userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
+ artifactsBusinessLogic.setGraphLockOperation(graphLockOperation);
+ artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ return artifactsBusinessLogic;
+ }
+
@Test
public void buildArtifactPayloadWhenShouldLockAndNotInTransaction() {
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
@@ -554,7 +567,7 @@ public class ArtifactBusinessLogicTest {
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
//TODO Remove if passes
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class)
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class)
, any(String.class))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
index 27e9f3f871..553877773f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -42,6 +44,7 @@ import org.openecomp.sdc.be.MockGenerator;
import org.openecomp.sdc.be.components.ArtifactsResolver;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.utils.ArtifactBuilder;
import org.openecomp.sdc.be.components.utils.ObjectGenerator;
import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -84,14 +87,20 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTemplateOperatio
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.servlets.RepresentationUtils;
import org.openecomp.sdc.be.tosca.CsarUtils;
+import org.openecomp.sdc.be.tosca.ToscaExportHandler;
+import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
@@ -126,7 +135,7 @@ import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME;
import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME;
-public class ArtifactsBusinessLogicTest {
+public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{
public static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN",
System.currentTimeMillis());
@@ -145,7 +154,7 @@ public class ArtifactsBusinessLogicTest {
ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
@InjectMocks
- private static ArtifactsBusinessLogic artifactBL;
+ private ArtifactsBusinessLogic artifactBL;
private static User user = null;
private static Resource resourceResponse = null;
private static ResponseFormatManager responseManager = null;
@@ -172,17 +181,17 @@ public class ArtifactsBusinessLogicTest {
@Mock
private NodeTemplateOperation nodeTemplateOperation;
@Mock
- private ArtifactsOperations artifactsOperations;
- @Mock
private IGraphLockOperation graphLockOperation;
@Mock
- private InterfaceOperation interfaceOperation;
- @Mock
private UserValidations userValidations;
@Mock
private ArtifactsResolver artifactsResolver;
@Mock
private CsarUtils csarUtils;
+ @Mock
+ private ToscaExportHandler toscaExportHandler;
+ @Mock
+ private LifecycleBusinessLogic lifecycleBusinessLogic;
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
private static List<ArtifactType> getAllTypes() {
@@ -436,7 +445,7 @@ public class ArtifactsBusinessLogicTest {
Resource component = new Resource();
component.setComponentType(ComponentTypeEnum.RESOURCE);
when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
- when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class),
+ when(artifactToscaOperation.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class),
eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
.thenReturn(Either.left(new ArtifactDefinition()));
Either<ArtifactDefinition, ResponseFormat> heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder(
@@ -458,7 +467,7 @@ public class ArtifactsBusinessLogicTest {
Resource component = new Resource();
when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
- when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class),
+ when(artifactToscaOperation.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class),
eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
.thenReturn(Either.left(new ArtifactDefinition()));
@@ -486,7 +495,7 @@ public class ArtifactsBusinessLogicTest {
artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA);
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
any(NodeTypeEnum.class), any(String.class))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
@@ -505,7 +514,7 @@ public class ArtifactsBusinessLogicTest {
artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA);
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
any(NodeTypeEnum.class), any(String.class))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
@@ -524,7 +533,7 @@ public class ArtifactsBusinessLogicTest {
artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA);
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(),
any(NodeTypeEnum.class), any(String.class))).thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK);
when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat());
@@ -540,7 +549,7 @@ public class ArtifactsBusinessLogicTest {
}
private ArtifactsBusinessLogic createTestSubject() {
- return new ArtifactsBusinessLogic();
+ return getTestSubject();
}
@Test
@@ -651,7 +660,7 @@ public class ArtifactsBusinessLogicTest {
ArtifactsBusinessLogic testSubject;
String componentId = "";
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String artifactId = "";
ArtifactDefinition artifactInfo = buildArtifactPayload();
@@ -754,7 +763,7 @@ public class ArtifactsBusinessLogicTest {
@Test
public void testIgnoreUnupdateableFieldsInUpdate() throws Exception {
ArtifactsBusinessLogic testSubject;
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
ArtifactDefinition artifactInfo = buildArtifactPayload();
ArtifactDefinition currentArtifactInfo = null;
@@ -771,7 +780,7 @@ public class ArtifactsBusinessLogicTest {
Component component = createResourceObject(true);
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
String parentId = "";
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String artifactId = "";
Either<ArtifactDefinition, ResponseFormat> result;
@@ -1150,7 +1159,7 @@ public class ArtifactsBusinessLogicTest {
ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS);
final boolean isArtifactMetadataUpdate = false;
- ArtifactsBusinessLogic testSubject = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic testSubject = getTestSubject();
Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload",
new Object[]{artifactInfo, isArtifactMetadataUpdate});
@@ -1165,7 +1174,7 @@ public class ArtifactsBusinessLogicTest {
ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS);
final boolean isArtifactMetadataUpdate = false;
- ArtifactsBusinessLogic testSubject = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic testSubject = getTestSubject();
testSubject.setComponentsUtils(componentsUtils);
Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload",
@@ -1183,7 +1192,7 @@ public class ArtifactsBusinessLogicTest {
ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS);
final boolean isArtifactMetadataUpdate = false;
- ArtifactsBusinessLogic testSubject = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic testSubject = getTestSubject();
testSubject.setComponentsUtils(componentsUtils);
Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload",
@@ -1193,13 +1202,14 @@ public class ArtifactsBusinessLogicTest {
assertEquals(expectedStatus, status);
}
+
@Test
public void testGivenValidHeatArtifactPayload_WhenHandlePayload_ThenResultIsDecodedPayload() {
final byte[] payload = "heat_template_version: 1.0".getBytes();
ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT);
final boolean isArtifactMetadataUpdate = false;
- ArtifactsBusinessLogic testSubject = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic testSubject = getTestSubject();
Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload",
new Object[]{artifactInfo, isArtifactMetadataUpdate});
@@ -1214,7 +1224,7 @@ public class ArtifactsBusinessLogicTest {
ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT);
final boolean isArtifactMetadataUpdate = false;
- ArtifactsBusinessLogic testSubject = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic testSubject = getTestSubject();
testSubject.setComponentsUtils(componentsUtils);
Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload",
@@ -1241,7 +1251,7 @@ public class ArtifactsBusinessLogicTest {
String componentId = "";
String artifactId = "";
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
Either<Boolean, ResponseFormat> result;
@@ -1255,7 +1265,7 @@ public class ArtifactsBusinessLogicTest {
@Test
public void testDetectAuditingType() throws Exception {
ArtifactsBusinessLogic testSubject;
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String origMd5 = "";
AuditingActionEnum result;
@@ -1464,7 +1474,7 @@ public class ArtifactsBusinessLogicTest {
Resource component = createResourceObject(true);
List<ArtifactDefinition> vfcsNewCreatedArtifacts = new ArrayList<>();
- ArtifactsBusinessLogic arb = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic arb = getTestSubject();
ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
boolean shouldLock = false;
boolean inTransaction = false;
@@ -1547,13 +1557,13 @@ public class ArtifactsBusinessLogicTest {
.thenReturn(user);
when(toscaOperationFacade.getToscaFullElement(any()))
.thenReturn(Either.left(resource));
- when(artifactsOperations.getArtifactById(any(), any(), any(), any()))
+ when(artifactToscaOperation.getArtifactById(any(), any(), any(), any()))
.thenReturn(Either.left(artifactDefinition));
when(artifactsResolver.findArtifactOnComponent(any(), any(ComponentTypeEnum.class), anyString()))
.thenReturn(artifactDefinition);
when(graphLockOperation.lockComponent(eq(resource.getUniqueId()), any(NodeTypeEnum.class)))
.thenReturn(StorageOperationStatus.OK);
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), any(), anyString(), any(NodeTypeEnum.class), any()))
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), anyString(), any(NodeTypeEnum.class), any()))
.thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any(ESArtifactData.class)))
.thenReturn(CassandraOperationStatus.OK);
@@ -1593,7 +1603,7 @@ public class ArtifactsBusinessLogicTest {
when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean()))
.thenReturn(Either.left(csar));
- when(artifactsOperations.updateArtifactOnResource(any(ArtifactDefinition.class), anyString(), anyString(), any(NodeTypeEnum.class), anyString()))
+ when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), anyString(), anyString(), any(NodeTypeEnum.class), anyString()))
.thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.saveArtifact(any(ESArtifactData.class)))
.thenReturn(CassandraOperationStatus.OK);
@@ -1610,7 +1620,7 @@ public class ArtifactsBusinessLogicTest {
@Test
public void testHandleDownloadToscaModelRequest() {
-
+ ArtifactsBusinessLogic testSubject = getTestSubject();
byte[] generatedCsar = "test.csar".getBytes();
Resource resource = new Resource();
@@ -1625,7 +1635,7 @@ public class ArtifactsBusinessLogicTest {
.thenReturn(Either.left(generatedCsar));
Either<ImmutablePair<String, byte[]>, ResponseFormat> result =
- artifactBL.handleDownloadToscaModelRequest(resource, csarArtifact);
+ testSubject.handleDownloadToscaModelRequest(resource, csarArtifact);
ImmutablePair<String, byte[]> leftResult = result.left().value();
assertEquals(csarArtifact.getArtifactName(), leftResult.getKey());
@@ -1670,7 +1680,7 @@ public class ArtifactsBusinessLogicTest {
.thenReturn(user);
when(toscaOperationFacade.getToscaFullElement(eq(componentId)))
.thenReturn(Either.left(resource));
- when(artifactsOperations.getArtifactById(anyString(), anyString(), any(ComponentTypeEnum.class), anyString()))
+ when(artifactToscaOperation.getArtifactById(anyString(), anyString(), any(ComponentTypeEnum.class), anyString()))
.thenReturn(Either.left(artifactDefinition));
when(artifactCassandraDao.getArtifact(any()))
.thenReturn(Either.left(esArtifactData));
@@ -1714,7 +1724,7 @@ public class ArtifactsBusinessLogicTest {
.thenReturn(Either.left(service));
when(graphLockOperation.lockComponent(eq(componentId), any(NodeTypeEnum.class)))
.thenReturn(StorageOperationStatus.OK);
- when(artifactsOperations.getArtifacts(any(), any(NodeTypeEnum.class), any(ArtifactGroupTypeEnum.class), any()))
+ when(artifactToscaOperation.getArtifacts(any(), any(NodeTypeEnum.class), any(ArtifactGroupTypeEnum.class), any()))
.thenReturn(Either.left(artifactDefinitionMap));
Either<Map<String, ArtifactDefinition>, ResponseFormat> result =
@@ -1780,9 +1790,9 @@ public class ArtifactsBusinessLogicTest {
.thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.getToscaElement(eq(parentId)))
.thenReturn(Either.left(resource));
- when(artifactsOperations.isCloneNeeded(any(), any(ArtifactDefinition.class), any(NodeTypeEnum.class)))
+ when(artifactToscaOperation.isCloneNeeded(any(), any(ArtifactDefinition.class), any(NodeTypeEnum.class)))
.thenReturn(Either.left(Boolean.FALSE));
- when(artifactsOperations.removeArtifactOnGraph(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class), anyBoolean()))
+ when(artifactToscaOperation.removeArtifactOnGraph(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class), anyBoolean()))
.thenReturn(Either.left(artifactDataDefinition));
when(artifactCassandraDao.deleteArtifact(any()))
.thenReturn(CassandraOperationStatus.OK);
@@ -1848,4 +1858,10 @@ public class ArtifactsBusinessLogicTest {
byte[] data = result.left().value();
Assert.assertEquals(esArtifactData.getDataAsArray(), data);
}
+
+ private ArtifactsBusinessLogic getTestSubject() {
+ return new ArtifactsBusinessLogic(artifactCassandraDao, toscaExportHandler, csarUtils, lifecycleBusinessLogic,
+ userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
+ }
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
index 55292f4bf5..2084e443fd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
@@ -7,17 +7,18 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components.impl;
import java.lang.reflect.Field;
@@ -49,10 +50,11 @@ import static org.mockito.Mockito.when;
import fj.data.Either;
-public class AttributeBusinessLogicTest {
+public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
private AttributeBusinessLogic createTestSubject() {
- return new AttributeBusinessLogic();
+ return new AttributeBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation );
}
UserValidations userValidations = Mockito.mock(UserValidations.class);
@@ -470,4 +472,4 @@ public class AttributeBusinessLogicTest {
}
-}
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogicMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogicMock.java
new file mode 100644
index 0000000000..e8d9ddcdf8
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogicMock.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.components.impl;
+
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+
+public abstract class BaseBusinessLogicMock {
+ protected final IElementOperation elementDao = Mockito.mock(IElementOperation.class);
+ protected final IGroupOperation groupOperation = Mockito.mock(IGroupOperation.class);
+ protected final IGroupInstanceOperation groupInstanceOperation = Mockito.mock(IGroupInstanceOperation.class);
+ protected final IGroupTypeOperation groupTypeOperation = Mockito.mock(IGroupTypeOperation.class);
+ protected final GroupBusinessLogic groupBusinessLogic = Mockito.mock(GroupBusinessLogic.class);
+ protected final InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
+ protected final InterfaceLifecycleOperation interfaceLifecycleTypeOperation = Mockito.mock(InterfaceLifecycleOperation.class);
+ protected final ArtifactsOperations artifactToscaOperation = Mockito.mock(ArtifactsOperations.class);
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogicTest.java
index b75d52cb42..25568b9a9f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogicTest.java
@@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ * ================================================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -46,9 +49,16 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.CapabilitiesOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ConfigurationSource;
@@ -72,7 +82,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-public class CapabilitiesBusinessLogicTest {
+public class CapabilitiesBusinessLogicTest extends BaseBusinessLogicMock {
private final String componentId = "resourceId1";
private final String capabilityId = "uniqueId1";
@@ -86,8 +96,10 @@ public class CapabilitiesBusinessLogicTest {
private final GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
private User user = null;
- @InjectMocks
- private CapabilitiesBusinessLogic capabilitiesBusinessLogicMock = new CapabilitiesBusinessLogic();
+ private final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
+
+ private CapabilitiesBusinessLogic capabilitiesBusinessLogicMock = new CapabilitiesBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, capabilityTypeOperation, artifactToscaOperation);
@Before
public void setup() {
@@ -129,11 +141,13 @@ public class CapabilitiesBusinessLogicTest {
.thenReturn(StorageOperationStatus.OK);
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
- capabilitiesBusinessLogicMock = new CapabilitiesBusinessLogic();
+ capabilitiesBusinessLogicMock = new CapabilitiesBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
+ capabilityTypeOperation, artifactToscaOperation);
capabilitiesBusinessLogicMock.setComponentsUtils(componentsUtils);
capabilitiesBusinessLogicMock.setUserAdmin(mockUserAdmin);
capabilitiesBusinessLogicMock.setGraphLockOperation(graphLockOperation);
- capabilitiesBusinessLogicMock.setJanusGraphGenericDao(mockJanusGraphDao);
+ capabilitiesBusinessLogicMock.setJanusGraphDao(mockJanusGraphDao);
capabilitiesBusinessLogicMock.setToscaOperationFacade(toscaOperationFacade);
capabilitiesBusinessLogicMock.setUserValidations(userValidations);
capabilitiesBusinessLogicMock.setCapabilitiesOperation(capabilitiesOperation);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index ad5ddafe0e..f0942f6be0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -42,6 +42,7 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -121,8 +122,6 @@ public class ComponentInstanceBusinessLogicTest {
private final static String PROP_NAME = "propName";
private final static String NON_EXIST_NAME = "nonExistName";
- @InjectMocks
- private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
@Mock
private ComponentsUtils componentsUtils;
@Mock
@@ -145,6 +144,8 @@ public class ComponentInstanceBusinessLogicTest {
private ArtifactsBusinessLogic artifactBusinessLogic;
@Mock
private GraphLockOperation graphLockOperation;
+ @InjectMocks
+ private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
private Component service;
private Component resource;
@@ -157,6 +158,13 @@ public class ComponentInstanceBusinessLogicTest {
@Before
public void init() {
+ MockitoAnnotations.initMocks(componentInstanceBusinessLogic);
+ componentInstanceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ componentInstanceBusinessLogic.setUserValidations(userValidations);
+ componentInstanceBusinessLogic.setComponentsUtils(componentsUtils);
+ componentInstanceBusinessLogic.setGraphLockOperation(graphLockOperation);
+ componentInstanceBusinessLogic.setJanusGraphDao(janusGraphDao);
+
stubMethods();
createComponents();
}
@@ -714,12 +722,11 @@ public class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
JanusGraphDao mock = Mockito.mock(JanusGraphDao.class);
- testSubject.setJanusGraphGenericDao(mock);
+ testSubject.setJanusGraphDao(mock);
result = testSubject.deleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceId,
userId);
}
-
@Test
public void testDeleteForwardingPaths() {
ComponentInstanceBusinessLogic testSubject;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java
index 23363bef47..407da47c51 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java
@@ -16,12 +16,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
+import org.mockito.Mockito;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -36,7 +39,10 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public class CompositionBusinessLogicTest {
- CompositionBusinessLogic compBl = new CompositionBusinessLogic();
+
+ private ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+
+ CompositionBusinessLogic compBl = new CompositionBusinessLogic(componentInstanceBusinessLogic);
@Test
public void testBuildSpiralPatternPositioningForComponentInstances() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
index 95aa8052d4..648072ba03 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
@@ -2,22 +2,23 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components.impl;
import org.apache.commons.lang3.RandomStringUtils;
@@ -33,9 +34,15 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ConsumerDefinition;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.ConsumerData;
import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -48,8 +55,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-
-public class ConsumerBusinessLogicTest {
+public class ConsumerBusinessLogicTest extends BaseBusinessLogicMock {
private User user;
private ConsumerDefinition consumer;
@@ -75,7 +81,8 @@ public class ConsumerBusinessLogicTest {
@Before
public void setUp(){
- consumerBusinessLogic = new ConsumerBusinessLogic();
+ consumerBusinessLogic = new ConsumerBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
consumerDataDefinition = new ConsumerDataDefinition();
consumer = new ConsumerDefinition();
MockitoAnnotations.initMocks(this);
@@ -266,4 +273,4 @@ public class ConsumerBusinessLogicTest {
.thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
assertTrue(consumerBusinessLogic.deleteConsumer("marvel123", user).isRight());
}
-}
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogicTest.java
index d6b59205aa..609a9f9302 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogicTest.java
@@ -82,6 +82,9 @@ public class DataTypeBusinessLogicTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+
+ testInstance.setToscaOperationFacade(toscaOperationFacadeMock);
+
service = new Service();
service.setUniqueId(COMPONENT_INSTANCE_ID);
ComponentInstance componentInstance = new ComponentInstance();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogicTest.java
index 9b84989b56..ed8daadced 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogicTest.java
@@ -35,6 +35,12 @@ import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.info.DistributionStatusListResponse;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -49,14 +55,13 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-public class DistributionMonitoringBusinessLogicTest {
+public class DistributionMonitoringBusinessLogicTest extends BaseBusinessLogicMock {
private String uId;
private User user;
private String ditributionId;
private String serviceId;
- @InjectMocks
private DistributionMonitoringBusinessLogic businessLogic;
@Mock
@@ -70,8 +75,12 @@ public class DistributionMonitoringBusinessLogicTest {
@Before
public void setUp() {
- businessLogic = new DistributionMonitoringBusinessLogic();
MockitoAnnotations.initMocks(this);
+ businessLogic = new DistributionMonitoringBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation,
+ cassandraDao, artifactToscaOperation);
+ businessLogic.setUserValidations(userValidations);
+ businessLogic.setComponentsUtils(componentsUtils);
user = new User();
uId = "userId";
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
index 34a8e090ef..3d890b9b9f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
@@ -129,6 +129,12 @@ public class ElementBLTest {
initServicesList();
initResourceslist();
+ elementBusinessLogic.setUserValidations(userValidations);
+ elementBusinessLogic.setComponentsUtils(componentsUtils);
+ elementBusinessLogic.setJanusGraphGenericDao(janusGraphGenericDao);
+ elementBusinessLogic.setJanusGraphDao(janusGraphDao);
+ elementBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+
when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java
index 6f97621d74..f4f8a2a784 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java
@@ -50,9 +50,14 @@ import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -67,7 +72,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public class ElementBusinessLogicTest {
+public class ElementBusinessLogicTest extends BaseBusinessLogicMock {
private User user;
@@ -77,28 +82,29 @@ public class ElementBusinessLogicTest {
@Mock
private UserBusinessLogic userAdminManager;
- @Mock
+ @Mock
private JanusGraphDao janusGraphDao;
- @Mock
+ @Mock
private UserValidations userValidations;
- @Mock
+ @Mock
private ToscaOperationFacade toscaOperationFacade;
- @Mock
- private IElementOperation elementOperation;
-
- @InjectMocks
- ElementBusinessLogic elementBusinessLogic;
+ @InjectMocks
+ ElementBusinessLogic elementBusinessLogic;
@Before
public void setUp() {
-
- elementBusinessLogic = new ElementBusinessLogic();
MockitoAnnotations.initMocks(this);
- user = new User();
- user.setUserId("admin");
+ elementBusinessLogic = new ElementBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation, elementDao, userAdminManager);
+ elementBusinessLogic.setComponentsUtils(componentsUtils);
+ elementBusinessLogic.setJanusGraphDao(janusGraphDao);
+ elementBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ elementBusinessLogic.setUserValidations(userValidations);
+ user = new User();
+ user.setUserId("admin");
}
@Test
@@ -231,7 +237,7 @@ public class ElementBusinessLogicTest {
categoryDefinitionList.add(new CategoryDefinition());
when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), anyBoolean())).thenReturn(user);
- when(elementOperation.getAllCategories(NodeTypeEnum.ResourceNewCategory, false))
+ when(elementDao.getAllCategories(NodeTypeEnum.ResourceNewCategory, false))
.thenReturn(Either.left(categoryDefinitionList));
Assert.assertTrue(elementBusinessLogic.getAllCategories(ComponentTypeEnum.RESOURCE_PARAM_NAME, user.getUserId())
.isLeft());
@@ -245,7 +251,7 @@ public class ElementBusinessLogicTest {
when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), anyBoolean()))
.thenReturn(user);
- when(elementOperation.getAllCategories(any(NodeTypeEnum.class), anyBoolean()))
+ when(elementDao.getAllCategories(any(NodeTypeEnum.class), anyBoolean()))
.thenReturn(Either.left(dummyCategoryDefinitionList));
Assert.assertTrue(elementBusinessLogic.getAllCategories(user.getUserId()).isLeft());
@@ -254,7 +260,7 @@ public class ElementBusinessLogicTest {
@Test
public void testDeleteCategory_givenValidComponentTypeAndCategoryId_thenReturnsSuccessful() {
- when(elementOperation.deleteCategory(any(NodeTypeEnum.class), anyString()))
+ when(elementDao.deleteCategory(any(NodeTypeEnum.class), anyString()))
.thenReturn(Either.left(new CategoryDefinition()));
Assert.assertTrue(elementBusinessLogic.deleteCategory("cat1", "resources", user.getUserId()).isLeft());
@@ -268,13 +274,13 @@ public class ElementBusinessLogicTest {
when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), anyBoolean()))
.thenReturn(user);
- when(elementOperation.getCategory(any(NodeTypeEnum.class), anyString()))
+ when(elementDao.getCategory(any(NodeTypeEnum.class), anyString()))
.thenReturn(Either.left(new CategoryDefinition()));
- when(elementOperation.isSubCategoryUniqueForCategory(any(NodeTypeEnum.class), anyString(), anyString()))
+ when(elementDao.isSubCategoryUniqueForCategory(any(NodeTypeEnum.class), anyString(), anyString()))
.thenReturn(Either.left(Boolean.TRUE));
- when(elementOperation.getSubCategoryUniqueForType(any(NodeTypeEnum.class), anyString()))
+ when(elementDao.getSubCategoryUniqueForType(any(NodeTypeEnum.class), anyString()))
.thenReturn(Either.left(subCatDef));
- when(elementOperation.createSubCategory(anyString(), any(SubCategoryDefinition.class), any(NodeTypeEnum.class)))
+ when(elementDao.createSubCategory(anyString(), any(SubCategoryDefinition.class), any(NodeTypeEnum.class)))
.thenReturn(Either.left(subCatDef));
Assert.assertTrue(elementBusinessLogic.createSubCategory(subCatDef, "resources",
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogicTest.java
index d57ee97c27..f817cdf11f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogicTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -27,8 +29,14 @@ import java.io.IOException;
import org.junit.Test;
import org.onap.sdc.gab.model.GABQuery;
import org.onap.sdc.gab.model.GABQuery.GABQueryType;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
-public class GenericArtifactBrowserBusinessLogicTest {
+public class GenericArtifactBrowserBusinessLogicTest extends BaseBusinessLogicMock {
private static String content = "event: {presence: required, action: [ any, any, alarm003,RECO-rebuildVnf ],\n"
+ " structure: {\n"
@@ -106,7 +114,9 @@ public class GenericArtifactBrowserBusinessLogicTest {
@Test
public void testShouldCorrectlyParseResponse() throws IOException {
- GenericArtifactBrowserBusinessLogic genericArtifactBrowserBusinessLogic = new GenericArtifactBrowserBusinessLogic();
+ GenericArtifactBrowserBusinessLogic genericArtifactBrowserBusinessLogic = new GenericArtifactBrowserBusinessLogic(
+ elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
String result = genericArtifactBrowserBusinessLogic.searchFor(
new GABQuery(ImmutableSet.of("event.presence", "event.action[0]"),
content, GABQueryType.CONTENT));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
index 6024462292..c5078a251d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
@@ -30,6 +30,7 @@
package org.openecomp.sdc.be.components.impl;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -118,6 +119,15 @@ public class GroupBusinessLogicTest {
private final static Configuration configuration = Mockito.mock(Configuration.class);
static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+ @Before
+ public void setUp() throws Exception {
+ test.setDataTypeCache(dataTypeCache);
+ test.setToscaOperationFacade(toscaOperationFacade);
+ test.setPropertyOperation(propertyOperation);
+ test.setComponentsUtils(componentsUtils);
+ test.setJanusGraphDao(janusGraphDao);
+ }
+
@Test
public void testCreateGroups_NoDataType() {
Either<List<GroupDefinition>, ResponseFormat> result;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
index 9d7ca19eb5..ab8061a49b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -144,6 +144,14 @@ public class InputsBusinessLogicTest {
service.setIsDeleted(false);
service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ testInstance.setUserValidations(userValidations);
+ testInstance.setToscaOperationFacade(toscaOperationFacadeMock);
+ testInstance.setGraphLockOperation(graphLockOperation);
+ testInstance.setComponentsUtils(componentsUtilsMock);
+ testInstance.setJanusGraphDao(janusGraphDao);
+ testInstance.setApplicationDataTypeCache(applicationDataTypeCache);
+ testInstance.setPropertyOperation(propertyOperation);
+
// add a ComponentInstance
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setUniqueId(COMPONENT_INSTANCE_ID);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
index 42eca256a2..ee40b0bdab 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
@@ -105,6 +105,11 @@ public class InterfaceOperationBusinessLogicTest {
@Before
public void setup() {
+ interfaceOperationBusinessLogic.setUserValidations(userValidations);
+ interfaceOperationBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ interfaceOperationBusinessLogic.setGraphLockOperation(graphLockOperation);
+ interfaceOperationBusinessLogic.setJanusGraphDao(janusGraphDao);
+ interfaceOperationBusinessLogic.setComponentsUtils(componentsUtils);
resource = new ResourceBuilder().setComponentType(ComponentTypeEnum.RESOURCE).setUniqueId(resourceId)
.setName(RESOURCE_NAME).build();
resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinitionMap(interfaceId, operationId,
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
index d5abdabec3..fcf4e643e9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
@@ -144,7 +144,7 @@ public class PolicyBusinessLogicTest {
public void initBl() {
businessLogic.setComponentsUtils(componentsUtils);
businessLogic.setToscaOperationFacade(toscaOperationFacade);
- businessLogic.setJanusGraphGenericDao(janusGraphDao);
+ businessLogic.setJanusGraphDao(janusGraphDao);
businessLogic.setUserValidations(userValidations);
businessLogic.setGraphLockOperation(graphLockOperation);
businessLogic.setPolicyTypeOperation(policyTypeOperation);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java
index 3b9a43af28..f717313a95 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java
@@ -90,7 +90,7 @@ public class PolicyPropertiesBusinessLogicTest {
@Before
public void setUp() throws Exception {
testInstance.setUserValidations(userValidations);
- testInstance.setJanusGraphGenericDao(janusGraphDao);
+ testInstance.setJanusGraphDao(janusGraphDao);
testInstance.setToscaOperationFacade(toscaOperationFacade);
testInstance.setComponentsUtils(componentsUtils);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java
index dd523b8b36..ff0e62f5e8 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java
@@ -33,6 +33,7 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.components.validation.ValidationUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -48,11 +49,16 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.GroupingDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import fj.data.Either;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.exception.ResponseFormat;
import static org.junit.Assert.assertEquals;
@@ -65,7 +71,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-public class ProductBusinessLogicTest {
+public class ProductBusinessLogicTest extends ComponentBusinessLogicMock {
private Product product;
private User user;
@@ -102,11 +108,13 @@ public class ProductBusinessLogicTest {
private UserValidations userValidations;
@Mock
- private IElementOperation elementOperation;
+ private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
@Before
public void setUp() {
- productBusinessLogic = new ProductBusinessLogic();
+ productBusinessLogic = new ProductBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
+ artifactsBusinessLogic, componentInstanceBusinessLogic, artifactToscaOperation);
MockitoAnnotations.initMocks(this);
product = new Product();
user = new User();
@@ -309,7 +317,7 @@ public class ProductBusinessLogicTest {
.thenReturn(Either.left(product));
when(toscaOperationFacade.getToscaElement(eq(componentId), any(JsonParseFlagEnum.class)))
.thenReturn(Either.left(product));
- when(elementOperation.getAllProductCategories())
+ when(elementDao.getAllProductCategories())
.thenReturn(Either.left(categoryDefinitionList));
when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
.thenReturn(StorageOperationStatus.OK);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogicTest.java
index da726505af..091d6f9a58 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogicTest.java
@@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ * ================================================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -42,10 +45,16 @@ import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.RequirementOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ConfigurationSource;
@@ -69,7 +78,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-public class RequirementBusinessLogicTest {
+public class RequirementBusinessLogicTest extends BaseBusinessLogicMock {
private final String componentId = "resourceId1";
private final String requirementId = "uniqueId1";
@@ -84,7 +93,9 @@ public class RequirementBusinessLogicTest {
private User user = null;
@InjectMocks
- private RequirementBusinessLogic requirementsBusinessLogicMock = new RequirementBusinessLogic();
+ private RequirementBusinessLogic requirementsBusinessLogicMock = new RequirementBusinessLogic(elementDao,
+ groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation,
+ interfaceLifecycleTypeOperation, artifactToscaOperation);
@Before
public void setup() {
@@ -126,12 +137,14 @@ public class RequirementBusinessLogicTest {
.thenReturn(StorageOperationStatus.OK);
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
- requirementsBusinessLogicMock = new RequirementBusinessLogic();
+ requirementsBusinessLogicMock = new RequirementBusinessLogic(elementDao,
+ groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation,
+ interfaceLifecycleTypeOperation, artifactToscaOperation);
requirementsBusinessLogicMock.setComponentsUtils(componentsUtils);
requirementsBusinessLogicMock.setUserAdmin(mockUserAdmin);
requirementsBusinessLogicMock.setGraphLockOperation(graphLockOperation);
- requirementsBusinessLogicMock.setJanusGraphGenericDao(mockJanusGraphDao);
+ requirementsBusinessLogicMock.setJanusGraphDao(mockJanusGraphDao);
requirementsBusinessLogicMock.setToscaOperationFacade(toscaOperationFacade);
requirementsBusinessLogicMock.setUserValidations(userValidations);
requirementsBusinessLogicMock.setRequirementOperation(requirementOperation);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index 06f74c10e8..92168fa871 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -32,9 +32,18 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.ArtifactsResolver;
+import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
+import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
+import org.openecomp.sdc.be.components.merge.utils.MergeInstanceUtils;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
+import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
@@ -68,14 +77,21 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOper
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
+import org.openecomp.sdc.be.tosca.ToscaExportHandler;
+import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
@@ -107,22 +123,15 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
-public class ResourceBusinessLogicTest {
+public class ResourceBusinessLogicTest extends ComponentBusinessLogicMock {
private static final Logger log = LoggerFactory.getLogger(ResourceBusinessLogicTest.class);
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
@@ -141,7 +150,7 @@ public class ResourceBusinessLogicTest {
private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
final ServletContext servletContext = Mockito.mock(ServletContext.class);
- IElementOperation mockElementDao;
+ IElementOperation mockElementDao = new ElementOperationMock();
JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
@@ -156,9 +165,27 @@ public class ResourceBusinessLogicTest {
UserValidations userValidations = Mockito.mock(UserValidations.class);
WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
+ ArtifactCassandraDao artifactCassandraDao = Mockito.mock(ArtifactCassandraDao.class);
+
+ CsarUtils csarUtils = Mockito.mock(CsarUtils.class);
+ IUserBusinessLogic userBusinessLogic = Mockito.mock(IUserBusinessLogic.class);
+ IGroupOperation groupOperation = Mockito.mock(IGroupOperation.class);
+ IGroupInstanceOperation groupInstanceOperation = Mockito.mock(IGroupInstanceOperation.class);
+ IGroupTypeOperation groupTypeOperation = Mockito.mock(IGroupTypeOperation.class);
+ GroupBusinessLogic groupBusinessLogic = Mockito.mock(GroupBusinessLogic.class);
+ InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
+ ArtifactsOperations artifactToscaOperation = Mockito.mock(ArtifactsOperations.class);
+ ArtifactsResolver artifactsResolver = Mockito.mock(ArtifactsResolver.class);
+ InterfaceLifecycleOperation interfaceLifecycleTypeOperation = Mockito.mock(InterfaceLifecycleOperation.class);
+ ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+ InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
+ CompositionBusinessLogic compositionBusinessLogic = Mockito.mock(CompositionBusinessLogic.class);
+ ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic = Mockito.mock(ResourceDataMergeBusinessLogic.class);
+ CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class);
+ MergeInstanceUtils mergeInstanceUtils = Mockito.mock(MergeInstanceUtils.class);
+ UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
- @InjectMocks
- ResourceBusinessLogic bl = new ResourceBusinessLogic();
ResponseFormatManager responseManager = null;
GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
User user = null;
@@ -168,13 +195,14 @@ public class ResourceBusinessLogicTest {
Resource genericVFC = null;
Resource genericPNF = null;
ComponentsUtils componentsUtils;
- ArtifactsBusinessLogic artifactManager = new ArtifactsBusinessLogic();
+ ArtifactsBusinessLogic artifactManager;
CsarOperation csarOperation = Mockito.mock(CsarOperation.class);
@InjectMocks
- CsarBusinessLogic csarBusinessLogic = new CsarBusinessLogic();
+ CsarBusinessLogic csarBusinessLogic;
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
List<Resource> reslist;
+ ResourceBusinessLogic bl;
public ResourceBusinessLogicTest() {
}
@@ -192,8 +220,7 @@ public class ResourceBusinessLogicTest {
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
- // Elements
- mockElementDao = new ElementOperationMock();
+ ToscaExportHandler toscaExportHandler = Mockito.mock(ToscaExportHandler.class);
// User data and management
user = new User();
@@ -243,17 +270,24 @@ public class ResourceBusinessLogicTest {
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
// BL object
+ artifactManager = new ArtifactsBusinessLogic(artifactCassandraDao, toscaExportHandler, csarUtils, lifecycleBl, userBusinessLogic,
+ artifactsResolver, mockElementDao, groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation,
+ interfaceLifecycleTypeOperation, artifactToscaOperation);
+
+ bl = new ResourceBusinessLogic(mockElementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactManager, componentInstanceBusinessLogic,
+ resourceImportManager, inputsBusinessLogic, compositionBusinessLogic, resourceDataMergeBusinessLogic,
+ csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils, uiComponentDataConverter, csarBusinessLogic,
+ artifactToscaOperation);
+
artifactManager.setNodeTemplateOperation(nodeTemplateOperation);
- bl = new ResourceBusinessLogic();
- bl.setElementDao(mockElementDao);
bl.setUserAdmin(mockUserAdmin);
bl.setCapabilityTypeOperation(capabilityTypeOperation);
bl.setComponentsUtils(componentsUtils);
bl.setLifecycleManager(lifecycleBl);
bl.setGraphLockOperation(graphLockOperation);
- bl.setArtifactsManager(artifactManager);
bl.setPropertyOperation(propertyOperation);
- bl.setJanusGraphGenericDao(mockJanusGraphDao);
+ bl.setJanusGraphDao(mockJanusGraphDao);
bl.setApplicationDataTypeCache(applicationDataTypeCache);
bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
index 67f7e2d5b2..16f81257c2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -23,15 +25,19 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.impl.instance.ComponentInstanceChangeOperationOrchestrator;
+import org.openecomp.sdc.be.components.merge.instance.ComponentInstanceMergeDataBusinessLogic;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ForwardingPathOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
@@ -55,7 +61,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-public class ResourceInstanceBusinessLogicTest {
+public class ResourceInstanceBusinessLogicTest extends BaseBusinessLogicMock {
private static final String RESOURCE_ID_WITH_HEAT_PARAMS = "MyResourceId";
private static final String RESOURCE_ID_NO_PAYLOAD = "NoHeatPayload";
@@ -67,24 +73,30 @@ public class ResourceInstanceBusinessLogicTest {
private static final String USER_ID = "jh0003";
private static final long ARTIFACT_CREATION_TIME = System.currentTimeMillis();
- static User adminUser = new User("John", "Doh", USER_ID, "", "ADMIN", null);
-
- @InjectMocks
- static ComponentInstanceBusinessLogic bl = new ComponentInstanceBusinessLogic();
+ private final IComponentInstanceOperation componentInstanceOperation = Mockito.mock(IComponentInstanceOperation.class);
+ private final ArtifactsBusinessLogic artifactBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
+ private final ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL = Mockito.mock(ComponentInstanceMergeDataBusinessLogic.class);
+ private final ComponentInstanceChangeOperationOrchestrator onChangeInstanceOperationOrchestrator = Mockito.mock(ComponentInstanceChangeOperationOrchestrator.class);
+ private final ForwardingPathOperation forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
+ private final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
- public static final ArtifactsBusinessLogic artifactBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
- public static final UserBusinessLogic userAdminManager = Mockito.mock(UserBusinessLogic.class);
-// public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class);
+ private static final UserBusinessLogic userAdminManager = Mockito.mock(UserBusinessLogic.class);
public static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
public static final IGroupInstanceOperation groupInstanceOperation = Mockito.mock(IGroupInstanceOperation.class);
public static final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
- static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+ static User adminUser = new User("John", "Doh", USER_ID, "", "ADMIN", null);
+
+ private ComponentInstanceBusinessLogic bl = new ComponentInstanceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation,
+ componentInstanceOperation, artifactBusinessLogic, compInstMergeDataBL, onChangeInstanceOperationOrchestrator,
+ forwardingPathOperation, serviceFilterOperation, artifactToscaOperation);
- // @BeforeClass
- public static void setup() {
+ static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
Map<String, Object> deploymentResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getDeploymentResourceInstanceArtifacts();
Map<String, Object> placeHolderData = (Map<String, Object>) deploymentResourceArtifacts.get(ArtifactsBusinessLogic.HEAT_ENV_NAME);
@@ -109,7 +121,7 @@ public class ResourceInstanceBusinessLogicTest {
Either<ArtifactDefinition, ResponseFormat> eitherPlaceHolder = Either.left(getArtifactPlaceHolder(RESOURCE_INSTANCE_ID, HEAT_ENV_LABEL));
Mockito.when(artifactBusinessLogic.createArtifactPlaceHolderInfo(RESOURCE_INSTANCE_ID, HEAT_ENV_LABEL.toLowerCase(), placeHolderData, USER_ID, ArtifactGroupTypeEnum.DEPLOYMENT, false)).thenReturn(eitherPlaceHolder);
- // Mockito.when(artifactBusinessLogic.createArtifactAuditingFields(Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.anyString())).thenReturn(new EnumMap<AuditingFieldsKey, Object>(AuditingFieldsKey.class));
+ // Mockito.when(artifactBusinessLogic.createArtifactAuditingFields(Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.anyString())).thenReturn(new EnumMap<AuditingFieldsKey, Object>(AuditingFieldsKey.class));
Either<ArtifactDefinition, StorageOperationStatus> eitherArtifact = Either.left(getHeatArtifactDefinition(USER_ID, RESOURCE_INSTANCE_ID, HEAT_ENV_LABEL, ARTIFACT_CREATION_TIME, true, false));
Mockito.when(artifactBusinessLogic.addHeatEnvArtifact(Mockito.any(ArtifactDefinition.class), Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.any(NodeTypeEnum.class), Mockito.anyString())).thenReturn(eitherArtifact);
@@ -121,12 +133,12 @@ public class ResourceInstanceBusinessLogicTest {
Either<Object, StorageOperationStatus> eitherLightService = Either.left(lightService);
Mockito.doNothing().when(componentsUtils).auditComponent(Mockito.any(ResponseFormat.class), Mockito.any(User.class), Mockito.any(Component.class), Mockito.any(AuditingActionEnum.class),
- Mockito.any(ResourceCommonInfo.class), Mockito.any(ResourceVersionInfo.class));
+ Mockito.any(ResourceCommonInfo.class), Mockito.any(ResourceVersionInfo.class));
Either<ArtifactDefinition, ResponseFormat> heatEnvEither = Either.left(getHeatArtifactDefinition(USER_ID, RESOURCE_INSTANCE_ID, HEAT_ENV_LABEL, ARTIFACT_CREATION_TIME, true, false));
Mockito.when(artifactBusinessLogic.createHeatEnvPlaceHolder(Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(NodeTypeEnum.class), Mockito.anyString(), Mockito.any(User.class),
- Mockito.any(Component.class), Mockito.any())).thenReturn(heatEnvEither);
+ Mockito.any(Component.class), Mockito.any())).thenReturn(heatEnvEither);
Either<List<GroupInstance>, StorageOperationStatus> groupInstanceEitherLeft = Either.left(new ArrayList<>());
Mockito.when(groupInstanceOperation.getAllGroupInstances(Mockito.anyString(), Mockito.any(NodeTypeEnum.class))).thenReturn(groupInstanceEitherLeft);
@@ -137,13 +149,6 @@ public class ResourceInstanceBusinessLogicTest {
Mockito.when(toscaOperationFacade.addDeploymentArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any(Map.class))).thenReturn(status);
Mockito.when(toscaOperationFacade.addInformationalArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any())).thenReturn(status);
Mockito.when(toscaOperationFacade.addGroupInstancesToComponentInstance(Mockito.any(Component.class), Mockito.any(ComponentInstance.class), Mockito.any(), Mockito.any(Map.class))).thenReturn(status);
-
- }
-
- @Before
- public void initMocks() {
- MockitoAnnotations.initMocks(this);
- setup();
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
index 05ca32cbbc..30cc8a2adc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
@@ -29,21 +29,27 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.distribution.engine.IDistributionEngine;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
+import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
+import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
+import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -76,7 +82,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.mockito.ArgumentMatchers.eq;
-public class ServiceBusinessLogicTest {
+public class ServiceBusinessLogicTest extends ComponentBusinessLogicMock {
private static final String SERVICE_CATEGORY = "Mobility";
private static final String INSTANTIATION_TYPE = "A-la-carte";
@@ -84,7 +90,7 @@ public class ServiceBusinessLogicTest {
private UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
private WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
private WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
- private ServiceBusinessLogic bl = new ServiceBusinessLogic();
+ private ServiceBusinessLogic bl;
private ResponseFormatManager responseManager = null;
private ComponentsUtils componentsUtils;
private AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
@@ -98,6 +104,14 @@ public class ServiceBusinessLogicTest {
private ResourceAdminEvent auditArchive2 = Mockito.mock(ResourceAdminEvent.class);
private ResourceAdminEvent auditRestore = Mockito.mock(ResourceAdminEvent.class);
+ private final IDistributionEngine distributionEngine = Mockito.mock(IDistributionEngine.class);
+ private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
+ private final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
+ private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ private final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
+ private final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
+
private User user = null;
private Resource genericService = null;
@@ -106,10 +120,6 @@ public class ServiceBusinessLogicTest {
private static final String COMPONNET_ID = "myUniqueId";
private static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
- public ServiceBusinessLogicTest() {
-
- }
-
@Before
public void setup() {
@@ -159,12 +169,14 @@ public class ServiceBusinessLogicTest {
when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_SERVICE_NAME)).thenReturn(findLatestGeneric);
- bl = new ServiceBusinessLogic();
- bl.setElementDao(mockElementDao);
+ bl = new ServiceBusinessLogic(mockElementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactBl, distributionEngine,
+ componentInstanceBusinessLogic, serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter,
+ serviceFilterOperation, serviceFilterValidator, artifactToscaOperation);
+
bl.setUserAdmin(mockUserAdmin);
- bl.setArtifactBl(artifactBl);
bl.setGraphLockOperation(graphLockOperation);
- bl.setJanusGraphGenericDao(mockJanusGraphDao);
+ bl.setJanusGraphDao(mockJanusGraphDao);
bl.setToscaOperationFacade(toscaOperationFacade);
bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
bl.setComponentsUtils(componentsUtils);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
index 7c4e66d9f9..11b4fa0556 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
@@ -2,22 +2,23 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components.impl.generic;
import fj.data.Either;
@@ -28,6 +29,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
@@ -49,11 +51,13 @@ public class GenericTypeBusinessLogicTest {
@Mock
private ToscaOperationFacade toscaOperationFacadeMock;
+ @Mock
+ private ComponentsUtils componentsUtils;
+
@Before
public void setUp() throws Exception {
- testInstance = new GenericTypeBusinessLogic();
MockitoAnnotations.initMocks(this);
-
+ testInstance = new GenericTypeBusinessLogic(componentsUtils, toscaOperationFacadeMock);
}
@Test
@@ -114,4 +118,4 @@ public class GenericTypeBusinessLogicTest {
}
-}
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
index e5462c6d71..0eea67e417 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
@@ -21,6 +21,8 @@
*/
package org.openecomp.sdc.be.components.lifecycle;
+import static org.mockito.Mockito.mock;
+
import org.junit.Test;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
@@ -42,16 +44,16 @@ import fj.data.Either;
import mockit.Deencapsulation;
import org.openecomp.sdc.test.utils.TestConfigurationProvider;
-import static org.mockito.Mockito.mock;
-
public class CertificationRequestTransitionTest extends LifecycleTestBase {
-
-
private CertificationRequestTransition createTestSubject() {
return new CertificationRequestTransition(
- new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(mock(CassandraClient.class)), new TestConfigurationProvider())),
- new ToscaElementLifecycleOperation(), new ServiceBusinessLogic(), new ToscaOperationFacade(), new JanusGraphDao(new JanusGraphClient()));
+ new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(mock(CassandraClient.class)), new TestConfigurationProvider())),
+ new ToscaElementLifecycleOperation(), new ServiceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+ groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic,
+ distributionEngine, componentInstanceBusinessLogic, serviceDistributionValidation, forwardingPathValidator,
+ uiComponentDataConverter, serviceFilterOperation, serviceFilterValidator, artifactToscaOperation), new ToscaOperationFacade(),
+ new JanusGraphDao(new JanusGraphClient()));
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
index 8f5362a12d..e48148c5cb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java
@@ -24,8 +24,18 @@ import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
+import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.CompositionBusinessLogic;
+import org.openecomp.sdc.be.components.impl.InputsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ResourceImportManager;
+import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
+import org.openecomp.sdc.be.components.merge.utils.MergeInstanceUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -34,14 +44,27 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.exception.ResponseFormat;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class CheckoutTest extends LifecycleTestBase {
private CheckoutTransition checkoutObj = null;
+ private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+ private final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
+ private final CompositionBusinessLogic compositionBusinessLogic = Mockito.mock(CompositionBusinessLogic.class);
+ private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic = Mockito.mock(ResourceDataMergeBusinessLogic.class);
+ private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class);
+ private final MergeInstanceUtils mergeInstanceUtils = Mockito.mock(MergeInstanceUtils.class);
+ private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ private final CsarBusinessLogic csarBusinessLogic = Mockito.mock(CsarBusinessLogic.class);
+
@InjectMocks
- ResourceBusinessLogic bl = new ResourceBusinessLogic();
+ ResourceBusinessLogic bl = new ResourceBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic,
+ componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, compositionBusinessLogic,
+ resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils,
+ uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation);
@Before
public void setup() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
index e2432ce584..830173dfb6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
@@ -27,11 +27,18 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.distribution.engine.IDistributionEngine;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
+import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
+import org.openecomp.sdc.be.components.utils.ComponentBusinessLogicMock;
+import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
+import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -40,6 +47,7 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementLifecycleOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
@@ -62,7 +70,7 @@ import java.util.List;
import static org.mockito.Mockito.when;
-public class LifecycleTestBase {
+public class LifecycleTestBase extends ComponentBusinessLogicMock {
private static final Logger log = LoggerFactory.getLogger(LifecycleTestBase.class);
@InjectMocks
protected final ServletContext servletContext = Mockito.mock(ServletContext.class);
@@ -79,6 +87,13 @@ public class LifecycleTestBase {
protected JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
protected ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
protected static ComponentsUtils componentsUtils;
+ protected final IDistributionEngine distributionEngine = Mockito.mock(IDistributionEngine.class);
+ protected final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+ protected final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
+ protected final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
+ protected final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
+ protected final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
+ protected final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
@BeforeClass
public static void setupClass() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java
index 671bfb7998..552d5cad64 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java
@@ -41,7 +41,6 @@ import static org.junit.Assert.*;
@ContextConfiguration(locations = "/paths/path-context.xml")
public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest {
-
@Test
public void shouldFailToUpdateForwardingPathSincePathDoesNotExist() {
Service service = initForwardPath();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java
index a6e597d8bf..56920c083d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java
@@ -38,6 +38,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -52,16 +53,10 @@ public class InMemoryJanusGraphClient extends JanusGraphClient {
private static final String OK = "GOOD";
- public InMemoryJanusGraphClient() {
- }
-
-
private JanusGraph graph;
- JanusGraphClientStrategy janusGraphClientStrategy;
- public InMemoryJanusGraphClient(JanusGraphClientStrategy janusGraphClientStrategy) {
+ public InMemoryJanusGraphClient() {
super();
- this.janusGraphClientStrategy = janusGraphClientStrategy;
logger.info("** JanusGraphClient created");
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogicTest.java
index 1cb0344af5..31e2092b0c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogicTest.java
@@ -2,22 +2,23 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
-
package org.openecomp.sdc.be.components.scheduledtasks;
import com.google.common.collect.Lists;
@@ -27,7 +28,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.impl.BaseBusinessLogicMock;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -45,25 +48,23 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
-@RunWith(MockitoJUnitRunner.class)
-public class ComponentsCleanBusinessLogicTest {
+public class ComponentsCleanBusinessLogicTest extends BaseBusinessLogicMock {
- @Mock
- private ResourceBusinessLogic resourceBusinessLogic;
- @Mock
- private ServiceBusinessLogic serviceBusinessLogic;
- @Mock
- private IGraphLockOperation graphLockOperation;
- @Mock
- private ComponentsUtils componentsUtils;
+ private ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
+ private ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
+ private IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
+ private ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
- @InjectMocks
- private ComponentsCleanBusinessLogic componentsCleanBL = new ComponentsCleanBusinessLogic();
+ private ComponentsCleanBusinessLogic componentsCleanBL = new ComponentsCleanBusinessLogic(elementDao, groupOperation,
+ groupInstanceOperation, groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation,
+ resourceBusinessLogic, serviceBusinessLogic, artifactToscaOperation);
@Before
public void setUp() {
mockResourceDeleting();
mockServiceDeleting();
+ componentsCleanBL.setGraphLockOperation(graphLockOperation);
+ componentsCleanBL.setComponentsUtils(componentsUtils);
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBusinessLogicMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBusinessLogicMock.java
new file mode 100644
index 0000000000..ce19e53ab6
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBusinessLogicMock.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.components.utils;
+
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.BaseBusinessLogicMock;
+
+public abstract class ComponentBusinessLogicMock extends BaseBusinessLogicMock {
+
+ protected final ArtifactsBusinessLogic artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java
index 4f60564e3e..e18b7415d0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java
@@ -22,11 +22,13 @@ package org.openecomp.sdc.be.distribution;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Mockito;
import org.openecomp.sdc.be.components.BeConfDependentTest;
import org.openecomp.sdc.be.components.distribution.engine.ArtifactInfoImpl;
import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -42,8 +44,10 @@ import static org.junit.Assert.assertTrue;
public class ServiceDistributionArtifactsBuilderTest extends BeConfDependentTest {
+ private final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+
@InjectMocks
- ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder = new ServiceDistributionArtifactsBuilder();
+ ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder = new ServiceDistributionArtifactsBuilder(toscaOperationFacade);
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
index cdb66185ab..2d181ccbf6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
@@ -72,7 +72,14 @@ import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTargetDTO;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.common.api.Constants;
@@ -477,13 +484,31 @@ public class PolicyServletTest extends JerseySpringBaseTest{
businessLogic = Mockito.mock(PolicyBusinessLogic.class);
businessLogic.setPropertyDeclarationOrchestrator(propertyDeclarationOrchestrator);
businessLogic.setToscaOperationFacade(toscaOperationFacade);
-
- baseBusinessLogic = Mockito.spy(BaseBusinessLogic.class);
- baseBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ BaseBusinessLogic bbl = new BaseBusinessLogicTest(Mockito.mock(IElementOperation.class),
+ Mockito.mock(IGroupOperation.class),
+ Mockito.mock(IGroupInstanceOperation.class), Mockito.mock(IGroupTypeOperation.class),
+ Mockito.mock(InterfaceOperation.class), Mockito.mock(InterfaceLifecycleOperation.class), Mockito.mock(
+ ArtifactsOperations.class));
+ PolicyServletTest.baseBusinessLogic = Mockito.spy(bbl);
+ PolicyServletTest.baseBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
componentsUtils = Mockito.mock(ComponentsUtils.class);
servletUtils = Mockito.mock(ServletUtils.class);
responseFormat = Mockito.mock(ResponseFormat.class);
}
+
+ private static class BaseBusinessLogicTest extends BaseBusinessLogic {
+
+ BaseBusinessLogicTest(IElementOperation elementDao,
+ IGroupOperation groupOperation,
+ IGroupInstanceOperation groupInstanceOperation,
+ IGroupTypeOperation groupTypeOperation,
+ InterfaceOperation interfaceOperation,
+ InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+ ArtifactsOperations artifactToscaOperation) {
+ super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation,
+ interfaceLifecycleTypeOperation, artifactToscaOperation);
+ }
+ }
}
diff --git a/catalog-be/src/test/resources/paths/path-context.xml b/catalog-be/src/test/resources/paths/path-context.xml
index b0312f8b92..dffd5ef200 100644
--- a/catalog-be/src/test/resources/paths/path-context.xml
+++ b/catalog-be/src/test/resources/paths/path-context.xml
@@ -59,34 +59,17 @@ Modifications copyright (c) 2018 Nokia
org.openecomp.sdc.be.dao.jsongraph">
</context:component-scan>
-
- <bean id="resourceImportManager" class="org.openecomp.sdc.be.components.impl.ResourceImportManager" />
- <bean id="capabilityTypeImportManager" class="org.openecomp.sdc.be.components.impl.CapabilityTypeImportManager" />
- <bean id="servletUtils" class="org.openecomp.sdc.be.impl.ServletUtils" />
- <bean id="resourceBusinessLogic" class="org.openecomp.sdc.be.components.impl.ResourceBusinessLogic" />
- <bean id="productBusinessLogic" class="org.openecomp.sdc.be.components.impl.ProductBusinessLogic" />
- <bean id="artifactBusinessLogic" class="org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic" />
+ <bean id="tosca-operation-facade" class="org.openecomp.sdc.be.components.path.beans.ForwardingPathToscaOperationFacade" />
+ <bean id="janusgraph-client" class="org.openecomp.sdc.be.components.path.beans.InMemoryJanusGraphClient" />
<bean id="lifecycleBusinessLogic" class="org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic" />
<bean id="transactionManager" class="org.openecomp.sdc.common.transaction.mngr.TransactionManager" />
- <bean id="userBusinessLogic" class="org.openecomp.sdc.be.user.UserBusinessLogic" />
- <bean id="elementsBusinessLogic" class="org.openecomp.sdc.be.components.impl.ElementBusinessLogic" />
- <bean id="propertyBusinessLogic" class="org.openecomp.sdc.be.components.impl.PropertyBusinessLogic" />
- <bean id="auditingManager" class="org.openecomp.sdc.be.auditing.impl.AuditingManager" />
- <bean id="distributionBusinessLogic" class="org.openecomp.sdc.be.distribution.DistributionBusinessLogic" />
- <bean id="interfaceLifecycleTypeImportManager" class="org.openecomp.sdc.be.components.impl.InterfaceLifecycleTypeImportManager" />
- <bean id="distributionMonitoringBusinessLogic" class="org.openecomp.sdc.be.components.impl.DistributionMonitoringBusinessLogic" />
- <bean id="additionalInformationBusinessLogic" class="org.openecomp.sdc.be.components.impl.AdditionalInformationBusinessLogic" />
- <bean id="distribution-engine-cluster-health" class="org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth" />
- <bean id="categoriesImportManager" class="org.openecomp.sdc.be.components.impl.CategoriesImportManager" />
<bean id="asset-metadata-utils" class="org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter" />
- <bean id="janusgraph-client" class="org.openecomp.sdc.be.components.path.beans.InMemoryJanusGraphClient" />
<bean class="org.openecomp.sdc.be.dao.config.DAOSpringConfig"/>
<bean id="cassandra-client" class="org.openecomp.sdc.be.components.path.beans.CassandraClientMock" />
<bean id="audit-cassandra-dao" class="org.openecomp.sdc.be.components.path.beans.AuditCassandraDaoMock" />
<bean id="artifact-cassandra-dao" class="org.openecomp.sdc.be.components.path.beans.ArtifactCassandraDaoMock" />
<bean id="operational-environment-dao" class="org.openecomp.sdc.be.components.path.beans.EnvironmentCassandraDaoMock"/>
<bean id="sdc-schema-files-cassandra-dao" class="org.openecomp.sdc.be.components.path.beans.SdcSchemaFilesCassandraDaoMock" />
- <bean id="tosca-operation-facade" class="org.openecomp.sdc.be.components.path.beans.ForwardingPathToscaOperationFacade" />
<bean id="distributionEngine" class="org.openecomp.sdc.be.components.path.beans.DistributionEngineMock"/>
<bean id="forwardingPathValidator" class="org.openecomp.sdc.be.components.path.beans.ForwardingPathValidatorMock" />
<bean id="dataTypeValidatorConverter" class="org.openecomp.sdc.be.model.tosca.validators.DataTypeValidatorConverter" />