From 79827ecb068e1e33ce28701f5dc59b37ee309b51 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Fri, 28 Jun 2019 12:17:09 +0200 Subject: 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 --- .../csar/CsarArtifactsAndGroupsBusinessLogic.java | 37 +++++-- .../sdc/be/components/csar/CsarBusinessLogic.java | 25 ++++- .../distribution/engine/DmaapConsumer.java | 11 +- .../ServiceDistributionArtifactsBuilder.java | 6 +- .../health/HealthCheckBusinessLogic.java | 8 +- .../impl/AdditionalInformationBusinessLogic.java | 24 ++++- .../be/components/impl/ArtifactsBusinessLogic.java | 80 ++++++++------- .../be/components/impl/AttributeBusinessLogic.java | 20 ++++ .../sdc/be/components/impl/BaseBusinessLogic.java | 112 ++++++++------------- .../components/impl/CapabilitiesBusinessLogic.java | 28 +++++- .../impl/CapabilityTypeImportManager.java | 3 +- .../be/components/impl/CommonImportManager.java | 2 + .../be/components/impl/ComponentBusinessLogic.java | 30 +++++- .../impl/ComponentInstanceBusinessLogic.java | 69 ++++++++----- .../components/impl/CompositionBusinessLogic.java | 8 +- .../be/components/impl/ConsumerBusinessLogic.java | 22 +++- .../be/components/impl/CsarValidationUtils.java | 28 +++--- .../be/components/impl/DataTypeBusinessLogic.java | 20 ++++ .../impl/DistributionMonitoringBusinessLogic.java | 22 +++- .../be/components/impl/ElementBusinessLogic.java | 33 ++++-- .../impl/GenericArtifactBrowserBusinessLogic.java | 19 +++- .../sdc/be/components/impl/GroupBusinessLogic.java | 32 ++++-- .../sdc/be/components/impl/ImportUtils.java | 12 +-- .../be/components/impl/InputsBusinessLogic.java | 34 +++++-- .../impl/InterfaceOperationBusinessLogic.java | 24 ++++- .../components/impl/NodeFilterUploadCreator.java | 1 - .../be/components/impl/PolicyBusinessLogic.java | 27 +++-- .../be/components/impl/ProductBusinessLogic.java | 25 ++++- .../be/components/impl/PropertyBusinessLogic.java | 19 ++++ .../impl/RelationshipTypeBusinessLogic.java | 10 +- .../impl/RelationshipTypeImportManager.java | 7 +- .../components/impl/RequirementBusinessLogic.java | 22 +++- .../be/components/impl/ResourceBusinessLogic.java | 100 +++++++++--------- .../be/components/impl/ResourceImportManager.java | 28 +++--- .../be/components/impl/ServiceBusinessLogic.java | 89 +++++++++------- .../impl/generic/GenericTypeBusinessLogic.java | 9 +- .../lifecycle/CertificationChangeTransition.java | 9 -- .../lifecycle/LifecycleBusinessLogic.java | 17 ++-- .../lifecycle/UndoCheckoutTransition.java | 10 -- .../ComponentInstanceMergeDataBusinessLogic.java | 3 + .../ComponentsCleanBusinessLogic.java | 34 +++++-- .../org/openecomp/sdc/be/impl/ComponentsUtils.java | 2 + .../components/BaseServiceBusinessLogicTest.java | 70 ++++++++----- .../be/components/ComponentBusinessLogicTest.java | 13 +-- .../components/HealthCheckBusinessLogicTest.java | 8 +- .../be/components/PropertyBusinessLogicTest.java | 10 +- .../be/components/ResourceImportManagerTest.java | 11 +- .../be/components/ServiceDistributionBLTest.java | 46 +++++---- .../be/components/csar/CsarBusinessLogicTest.java | 33 +++--- .../distribution/engine/DmaapConsumerTest.java | 2 +- .../health/HealthCheckBusinessLogicTest.java | 5 +- .../AdditionalInformationBusinessLogicTest.java | 10 ++ .../components/impl/ArtifactBusinessLogicTest.java | 67 +++++++----- .../impl/ArtifactsBusinessLogicTest.java | 80 +++++++++------ .../impl/AttributeBusinessLogicTest.java | 14 +-- .../be/components/impl/BaseBusinessLogicMock.java | 40 ++++++++ .../impl/CapabilitiesBusinessLogicTest.java | 24 ++++- .../impl/ComponentInstanceBusinessLogicTest.java | 15 ++- .../impl/CompositionBusinessLogicTest.java | 8 +- .../components/impl/ConsumerBusinessLogicTest.java | 23 +++-- .../components/impl/DataTypeBusinessLogicTest.java | 3 + .../DistributionMonitoringBusinessLogicTest.java | 15 ++- .../sdc/be/components/impl/ElementBLTest.java | 6 ++ .../components/impl/ElementBusinessLogicTest.java | 46 +++++---- .../GenericArtifactBrowserBusinessLogicTest.java | 14 ++- .../be/components/impl/GroupBusinessLogicTest.java | 10 ++ .../components/impl/InputsBusinessLogicTest.java | 8 ++ .../impl/InterfaceOperationBusinessLogicTest.java | 5 + .../components/impl/PolicyBusinessLogicTest.java | 2 +- .../impl/PolicyPropertiesBusinessLogicTest.java | 2 +- .../components/impl/ProductBusinessLogicTest.java | 16 ++- .../impl/RequirementBusinessLogicTest.java | 21 +++- .../components/impl/ResourceBusinessLogicTest.java | 72 +++++++++---- .../impl/ResourceInstanceBusinessLogicTest.java | 51 +++++----- .../components/impl/ServiceBusinessLogicTest.java | 34 +++++-- .../impl/generic/GenericTypeBusinessLogicTest.java | 18 ++-- .../CertificationRequestTransitionTest.java | 14 +-- .../sdc/be/components/lifecycle/CheckoutTest.java | 27 ++++- .../be/components/lifecycle/LifecycleTestBase.java | 17 +++- .../path/ForwardingPathBusinessLogicTest.java | 1 - .../path/beans/InMemoryJanusGraphClient.java | 9 +- .../ComponentsCleanBusinessLogicTest.java | 33 +++--- .../utils/ComponentBusinessLogicMock.java | 30 ++++++ .../ServiceDistributionArtifactsBuilderTest.java | 6 +- .../sdc/be/servlets/PolicyServletTest.java | 31 +++++- .../src/test/resources/paths/path-context.xml | 21 +--- 86 files changed, 1436 insertions(+), 676 deletions(-) create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogicMock.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBusinessLogicMock.java (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java index 7469a0531a..f94cd38670 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java @@ -32,6 +32,7 @@ import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOpera import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo; import org.openecomp.sdc.be.components.impl.BaseBusinessLogic; import org.openecomp.sdc.be.components.impl.CsarValidationUtils; +import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; import org.openecomp.sdc.be.components.impl.ImportUtils; import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -48,7 +49,14 @@ import org.openecomp.sdc.be.info.ArtifactTemplateInfo; import org.openecomp.sdc.be.info.MergedArtifactInfo; import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.heat.HeatParameterType; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.servlets.RepresentationUtils; import org.openecomp.sdc.be.tosca.CsarUtils; @@ -73,16 +81,31 @@ import static org.openecomp.sdc.be.tosca.CsarUtils.ARTIFACTS_PATH; public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(CsarArtifactsAndGroupsBusinessLogic.class.getName()); - public static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMATR_FILE_NAME = "Artifact file is not in expected formatr, fileName {}"; - public static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME = "Artifact file is not in expected format, fileName {}"; - public static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMATR_FILE_NAME1 = "Artifact file is not in expected formatr, fileName "; - public static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME1 = "Artifact file is not in expected format, fileName "; - public static final String ARTIFACT_INTERNALS_ARE_INVALID = "Artifact internals are invalid"; - public static final String ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE = "Artifact with name {} and type {} already exist with type {}"; + private static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMATR_FILE_NAME = "Artifact file is not in expected formatr, fileName {}"; + private static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME = "Artifact file is not in expected format, fileName {}"; + private static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMATR_FILE_NAME1 = "Artifact file is not in expected formatr, fileName "; + private static final String ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME1 = "Artifact file is not in expected format, fileName "; + private static final String ARTIFACT_INTERNALS_ARE_INVALID = "Artifact internals are invalid"; + private static final String ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE = "Artifact with name {} and type {} already exist with type {}"; private final Gson gson = new Gson(); private static final Pattern pattern = Pattern.compile("\\..(.*?)\\.."); + protected final ArtifactsBusinessLogic artifactsBusinessLogic; + private final GroupBusinessLogic groupBusinessLogic; + @Autowired - protected ArtifactsBusinessLogic artifactsBusinessLogic; + public CsarArtifactsAndGroupsBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsBusinessLogic artifactsBusinessLogic, ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.artifactsBusinessLogic = artifactsBusinessLogic; + this.groupBusinessLogic = groupBusinessLogic; + } public Either createResourceArtifactsFromCsar(CsarInfo csarInfo, Resource resource, String artifactsMetaFile, String artifactsMetaFileName, List createdArtifacts, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java index addd9d2407..af914e9019 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java @@ -25,6 +25,7 @@ import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.impl.BaseBusinessLogic; import org.openecomp.sdc.be.components.impl.CsarValidationUtils; +import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -33,9 +34,16 @@ import org.openecomp.sdc.be.model.NodeTypeInfo; import org.openecomp.sdc.be.model.ParsedToscaYamlInfo; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; +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.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.CsarOperation; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; @@ -51,12 +59,25 @@ public class CsarBusinessLogic extends BaseBusinessLogic { private static final String CREATING_RESOURCE_FROM_CSAR_FETCHING_CSAR_WITH_ID = "Creating resource from CSAR: fetching CSAR with id "; private static final String FAILED = " failed"; - @Autowired + private final YamlTemplateParsingHandler yamlHandler; private CsarOperation csarOperation; @Autowired - private YamlTemplateParsingHandler yamlHandler; + public CsarBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + YamlTemplateParsingHandler yamlHandler, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.yamlHandler = yamlHandler; + } + @Autowired public void setCsarOperation(CsarOperation csarOperation) { this.csarOperation = csarOperation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java index 0c05dd1974..6388083a57 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java @@ -39,21 +39,22 @@ import java.util.function.Consumer; */ @Service public class DmaapConsumer { + private static final Logger logger = Logger.getLogger(DmaapClientFactory.class.getName()); private final ExecutorFactory executorFactory; private final DmaapClientFactory dmaapClientFactory; - private static final Logger logger = Logger.getLogger(DmaapClientFactory.class.getName()); - - @Autowired - private DmaapHealth dmaapHealth; + private final DmaapHealth dmaapHealth; /** * Allows to create an object of type DmaapConsumer * @param executorFactory * @param dmaapClientFactory + * @param dmaapHealth */ @Autowired - public DmaapConsumer(ExecutorFactory executorFactory, DmaapClientFactory dmaapClientFactory) { + public DmaapConsumer(ExecutorFactory executorFactory, DmaapClientFactory dmaapClientFactory, + DmaapHealth dmaapHealth) { this.executorFactory = executorFactory; this.dmaapClientFactory = dmaapClientFactory; + this.dmaapHealth = dmaapHealth; } /** diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilder.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilder.java index 04c4d11679..de695d6501 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilder.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilder.java @@ -56,8 +56,12 @@ public class ServiceDistributionArtifactsBuilder { @javax.annotation.Resource IArtifactOperation artifactOperation; + private final ToscaOperationFacade toscaOperationFacade; + @Autowired - ToscaOperationFacade toscaOperationFacade; + public ServiceDistributionArtifactsBuilder(ToscaOperationFacade toscaOperationFacade) { + this.toscaOperationFacade = toscaOperationFacade; + } public InterfaceLifecycleOperation getInterfaceLifecycleOperation() { return interfaceLifecycleOperation; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java index 00efd80200..857fd1bdd7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java @@ -87,11 +87,15 @@ public class HealthCheckBusinessLogic { private DmaapHealth dmaapHealth; @Resource private CassandraHealthCheck cassandraHealthCheck; - @Autowired - private SwitchoverDetector switchoverDetector; + private final SwitchoverDetector switchoverDetector; private volatile List prevBeHealthCheckInfos = null; private ScheduledFuture scheduledFuture = null; + @Autowired + public HealthCheckBusinessLogic(SwitchoverDetector switchoverDetector) { + this.switchoverDetector = switchoverDetector; + } + @PostConstruct public void init() { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java index 19e696c07a..f0ccffa633 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java @@ -30,10 +30,16 @@ import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; +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.IAdditionalInformationOperation; 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.DaoStatusConverter; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.converters.StringConvertor; import org.openecomp.sdc.be.model.tosca.validators.StringValidator; @@ -41,6 +47,7 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.context.WebApplicationContext; @@ -61,8 +68,21 @@ public class AdditionalInformationBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(AdditionalInformationBusinessLogic.class.getName()); private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {} error - {}"; - @javax.annotation.Resource - private IAdditionalInformationOperation additionalInformationOperation = null; + private final IAdditionalInformationOperation additionalInformationOperation; + + @Autowired + public AdditionalInformationBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + IAdditionalInformationOperation additionalInformationOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.additionalInformationOperation = additionalInformationOperation; + } protected static IElementOperation getElementDao(Class class1, ServletContext context) { WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index dcc6eee01a..3d149f79e6 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -22,7 +22,6 @@ package org.openecomp.sdc.be.components.impl; -import com.google.common.annotations.VisibleForTesting; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import fj.data.Either; @@ -73,13 +72,19 @@ 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.heat.HeatParameterType; +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.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.IHeatParametersOperation; 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.DaoStatusConverter; +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.ComponentMetadataData; import org.openecomp.sdc.be.resources.data.ESArtifactData; @@ -154,21 +159,21 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension"; private static final Logger log = Logger.getLogger(ArtifactsBusinessLogic.class); - public static final String FAILED_UPDATE_GROUPS = "Failed to update groups of the component {}. "; - public static final String FAILED_UPDATE_ARTIFACT = "Failed to delete or update the artifact {}. Parent uniqueId is {}"; - public static final String FAILED_SAVE_ARTIFACT = "Failed to save the artifact."; - public static final String UPDATE_ARTIFACT_LOCK = "Update Artifact - lock "; - public static final String FAILED_DOWNLOAD_ARTIFACT = "Download artifact {} failed"; - public static final String FAILED_UPLOAD_ARTIFACT_TO_COMPONENT = "Failed to upload artifact to component with type {} and uuid {}. Status is {}. "; - public static final String FAILED_UPLOAD_ARTIFACT_TO_INSTANCE = "Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. "; - public static final String FAILED_FETCH_COMPONENT = "Could not fetch component with type {} and uuid {}. Status is {}. "; - public static final String NULL_PARAMETER = "One of the function parameteres is null"; + private static final String FAILED_UPDATE_GROUPS = "Failed to update groups of the component {}. "; + private static final String FAILED_UPDATE_ARTIFACT = "Failed to delete or update the artifact {}. Parent uniqueId is {}"; + private static final String FAILED_SAVE_ARTIFACT = "Failed to save the artifact."; + private static final String UPDATE_ARTIFACT_LOCK = "Update Artifact - lock "; + private static final String FAILED_DOWNLOAD_ARTIFACT = "Download artifact {} failed"; + private static final String FAILED_UPLOAD_ARTIFACT_TO_COMPONENT = "Failed to upload artifact to component with type {} and uuid {}. Status is {}. "; + private static final String FAILED_UPLOAD_ARTIFACT_TO_INSTANCE = "Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. "; + private static final String FAILED_FETCH_COMPONENT = "Could not fetch component with type {} and uuid {}. Status is {}. "; + private static final String NULL_PARAMETER = "One of the function parameteres is null"; public static final String COMPONENT_INSTANCE_NOT_FOUND = "Component instance {} was not found for component {}"; - public static final String ROLLBACK = "all changes rollback"; - public static final String COMMIT = "all changes committed"; - public static final String ARTIFACT_SAVED = "Artifact saved into ES - {}"; - public static final String UPDATE_ARTIFACT = "Update Artifact"; - public static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; + private static final String ROLLBACK = "all changes rollback"; + private static final String COMMIT = "all changes committed"; + private static final String ARTIFACT_SAVED = "Artifact saved into ES - {}"; + private static final String UPDATE_ARTIFACT = "Update Artifact"; + private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @javax.annotation.Resource @@ -179,38 +184,35 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { @javax.annotation.Resource private IElementOperation elementOperation; - @javax.annotation.Resource - private ResourceBusinessLogic resourceBusinessLogic; - - @javax.annotation.Resource - private ServiceBusinessLogic serviceBusinessLogic; - @javax.annotation.Resource private UserBusinessLogic userAdminManager; @javax.annotation.Resource private IHeatParametersOperation heatParametersOperation; - @Autowired - private ArtifactCassandraDao artifactCassandraDao; - - @Autowired - private ToscaExportHandler toscaExportUtils; - - @Autowired - private CsarUtils csarUtils; - - @Autowired - private LifecycleBusinessLogic lifecycleBusinessLogic; - - @Autowired - private IUserBusinessLogic userBusinessLogic; - - @Autowired + private final ArtifactCassandraDao artifactCassandraDao; + private final ToscaExportHandler toscaExportUtils; + private final CsarUtils csarUtils; + private final LifecycleBusinessLogic lifecycleBusinessLogic; + private final IUserBusinessLogic userBusinessLogic; + private final ArtifactsResolver artifactsResolver; private NodeTemplateOperation nodeTemplateOperation; @Autowired - private ArtifactsResolver artifactsResolver; + public ArtifactsBusinessLogic(ArtifactCassandraDao artifactCassandraDao, ToscaExportHandler toscaExportUtils, + CsarUtils csarUtils, LifecycleBusinessLogic lifecycleBusinessLogic, IUserBusinessLogic userBusinessLogic, + ArtifactsResolver artifactsResolver, IElementOperation elementDao, IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, IGroupTypeOperation groupTypeOperation, InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.artifactCassandraDao = artifactCassandraDao; + this.toscaExportUtils = toscaExportUtils; + this.csarUtils = csarUtils; + this.lifecycleBusinessLogic = lifecycleBusinessLogic; + this.userBusinessLogic = userBusinessLogic; + this.artifactsResolver = artifactsResolver; + } public enum ArtifactOperationEnum { CREATE, UPDATE, DELETE, DOWNLOAD, LINK; @@ -5630,7 +5632,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return gson.toJson(json); } - @VisibleForTesting + @Autowired void setNodeTemplateOperation(NodeTemplateOperation nodeTemplateOperation) { this.nodeTemplateOperation = nodeTemplateOperation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java index ef0cd463db..c20a2b3b28 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java @@ -27,10 +27,18 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; @@ -54,6 +62,18 @@ public class AttributeBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(AttributeBusinessLogic.class.getName()); private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {}. Error - {}"; + @Autowired + public AttributeBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + } + /** * Created attribute on the resource with resourceId * diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java index 8a4b761a5a..a764c89db2 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java @@ -91,116 +91,101 @@ public abstract class BaseBusinessLogic { private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {} error - {}"; - private static final Logger log = Logger.getLogger(BaseBusinessLogic.class.getName()); + private static final Logger log = Logger.getLogger(BaseBusinessLogic.class.getName()); private static final String EMPTY_VALUE = null; private static final String SCHEMA_DOESN_T_EXISTS_FOR_PROPERTY_OF_TYPE = "Schema doesn't exists for property of type {}"; private static final String PROPERTY_IN_SCHEMA_DEFINITION_INSIDE_PROPERTY_OF_TYPE_DOESN_T_EXIST = "Property in Schema Definition inside property of type {} doesn't exist"; private static final String ADD_PROPERTY_VALUE = "Add property value"; private static final String THE_VALUE_OF_PROPERTY_FROM_TYPE_IS_INVALID = "The value {} of property from type {} is invalid"; - @Autowired + protected final IGroupTypeOperation groupTypeOperation; + protected final InterfaceOperation interfaceOperation; + protected final IElementOperation elementDao; protected ComponentsUtils componentsUtils; - - @Autowired protected IUserBusinessLogic userAdmin; - - @Autowired protected IGraphLockOperation graphLockOperation; - - @Autowired protected JanusGraphDao janusGraphDao; - - @Autowired protected JanusGraphGenericDao janusGraphGenericDao; - - @Autowired - protected IElementOperation elementDao; - - @Autowired - protected IGroupOperation groupOperation; - - @Autowired - IGroupInstanceOperation groupInstanceOperation; - - @Autowired - protected IGroupTypeOperation groupTypeOperation; - - @Autowired - protected GroupBusinessLogic groupBusinessLogic; - - @Autowired - PolicyTypeOperation policyTypeOperation; - - @javax.annotation.Resource - protected ArtifactsOperations artifactToscaOperation; - - @Autowired protected PropertyOperation propertyOperation; - - @Autowired protected ApplicationDataTypeCache applicationDataTypeCache; - - @Autowired protected ToscaOperationFacade toscaOperationFacade; - - @Autowired protected ApplicationDataTypeCache dataTypeCache; - - @Autowired - protected InterfaceOperation interfaceOperation; - - @Autowired - protected InterfaceOperationBusinessLogic interfaceOperationBusinessLogic; - - @Autowired - protected InterfaceLifecycleOperation interfaceLifecycleTypeOperation; - - @javax.annotation.Resource + final IGroupOperation groupOperation; + final IGroupInstanceOperation groupInstanceOperation; + final InterfaceLifecycleOperation interfaceLifecycleTypeOperation; + PolicyTypeOperation policyTypeOperation; + protected final ArtifactsOperations artifactToscaOperation; private UserValidations userValidations; DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance(); + public BaseBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, IGroupTypeOperation groupTypeOperation, InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ArtifactsOperations artifactToscaOperation) { + this.elementDao = elementDao; + this.groupOperation = groupOperation; + this.groupInstanceOperation = groupInstanceOperation; + this.groupTypeOperation = groupTypeOperation; + this.interfaceOperation = interfaceOperation; + this.interfaceLifecycleTypeOperation = interfaceLifecycleTypeOperation; + this.artifactToscaOperation = artifactToscaOperation; + } + @Autowired public void setUserAdmin(UserBusinessLogic userAdmin) { this.userAdmin = userAdmin; } + @Autowired public void setUserValidations(UserValidations userValidations) { this.userValidations = userValidations; } + @Autowired public void setComponentsUtils(ComponentsUtils componentsUtils) { this.componentsUtils = componentsUtils; } + @Autowired + public void setJanusGraphDao(JanusGraphDao janusGraphDao) { + this.janusGraphDao = janusGraphDao; + } + + @Autowired + public void setApplicationDataTypeCache(ApplicationDataTypeCache applicationDataTypeCache) { + this.applicationDataTypeCache = applicationDataTypeCache; + } + + @Autowired + public void setJanusGraphGenericDao(JanusGraphGenericDao janusGraphGenericDao) { + this.janusGraphGenericDao = janusGraphGenericDao; + } + + @Autowired public void setGraphLockOperation(IGraphLockOperation graphLockOperation) { this.graphLockOperation = graphLockOperation; } + @Autowired public void setToscaOperationFacade(ToscaOperationFacade toscaOperationFacade) { this.toscaOperationFacade = toscaOperationFacade; } - public void setPolicyTypeOperation(PolicyTypeOperation policyTypeOperation) { + @Autowired + void setPolicyTypeOperation(PolicyTypeOperation policyTypeOperation) { this.policyTypeOperation = policyTypeOperation; } + @Autowired public void setDataTypeCache(ApplicationDataTypeCache dataTypeCache) { this.dataTypeCache = dataTypeCache; } + @Autowired public void setPropertyOperation(PropertyOperation propertyOperation) { this.propertyOperation = propertyOperation; } - public void setInterfaceOperation(InterfaceOperation interfaceOperation) { - this.interfaceOperation = interfaceOperation; - } - public void setInterfaceOperationBusinessLogic(InterfaceOperationBusinessLogic interfaceOperationBusinessLogic) { - this.interfaceOperationBusinessLogic = interfaceOperationBusinessLogic; - } - - User validateUserNotEmpty(User user, String ecompErrorContext) { return userValidations.validateUserNotEmpty(user, ecompErrorContext); } @@ -213,11 +198,6 @@ public abstract class BaseBusinessLogic { userValidations.validateUserExist(userId, ecompErrorContext); } - public void setGroupTypeOperation(IGroupTypeOperation groupTypeOperation) { - this.groupTypeOperation = groupTypeOperation; - } - - Either validateUserExistsActionStatus(String userId, String ecompErrorContext) { return userValidations.validateUserExistsActionStatus(userId, ecompErrorContext); } @@ -429,10 +409,6 @@ public abstract class BaseBusinessLogic { return null; } - // For UT - public void setJanusGraphGenericDao(JanusGraphDao janusGraphDao) { - this.janusGraphDao = janusGraphDao; - } protected Either, ResponseFormat> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) { Either, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogic.java index 425458f518..63aa08063a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilitiesBusinessLogic.java @@ -33,10 +33,17 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations; 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.utils.ModelConverter; 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.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; @@ -62,17 +69,32 @@ public class CapabilitiesBusinessLogic extends BaseBusinessLogic { private static final String GET_CAPABILITIES = "getCapabilities"; private static final String EXCEPTION_OCCURRED_DURING_CAPABILITIES = "Exception occurred during {}. Response is {}"; - @Autowired + private final ICapabilityTypeOperation capabilityTypeOperation; + private CapabilitiesOperation capabilitiesOperation; - @Autowired private CapabilitiesValidation capabilitiesValidation; + @Autowired - private ICapabilityTypeOperation capabilityTypeOperation; + public CapabilitiesBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ICapabilityTypeOperation capabilityTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.capabilityTypeOperation = capabilityTypeOperation; + } + @Autowired public void setCapabilitiesValidation(CapabilitiesValidation capabilitiesValidation) { this.capabilitiesValidation = capabilitiesValidation; } + @Autowired public void setCapabilitiesOperation(CapabilitiesOperation capabilitiesOperation) { this.capabilitiesOperation = capabilitiesOperation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java index b54a8050ce..ebe79f57f8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java @@ -30,6 +30,7 @@ import org.openecomp.sdc.be.model.utils.TypeCompareUtils; import org.openecomp.sdc.be.utils.TypeUtils; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; @@ -42,10 +43,10 @@ public class CapabilityTypeImportManager { private final CapabilityTypeOperation capabilityTypeOperation; private final CommonImportManager commonImportManager; + @Autowired public CapabilityTypeImportManager(CapabilityTypeOperation capabilityTypeOperation, CommonImportManager commonImportManager) { this.capabilityTypeOperation = capabilityTypeOperation; this.commonImportManager = commonImportManager; - } public Either>, ResponseFormat> createCapabilityTypes(String capabilityTypesYml) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java index 1de92e2e15..4dd012fcf7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java @@ -39,6 +39,7 @@ import org.openecomp.sdc.be.model.operations.api.TypeOperations; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; @@ -59,6 +60,7 @@ public class CommonImportManager { private final ComponentsUtils componentsUtils; private final PropertyOperation propertyOperation; + @Autowired public CommonImportManager(ComponentsUtils componentsUtils, PropertyOperation propertyOperation) { this.componentsUtils = componentsUtils; this.propertyOperation = propertyOperation; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java index ccccd58ce7..785b545d7e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java @@ -66,7 +66,14 @@ import org.openecomp.sdc.be.model.Operation; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.resources.data.ComponentMetadataData; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; @@ -84,15 +91,28 @@ import org.springframework.beans.factory.annotation.Autowired; public abstract class ComponentBusinessLogic extends BaseBusinessLogic { - @Autowired - protected ArtifactsBusinessLogic artifactsBusinessLogic; + protected final ArtifactsBusinessLogic artifactsBusinessLogic; + + protected final GroupBusinessLogic groupBusinessLogic; - @Autowired private GenericTypeBusinessLogic genericTypeBusinessLogic; - @Autowired - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + public ComponentBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsBusinessLogic artifactsBusinessLogic, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.artifactsBusinessLogic = artifactsBusinessLogic; + this.groupBusinessLogic = groupBusinessLogic; + } + @Autowired public void setGenericTypeBusinessLogic(GenericTypeBusinessLogic genericTypeBusinessLogic) { this.genericTypeBusinessLogic = genericTypeBusinessLogic; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index eebbb0a2bf..fd2af0bb7c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -76,13 +76,20 @@ 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.ArtifactsOperations; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ForwardingPathOperation; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter; import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation; +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.DaoStatusConverter; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; @@ -122,38 +129,46 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class.getName()); private static final String VF_MODULE = "org.openecomp.groups.VfModule"; - public static final String TRY_TO_CREATE_ENTRY_ON_GRAPH = "Try to create entry on graph"; + private static final String TRY_TO_CREATE_ENTRY_ON_GRAPH = "Try to create entry on graph"; private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech"; private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = {{"k8s", "azure", "aws"}, /* cloud specific technology */ {"charts", "day0", "configtemplate"} /*cloud specific sub type*/}; - public static final String FAILED_TO_CREATE_ENTRY_ON_GRAPH_FOR_COMPONENT_INSTANCE = "Failed to create entry on graph for component instance {}"; - public static final String ENTITY_ON_GRAPH_IS_CREATED = "Entity on graph is created."; - public static final String INVALID_COMPONENT_TYPE = "invalid component type"; - public static final String FAILED_TO_RETRIEVE_COMPONENT_COMPONENT_ID = "Failed to retrieve component, component id {}"; - public static final String FAILED_TO_LOCK_SERVICE = "Failed to lock service {}"; - public static final String CREATE_OR_UPDATE_PROPERTY_VALUE = "CreateOrUpdatePropertyValue"; - public static final String FAILED_TO_COPY_COMP_INSTANCE_TO_CANVAS = "Failed to copy the component instance to the canvas"; - public static final String COPY_COMPONENT_INSTANCE_OK = "Copy component instance OK"; + private static final String FAILED_TO_CREATE_ENTRY_ON_GRAPH_FOR_COMPONENT_INSTANCE = "Failed to create entry on graph for component instance {}"; + private static final String ENTITY_ON_GRAPH_IS_CREATED = "Entity on graph is created."; + private static final String INVALID_COMPONENT_TYPE = "invalid component type"; + private static final String FAILED_TO_RETRIEVE_COMPONENT_COMPONENT_ID = "Failed to retrieve component, component id {}"; + private static final String FAILED_TO_LOCK_SERVICE = "Failed to lock service {}"; + private static final String CREATE_OR_UPDATE_PROPERTY_VALUE = "CreateOrUpdatePropertyValue"; + private static final String FAILED_TO_COPY_COMP_INSTANCE_TO_CANVAS = "Failed to copy the component instance to the canvas"; + private static final String COPY_COMPONENT_INSTANCE_OK = "Copy component instance OK"; + + private final IComponentInstanceOperation componentInstanceOperation; + private final ArtifactsBusinessLogic artifactBusinessLogic; + private final ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL; + private final ComponentInstanceChangeOperationOrchestrator onChangeInstanceOperationOrchestrator; + private final ForwardingPathOperation forwardingPathOperation; + private final NodeFilterOperation serviceFilterOperation; @Autowired - private IComponentInstanceOperation componentInstanceOperation; - - @Autowired - private ArtifactsBusinessLogic artifactBusinessLogic; - - @Autowired - private ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL; - - @Autowired - private ComponentInstanceChangeOperationOrchestrator onChangeInstanceOperationOrchestrator; - - @Autowired - private ForwardingPathOperation forwardingPathOperation; - - @Autowired - private NodeFilterOperation serviceFilterOperation; - - public ComponentInstanceBusinessLogic() { + public ComponentInstanceBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + IComponentInstanceOperation componentInstanceOperation, ArtifactsBusinessLogic artifactBusinessLogic, + ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL, + ComponentInstanceChangeOperationOrchestrator onChangeInstanceOperationOrchestrator, + ForwardingPathOperation forwardingPathOperation, NodeFilterOperation serviceFilterOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.componentInstanceOperation = componentInstanceOperation; + this.artifactBusinessLogic = artifactBusinessLogic; + this.compInstMergeDataBL = compInstMergeDataBL; + this.onChangeInstanceOperationOrchestrator = onChangeInstanceOperationOrchestrator; + this.forwardingPathOperation = forwardingPathOperation; + this.serviceFilterOperation = serviceFilterOperation; } public Either createComponentInstance(String containerComponentParam, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java index 4e7f86aed6..ba256d4c84 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java @@ -46,8 +46,7 @@ import java.util.stream.Collectors; */ @Component("compositionBusinessLogic") public class CompositionBusinessLogic { - @Autowired - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; private static final int VFC_CANVAS_ELEMENT_SIZE = 50; private static final int CP_CANVAS_ELEMENT_SIZE = 21; @@ -56,6 +55,11 @@ public class CompositionBusinessLogic { private static final int SPACE_BETWEEN_ELEMENTS = VFC_CANVAS_ELEMENT_SIZE * 4; private static final double CP_RADIUS_FACTOR = 0.4; + @Autowired + public CompositionBusinessLogic(ComponentInstanceBusinessLogic componentInstanceBusinessLogic) { + this.componentInstanceBusinessLogic = componentInstanceBusinessLogic; + } + enum RelativePosition { LEFT, RIGHT, UP, DOWN }; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java index 213c4b67db..5c7c35a6b5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java @@ -26,14 +26,22 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ConsumerDefinition; import org.openecomp.sdc.be.model.User; +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.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.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; @@ -44,13 +52,25 @@ public class ConsumerBusinessLogic extends BaseBusinessLogic { private static final String CONSUMER_NAME = "Consumer name"; private static final String CONSUMER_SALT = "Consumer salt"; private static final String CONSUMER_PW = "Consumer password"; - public static final String AUDIT_BEFORE_SENDING_RESPONSE = "audit before sending response"; + private static final String AUDIT_BEFORE_SENDING_RESPONSE = "audit before sending response"; @javax.annotation.Resource private ConsumerOperation consumerOperation; private static final Logger log = Logger.getLogger(ConsumerBusinessLogic.class.getName()); + @Autowired + public ConsumerBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + } + public Either createConsumer(User user, ConsumerDefinition consumer) { Either userValidation = validateUser(user, consumer, AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java index dbfe7d8b71..d29a2c4458 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java @@ -47,24 +47,24 @@ public class CsarValidationUtils { private static final String CSAR_VERSION = "CSAR-Version"; private static final String CREATED_BY = "Created-By"; private static final String NEW_LINE_DELM = "\n"; - public static final String TOSCA_METADATA = "TOSCA-Metadata"; - public static final String TOSCA_FILE = "TOSCA.meta"; - public static final String DEL_PATTERN = "([/\\\\]+)"; - public static final String TOSCA_METADATA_PATH_PATTERN = TOSCA_METADATA + + private static final String TOSCA_METADATA = "TOSCA-Metadata"; + private static final String TOSCA_FILE = "TOSCA.meta"; + private static final String DEL_PATTERN = "([/\\\\]+)"; + private static final String TOSCA_METADATA_PATH_PATTERN = TOSCA_METADATA + // Artifact Group (i.e Deployment/Informational) DEL_PATTERN + TOSCA_FILE; - public static final String TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions"; + private static final String TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions"; private static final String[] TOSCA_METADATA_FIELDS = { TOSCA_META_FILE_VERSION, CSAR_VERSION, CREATED_BY, TOSCA_META_ENTRY_DEFINITIONS }; - public static final String ARTIFACTS_METADATA_FILE = "HEAT.meta"; - public static final String TOSCA_CSAR_EXTENSION = ".csar"; - public static final String TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID = "TOSCA-Metadata/TOSCA.meta file is not in expected key-value form in csar, csar ID {}"; - public static final String TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID = "TOSCA-Metadata/TOSCA.meta file not in expected key-value form in CSAR with id "; - public static final String CSAR_INTERNALS_ARE_INVALID = "CSAR internals are invalid"; - public static final String ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID = "Entry-Definitions entry not found in TOSCA-Metadata/TOSCA.meta file, csar ID {}"; - public static final String FILE_NOT_FOUND_IN_CSAR_WITH_ID = " file not found in CSAR with id "; - public static final String CSAR_STRUCTURE_IS_INVALID = "CSAR structure is invalid"; - public static final String ENTRY_DEFINITIONS = "Entry-Definitions "; + private static final String ARTIFACTS_METADATA_FILE = "HEAT.meta"; + private static final String TOSCA_CSAR_EXTENSION = ".csar"; + private static final String TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID = "TOSCA-Metadata/TOSCA.meta file is not in expected key-value form in csar, csar ID {}"; + private static final String TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID = "TOSCA-Metadata/TOSCA.meta file not in expected key-value form in CSAR with id "; + private static final String CSAR_INTERNALS_ARE_INVALID = "CSAR internals are invalid"; + private static final String ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID = "Entry-Definitions entry not found in TOSCA-Metadata/TOSCA.meta file, csar ID {}"; + private static final String FILE_NOT_FOUND_IN_CSAR_WITH_ID = " file not found in CSAR with id "; + private static final String CSAR_STRUCTURE_IS_INVALID = "CSAR structure is invalid"; + private static final String ENTRY_DEFINITIONS = "Entry-Definitions "; private static final Pattern floatPattern = Pattern.compile("^\\d{1}[.]\\d{1}$"); /** diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogic.java index e020876b3b..5af7cf660b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeBusinessLogic.java @@ -24,7 +24,15 @@ import fj.data.Either; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.DataTypeDefinition; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import java.util.ArrayList; @@ -34,6 +42,18 @@ import java.util.Optional; @org.springframework.stereotype.Component("dataTypeBusinessLogic") public class DataTypeBusinessLogic extends BaseBusinessLogic { + @Autowired + public DataTypeBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + } + /** * Get a list of data types that the Component has. * diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java index 4cf7c44e85..5d9a06cc4c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DistributionMonitoringBusinessLogic.java @@ -28,6 +28,13 @@ import org.openecomp.sdc.be.info.DistributionStatusInfo; import org.openecomp.sdc.be.info.DistributionStatusListResponse; import org.openecomp.sdc.be.info.DistributionStatusOfServiceInfo; import org.openecomp.sdc.be.info.DistributionStatusOfServiceListResponce; +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; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent; @@ -52,11 +59,20 @@ public class DistributionMonitoringBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(ArtifactsBusinessLogic.class.getName()); + private final AuditCassandraDao cassandraDao; @Autowired - private AuditCassandraDao cassandraDao; - - public DistributionMonitoringBusinessLogic() { + public DistributionMonitoringBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + AuditCassandraDao cassandraDao, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.cassandraDao = cassandraDao; } public Either getListOfDistributionStatus(String did, String userId) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java index 91d7fa6034..ca2e4a8078 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java @@ -46,9 +46,15 @@ import org.openecomp.sdc.be.model.catalog.CatalogComponent; 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.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.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; +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.ComponentMetadataData; import org.openecomp.sdc.be.resources.data.ResourceMetadataData; @@ -68,6 +74,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; import static org.apache.commons.lang.BooleanUtils.isTrue; @@ -81,11 +88,24 @@ public class ElementBusinessLogic extends BaseBusinessLogic { private static final String COMPONENT_TYPE_IS_INVALID = "Component type {} is invalid"; private static final String VALIDATION_OF_USER_ROLE_FAILED_USER_ID = "Validation of user role failed, userId {}"; - @javax.annotation.Resource - private IElementOperation elementOperation; - - @javax.annotation.Resource - private UserBusinessLogic userAdminManager; + private final IElementOperation elementOperation; + private final UserBusinessLogic userAdminManager; + + @Autowired + public ElementBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation, IElementOperation elementOperation, + UserBusinessLogic userAdminManager) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.elementOperation = elementOperation; + this.userAdminManager = userAdminManager; + } /** * @@ -1261,8 +1281,7 @@ public class ElementBusinessLogic extends BaseBusinessLogic { Class categoryClazz = categoryType == NodeTypeEnum.ServiceNewCategory ? CategoryData.class : SubCategoryData.class; Map props = new HashMap<>(); props.put(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty(), ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); - Either, JanusGraphOperationStatus> getCategory = janusGraphGenericDao - .getByCriteria(categoryType, props, categoryClazz); + Either, JanusGraphOperationStatus> getCategory = janusGraphGenericDao.getByCriteria(categoryType, props, categoryClazz); if (getCategory.isRight()) { return Either.right(StorageOperationStatus.CATEGORY_NOT_FOUND); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogic.java index fed1eb7fe9..d95045b87b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GenericArtifactBrowserBusinessLogic.java @@ -34,13 +34,30 @@ import org.onap.sdc.gab.GABServiceImpl; import org.onap.sdc.gab.model.GABQuery; import org.onap.sdc.gab.model.GABResult; import org.onap.sdc.gab.model.GABResults; +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; +import org.springframework.beans.factory.annotation.Autowired; @org.springframework.stereotype.Component public class GenericArtifactBrowserBusinessLogic extends BaseBusinessLogic { private GABService gabService; - public GenericArtifactBrowserBusinessLogic() { + @Autowired + public GenericArtifactBrowserBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); gabService = new GABServiceImpl(); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java index 7c5a596319..1f906aefac 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java @@ -31,7 +31,6 @@ import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.tuple.ImmutablePair; 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.lock.LockingTransactional; import org.openecomp.sdc.be.components.impl.policy.PolicyTargetsUpdateHandler; import org.openecomp.sdc.be.components.utils.Utils; @@ -54,10 +53,17 @@ import org.openecomp.sdc.be.info.GroupDefinitionInfo; import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.PropertyDefinition.GroupInstancePropertyValueUpdateBehavior; import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.GroupsOperation; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation; +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.DaoStatusConverter; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.log.wrappers.Logger; @@ -92,15 +98,29 @@ public class GroupBusinessLogic extends BaseBusinessLogic { private static final String DELETE_GROUP = "DeleteGroup"; private static final Logger log = Logger.getLogger(GroupBusinessLogic.class); - @Autowired - private AccessValidations accessValidations; + + private final AccessValidations accessValidations; + private final PolicyTargetsUpdateHandler policyTargetsUpdateHandler; @javax.annotation.Resource - @Autowired - private GroupsOperation groupsOperation; + private final GroupsOperation groupsOperation; + @Autowired - PolicyTargetsUpdateHandler policyTargetsUpdateHandler; + public GroupBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, AccessValidations accessValidations, + GroupsOperation groupsOperation, PolicyTargetsUpdateHandler policyTargetsUpdateHandler, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.accessValidations = accessValidations; + this.groupsOperation = groupsOperation; + this.policyTargetsUpdateHandler = policyTargetsUpdateHandler; + } private String getComponentTypeForResponse(org.openecomp.sdc.be.model.Component component) { String componentTypeForResponse = "SERVICE"; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java index 726c038e2b..7001c0c05f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java @@ -43,6 +43,7 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.YamlProcessor; +import org.springframework.stereotype.Component; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; @@ -60,23 +61,22 @@ import static org.apache.commons.collections.CollectionUtils.isEmpty; import static org.openecomp.sdc.be.components.impl.ResourceImportManager.PROPERTY_NAME_PATTERN_IGNORE_LENGTH; import static org.openecomp.sdc.be.datatypes.elements.Annotation.setAnnotationsName; - +@Component public final class ImportUtils { - private static final CustomResolver customResolver = new CustomResolver(); private static final Yaml strictYamlLoader = new YamlLoader().getStrictYamlLoader(); - @Autowired protected static ComponentsUtils componentsUtils; - @Autowired - private ExceptionUtils exceptionUtils; - private static final Logger log = Logger.getLogger(ImportUtils.class); private ImportUtils() { + } + @Autowired + public static void setComponentsUtils(ComponentsUtils componentsUtils) { + ImportUtils.componentsUtils = componentsUtils; } private static class CustomResolver extends Resolver { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java index 8aec0cdfe2..bce60066f5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java @@ -60,13 +60,21 @@ import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +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.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component("inputsBusinessLogic") @@ -82,12 +90,26 @@ public class InputsBusinessLogic extends BaseBusinessLogic { private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP = "Going to execute rollback on create group."; private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP = "Going to execute commit on create group."; - @Inject - private PropertyDeclarationOrchestrator propertyDeclarationOrchestrator; - @Inject - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; - @Inject - private DataTypeBusinessLogic dataTypeBusinessLogic; + private final PropertyDeclarationOrchestrator propertyDeclarationOrchestrator; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + private final DataTypeBusinessLogic dataTypeBusinessLogic; + + @Autowired + public InputsBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + PropertyDeclarationOrchestrator propertyDeclarationOrchestrator, + ComponentInstanceBusinessLogic componentInstanceBusinessLogic, DataTypeBusinessLogic dataTypeBusinessLogic, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.propertyDeclarationOrchestrator = propertyDeclarationOrchestrator; + this.componentInstanceBusinessLogic = componentInstanceBusinessLogic; + this.dataTypeBusinessLogic = dataTypeBusinessLogic; + } /** * associate inputs to a given component with paging diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java index 7815b81755..add5df225c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java @@ -61,7 +61,14 @@ import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Operation; import org.openecomp.sdc.be.model.User; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.exception.ResponseFormat; @@ -81,11 +88,22 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { private static final String CREATE_INTERFACE_OPERATION = "createInterfaceOperation"; private static final String UPDATE_INTERFACE_OPERATION = "updateInterfaceOperation"; - @Autowired - private ArtifactCassandraDao artifactCassandraDao; + private final ArtifactCassandraDao artifactCassandraDao; + private final InterfaceOperationValidation interfaceOperationValidation; @Autowired - private InterfaceOperationValidation interfaceOperationValidation; + public InterfaceOperationBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ArtifactCassandraDao artifactCassandraDao, + InterfaceOperationValidation interfaceOperationValidation, ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.artifactCassandraDao = artifactCassandraDao; + this.interfaceOperationValidation = interfaceOperationValidation; + } public Either, ResponseFormat> deleteInterfaceOperation(String componentId, String interfaceId, List operationsToDelete, User user, boolean lock) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java index 444ac0b0cf..e622a3037a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java @@ -29,7 +29,6 @@ import org.openecomp.sdc.be.utils.TypeUtils; public class NodeFilterUploadCreator { - public UploadNodeFilterInfo createNodeFilterData(Object obj) { if (!(obj instanceof Map)) { return null; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java index 452cd3809b..17233d6663 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java @@ -52,10 +52,18 @@ import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.PolicyTypeDefinition; import org.openecomp.sdc.be.model.Resource; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; /** * Provides specified business logic to create, retrieve, update, delete a policy @@ -65,20 +73,23 @@ public class PolicyBusinessLogic extends BaseBusinessLogic { private static final String FAILED_TO_VALIDATE_COMPONENT = "#{} - failed to validate the component {} before policy processing. "; private static final String DECLARE_PROPERTIES_TO_POLICIES = "declare properties to policies"; - private static final String EXECUTE_ROLLBACK = "execute rollback"; - private static final String EXECUTE_COMMIT = "execute commit"; private static final Logger log = Logger.getLogger(PolicyBusinessLogic.class); - @Inject private PropertyDeclarationOrchestrator propertyDeclarationOrchestrator; - public PolicyBusinessLogic() { - } - - public PolicyBusinessLogic(PropertyDeclarationOrchestrator propertyDeclarationOrchestrator) { - this.propertyDeclarationOrchestrator = propertyDeclarationOrchestrator; + @Autowired + public PolicyBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); } + @Autowired public void setPropertyDeclarationOrchestrator(PropertyDeclarationOrchestrator propertyDeclarationOrchestrator) { this.propertyDeclarationOrchestrator = propertyDeclarationOrchestrator; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java index 81c4af8b98..8f3d17b74d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java @@ -35,7 +35,14 @@ 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.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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; @@ -61,10 +68,23 @@ public class ProductBusinessLogic extends ComponentBusinessLogic { private static List updateRoles; private static List contactsRoles; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + @Autowired - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + public ProductBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsBusinessLogic artifactsBusinessLogic, + ComponentInstanceBusinessLogic componentInstanceBusinessLogic, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, + interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation); + this.componentInstanceBusinessLogic = componentInstanceBusinessLogic; - public ProductBusinessLogic() { creationRoles = new ArrayList<>(); updateRoles = new ArrayList<>(); contactsRoles = new ArrayList<>(); @@ -76,7 +96,6 @@ public class ProductBusinessLogic extends ComponentBusinessLogic { contactsRoles.add(Role.PRODUCT_MANAGER); } - public Either createProduct(Product product, User user) { AuditingActionEnum actionEnum = AuditingActionEnum.CREATE_RESOURCE; ComponentTypeEnum typeEnum = ComponentTypeEnum.PRODUCT; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java index f3a40ad9f7..950971ef0b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java @@ -49,8 +49,14 @@ import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.IComplexDefaultValue; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter; @@ -59,6 +65,7 @@ import org.openecomp.sdc.be.resources.data.EntryData; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.context.WebApplicationContext; @org.springframework.stereotype.Component("propertyBusinessLogic") @@ -70,6 +77,18 @@ public class PropertyBusinessLogic extends BaseBusinessLogic { private static final String EMPTY_VALUE = null; + @Autowired + public PropertyBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + } + protected static IElementOperation getElementDao(Class class1, ServletContext context) { WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeBusinessLogic.java index 695d82f5d9..5ca6255db8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeBusinessLogic.java @@ -32,11 +32,15 @@ import org.springframework.stereotype.Component; @Component("relationshipTypeBusinessLogic") public class RelationshipTypeBusinessLogic { - @Autowired - private RelationshipTypeOperation relationshipTypeOperation; + private final RelationshipTypeOperation relationshipTypeOperation; + protected final ComponentsUtils componentsUtils; @Autowired - protected ComponentsUtils componentsUtils; + public RelationshipTypeBusinessLogic(RelationshipTypeOperation relationshipTypeOperation, + ComponentsUtils componentsUtils) { + this.relationshipTypeOperation = relationshipTypeOperation; + this.componentsUtils = componentsUtils; + } public Either, ResponseFormat> getAllRelationshipTypes() { Either, JanusGraphOperationStatus> allRelationshipTypes = diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java index 19dd0f41a3..a2da4cca2f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java @@ -29,6 +29,7 @@ import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.RelationshipTypeOperation; import org.openecomp.sdc.be.utils.TypeUtils; import org.openecomp.sdc.exception.ResponseFormat; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component("relationshipTypeImportManager") @@ -36,12 +37,14 @@ public class RelationshipTypeImportManager { private final RelationshipTypeOperation relationshipTypeOperation; private final CommonImportManager commonImportManager; - private ComponentsUtils componentsUtils; + private final ComponentsUtils componentsUtils; + @Autowired public RelationshipTypeImportManager(RelationshipTypeOperation relationshipTypeOperation, - CommonImportManager commonImportManager) { + CommonImportManager commonImportManager, ComponentsUtils componentsUtils) { this.relationshipTypeOperation = relationshipTypeOperation; this.commonImportManager = commonImportManager; + this.componentsUtils = componentsUtils; } public Either>, ResponseFormat> createRelationshipTypes( diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogic.java index c2d9c95cf7..067b5db97c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementBusinessLogic.java @@ -25,8 +25,15 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.RequirementDefinition; import org.openecomp.sdc.be.model.User; +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.RequirementOperation; +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.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,16 +60,27 @@ public class RequirementBusinessLogic extends BaseBusinessLogic { private static final String EXCEPTION_OCCURRED_DURING_REQUIREMENTS = "Exception occurred during {}. Response is {}"; - @Autowired private RequirementOperation requirementOperation; - @Autowired private RequirementValidation requirementValidation; + @Autowired + public RequirementBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + } + @Autowired public void setRequirementOperation(RequirementOperation requirementOperation) { this.requirementOperation = requirementOperation; } + @Autowired public void setRequirementValidation(RequirementValidation requirementValidation) { this.requirementValidation = requirementValidation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 0118a7943d..5355ad95df 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -22,7 +22,6 @@ package org.openecomp.sdc.be.components.impl; - import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; @@ -127,13 +126,19 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; +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.utils.ModelConverter; import org.openecomp.sdc.be.model.operations.StorageException; 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.DaoStatusConverter; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; @@ -156,6 +161,7 @@ import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.web.context.WebApplicationContext; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -178,54 +184,53 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private static final String COMPONENT_INSTANCE_WITH_NAME = "component instance with name "; private static final String COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE = "component instance with name {} in resource {} "; - - @Autowired - private ICapabilityTypeOperation capabilityTypeOperation = null; - - @Autowired - private IInterfaceLifecycleOperation interfaceTypeOperation = null; - - @Autowired + private ICapabilityTypeOperation capabilityTypeOperation; + private IInterfaceLifecycleOperation interfaceTypeOperation; private LifecycleBusinessLogic lifecycleBusinessLogic; - @Autowired - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; - - @Autowired - private ResourceImportManager resourceImportManager; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + private final ResourceImportManager resourceImportManager; + private final InputsBusinessLogic inputsBusinessLogic; + private final CompositionBusinessLogic compositionBusinessLogic; + private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic; + private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic; + private final MergeInstanceUtils mergeInstanceUtils; + private final UiComponentDataConverter uiComponentDataConverter; + private final CsarBusinessLogic csarBusinessLogic; @Autowired - private InputsBusinessLogic inputsBusinessLogic; - - @Autowired - private CompositionBusinessLogic compositionBusinessLogic; - - @Autowired - private ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic; - - @Autowired - private CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic; - - @Autowired - private MergeInstanceUtils mergeInstanceUtils; - - @Autowired - private UiComponentDataConverter uiComponentDataConverter; - - @Autowired - private CsarBusinessLogic csarBusinessLogic; - - /** - * Default constructor - */ - public ResourceBusinessLogic() { - log.debug("ResourceBusinessLogic started"); + public ResourceBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsBusinessLogic artifactsBusinessLogic, + ComponentInstanceBusinessLogic componentInstanceBusinessLogic, @Lazy ResourceImportManager resourceImportManager, + InputsBusinessLogic inputsBusinessLogic, CompositionBusinessLogic compositionBusinessLogic, + ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic, + CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic, MergeInstanceUtils mergeInstanceUtils, + UiComponentDataConverter uiComponentDataConverter, CsarBusinessLogic csarBusinessLogic, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, + interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation); + this.componentInstanceBusinessLogic = componentInstanceBusinessLogic; + this.resourceImportManager = resourceImportManager; + this.inputsBusinessLogic = inputsBusinessLogic; + this.compositionBusinessLogic = compositionBusinessLogic; + this.resourceDataMergeBusinessLogic = resourceDataMergeBusinessLogic; + this.csarArtifactsAndGroupsBusinessLogic = csarArtifactsAndGroupsBusinessLogic; + this.mergeInstanceUtils = mergeInstanceUtils; + this.uiComponentDataConverter = uiComponentDataConverter; + this.csarBusinessLogic = csarBusinessLogic; } public LifecycleBusinessLogic getLifecycleBusinessLogic() { return lifecycleBusinessLogic; } + @Autowired public void setLifecycleManager(LifecycleBusinessLogic lifecycleBusinessLogic) { this.lifecycleBusinessLogic = lifecycleBusinessLogic; } @@ -234,14 +239,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return elementDao; } - public void setElementDao(IElementOperation elementDao) { - this.elementDao = elementDao; - } - public IUserBusinessLogic getUserAdmin() { return this.userAdmin; } + @Autowired public void setUserAdmin(UserBusinessLogic userAdmin) { this.userAdmin = userAdmin; } @@ -250,26 +252,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return this.componentsUtils; } + @Autowired public void setComponentsUtils(ComponentsUtils componentsUtils) { this.componentsUtils = componentsUtils; } - public ArtifactsBusinessLogic getArtifactsManager() { - return artifactsBusinessLogic; - } - - public void setArtifactsManager(ArtifactsBusinessLogic artifactsManager) { - this.artifactsBusinessLogic = artifactsManager; - } - public ApplicationDataTypeCache getApplicationDataTypeCache() { return applicationDataTypeCache; } + @Autowired public void setApplicationDataTypeCache(ApplicationDataTypeCache applicationDataTypeCache) { this.applicationDataTypeCache = applicationDataTypeCache; } + @Autowired public void setInterfaceTypeOperation(IInterfaceLifecycleOperation interfaceTypeOperation) { this.interfaceTypeOperation = interfaceTypeOperation; } @@ -4877,6 +4874,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return capabilityTypeOperation; } + @Autowired public void setCapabilityTypeOperation(ICapabilityTypeOperation capabilityTypeOperation) { this.capabilityTypeOperation = capabilityTypeOperation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java index dbb421b6a0..8dbf1ceff4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java @@ -73,32 +73,29 @@ import java.util.stream.Collectors; @Component("resourceImportManager") public class ResourceImportManager { + static final Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern.compile("[\\w\\-\\_\\d\\:]+"); private ServletContext servletContext; - @Autowired private AuditingManager auditingManager; - - @Autowired private ResourceBusinessLogic resourceBusinessLogic; - - @Autowired private IGraphLockOperation graphLockOperation; - - @Autowired - protected ComponentsUtils componentsUtils; - - public static final Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern - .compile("[\\w\\-\\_\\d\\:]+"); - @Autowired - protected CapabilityTypeOperation capabilityTypeOperation; - @Autowired protected ToscaOperationFacade toscaOperationFacade; + protected final ComponentsUtils componentsUtils; + private final CapabilityTypeOperation capabilityTypeOperation; + private ResponseFormatManager responseFormatManager; private static final Logger log = Logger.getLogger(ResourceImportManager.class); + @Autowired + public ResourceImportManager(ComponentsUtils componentsUtils, CapabilityTypeOperation capabilityTypeOperation) { + this.componentsUtils = componentsUtils; + this.capabilityTypeOperation = capabilityTypeOperation; + } + + @Autowired public void setToscaOperationFacade(ToscaOperationFacade toscaOperationFacade) { this.toscaOperationFacade = toscaOperationFacade; } @@ -979,6 +976,7 @@ public class ResourceImportManager { return resourceBusinessLogic; } + @Autowired public void setResourceBusinessLogic(ResourceBusinessLogic resourceBusinessLogic) { this.resourceBusinessLogic = resourceBusinessLogic; } @@ -987,6 +985,7 @@ public class ResourceImportManager { return graphLockOperation; } + @Autowired public void setGraphLockOperation(IGraphLockOperation graphLockOperation) { this.graphLockOperation = graphLockOperation; } @@ -995,6 +994,7 @@ public class ResourceImportManager { this.servletContext = servletContext; } + @Autowired public void setAuditingManager(AuditingManager auditingManager) { this.auditingManager = auditingManager; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java index 7f4ec46714..fc0380a108 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java @@ -117,11 +117,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.category.CategoryDefinition; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ForwardingPathOperation; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation; 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.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaFunctions; @@ -158,34 +163,49 @@ import javax.servlet.http.HttpServletRequest; @org.springframework.stereotype.Component("serviceBusinessLogic") public class ServiceBusinessLogic extends ComponentBusinessLogic { - private static final String CHANGE_SERVICE_DISTRIBUTION = "Change Service Distribution"; - private static final String THE_SERVICE_WITH_SYSTEM_NAME_LOCKED = "The service with system name {} locked. "; - private static final String FAILED_TO_LOCK_SERVICE_RESPONSE_IS = "Failed to lock service {}. Response is {}. "; - private static final String AUDIT_BEFORE_SENDING_RESPONSE = "audit before sending response"; - private static final Logger log = Logger.getLogger(ServiceBusinessLogic.class); - private static final String INITIAL_VERSION = "0.1"; - private static final String STATUS_SUCCESS_200 = "200"; - private static final String STATUS_DEPLOYED = "DEPLOYED"; + private static final String CHANGE_SERVICE_DISTRIBUTION = "Change Service Distribution"; + private static final String THE_SERVICE_WITH_SYSTEM_NAME_LOCKED = "The service with system name {} locked. "; + private static final String FAILED_TO_LOCK_SERVICE_RESPONSE_IS = "Failed to lock service {}. Response is {}. "; + private static final String AUDIT_BEFORE_SENDING_RESPONSE = "audit before sending response"; + private static final Logger log = Logger.getLogger(ServiceBusinessLogic.class); + private static final String INITIAL_VERSION = "0.1"; + private static final String STATUS_SUCCESS_200 = "200"; + private static final String STATUS_DEPLOYED = "DEPLOYED"; - @Autowired - private IDistributionEngine distributionEngine; - @Autowired + private ForwardingPathOperation forwardingPathOperation; private AuditCassandraDao auditCassandraDao; - @Autowired - private ComponentInstanceBusinessLogic componentInstanceBusinessLogic; - @Autowired - private ServiceDistributionValidation serviceDistributionValidation; + + private final IDistributionEngine distributionEngine; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; + private final ServiceDistributionValidation serviceDistributionValidation; + private final ForwardingPathValidator forwardingPathValidator; + private final UiComponentDataConverter uiComponentDataConverter; + private final NodeFilterOperation serviceFilterOperation; + private final NodeFilterValidator serviceFilterValidator; @Autowired - private ForwardingPathOperation forwardingPathOperation; - @Autowired - private ForwardingPathValidator forwardingPathValidator; - @Autowired - private UiComponentDataConverter uiComponentDataConverter; - @Autowired - private NodeFilterOperation serviceFilterOperation; - @Autowired - private NodeFilterValidator serviceFilterValidator; + public ServiceBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + GroupBusinessLogic groupBusinessLogic, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, + ArtifactsBusinessLogic artifactsBusinessLogic, + IDistributionEngine distributionEngine, ComponentInstanceBusinessLogic componentInstanceBusinessLogic, + ServiceDistributionValidation serviceDistributionValidation, ForwardingPathValidator forwardingPathValidator, + UiComponentDataConverter uiComponentDataConverter, NodeFilterOperation serviceFilterOperation, + NodeFilterValidator serviceFilterValidator, ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, + interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation); + this.distributionEngine = distributionEngine; + this.componentInstanceBusinessLogic = componentInstanceBusinessLogic; + this.serviceDistributionValidation = serviceDistributionValidation; + this.forwardingPathValidator = forwardingPathValidator; + this.uiComponentDataConverter = uiComponentDataConverter; + this.serviceFilterOperation = serviceFilterOperation; + this.serviceFilterValidator = serviceFilterValidator; + } public Either changeServiceDistributionState(String serviceId, String state, LifecycleChangeInfoWithAction commentObj, User user) { @@ -1023,10 +1043,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { return Either.right(responseFormat); } - public void setElementDao(IElementOperation elementDao) { - this.elementDao = elementDao; - } - + @Autowired public void setCassandraAuditingDao(AuditCassandraDao auditingDao) { this.auditCassandraDao = auditingDao; } @@ -1035,10 +1052,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { return artifactsBusinessLogic; } - public void setArtifactBl(ArtifactsBusinessLogic artifactBl) { - this.artifactsBusinessLogic = artifactBl; - } - public Either updateServiceMetadata(String serviceId, Service serviceUpdate, User user) { user = validateUser(user, "updateServiceMetadata", serviceUpdate, null, false); // validate user role @@ -2438,14 +2451,12 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { return Either.left(componentInstances); } + @Autowired public void setForwardingPathOperation(ForwardingPathOperation forwardingPathOperation) { this.forwardingPathOperation = forwardingPathOperation; } - @Override - public void setToscaOperationFacade(ToscaOperationFacade toscaOperationFacade) { - this.toscaOperationFacade = toscaOperationFacade; - }/** + /** * updates group instance with new property values in case of successful update of group instance related component instance will be updated with new modification time and related service will be updated with new last update date * */ @@ -2939,4 +2950,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { } return Either.left(serviceFilterResult); } + + + + } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java index 6b3be5921e..840fd03e0d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java @@ -45,11 +45,14 @@ public class GenericTypeBusinessLogic { private final static Logger log = Logger.getLogger(GenericTypeBusinessLogic.class); - @Autowired - private ComponentsUtils componentsUtils; + private final ComponentsUtils componentsUtils; + private final ToscaOperationFacade toscaOperationFacade; @Autowired - private ToscaOperationFacade toscaOperationFacade; + public GenericTypeBusinessLogic(ComponentsUtils componentsUtils, ToscaOperationFacade toscaOperationFacade) { + this.componentsUtils = componentsUtils; + this.toscaOperationFacade = toscaOperationFacade; + } /** * @param component the component of which to fetch its generic type diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java index 5826ef1254..409fad22b4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java @@ -59,7 +59,6 @@ public class CertificationChangeTransition extends LifeCycleTransition { private LifecycleStateEnum nextState; private LifeCycleTransitionEnum name; private AuditingActionEnum auditingAction; - private ArtifactsBusinessLogic artifactsManager; private NodeTemplateOperation nodeTemplateOperation; public CertificationChangeTransition(LifeCycleTransitionEnum name, ComponentsUtils componentUtils, ToscaElementLifecycleOperation lifecycleOperation, ToscaOperationFacade toscaOperationFacade, JanusGraphDao janusGraphDao) { @@ -103,14 +102,6 @@ public class CertificationChangeTransition extends LifeCycleTransition { return auditingAction; } - public ArtifactsBusinessLogic getArtifactsManager() { - return artifactsManager; - } - - public void setArtifactsManager(ArtifactsBusinessLogic artifactsManager) { - this.artifactsManager = artifactsManager; - } - public NodeTemplateOperation getNodeTemplateOperation() { return nodeTemplateOperation; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java index c7376d352b..91f4f5680a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java @@ -57,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; import java.util.HashMap; import java.util.Map; +import org.springframework.context.annotation.Lazy; @org.springframework.stereotype.Component("lifecycleBusinessLogic") public class LifecycleBusinessLogic { @@ -66,9 +67,6 @@ public class LifecycleBusinessLogic { @Autowired private IGraphLockOperation graphLockOperation = null; - @Autowired - private ArtifactsBusinessLogic artifactsBusinessLogic; - @Autowired private JanusGraphDao janusGraphDao; @@ -82,19 +80,20 @@ public class LifecycleBusinessLogic { @javax.annotation.Resource private ToscaElementLifecycleOperation lifecycleOperation; - @javax.annotation.Resource - ArtifactsBusinessLogic artifactsManager; @javax.annotation.Resource private ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder; - @javax.annotation.Resource + @Autowired + @Lazy private ServiceBusinessLogic serviceBusinessLogic; - @javax.annotation.Resource + @Autowired + @Lazy private ResourceBusinessLogic resourceBusinessLogic; - @javax.annotation.Resource + @Autowired + @Lazy private ProductBusinessLogic productBusinessLogic; @Autowired @@ -131,7 +130,6 @@ public class LifecycleBusinessLogic { UndoCheckoutTransition undoCheckoutOp = new UndoCheckoutTransition(componentUtils, lifecycleOperation, toscaOperationFacade, janusGraphDao); - undoCheckoutOp.setArtifactsBusinessLogic(artifactsBusinessLogic); stateTransitions.put(undoCheckoutOp.getName().name(), undoCheckoutOp); LifeCycleTransition checkinOp = new CheckinTransition(componentUtils, lifecycleOperation, toscaOperationFacade, @@ -156,7 +154,6 @@ public class LifecycleBusinessLogic { CertificationChangeTransition successCertification = new CertificationChangeTransition(LifeCycleTransitionEnum.CERTIFY, componentUtils, lifecycleOperation, toscaOperationFacade, janusGraphDao); - successCertification.setArtifactsManager(artifactsBusinessLogic); successCertification.setNodeTemplateOperation(nodeTemplateOperation); stateTransitions.put(successCertification.getName().name(), successCertification); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java index ff4746dcc3..5342367a09 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java @@ -21,7 +21,6 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -46,7 +45,6 @@ import java.util.Arrays; public class UndoCheckoutTransition extends LifeCycleTransition { private static final Logger log = Logger.getLogger(CheckoutTransition.class); - private ArtifactsBusinessLogic artifactsManager; public UndoCheckoutTransition(ComponentsUtils componentUtils, ToscaElementLifecycleOperation lifecycleOperation, ToscaOperationFacade toscaOperationFacade, JanusGraphDao janusGraphDao) { super(componentUtils, lifecycleOperation, toscaOperationFacade, janusGraphDao); @@ -70,14 +68,6 @@ public class UndoCheckoutTransition extends LifeCycleTransition { return AuditingActionEnum.UNDO_CHECKOUT_RESOURCE; } - public ArtifactsBusinessLogic getArtifactsBusinessLogic() { - return artifactsManager; - } - - public void setArtifactsBusinessLogic(ArtifactsBusinessLogic artifactsBusinessLogic) { - this.artifactsManager = artifactsBusinessLogic; - } - @Override public Either validateBeforeTransition(Component component, ComponentTypeEnum componentType, User modifier, User owner, LifecycleStateEnum oldState, LifecycleChangeInfoWithAction lifecycleChangeInfo) { String componentName = component.getComponentMetadataDefinition().getMetadataDataDefinition().getName(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java index 6c9f86fc20..a9e3aa4cbf 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java @@ -35,6 +35,8 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; +import org.springframework.context.annotation.Lazy; + /** * Created by chaya on 9/12/2017. */ @@ -44,6 +46,7 @@ public class ComponentInstanceMergeDataBusinessLogic { private static final Logger log = Logger.getLogger(ComponentInstanceMergeDataBusinessLogic.class); @Autowired + @Lazy private List componentInstancesMergeBLs; @Autowired diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogic.java index 06f37db6f3..03dcf76619 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/scheduledtasks/ComponentsCleanBusinessLogic.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.scheduledtasks; @@ -24,11 +26,19 @@ import com.google.common.annotations.VisibleForTesting; import fj.data.Either; import org.openecomp.sdc.be.components.impl.BaseBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; +import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; +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.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; @@ -41,17 +51,29 @@ import java.util.Map; @Component("componentsCleanBusinessLogic") public class ComponentsCleanBusinessLogic extends BaseBusinessLogic { - @Autowired - private ResourceBusinessLogic resourceBusinessLogic; - - @Autowired - private ServiceBusinessLogic serviceBusinessLogic; + private final ResourceBusinessLogic resourceBusinessLogic; + private final ServiceBusinessLogic serviceBusinessLogic; @VisibleForTesting - public static final String DELETE_LOCKER = "DELETE_LOCKER"; + static final String DELETE_LOCKER = "DELETE_LOCKER"; private static final Logger log = Logger.getLogger(ComponentsCleanBusinessLogic.class.getName()); + @Autowired + public ComponentsCleanBusinessLogic(IElementOperation elementDao, + IGroupOperation groupOperation, + IGroupInstanceOperation groupInstanceOperation, + IGroupTypeOperation groupTypeOperation, + InterfaceOperation interfaceOperation, + InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ResourceBusinessLogic resourceBusinessLogic, + ServiceBusinessLogic serviceBusinessLogic, + ArtifactsOperations artifactToscaOperation) { + super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + this.resourceBusinessLogic = resourceBusinessLogic; + this.serviceBusinessLogic = serviceBusinessLogic; + } + public Map, ResponseFormat>> cleanComponents(List componentsToClean){ return cleanComponents(componentsToClean, false); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java index 0d9e21a66a..3c3a3dbef7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java @@ -72,6 +72,7 @@ import javax.servlet.http.HttpServletRequest; import java.lang.reflect.Type; import java.util.Collections; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; @org.springframework.stereotype.Component("componentUtils") public class ComponentsUtils { @@ -84,6 +85,7 @@ public class ComponentsUtils { private final AuditingManager auditingManager; private final ResponseFormatManager responseFormatManager; + @Autowired public ComponentsUtils(AuditingManager auditingManager) { this.auditingManager = auditingManager; this.responseFormatManager = ResponseFormatManager.getInstance(); 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, 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 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 NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND); Either, 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, StorageOperationStatus> notFoundInterfaces = Either.right(StorageOperationStatus.NOT_FOUND); - when(lifecycleOperation.getAllInterfacesOfResource(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(notFoundInterfaces); - Either getUserResult = Either.left(USER); - when(userOperation.getUserData("jh0003", false)).thenReturn(getUserResult); - Either, 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, 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, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap); - when(artifactsOperations.getArtifacts(anyString())).thenReturn(artifacts); + when(artifactToscaOperation.getArtifacts(anyString())).thenReturn(artifacts); Either, StorageOperationStatus> allInterfacesOfResource = @@ -322,13 +330,11 @@ public class ArtifactBusinessLogicTest { artifactDefinitionMap.put(deploymentArtifactDefinition2.getArtifactLabel(), deploymentArtifactDefinition2); Either, StorageOperationStatus> artifacts = Either.left(artifactDefinitionMap); - when(artifactsOperations.getArtifacts(anyString())).thenReturn(artifacts); + when(artifactToscaOperation.getArtifacts(anyString())).thenReturn(artifacts); Either, 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, 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, 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, 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 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 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 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 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 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 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 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 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 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 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 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 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, ResponseFormat> result = - artifactBL.handleDownloadToscaModelRequest(resource, csarArtifact); + testSubject.handleDownloadToscaModelRequest(resource, csarArtifact); ImmutablePair 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, 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, 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 emptyDataTypes = new HashMap<>(); private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class); List 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 deploymentResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getDeploymentResourceInstanceArtifacts(); Map placeHolderData = (Map) deploymentResourceArtifacts.get(ArtifactsBusinessLogic.HEAT_ENV_NAME); @@ -109,7 +121,7 @@ public class ResourceInstanceBusinessLogicTest { Either 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.class)); + // Mockito.when(artifactBusinessLogic.createArtifactAuditingFields(Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.anyString())).thenReturn(new EnumMap(AuditingFieldsKey.class)); Either 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 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 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, 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"> - - - - - - - + + - - - - - - - - - - - - -- cgit 1.2.3-korg