summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-be/src/test/java/org
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java40
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java75
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java31
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java31
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java168
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java15
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java245
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java25
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java1253
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java97
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java57
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java27
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java86
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java62
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java112
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java119
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java112
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java94
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java186
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java88
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceDataMergingTest.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java101
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java115
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java154
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java120
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java114
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java122
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java253
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java82
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java42
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java49
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/HeatParameterBuilder.java36
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java101
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java68
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java53
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java126
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java21
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java188
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java39
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java17
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java419
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java34
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java124
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java2
150 files changed, 3936 insertions, 1760 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java
index d55d5752c1..c3f211f7ab 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java
@@ -21,8 +21,6 @@
package org.openecomp.sdc;
import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java b/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java
new file mode 100644
index 0000000000..a6c8dc4f0c
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.be;
+
+import static org.mockito.Mockito.mock;
+
+import org.openecomp.sdc.be.config.Configuration;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+
+public class DummyConfigurationManager {
+
+ private DistributionEngineConfiguration distributionConfigurationMock = mock(DistributionEngineConfiguration.class);
+ private Configuration configurationMock = mock(Configuration.class);
+
+ public DummyConfigurationManager() {
+ new ConfigurationManager(new DummyConfigurationSource());
+ }
+
+ public class DummyConfigurationSource implements ConfigurationSource {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+ if (className.equals(DistributionEngineConfiguration.class)) {
+ return (T) distributionConfigurationMock;
+ }
+ if (className.equals(Configuration.class)) {
+ return (T) configurationMock;
+ }
+ return null;
+ }
+
+ @Override
+ public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+
+ }
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java
index dff0e3c729..87dfbc45de 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java
@@ -25,8 +25,6 @@ import static org.mockito.Mockito.when;
import java.util.EnumMap;
import java.util.UUID;
-import junit.framework.Assert;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -38,10 +36,8 @@ import org.openecomp.sdc.be.dao.impl.AuditingDao;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
-import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
+import junit.framework.Assert;
public class AuditingManagerTest extends BaseConfDependentTest{
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 90f5b19acc..7774b7f412 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
@@ -20,49 +20,108 @@
package org.openecomp.sdc.be.components;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+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.ResourceBuilder;
+import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.exception.ResponseFormat;
import fj.data.Either;
+@RunWith(MockitoJUnitRunner.class)
public class ComponentBusinessLogicTest {
- ComponentBusinessLogic businessLogic = new ComponentBusinessLogic() {
+ 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() {
@Override
public Either<List<String>, ResponseFormat> deleteMarkedComponents() {
- // TODO Auto-generated method stub
return null;
}
@Override
public ComponentInstanceBusinessLogic getComponentInstanceBL() {
- // TODO Auto-generated method stub
return null;
}
@Override
public Either<List<ComponentInstance>, ResponseFormat> getComponentInstancesFilteredByPropertiesAndInputs(String componentId, ComponentTypeEnum componentTypeEnum, String userId, String searchText) {
- // TODO Auto-generated method stub
return null;
}
@Override
public Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String componentId, List<String> dataParamsToReturn) {
- // TODO Auto-generated method stub
return null;
}
};
+ @Mock
+ private ArtifactsBusinessLogic artifactsBusinessLogic;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ new DummyConfigurationManager();
+ }
+
+ @SuppressWarnings("unchecked")
@Test
- public void testGetRequirementsAndCapabilities() {
- // businessLogic.getRequirementsAndCapabilities(componentId,
- // componentTypeEnum);
+ public void setToscaArtifactsPlaceHolders_normalizeArtifactName() throws Exception {
+ Resource resource = new ResourceBuilder().setUniqueId("uid")
+ .setComponentType(ComponentTypeEnum.RESOURCE)
+ .setSystemName("myResource")
+ .build();
+ Map<String, Object> artifactsFromConfig = new HashMap<>();
+ artifactsFromConfig.put(ARTIFACT_LABEL, buildArtifactMap("artifact:not normalized.yml"));
+ artifactsFromConfig.put(ARTIFACT_LABEL2, buildArtifactMap("alreadyNormalized.csar"));
+ when(ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts()).thenReturn(artifactsFromConfig);
+ when(artifactsBusinessLogic.createArtifactPlaceHolderInfo(resource.getUniqueId(), ARTIFACT_LABEL, (Map<String, Object>) artifactsFromConfig.get(ARTIFACT_LABEL), USER, ArtifactGroupTypeEnum.TOSCA))
+ .thenReturn(buildArtifactDef(ARTIFACT_LABEL));
+ when(artifactsBusinessLogic.createArtifactPlaceHolderInfo(resource.getUniqueId(), ARTIFACT_LABEL2, (Map<String, Object>) artifactsFromConfig.get(ARTIFACT_LABEL2), USER, ArtifactGroupTypeEnum.TOSCA))
+ .thenReturn(buildArtifactDef(ARTIFACT_LABEL2));
+ testInstance.setToscaArtifactsPlaceHolders(resource, USER);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = resource.getToscaArtifacts();
+ assertThat(toscaArtifacts).hasSize(2);
+ ArtifactDefinition artifactDefinition = toscaArtifacts.get(ARTIFACT_LABEL);
+ assertThat(artifactDefinition.getArtifactName()).isEqualTo("resource-myResourceartifactnot-normalized.yml");
+ ArtifactDefinition artifactDefinition2 = toscaArtifacts.get(ARTIFACT_LABEL2);
+ assertThat(artifactDefinition2.getArtifactName()).isEqualTo("resource-myResourcealreadyNormalized.csar");
+ }
+
+ private Map<String, Object> buildArtifactMap(String artifactName) {
+ Map<String, Object> artifact = new HashMap<>();
+ artifact.put("artifactName", artifactName);
+ return artifact;
+ }
+
+ private ArtifactDefinition buildArtifactDef(String artifactLabel) {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setArtifactLabel(artifactLabel);
+ return artifactDefinition;
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java
index 0dceaed4f2..9bf7f16a50 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java
@@ -20,15 +20,8 @@
package org.openecomp.sdc.be.components;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-
import javax.servlet.ServletContext;
import org.junit.Before;
@@ -43,8 +36,6 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupProperty;
-import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -53,11 +44,8 @@ import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
/**
* tests GroupBusinessLogic class
* @author ns019t
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 be3bf9b234..2a34baeb0f 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
@@ -20,28 +20,17 @@
package org.openecomp.sdc.be.components;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Resource;
-
import org.junit.Test;
import org.openecomp.sdc.be.components.impl.HealthCheckBusinessLogic;
-import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaUtils;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
-import org.openecomp.sdc.be.resources.data.UserData;
+import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.HealthCheckInfo;
-import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
-
-import com.datastax.driver.core.Cluster;
-
-import fj.data.Either;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
public class HealthCheckBusinessLogicTest {
HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
@@ -58,8 +47,8 @@ public class HealthCheckBusinessLogicTest {
statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
assertFalse("check false", statusChanged);
- HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.UP, null, null);
- HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.DOWN, null, null);
+ HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.UP, null, null);
+ HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.DOWN, null, null);
/*
* HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
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 1309af8ff7..572804636d 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
@@ -20,10 +20,17 @@
package org.openecomp.sdc.be.components;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import fj.data.Either;
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -41,7 +48,6 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.EntryData;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
@@ -54,16 +60,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
-import javax.servlet.ServletContext;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import fj.data.Either;
+import junit.framework.Assert;
public class PropertyBusinessLogicTest {
@@ -195,7 +196,7 @@ public class PropertyBusinessLogicTest {
resource.setUniqueId(resourceId);
Mockito.when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
- Either<Map.Entry<String, PropertyDefinition>, ResponseFormat> notFoundProperty = bl.getProperty(resourceId, property1.getUniqueId(), user.getUserId());
+ Either<Map.Entry<String, PropertyDefinition>, ResponseFormat> notFoundProperty = bl.getProperty(resourceId, "invalidId", user.getUserId());
assertTrue(notFoundProperty.isRight());
Mockito.verify(componentsUtils).getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, "");
}
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 c545474f5d..30e12e85d0 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
@@ -156,7 +156,7 @@ public class ResourceImportManagerTest {
// Mockito.verify(log).error(Mockito.anyString(), Mockito.anyString(),
// Mockito.anyString());
- Mockito.verify(resourceBusinessLogic, Mockito.times(0)).createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.eq(user), Mockito.eq(true), Mockito.eq(false), Mockito.eq(true), Mockito.eq(null));
+ Mockito.verify(resourceBusinessLogic, Mockito.times(0)).createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.eq(user), Mockito.eq(true), Mockito.eq(false), Mockito.eq(true), Mockito.eq(null), Mockito.eq(null), Mockito.eq(false));
Mockito.verify(resourceBusinessLogic, Mockito.times(0)).propagateStateToCertified(Mockito.eq(user), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false));
@@ -181,7 +181,7 @@ public class ResourceImportManagerTest {
testSetCapabilities(resource);
Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false));
- Mockito.verify(resourceBusinessLogic, Mockito.times(1)).createOrUpdateResourceByImport(resource, user, true, false, true, null);
+ Mockito.verify(resourceBusinessLogic, Mockito.times(1)).createOrUpdateResourceByImport(resource, user, true, false, true, null, null, false);
}
@@ -206,7 +206,7 @@ public class ResourceImportManagerTest {
private void setResourceBusinessLogicMock() {
when(resourceBusinessLogic.getUserAdmin()).thenReturn(userAdmin);
- when(resourceBusinessLogic.createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.eq(null)))
+ when(resourceBusinessLogic.createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.eq(null), Mockito.eq(null), Mockito.eq(false)))
.thenAnswer(new Answer<Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat>>() {
public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
@@ -250,6 +250,7 @@ public class ResourceImportManagerTest {
private UploadResourceInfo createDummyResourceMD() {
UploadResourceInfo resourceMD = new UploadResourceInfo();
resourceMD.setName("tosca.nodes.BlockStorage");
+ resourceMD.setPayloadName("payLoad");
resourceMD.addSubCategory("Generic", "Infrastructure");
resourceMD.setContactId("ya107f");
resourceMD.setResourceIconPath("defaulticon");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java
index 95845c3660..1af1ac3070 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java
@@ -44,6 +44,7 @@ import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
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.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
@@ -104,6 +105,7 @@ public class ServiceBusinessLogicTest {
TitanDao mockTitanDao = Mockito.mock(TitanDao.class);
ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class);
+ GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
User user = null;
Service serviceResponse = null;
@@ -154,7 +156,7 @@ public class ServiceBusinessLogicTest {
// artifact bussinesslogic
ArtifactDefinition artifactDef = new ArtifactDefinition();
- when(artifactBl.createArtifactPlaceHolderInfo(Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef);
+ when(artifactBl.createArtifactPlaceHolderInfo(Mockito.any(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef);
// createService
serviceResponse = createServiceObject(true);
@@ -177,7 +179,7 @@ public class ServiceBusinessLogicTest {
bl.setGraphLockOperation(graphLockOperation);
bl.setTitanGenericDao(mockTitanDao);
bl.setToscaOperationFacade(toscaOperationFacade);
-
+ bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
componentsUtils.Init();
componentsUtils.setAuditingManager(auditingManager);
bl.setComponentsUtils(componentsUtils);
@@ -209,6 +211,7 @@ public class ServiceBusinessLogicTest {
@Test
public void testHappyScenario() {
Service service = createServiceObject(false);
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service)).thenReturn(Either.left(genericService));
Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
if (createResponse.isRight()) {
@@ -744,8 +747,6 @@ public class ServiceBusinessLogicTest {
Either<Component, StorageOperationStatus> eitherDelete = Either.left(new Resource());
when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
- when(artifactBl.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK);
-
Either<List<String>, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents();
assertTrue(deleteMarkedResources.isLeft());
List<String> resourceIdList = deleteMarkedResources.left().value();
@@ -753,7 +754,6 @@ public class ServiceBusinessLogicTest {
assertTrue(resourceIdList.contains(resourceFree));
assertFalse(resourceIdList.contains(resourceInUse));
- Mockito.verify(artifactBl, Mockito.times(1)).deleteAllComponentArtifactsIfNotOnGraph(artifacts);
}
private Service createServiceObject(boolean afterCreate) {
@@ -1004,6 +1004,7 @@ public class ServiceBusinessLogicTest {
public void testDerivedFromGeneric() {
Service service = createServiceObject(true);
when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(service));
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service)).thenReturn(Either.left(genericService));
Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
assertTrue(createResponse.isLeft());
service = createResponse.left().value();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java
index be55cbd12a..90a02a2fc5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.components.clean;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java
index 7ad93226c7..8d48a4c320 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java
@@ -20,7 +20,8 @@
package org.openecomp.sdc.be.components.distribution.engine;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.ArrayList;
@@ -28,7 +29,6 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import org.openecomp.sdc.be.components.distribution.engine.DistributionEngine;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java
index b3a254f531..990ea4f99b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java
@@ -30,10 +30,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.BaseConfDependentTest;
-import org.openecomp.sdc.be.components.distribution.engine.CambriaErrorResponse;
-import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler;
-import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth;
-import org.openecomp.sdc.be.components.distribution.engine.UebHealthCheckCall;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java
index de7b84fa82..5bf12d56bc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java
@@ -27,20 +27,15 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.openecomp.sdc.be.components.distribution.engine.CambriaErrorResponse;
-import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler;
-import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineInitTask;
-import org.openecomp.sdc.be.components.distribution.engine.SubscriberTypeEnum;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig;
@@ -63,8 +58,8 @@ public class DistributionEngineInitTaskTest {
// public static final IAuditingDao iAuditingDao =
// Mockito.mock(AuditingDao.class);
- @Before
- public void setup() {
+ @BeforeClass
+ public static void setup() {
// ExternalConfiguration.setAppName("distribEngine1");
ExternalConfiguration.setAppName("catalog-be");
ExternalConfiguration.setConfigDir("src/test/resources/config");
@@ -128,11 +123,11 @@ public class DistributionEngineInitTaskTest {
String realNotifTopic = notifTopic + "-" + envName.toUpperCase();
String realStatusTopic = statusTopic + "-" + envName.toUpperCase();
- when(cambriaHandler.createTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.eq(realNotifTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
- when(cambriaHandler.createTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.eq(realStatusTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
+ when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realNotifTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
+ when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realStatusTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.OK);
- when(cambriaHandler.registerToTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(SubscriberTypeEnum.class)))
+ when(cambriaHandler.registerToTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
.thenReturn(cambriaErrorResponse);
DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null);
@@ -159,7 +154,6 @@ public class DistributionEngineInitTaskTest {
List<String> uebServers = new ArrayList<>();
uebServers.add("server1");
- CambriaErrorResponse cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.NOT_FOUND);
Either<Set<String>, CambriaErrorResponse> left = Either.left(topics);
when(cambriaHandler.getTopics(Mockito.any(List.class))).thenReturn(left);
@@ -177,8 +171,8 @@ public class DistributionEngineInitTaskTest {
createTopic.setReplicationCount(1);
deConfiguration.setCreateTopic(createTopic);
- cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.OK);
- when(cambriaHandler.registerToTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(SubscriberTypeEnum.class)))
+ CambriaErrorResponse cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.OK);
+ when(cambriaHandler.registerToTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
.thenReturn(cambriaErrorResponse);
DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null);
@@ -224,15 +218,16 @@ public class DistributionEngineInitTaskTest {
String realNotifTopic = notifTopic + "-" + envName.toUpperCase();
String realStatusTopic = statusTopic + "-" + envName.toUpperCase();
- when(cambriaHandler.createTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.eq(realNotifTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
- when(cambriaHandler.createTopic(Mockito.any(Collection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.eq(realStatusTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
+ when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realNotifTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
+ when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realStatusTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse);
- when(cambriaHandler.registerToTopic(Mockito.any(Collection.class), Mockito.eq(realNotifTopic), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(SubscriberTypeEnum.class)))
+ when(cambriaHandler.registerToTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(SubscriberTypeEnum.class)))
.thenReturn(new CambriaErrorResponse(CambriaOperationStatus.OK));
- when(cambriaHandler.registerToTopic(Mockito.any(Collection.class), Mockito.eq(realStatusTopic), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(SubscriberTypeEnum.class)))
+ when(cambriaHandler.registerToTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(SubscriberTypeEnum.class)))
.thenReturn(new CambriaErrorResponse(CambriaOperationStatus.CONNNECTION_ERROR));
+
DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null);
initTask.setCambriaHandler(cambriaHandler);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
index 1bc8c47f8c..4144dcf620 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
@@ -4,11 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.GroupInstanceProperty;
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 f2053535ad..e2fceddcf6 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
@@ -2,7 +2,6 @@ package org.openecomp.sdc.be.components.impl;
import java.util.List;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import org.junit.Test;
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 5de6762bdd..c57f2a65af 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
@@ -20,20 +20,36 @@
package org.openecomp.sdc.be.components.impl;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import fj.data.Either;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+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;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig.Feature;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.junit.Before;
-import org.junit.BeforeClass;
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.components.utils.ArtifactBuilder;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -45,10 +61,13 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ArtifactType;
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
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.jsontitan.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
@@ -57,6 +76,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
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.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
@@ -64,30 +84,40 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
+import fj.data.Either;
public class ArtifactBusinessLogicTest {
+ public static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis());
static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
@InjectMocks
- static ArtifactsBusinessLogic artifactBL = new ArtifactsBusinessLogic();
-
- public static final ArtifactOperation artifactOperation = Mockito.mock(ArtifactOperation.class);
- public static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
- public static final IInterfaceLifecycleOperation lifecycleOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
- public static final IUserAdminOperation userOperation = Mockito.mock(IUserAdminOperation.class);
- public static final IElementOperation elementOperation = Mockito.mock(IElementOperation.class);
- public static final ArtifactCassandraDao artifactCassandraDao = Mockito.mock(ArtifactCassandraDao.class);
- public static final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private static ArtifactsBusinessLogic artifactBL;
+ @Mock
+ private ArtifactOperation artifactOperation;
+ @Mock
+ public ComponentsUtils componentsUtils;
+ @Mock
+ private IInterfaceLifecycleOperation lifecycleOperation;
+ @Mock
+ private IUserAdminOperation userOperation;
+ @Mock
+ private IElementOperation elementOperation;
+ @Mock
+ private ArtifactCassandraDao artifactCassandraDao;
+ @Mock
+ public ToscaOperationFacade toscaOperationFacade;
+ @Mock
+ private UserBusinessLogic userBusinessLogic;
+ @Mock
+ private NodeTemplateOperation nodeTemplateOperation;
+ @Mock
+ private ArtifactsOperations artifactsOperations;
// public static final InformationDeployedArtifactsBusinessLogic
// informationDeployedArtifactsBusinessLogic =
@@ -96,31 +126,6 @@ public class ArtifactBusinessLogicTest {
public static final Resource resource = Mockito.mock(Resource.class);
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
- @BeforeClass
- public static void setup() {
-
- Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND);
-// when(artifactOperation.getArtifactById(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(NotFoundResult);
-
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either.right(StorageOperationStatus.NOT_FOUND);
- when(artifactOperation.getArtifacts(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
- when(artifactOperation.getArtifacts(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
-
- Either<Map<String, InterfaceDefinition>, StorageOperationStatus> notFoundInterfaces = Either.right(StorageOperationStatus.NOT_FOUND);
- when(lifecycleOperation.getAllInterfacesOfResource(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(notFoundInterfaces);
-
- User userJH = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis());
- Either<User, ActionStatus> getUserResult = Either.left(userJH);
-
- when(userOperation.getUserData("jh0003", false)).thenReturn(getUserResult);
-
- Either<List<ArtifactType>, ActionStatus> getType = Either.left(getAllTypes());
- when(elementOperation.getAllArtifactTypes()).thenReturn(getType);
-
- when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC);
- // when(informationDeployedArtifactsBusinessLogic.getAllDeployableArtifacts(Mockito.any(Resource.class))).thenReturn(new
- // ArrayList<ArtifactDefinition>());
- }
private static List<ArtifactType> getAllTypes() {
List<ArtifactType> artifactTypes = new ArrayList<ArtifactType>();
@@ -136,6 +141,23 @@ public class ArtifactBusinessLogicTest {
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
+ Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND);
+
+ Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either.right(StorageOperationStatus.NOT_FOUND);
+ when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Service), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
+ when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Resource), Mockito.anyBoolean())).thenReturn(NotFoundResult2);
+
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> notFoundInterfaces = Either.right(StorageOperationStatus.NOT_FOUND);
+ when(lifecycleOperation.getAllInterfacesOfResource(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(notFoundInterfaces);
+
+ Either<User, ActionStatus> getUserResult = Either.left(USER);
+
+ when(userOperation.getUserData("jh0003", false)).thenReturn(getUserResult);
+
+ Either<List<ArtifactType>, ActionStatus> getType = Either.left(getAllTypes());
+ when(elementOperation.getAllArtifactTypes()).thenReturn(getType);
+
+ when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC);
}
@Test
@@ -283,9 +305,59 @@ public class ArtifactBusinessLogicTest {
assertTrue(downloadServiceArtifactByNamesRes.isLeft());
assertTrue(downloadServiceArtifactByNamesRes.left().value() !=null && downloadServiceArtifactByNamesRes.left().value().length == payload.length);
}
-
- // @Test
+ @Test
+ public void createHeatEnvPlaceHolder_vf_emptyHeatParameters() throws Exception {
+ ArtifactDefinition heatArtifact = new ArtifactBuilder()
+ .addHeatParam(ObjectGenerator.buildHeatParam("defVal1", "val1"))
+ .addHeatParam(ObjectGenerator.buildHeatParam("defVal2", "val2"))
+ .build();
+
+ Resource component = new Resource();
+ when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
+ when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
+ .thenReturn(Either.left(new ArtifactDefinition()));
+ Either<ArtifactDefinition, ResponseFormat> heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder(heatArtifact, HEAT_VF_ENV_NAME, "parentId", NodeTypeEnum.Resource, "parentName", USER, component, Collections.emptyMap());
+ assertTrue(heatEnvPlaceHolder.isLeft());
+ assertNull(heatEnvPlaceHolder.left().value().getListHeatParameters());
+ }
+
+ @Test
+ public void createHeatEnvPlaceHolder_resourceInstance_copyHeatParamasCurrValuesToHeatEnvDefaultVal() throws Exception {
+ HeatParameterDefinition heatParam1 = ObjectGenerator.buildHeatParam("defVal1", "val1");
+ HeatParameterDefinition heatParam2 = ObjectGenerator.buildHeatParam("defVal2", "val2");
+ HeatParameterDefinition heatParam3 = ObjectGenerator.buildHeatParam("defVal3", "val3");
+ ArtifactDefinition heatArtifact = new ArtifactBuilder()
+ .addHeatParam(heatParam1)
+ .addHeatParam(heatParam2)
+ .addHeatParam(heatParam3)
+ .build();
+
+ Resource component = new Resource();
+
+ when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(Either.left(USER));
+ when(artifactsOperations.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), eq(component.getUniqueId()), eq(NodeTypeEnum.Resource), eq(true), eq("parentId")))
+ .thenReturn(Either.left(new ArtifactDefinition()));
+
+ Either<ArtifactDefinition, ResponseFormat> heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder(heatArtifact, HEAT_ENV_NAME, "parentId", NodeTypeEnum.ResourceInstance, "parentName", USER, component, Collections.emptyMap());
+
+ assertTrue(heatEnvPlaceHolder.isLeft());
+ ArtifactDefinition heatEnvArtifact = heatEnvPlaceHolder.left().value();
+ List<HeatParameterDefinition> listHeatParameters = heatEnvArtifact.getListHeatParameters();
+ assertEquals(listHeatParameters.size(), 3);
+ verifyHeatParam(listHeatParameters.get(0), heatParam1);
+ verifyHeatParam(listHeatParameters.get(1), heatParam2);
+ verifyHeatParam(listHeatParameters.get(2), heatParam3);
+ }
+
+ private void verifyHeatParam(HeatParameterDefinition heatEnvParam, HeatParameterDefinition heatYamlParam) {
+ assertEquals(heatEnvParam.getDefaultValue(), heatYamlParam.getCurrentValue());
+ assertNull(heatEnvParam.getCurrentValue());
+ }
+
+
+
+// @Test
// public void convertAndValidateDeploymentArtifactNonHeatSuccess(){
// ArtifactDefinition createArtifactDef = createArtifactDef();
// createArtifactDef.setArtifactType(ArtifactTypeEnum.YANG_XML.getType());
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
index a325817316..8ad9bf80b2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
@@ -20,6 +20,12 @@
package org.openecomp.sdc.be.components.impl;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -28,12 +34,6 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
public class ArtifactResolverTest {
private ArtifactResolverImpl testInstance = new ArtifactResolverImpl();
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 e10c3b41ba..630f41f905 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
@@ -2,9 +2,6 @@ package org.openecomp.sdc.be.components.impl;
import java.util.List;
-import javax.annotation.Generated;
-
-import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.exception.ResponseFormat;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java
index 776fe8864e..41835a6cdc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java
@@ -39,8 +39,6 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.sdc.be.components.impl.CapabilityTypeImportManager;
-import org.openecomp.sdc.be.components.impl.CommonImportManager;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
index 05fc6a2948..2c83c60fc6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java
@@ -38,8 +38,6 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.sdc.be.components.impl.CategoriesImportManager;
-import org.openecomp.sdc.be.components.impl.InterfaceLifecycleTypeImportManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -68,13 +66,12 @@ public class CategoriesImportManagerTest {
subcategory = new SubCategoryDefinition();
subcategory.setUniqueId("123");
- when(elementOperation.createCategory(Mockito.any(CategoryDefinition.class), Mockito.any(NodeTypeEnum.class))).thenAnswer(new Answer<Either<CategoryDefinition, ActionStatus>>() {
- public Either<CategoryDefinition, ActionStatus> answer(InvocationOnMock invocation) {
- Object[] args = invocation.getArguments();
- Either<CategoryDefinition, ActionStatus> ans = Either.left((CategoryDefinition) args[0]);
- return ans;
- }
-
+ when(elementOperation.createCategory(Mockito.any(CategoryDefinition.class), Mockito.any(NodeTypeEnum.class))).thenAnswer((Answer<Either<CategoryDefinition, ActionStatus>>) invocation -> {
+ Object[] args = invocation.getArguments();
+ CategoryDefinition category = (CategoryDefinition) args[0];
+ category.setUniqueId("123");
+ Either<CategoryDefinition, ActionStatus> ans = Either.left(category);
+ return ans;
});
when(elementOperation.createSubCategory(Mockito.any(String.class), Mockito.any(SubCategoryDefinition.class), Mockito.any(NodeTypeEnum.class))).thenAnswer(new Answer<Either<SubCategoryDefinition, ActionStatus>>() {
public Either<SubCategoryDefinition, ActionStatus> answer(InvocationOnMock invocation) {
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
new file mode 100644
index 0000000000..65f7ac46b6
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -0,0 +1,245 @@
+package org.openecomp.sdc.be.components.impl;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiPredicate;
+
+import org.assertj.core.util.Lists;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.RelationshipImpl;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+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.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+/**
+ * The test suite designed for test functionality of ComponentInstanceBusinessLogic class
+ */
+public class ComponentInstanceBusinessLogicTest {
+
+ private final static String USER_ID = "jh0003";
+ private final static String COMPONENT_ID = "componentId";
+ private final static String TO_INSTANCE_ID = "toInstanceId";
+ private final static String FROM_INSTANCE_ID = "fromInstanceId";
+ private final static String RELATION_ID = "relationId";
+ private final static String CAPABILITY_OWNER_ID = "capabilityOwnerId";
+ private final static String CAPABILITY_UID = "capabilityUid";
+ private final static String CAPABILITY_NAME = "capabilityName";
+ private final static String REQUIREMENT_OWNER_ID = "requirementOwnerId";
+ private final static String REQUIREMENT_UID = "requirementUid";
+ private final static String REQUIREMENT_NAME = "requirementName";
+ private final static String RELATIONSHIP_TYPE = "relationshipType";
+
+ private static ComponentsUtils componentsUtils;
+ private static ServletUtils servletUtils;
+ private static ResponseFormat responseFormat;
+ private static ToscaOperationFacade toscaOperationFacade;
+ private static UserBusinessLogic userAdmin;
+
+ private static ComponentInstanceBusinessLogic serviceBusinessLogic;
+ private static ComponentInstanceBusinessLogic resourceBusinessLogic;
+ private static User user;
+ private static Component service;
+ private static Component resource;
+ private static ComponentInstance toInstance;
+ private static ComponentInstance fromInstance;
+ private static CapabilityDataDefinition capability;
+ private static RequirementDataDefinition requirement;
+ private static RequirementCapabilityRelDef relation;
+
+ @BeforeClass
+ public static void setup() {
+ createMocks();
+ setMocks();
+ stubMethods();
+ createComponents();
+ }
+
+ @Test
+ public void testGetRelationByIdSuccess(){
+ getServiceRelationByIdSuccess(service);
+ getServiceRelationByIdSuccess(resource);
+ }
+
+ @Test
+ public void testGetRelationByIdUserValidationFailure(){
+ getServiceRelationByIdUserValidationFailure(service);
+ getServiceRelationByIdUserValidationFailure(resource);
+ }
+
+ @Test
+ public void testGetRelationByIdComponentNotFoundFailure(){
+ getRelationByIdComponentNotFoundFailure(service);
+ getRelationByIdComponentNotFoundFailure(resource);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void getServiceRelationByIdSuccess(Component component){
+ Either<User, ActionStatus> eitherCreator = Either.left(user);
+ when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
+ Either<Component, StorageOperationStatus> getComponentRes = Either.left(component);
+ when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(getComponentRes);
+
+ Either<RequirementDataDefinition, StorageOperationStatus> getfulfilledRequirementRes = Either.left(requirement);
+ when(toscaOperationFacade.getFulfilledRequirementByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID), eq(relation), any(BiPredicate.class))).thenReturn(getfulfilledRequirementRes);
+
+ Either<CapabilityDataDefinition, StorageOperationStatus> getfulfilledCapabilityRes = Either.left(capability);
+ when(toscaOperationFacade.getFulfilledCapabilityByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID), eq(relation), any(BiPredicate.class))).thenReturn(getfulfilledCapabilityRes);
+
+ Either<RequirementCapabilityRelDef, ResponseFormat> response = serviceBusinessLogic.getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
+ assertTrue(response.isLeft());
+ }
+
+ private void getServiceRelationByIdUserValidationFailure(Component component){
+ Either<User, ActionStatus> eitherCreator = Either.right(ActionStatus.USER_NOT_FOUND);
+ when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
+
+ Either<RequirementCapabilityRelDef, ResponseFormat> response = serviceBusinessLogic.getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
+ assertTrue(response.isRight());
+ }
+
+ private void getRelationByIdComponentNotFoundFailure(Component component){
+ Either<User, ActionStatus> eitherCreator = Either.left(user);
+ when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
+ Either<Component, StorageOperationStatus> getComponentRes = Either.right(StorageOperationStatus.NOT_FOUND);
+ when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(getComponentRes);
+
+ Either<RequirementCapabilityRelDef, ResponseFormat> response = serviceBusinessLogic.getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
+ assertTrue(response.isRight());
+ }
+
+ private static void createMocks() {
+ componentsUtils = Mockito.mock(ComponentsUtils.class);
+ servletUtils = Mockito.mock(ServletUtils.class);
+ responseFormat = Mockito.mock(ResponseFormat.class);
+ toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ userAdmin = Mockito.mock(UserBusinessLogic.class);
+ user = Mockito.mock(User.class);
+ }
+
+ private static void setMocks() {
+ serviceBusinessLogic = new ServiceComponentInstanceBusinessLogic();
+ serviceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ serviceBusinessLogic.setUserAdmin(userAdmin);
+ serviceBusinessLogic.setComponentsUtils(componentsUtils);
+
+ resourceBusinessLogic = new VFComponentInstanceBusinessLogic();
+ resourceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+ resourceBusinessLogic.setUserAdmin(userAdmin);
+ resourceBusinessLogic.setComponentsUtils(componentsUtils);
+ }
+
+ private static void stubMethods() {
+ when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
+ when(componentsUtils.getResponseFormat(eq(ActionStatus.RELATION_NOT_FOUND), eq(RELATION_ID), eq(COMPONENT_ID))).thenReturn(responseFormat);
+ }
+
+ private static void createComponents() {
+ createRelation();
+ createInstances();
+ createService();
+ createResource();
+ }
+
+ private static void createResource() {
+ resource = new Resource();
+ resource.setUniqueId(COMPONENT_ID);
+ resource.setComponentInstancesRelations(Lists.newArrayList(relation));
+ resource.setComponentInstances(Lists.newArrayList(toInstance,fromInstance));
+ resource.setCapabilities(toInstance.getCapabilities());
+ resource.setRequirements(fromInstance.getRequirements());
+ resource.setComponentType(ComponentTypeEnum.RESOURCE);
+ }
+
+
+ private static void createService() {
+ service = new Service();
+ service.setUniqueId(COMPONENT_ID);
+ service.setComponentInstancesRelations(Lists.newArrayList(relation));
+ service.setComponentInstances(Lists.newArrayList(toInstance,fromInstance));
+ service.setCapabilities(toInstance.getCapabilities());
+ service.setRequirements(fromInstance.getRequirements());
+ service.setComponentType(ComponentTypeEnum.SERVICE);
+ }
+
+
+ private static void createInstances() {
+ toInstance = new ComponentInstance();
+ toInstance.setUniqueId(TO_INSTANCE_ID);
+
+ fromInstance = new ComponentInstance();
+ fromInstance.setUniqueId(FROM_INSTANCE_ID);
+
+ capability = new CapabilityDataDefinition();
+ capability.setOwnerId(CAPABILITY_OWNER_ID);
+ capability.setUniqueId(CAPABILITY_UID);
+ capability.setName(CAPABILITY_NAME);
+
+ Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
+ capabilities.put(capability.getName(), Lists.newArrayList(new CapabilityDefinition(capability)));
+
+ requirement = new RequirementDataDefinition();
+ requirement.setOwnerId(REQUIREMENT_OWNER_ID);
+ requirement.setUniqueId(REQUIREMENT_UID);
+ requirement.setName(REQUIREMENT_NAME);
+ requirement.setRelationship(RELATIONSHIP_TYPE);
+
+
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ requirements.put(requirement.getCapability(), Lists.newArrayList(new RequirementDefinition(requirement)));
+
+ toInstance.setCapabilities(capabilities);
+ fromInstance.setRequirements(requirements);
+ }
+
+
+ private static void createRelation() {
+
+ relation = new RequirementCapabilityRelDef();
+ CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
+ RelationshipInfo relationInfo = new RelationshipInfo();
+ relationInfo.setId(RELATION_ID);
+ relationship.setRelation(relationInfo);
+
+ relation.setRelationships(Lists.newArrayList(relationship));
+ relation.setToNode(TO_INSTANCE_ID);
+ relation.setFromNode(FROM_INSTANCE_ID);
+
+ relationInfo.setCapabilityOwnerId(CAPABILITY_OWNER_ID);
+ relationInfo.setCapabilityUid(CAPABILITY_UID);
+ relationInfo.setCapability(CAPABILITY_NAME);
+ relationInfo.setRequirementOwnerId(REQUIREMENT_OWNER_ID);
+ relationInfo.setRequirementUid(REQUIREMENT_UID);
+ relationInfo.setRequirement(REQUIREMENT_NAME);
+ RelationshipImpl relationshipImpl = new RelationshipImpl();
+ relationshipImpl.setType(RELATIONSHIP_TYPE);
+ relationInfo.setRelationships(relationshipImpl);
+ }
+}
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 135caf2c82..4f1f929382 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
@@ -31,7 +31,6 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.CompositionBusinessLogic;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
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 259d47befa..db95ee8827 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
@@ -1,12 +1,8 @@
package org.openecomp.sdc.be.components.impl;
-import javax.annotation.Generated;
-
-import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.model.ConsumerDefinition;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.exception.ResponseFormat;
import fj.data.Either;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java
index 84c8286f14..50ad990560 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java
@@ -21,9 +21,9 @@
package org.openecomp.sdc.be.components.impl;
import java.util.Arrays;
+
import org.junit.Assert;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.CsarValidationUtils;
public class CsarValidationUtilsTest {
private String[] invalidExtensions = { null, ".bla", ".yaml", ".yml", ".txt", ".zip" };
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 7722c1fdea..bcde49295e 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
@@ -2,48 +2,23 @@ package org.openecomp.sdc.be.components.impl;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import javax.annotation.Generated;
-
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.datamodel.api.CategoryTypeEnum;
-import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ArtifactType;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PropertyScope;
-import org.openecomp.sdc.be.model.Resource;
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.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.resources.data.category.SubCategoryData;
import org.openecomp.sdc.be.ui.model.UiCategories;
import org.openecomp.sdc.exception.ResponseFormat;
-import com.google.common.util.concurrent.Service;
-import com.thinkaurelius.titan.core.TitanGraph;
-
import fj.data.Either;
-import io.swagger.annotations.Tag;
public class ElementBusinessLogicTest {
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 df2d2e7fdc..d9ca7b06c2 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
@@ -4,8 +4,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index 59d49de3a3..5edf448cc2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -22,8 +22,9 @@ package org.openecomp.sdc.be.components.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
@@ -33,10 +34,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.function.Function;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
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 db5531debf..ac4d37ef76 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
@@ -20,7 +20,15 @@
package org.openecomp.sdc.be.components.impl;
-import fj.data.Either;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -35,18 +43,10 @@ import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import fj.data.Either;
public class InputsBusinessLogicTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java
index 6ba74ec133..8109e36be1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java
@@ -37,8 +37,6 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.sdc.be.components.impl.CommonImportManager;
-import org.openecomp.sdc.be.components.impl.InterfaceLifecycleTypeImportManager;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
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 222bba53d2..cbb5f7b719 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
@@ -3,10 +3,7 @@ package org.openecomp.sdc.be.components.impl;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.apache.commons.math3.stat.descriptive.summary.Product;
-import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.Component;
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 0e27636901..f7724aaeff 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,14 +32,11 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.ServletContext;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -51,55 +48,31 @@ import org.openecomp.sdc.be.auditing.api.IAuditingManager;
import org.openecomp.sdc.be.auditing.impl.AuditingLogFormatUtil;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
-import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
-import org.openecomp.sdc.be.info.MergedArtifactInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceInput;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.CsarInfo;
import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupProperty;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.NodeTypeInfo;
-import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.UploadCapInfo;
-import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
-import org.openecomp.sdc.be.model.UploadPropInfo;
-import org.openecomp.sdc.be.model.UploadReqInfo;
-import org.openecomp.sdc.be.model.UploadResourceInfo;
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.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
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.IPropertyOperation;
@@ -110,15 +83,12 @@ import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
-import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
-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;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.common.util.GeneralUtility;
@@ -128,10 +98,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
-import com.att.nsa.cambria.test.support.CambriaBatchingPublisherMock.Entry;
-import com.google.common.base.Equivalence.Wrapper;
-import com.netflix.astyanax.connectionpool.Operation;
-
import fj.data.Either;
public class ResourceBusinessLogicTest {
@@ -145,10 +111,10 @@ public class ResourceBusinessLogicTest {
public static final String UPDATED_SUBCATEGORY = "Gateway";
public static final String RESOURCE_NAME = "My-Resource_Name with space";
- private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
- private static final String GENERIC_VFC_NAME = "org.openecomp.resource.abstract.nodes.VFC";
- private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
-
+ private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
+ private static final String GENERIC_VFC_NAME = "org.openecomp.resource.abstract.nodes.VFC";
+ private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
+
final ServletContext servletContext = Mockito.mock(ServletContext.class);
IAuditingManager iAuditingManager = null;
IElementOperation mockElementDao;
@@ -179,9 +145,10 @@ public class ResourceBusinessLogicTest {
ArtifactsBusinessLogic artifactManager = new ArtifactsBusinessLogic();
CsarOperation csarOperation = Mockito.mock(CsarOperation.class);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
-
+ private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class);
+
public ResourceBusinessLogicTest() {
}
@@ -195,8 +162,7 @@ public class ResourceBusinessLogicTest {
// Init Configuration
String appConfigDir = "src/test/resources/config/catalog-be";
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- appConfigDir);
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
// Elements
@@ -214,38 +180,30 @@ public class ResourceBusinessLogicTest {
// Servlet Context attributes
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
- when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
- .thenReturn(webAppContextWrapper);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext);
when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao);
Either<Integer, StorageOperationStatus> eitherCountRoot = Either.left(1);
Either<Boolean, StorageOperationStatus> eitherFalse = Either.left(true);
- when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE))
- .thenReturn(eitherFalse);
+ when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherFalse);
Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
- when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC,
- ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
-
+ when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
+
Either<Boolean, StorageOperationStatus> eitherCount = Either.left(false);
- when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VFC,
- ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
- when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VF,
- ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
- when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.PNF,
- ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
-
+ when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
+ when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
+ when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.PNF, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
+
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
-
+
Either<Boolean, StorageOperationStatus> validateDerivedNotExists = Either.left(false);
when(toscaOperationFacade.validateToscaResourceNameExists("kuku")).thenReturn(validateDerivedNotExists);
- when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource)))
- .thenReturn(StorageOperationStatus.OK);
- when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource)))
- .thenReturn(StorageOperationStatus.OK);
-
+ when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource))).thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource))).thenReturn(StorageOperationStatus.OK);
+
// createResource
resourceResponse = createResourceObject(true);
Either<Resource, StorageOperationStatus> eitherCreate = Either.left(resourceResponse);
@@ -272,6 +230,7 @@ public class ResourceBusinessLogicTest {
bl.setApplicationDataTypeCache(applicationDataTypeCache);
bl.setCsarOperation(csarOperation);
bl.setCacheManagerOperation(cacheManager);
+ bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
toscaOperationFacade.setTopologyTemplateOperation(topologyTemplateOperation);
bl.setToscaOperationFacade(toscaOperationFacade);
@@ -334,7 +293,7 @@ public class ResourceBusinessLogicTest {
if (afterCreate) {
resource.setName(resource.getName());
resource.setVersion("0.1");
-
+
resource.setUniqueId(resource.getName().toLowerCase() + ":" + resource.getVersion());
resource.setCreatorUserId(user.getUserId());
resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
@@ -352,8 +311,7 @@ public class ResourceBusinessLogicTest {
@Test
public void testHappyScenario() {
Resource resource = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
if (createResponse.isRight()) {
assertEquals(new Integer(200), createResponse.right().value().getStatus());
@@ -365,17 +323,15 @@ public class ResourceBusinessLogicTest {
public void testUpdateHappyScenario() {
Resource resource = createResourceObjectCsar(true);
setCanWorkOnResource(resource);
-
+
Either<Resource, StorageOperationStatus> resourceLinkedToCsarRes = Either.left(resource);
- when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(),
- resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
+ when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(), resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
-
+
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> updateResponse = bl.validateAndUpdateResourceFromCsar(resource, user, null,
- null, resource.getUniqueId());
+ Either<Resource, ResponseFormat> updateResponse = bl.validateAndUpdateResourceFromCsar(resource, user, null, null, resource.getUniqueId());
if (updateResponse.isRight()) {
assertEquals(new Integer(200), updateResponse.right().value().getStatus());
}
@@ -403,7 +359,7 @@ public class ResourceBusinessLogicTest {
testTagsExceedsLimitCreate();
testTagsNoServiceName();
testInvalidTag();
-
+
testContactIdTooLong();
testContactIdWrongFormatCreate();
testResourceContactIdEmpty();
@@ -431,18 +387,15 @@ public class ResourceBusinessLogicTest {
resourceExist.setName(resourceName);
resourceExist.getTags().add(resourceName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
- resourceName);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resourceName);
}
private void testResourceNameEmpty() {
Resource resourceExist = createResourceObject(false);
resourceExist.setName(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertResponse(createResponse, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -452,11 +405,9 @@ public class ResourceBusinessLogicTest {
String tooLongResourceName = "zCRCAWjqte0DtgcAAMmcJcXeNubeX1p1vOZNTShAHOYNAHvV3iK";
resourceExccedsNameLimit.setName(tooLongResourceName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
- "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
}
private void testResourceNameWrongFormat() {
@@ -465,8 +416,7 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "ljg?fd";
resource.setName(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -487,11 +437,9 @@ public class ResourceBusinessLogicTest {
resourceExccedsDescLimit.setDescription(tooLongResourceDesc);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsDescLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsDescLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
- ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
private void testResourceDescNotEnglish() {
@@ -500,35 +448,29 @@ public class ResourceBusinessLogicTest {
String notEnglishDesc = "\uC2B5";
notEnglish.setDescription(notEnglishDesc);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(notEnglish,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(notEnglish, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_DESCRIPTION,
- ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
}
private void testResourceDescriptionEmpty() {
Resource resourceExist = createResourceObject(false);
resourceExist.setDescription("");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
- ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
}
private void testResourceDescriptionMissing() {
Resource resourceExist = createResourceObject(false);
resourceExist.setDescription(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
- ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
}
// Resource description - end
// Resource icon start
@@ -537,8 +479,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -548,8 +489,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon("kjk3453^&");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -559,12 +499,10 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon("dsjfhskdfhskjdhfskjdhkjdhfkshdfksjsdkfhsdfsdfsdfsfsdfsf");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
- "" + ValidationUtils.ICON_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.ICON_MAX_LENGTH);
}
// Resource icon end
@@ -573,8 +511,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setTags(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
@@ -584,8 +521,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setTags(new ArrayList<String>());
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
@@ -641,11 +577,9 @@ public class ResourceBusinessLogicTest {
resourceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
- "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
}
@@ -659,11 +593,9 @@ public class ResourceBusinessLogicTest {
resourceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT,
- "" + ValidationUtils.TAG_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, "" + ValidationUtils.TAG_MAX_LENGTH);
}
@@ -674,8 +606,7 @@ public class ResourceBusinessLogicTest {
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
@@ -688,8 +619,7 @@ public class ResourceBusinessLogicTest {
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_FIELD_FORMAT, new String[] { "Resource", "tag" });
@@ -697,15 +627,14 @@ public class ResourceBusinessLogicTest {
// Resource tags - stop
// Resource contact start
-
+
private void testContactIdTooLong() {
Resource resourceContactId = createResourceObject(false);
// 59 chars instead of 50
String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
resourceContactId.setContactId(contactIdTooLong);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -716,8 +645,7 @@ public class ResourceBusinessLogicTest {
String contactIdFormatWrong = "yrt134!!!";
resourceContactId.setContactId(contactIdFormatWrong);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -726,8 +654,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setContactId("");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -737,8 +664,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setContactId(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -749,23 +675,19 @@ public class ResourceBusinessLogicTest {
String tooLongVendorName = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsVendorNameLimit.setVendorName(tooLongVendorName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
- "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
}
-
+
private void testResourceVendorModelNumberExceedsLimit() {
Resource resourceExccedsVendorModelNumberLimit = createResourceObject(false);
String tooLongVendorModelNumber = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsVendorModelNumberLimit.setResourceVendorModelNumber(tooLongVendorModelNumber);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorModelNumberLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorModelNumberLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
- "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
}
private void testVendorNameWrongFormatCreate() {
@@ -774,8 +696,7 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "ljg*fd";
resource.setVendorName(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
}
@@ -786,8 +707,7 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "1>2";
resource.setVendorRelease(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_RELEASE);
@@ -798,19 +718,16 @@ public class ResourceBusinessLogicTest {
String tooLongVendorRelease = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsNameLimit.setVendorRelease(tooLongVendorRelease);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
- "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
private void testResourceVendorNameMissing() {
Resource resourceExist = createResourceObject(false);
resourceExist.setVendorName(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_VENDOR_NAME);
@@ -820,8 +737,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setVendorRelease(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_VENDOR_RELEASE);
@@ -833,8 +749,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setCategories(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -846,8 +761,7 @@ public class ResourceBusinessLogicTest {
resourceExist.setCategories(null);
resourceExist.addCategory("koko", "koko");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -866,8 +780,7 @@ public class ResourceBusinessLogicTest {
String licenseType = "User";
createResourceObject.setCost(cost);
createResourceObject.setLicenseType(licenseType);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(createResourceObject,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(createResourceObject, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
if (createResponse.isRight()) {
assertEquals(new Integer(200), createResponse.right().value().getStatus());
@@ -883,8 +796,7 @@ public class ResourceBusinessLogicTest {
String cost = "12356,464";
resourceCost.setCost(cost);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceCost,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceCost, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
}
@@ -897,8 +809,7 @@ public class ResourceBusinessLogicTest {
String licenseType = "cpu";
resourceLicenseType.setLicenseType(licenseType);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceLicenseType,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceLicenseType, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
}
@@ -910,8 +821,7 @@ public class ResourceBusinessLogicTest {
List<String> list = null;
resourceExist.setDerivedFrom(list);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -921,8 +831,7 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setDerivedFrom(new ArrayList<String>());
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -934,21 +843,18 @@ public class ResourceBusinessLogicTest {
derivedFrom.add("kuku");
resourceExist.setDerivedFrom(derivedFrom);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
}
// Derived from stop
- private void assertResponse(Either<Resource, ResponseFormat> createResponse, ActionStatus expectedStatus,
- String... variables) {
+ private void assertResponse(Either<Resource, ResponseFormat> createResponse, ActionStatus expectedStatus, String... variables) {
ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
ResponseFormat actualResponse = createResponse.right().value();
assertEquals(expectedResponse.getStatus(), actualResponse.getStatus());
- assertEquals("assert error description", expectedResponse.getFormattedMessage(),
- actualResponse.getFormattedMessage());
+ assertEquals("assert error description", expectedResponse.getFormattedMessage(), actualResponse.getFormattedMessage());
}
// UPDATE tests - start
@@ -967,9 +873,8 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
-
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
@@ -988,12 +893,11 @@ public class ResourceBusinessLogicTest {
String name = "ljg";
updatedResource.setName(name);
resource.setVersion("1.0");
-
+
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
@@ -1014,11 +918,9 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
- "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
}
@Test
@@ -1034,11 +936,9 @@ public class ResourceBusinessLogicTest {
updatedResource.setName(resourceName);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
- resourceName);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resourceName);
}
//
@@ -1064,11 +964,9 @@ public class ResourceBusinessLogicTest {
updatedResource.setDescription(tooLongResourceDesc);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
- ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
@@ -1087,8 +985,7 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -1111,8 +1008,7 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED);
@@ -1176,12 +1072,10 @@ public class ResourceBusinessLogicTest {
updatedResource.setTags(tagsList);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
- "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
}
@Test
@@ -1198,8 +1092,7 @@ public class ResourceBusinessLogicTest {
updatedResource.setVendorName(nameWrongFormat);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
@@ -1221,8 +1114,7 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED);
@@ -1241,11 +1133,9 @@ public class ResourceBusinessLogicTest {
updatedResource.setVendorRelease(tooLongVendorRelease);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
- updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
- "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
@Ignore
@@ -1263,8 +1153,7 @@ public class ResourceBusinessLogicTest {
updatedResource.setContactId(contactIdTooLong);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -1285,8 +1174,7 @@ public class ResourceBusinessLogicTest {
updatedResource.addCategory(badCategory, "fikt");
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -1308,8 +1196,7 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_CATEGORY_CANNOT_BE_CHANGED);
@@ -1330,8 +1217,7 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(list);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -1350,8 +1236,7 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(new ArrayList<String>());
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -1372,8 +1257,7 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
@@ -1388,16 +1272,13 @@ public class ResourceBusinessLogicTest {
// this is in order to prevent failing with 403 earlier
Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
-
+
Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(true);
- when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
- .thenReturn(isToscaNameExtending);
-
- Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either
- .left(new HashMap<>());
- when(propertyOperation.deleteAllPropertiesAssociatedToNode(Mockito.any(NodeTypeEnum.class),
- Mockito.anyString())).thenReturn(findPropertiesOfNode);
-
+ when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString())).thenReturn(isToscaNameExtending);
+
+ Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either.left(new HashMap<>());
+ when(propertyOperation.deleteAllPropertiesAssociatedToNode(Mockito.any(NodeTypeEnum.class), Mockito.anyString())).thenReturn(findPropertiesOfNode);
+
resource.setVersion("1.0");
ArrayList<String> derivedFrom = new ArrayList<String>();
@@ -1405,11 +1286,10 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
assertTrue(createResponse.isLeft());
}
-
+
@Test
public void testResourceTemplateCertify_UPDATE_SAD() {
Resource resource = createResourceObject(true);
@@ -1419,7 +1299,7 @@ public class ResourceBusinessLogicTest {
// this is in order to prevent failing with 403 earlier
Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
-
+
Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(false);
when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
.thenReturn(isToscaNameExtending);
@@ -1431,8 +1311,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
- user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user,
+ false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND);
@@ -1443,28 +1323,23 @@ public class ResourceBusinessLogicTest {
public void createOrUpdateResourceAlreadyCheckout() {
Resource resourceExist = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
createResponse.left().value().setLastUpdaterUserId(user.getUserId());
assertTrue(createResponse.isLeft());
- Either<Component, StorageOperationStatus> getLatestResult = Either.left(createResponse.left().value());
- when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getLatestResult);
- when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)))
- .thenReturn(getLatestResult);
+ Either<Resource, StorageOperationStatus> getLatestResult = Either.left(createResponse.left().value());
+ Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createResponse.left().value());
+ when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getCompLatestResult);
+ when(toscaOperationFacade.overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class))).thenReturn(getLatestResult);
Resource resourceToUpdtae = createResourceObject(false);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
- .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class),
- Mockito.any(Resource.class));
- Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user),
- Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
- Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class));
+ Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1472,34 +1347,28 @@ public class ResourceBusinessLogicTest {
public void createOrUpdateResourceCertified() {
Resource resourceExist = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
Resource certifiedResource = createResponse.left().value();
certifiedResource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
certifiedResource.setVersion("1.0");
+
- Either<Component, StorageOperationStatus> getLatestResult = Either.left(certifiedResource);
- when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getLatestResult);
- when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)))
- .thenReturn(getLatestResult);
+ Either<Resource, StorageOperationStatus> getLatestResult = Either.left(certifiedResource);
+ Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createResponse.left().value());
+ when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getCompLatestResult);
+ when(toscaOperationFacade.overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class))).thenReturn(getLatestResult);
- when(lifecycleBl.changeState(Mockito.anyString(), Mockito.eq(user),
- Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
- Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(createResponse);
+ when(lifecycleBl.changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(createResponse);
Resource resourceToUpdtae = createResourceObject(false);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
- .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Component.class),
- Mockito.any(Component.class));
- Mockito.verify(lifecycleBl, Mockito.times(1)).changeState(Mockito.anyString(), Mockito.eq(user),
- Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
- Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class));
+ Mockito.verify(lifecycleBl, Mockito.times(1)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1510,20 +1379,14 @@ public class ResourceBusinessLogicTest {
Either<Component, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.NOT_FOUND);
when(toscaOperationFacade.getLatestByName(resourceToUpdtae.getName())).thenReturn(getLatestResult);
- Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either
- .right(StorageOperationStatus.NOT_FOUND);
- when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName()))
- .thenReturn(getLatestToscaNameResult);
+ Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either.right(StorageOperationStatus.NOT_FOUND);
+ when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName())).thenReturn(getLatestToscaNameResult);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
- .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(Mockito.any(Component.class),
- Mockito.any(Component.class));
- Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user),
- Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
- Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class));
+ Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1567,381 +1430,294 @@ public class ResourceBusinessLogicTest {
assertTrue(validatePropertiesDefaultValues.isRight());
}
- // @Test
- // public void testDeleteMarkedResourcesNoResources() {
- // List<GraphVertex> ids = new ArrayList<>();
- // Either<List<GraphVertex>, StorageOperationStatus> eitherNoResources =
- // Either.left(ids);
- // when(topologyTemplateOperation.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources);
- //
- // Either<List<String>, ResponseFormat> deleteMarkedResources =
- // bl.deleteMarkedComponents();
- // assertTrue(deleteMarkedResources.isLeft());
- // assertTrue(deleteMarkedResources.left().value().isEmpty());
- //
- // Mockito.verify(artifactManager,
- // Mockito.times(0)).deleteAllComponentArtifactsIfNotOnGraph(Mockito.anyList());
- //
- // }
- //
- // @Test
- // public void testDeleteMarkedResources() {
- // List<String> ids = new ArrayList<String>();
- // String resourceInUse = "123";
- // ids.add(resourceInUse);
- // String resourceFree = "456";
- // ids.add(resourceFree);
- // Either<List<String>, StorageOperationStatus> eitherNoResources =
- // Either.left(ids);
- // when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources);
- //
- // Either<Boolean, StorageOperationStatus> resourceInUseResponse =
- // Either.left(true);
- // Either<Boolean, StorageOperationStatus> resourceFreeResponse =
- // Either.left(false);
- //
- // List<ArtifactDefinition> artifacts = new ArrayList<ArtifactDefinition>();
- // Either<List<ArtifactDefinition>, StorageOperationStatus>
- // getArtifactsResponse = Either.left(artifacts);
- // when(toscaOperationFacade.getComponentArtifactsForDelete(resourceFree,
- // NodeTypeEnum.Resource, true)).thenReturn(getArtifactsResponse);
- //
- // when(toscaOperationFacade.isComponentInUse(resourceFree)).thenReturn(resourceFreeResponse);
- // when(toscaOperationFacade.isComponentInUse(resourceInUse)).thenReturn(resourceInUseResponse);
- //
- // Either<Component, StorageOperationStatus> eitherDelete = Either.left(new
- // Resource());
- // when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
- //
- // when(artifactManager.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK);
- // List<String> deletedComponents = new ArrayList<>();
- // deletedComponents.add(resourceFree);
- // when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(deletedComponents));
- //
- // Either<List<String>, ResponseFormat> deleteMarkedResources =
- // bl.deleteMarkedComponents();
- // assertTrue(deleteMarkedResources.isLeft());
- // List<String> resourceIdList = deleteMarkedResources.left().value();
- // assertFalse(resourceIdList.isEmpty());
- // assertTrue(resourceIdList.contains(resourceFree));
- // assertFalse(resourceIdList.contains(resourceInUse));
- //
- // Mockito.verify(artifactManager,
- // Mockito.times(1)).deleteAllComponentArtifactsIfNotOnGraph(artifacts);
- // }
-
+// @Test
+// public void testDeleteMarkedResourcesNoResources() {
+// List<GraphVertex> ids = new ArrayList<>();
+// Either<List<GraphVertex>, StorageOperationStatus> eitherNoResources = Either.left(ids);
+// when(topologyTemplateOperation.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources);
+//
+// Either<List<String>, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents();
+// assertTrue(deleteMarkedResources.isLeft());
+// assertTrue(deleteMarkedResources.left().value().isEmpty());
+//
+// Mockito.verify(artifactManager, Mockito.times(0)).deleteAllComponentArtifactsIfNotOnGraph(Mockito.anyList());
+//
+// }
+//
+// @Test
+// public void testDeleteMarkedResources() {
+// List<String> ids = new ArrayList<String>();
+// String resourceInUse = "123";
+// ids.add(resourceInUse);
+// String resourceFree = "456";
+// ids.add(resourceFree);
+// Either<List<String>, StorageOperationStatus> eitherNoResources = Either.left(ids);
+// when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources);
+//
+// Either<Boolean, StorageOperationStatus> resourceInUseResponse = Either.left(true);
+// Either<Boolean, StorageOperationStatus> resourceFreeResponse = Either.left(false);
+//
+// List<ArtifactDefinition> artifacts = new ArrayList<ArtifactDefinition>();
+// Either<List<ArtifactDefinition>, StorageOperationStatus> getArtifactsResponse = Either.left(artifacts);
+// when(toscaOperationFacade.getComponentArtifactsForDelete(resourceFree, NodeTypeEnum.Resource, true)).thenReturn(getArtifactsResponse);
+//
+// when(toscaOperationFacade.isComponentInUse(resourceFree)).thenReturn(resourceFreeResponse);
+// when(toscaOperationFacade.isComponentInUse(resourceInUse)).thenReturn(resourceInUseResponse);
+//
+// Either<Component, StorageOperationStatus> eitherDelete = Either.left(new Resource());
+// when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
+//
+// when(artifactManager.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK);
+// List<String> deletedComponents = new ArrayList<>();
+// deletedComponents.add(resourceFree);
+// when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(deletedComponents));
+//
+// Either<List<String>, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents();
+// assertTrue(deleteMarkedResources.isLeft());
+// List<String> resourceIdList = deleteMarkedResources.left().value();
+// assertFalse(resourceIdList.isEmpty());
+// assertTrue(resourceIdList.contains(resourceFree));
+// assertFalse(resourceIdList.contains(resourceInUse));
+//
+// Mockito.verify(artifactManager, Mockito.times(1)).deleteAllComponentArtifactsIfNotOnGraph(artifacts);
+// }
@SuppressWarnings("unchecked")
@Test
public void testFindVfCsarArtifactsToHandle() {
-
+
Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
String methodName = "findVfCsarArtifactsToHandle";
Resource resource = new Resource();
String deploymentArtifactToUpdateFileName = "deploymentArtifactToUpdate.yaml";
String deploymentArtifactToDeleteFileName = "deploymentArtifactToDelete.yaml";
String deploymentArtifactToCreateFileName = "deploymentArtifactToCreate.yaml";
-
+
String artifactInfoToUpdateFileName = "infoArtifactToUpdate.yaml";
String artifactInfoToDeleteFileName = "infoArtifactToDelete.yaml";
String artifactInfoToCreateFileName = "infoArtifactToCreate.yaml";
-
+
byte[] oldPayloadData = "oldPayloadData".getBytes();
byte[] newPayloadData = "newPayloadData".getBytes();
- Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
-
+ Map<String, ArtifactDefinition> deploymentArtifacts =new HashMap<>();
+
ArtifactDefinition deploymentArtifactToUpdate = new ArtifactDefinition();
deploymentArtifactToUpdate.setMandatory(false);
deploymentArtifactToUpdate.setArtifactName(deploymentArtifactToUpdateFileName);
deploymentArtifactToUpdate.setArtifactType("SNMP_POLL");
deploymentArtifactToUpdate.setPayload(oldPayloadData);
- deploymentArtifactToUpdate
- .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+ deploymentArtifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
+
ArtifactDefinition deploymentArtifactToDelete = new ArtifactDefinition();
deploymentArtifactToDelete.setMandatory(false);
deploymentArtifactToDelete.setArtifactName(deploymentArtifactToDeleteFileName);
deploymentArtifactToDelete.setArtifactType("SNMP_TRAP");
deploymentArtifactToDelete.setPayload(oldPayloadData);
- deploymentArtifactToDelete
- .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+ deploymentArtifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
+
ArtifactDefinition deploymentArtifactToIgnore = new ArtifactDefinition();
-
- deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()),
- deploymentArtifactToUpdate);
- deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToDelete.getArtifactName()),
- deploymentArtifactToDelete);
+
+ deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()), deploymentArtifactToUpdate);
+ deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToDelete.getArtifactName()), deploymentArtifactToDelete);
deploymentArtifacts.put("ignore", deploymentArtifactToIgnore);
-
+
Map<String, ArtifactDefinition> artifacts = new HashMap<>();
-
+
ArtifactDefinition artifactToUpdate = new ArtifactDefinition();
artifactToUpdate.setMandatory(false);
artifactToUpdate.setArtifactName(artifactInfoToUpdateFileName);
artifactToUpdate.setArtifactType("SNMP_POLL");
artifactToUpdate.setPayload(oldPayloadData);
artifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+
ArtifactDefinition artifactToDelete = new ArtifactDefinition();
artifactToDelete.setMandatory(false);
artifactToDelete.setArtifactName(artifactInfoToDeleteFileName);
artifactToDelete.setArtifactType("SNMP_TRAP");
artifactToDelete.setPayload(oldPayloadData);
artifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+
ArtifactDefinition artifactToIgnore = new ArtifactDefinition();
-
- artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToUpdate.getArtifactName()), artifactToUpdate);
- artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToDelete.getArtifactName()), artifactToDelete);
- artifacts.put("ignore", artifactToIgnore);
-
+
+ artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToUpdate.getArtifactName()),artifactToUpdate);
+ artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToDelete.getArtifactName()),artifactToDelete);
+ artifacts.put("ignore",artifactToIgnore);
+
resource.setDeploymentArtifacts(deploymentArtifacts);
resource.setArtifacts(artifacts);
-
+
List<NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
- NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo(
- deploymentArtifactToUpdate.getArtifactName(), null,
- ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()),
- ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName());
-
- NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo(
- artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()),
- ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName());
-
- NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName,
- null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData,
- deploymentArtifactToCreateFileName);
-
- NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName,
- null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData,
- artifactInfoToCreateFileName);
-
+ NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo(deploymentArtifactToUpdate.getArtifactName(), null,
+ ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()), ArtifactGroupTypeEnum.DEPLOYMENT,
+ newPayloadData, deploymentArtifactToUpdate.getArtifactName());
+
+ NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo(artifactToUpdate.getArtifactName(), null,
+ ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), ArtifactGroupTypeEnum.DEPLOYMENT,
+ newPayloadData, artifactToUpdate.getArtifactName());
+
+ NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName, null,
+ ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToCreateFileName);
+
+ NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName, null,
+ ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT,
+ newPayloadData, artifactInfoToCreateFileName);
+
artifactPathAndNameList.add(deploymentArtifactInfoToUpdate);
artifactPathAndNameList.add(informationalArtifactInfoToUpdate);
artifactPathAndNameList.add(deploymentArtifactInfoToCreate);
artifactPathAndNameList.add(informationalArtifactInfoToCreate);
-
- Object[] argObjects = { resource, artifactPathAndNameList, user };
- Class[] argClasses = { Resource.class, List.class, User.class };
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = (Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat>) method
- .invoke(bl, argObjects);
- assertTrue(findVfCsarArtifactsToHandleRes.isLeft());
- EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> foundVfArtifacts = findVfCsarArtifactsToHandleRes
- .left().value();
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size() == 2);
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Update).size() == 2);
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size() == 2);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testBuildNestedVfcToscaNamespace() {
-
- Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
- String methodName = "buildNestedVfcToscaNamespace";
- String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- String expectedNestedVfcToscaNamespace = "org.openecomp.resource.vfc.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- Object[] argObjects = { nodeTypeFullName };
- Class[] argClasses = { String.class };
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedVfcToscaNamespace = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedVfcToscaNamespace.isEmpty());
- assertTrue(actualNestedVfcToscaNamespace.equals(expectedNestedVfcToscaNamespace));
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testBuildNestedVfcToscaResourceName() {
-
- Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
- String methodName = "buildNestedVfcToscaResourceName";
- String vfResourceName = "vfname";
- String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- String expectedNestedVfcToscaResourceName = "org.openecomp.resource.vfc.vfname.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- Object[] argObjects = { vfResourceName, nodeTypeFullName };
- Class[] argClasses = { String.class, String.class };
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedVfcToscaResourceName = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedVfcToscaResourceName.isEmpty());
- assertTrue(actualNestedVfcToscaResourceName.equals(expectedNestedVfcToscaResourceName));
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testBuildNestedSubstituteYamlName() {
-
- Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
- String methodName = "buildNestedSubstituteYamlName";
- String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- String expectedNestedSubstituteYamlName = "Definitions/FEAdd_On_Module_vLBAgentTemplateServiceTemplate.yaml";
- Object[] argObjects = { nodeTypeFullName };
- Class[] argClasses = { String.class };
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedSubstituteYamlName = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedSubstituteYamlName.isEmpty());
- assertTrue(actualNestedSubstituteYamlName.equals(expectedNestedSubstituteYamlName));
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+
+ Object[] argObjects = {resource, artifactPathAndNameList, user};
+ Class[] argClasses = {Resource.class, List.class, User.class};
+ try {
+ Method method = targetClass.getDeclaredMethod(methodName, argClasses);
+ method.setAccessible(true);
+ Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes =
+ (Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat>) method.invoke(bl, argObjects);
+ assertTrue(findVfCsarArtifactsToHandleRes.isLeft());
+ EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> foundVfArtifacts = findVfCsarArtifactsToHandleRes.left().value();
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size()==2);
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Update).size()==2);
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size()==2);
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
@Test
public void testVFGeneratedInputs() {
-
+
Resource resource = createVF();
List<InputDefinition> inputs = resource.getInputs();
assertTrue(8 == inputs.size());
- for (InputDefinition input : inputs) {
+ for(InputDefinition input : inputs){
assertNotNull(input.getOwnerId());
}
assertTrue(resource.getDerivedFromGenericType().equals(genericVF.getToscaResourceName()));
assertTrue(resource.getDerivedFromGenericVersion().equals(genericVF.getVersion()));
}
-
+
@Test
public void testVFUpdateGenericInputsToLatestOnCheckout() {
-
- // create a VF that is derived from generic version 1.0
- Resource resource = createVF();
+
+ //create a VF that is derived from generic version 1.0
+ Resource resource = createVF();
// create a new generic version without properties
genericVF.setVersion("2.0");
genericVF.setProperties(null);
String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
List<InputDefinition> currentInputs = resource.getInputs();
- // verify previous inputs ownerId fields exist - user may not delete
- // generated inputs
+ //verify previous inputs ownerId fields exist - user may not delete generated inputs
assertTrue(8 == currentInputs.stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList()).size());
Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
- // verify success
+ //verify success
assertTrue(upgradeToLatestGeneric.isLeft());
- // verify update required and valid
+ //verify update required and valid
assertTrue(upgradeToLatestGeneric.left().value());
- // verify version was upgraded
+ //verify version was upgraded
assertFalse(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
- // verify inputs were not deleted
+ //verify inputs were not deleted
assertTrue(8 == resource.getInputs().size());
- // verify inputs ownerId fields were removed - user may delete/edit
- // inputs
- assertTrue(8 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
- .size());
+ //verify inputs ownerId fields were removed - user may delete/edit inputs
+ assertTrue(8 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList()).size());
}
-
+
+
@Test
public void testVFUpdateGenericInputsToLatestOnCheckoutNotPerformed() {
-
- // create a VF that is derived from generic version 1.0
+
+ //create a VF that is derived from generic version 1.0
Resource resource = createVF();
-
- // add an input to the VF
+
+ //add an input to the VF
PropertyDefinition newProp = new PropertyDefinition();
newProp.setType("integer");
newProp.setName("newProp");
resource.getInputs().add(new InputDefinition(newProp));
-
- // create a new generic version with a new property which has the same
- // name as a user defined input on the VF with a different type
+
+ //create a new generic version with a new property which has the same name as a user defined input on the VF with a different type
genericVF.setVersion("2.0");
newProp.setType("string");
genericVF.setProperties(new ArrayList<PropertyDefinition>());
genericVF.getProperties().add(newProp);
-
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericVF));
+ when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericVF.getProperties(), genericVF.getUniqueId())).thenCallRealMethod();
String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
- assertTrue(8 == resource.getInputs().stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList())
- .size());
+ assertTrue(8 == resource.getInputs().stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList()).size());
Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
- // verify success
+ //verify success
assertTrue(upgradeToLatestGeneric.isLeft());
- // verify update is invalid an void
+ //verify update is invalid an void
assertFalse(upgradeToLatestGeneric.left().value());
- // verify version was not upgraded
+ //verify version was not upgraded
assertTrue(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
- // verify inputs were not removed
+ //verify inputs were not removed
assertTrue(9 == resource.getInputs().size());
- // verify user defined input exists
- assertTrue(1 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
- .size());
- assertTrue(resource.getInputs().stream().filter(p -> null == p.getOwnerId()).findAny().get().getType()
- .equals("integer"));
+ //verify user defined input exists
+ assertTrue(1 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList()).size());
+ assertTrue(resource.getInputs().stream().filter(p -> null == p.getOwnerId()).findAny().get().getType().equals("integer"));
}
-
+
@Test
public void testPNFGeneratedInputsNoGeneratedInformationalArtifacts() {
-
+
Resource resource = createPNF();
List<InputDefinition> inputs = resource.getInputs();
assertTrue(8 == inputs.size());
- for (InputDefinition input : inputs) {
+ for(InputDefinition input : inputs){
assertNotNull(input.getOwnerId());
}
assertTrue(resource.getDerivedFromGenericType().equals(genericPNF.getToscaResourceName()));
assertTrue(resource.getDerivedFromGenericVersion().equals(genericPNF.getVersion()));
assertTrue(0 == resource.getArtifacts().size());
}
-
+
+
private Resource createVF() {
-
+
genericVF = setupGenericTypeMock(GENERIC_VF_NAME);
- when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_VF_NAME))
- .thenReturn(Either.left(genericVF));
+ when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_VF_NAME)).thenReturn(Either.left(genericVF));
Resource resource = createResourceObject(true);
resource.setDerivedFrom(null);
resource.setResourceType(ResourceTypeEnum.VF);
when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericVF));
+ when(genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericVF)).thenCallRealMethod();
+ when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericVF.getProperties(), resource.getUniqueId())).thenCallRealMethod();
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
return createResponse.left().value();
}
-
- private Resource createPNF() {
-
+
+ private Resource createPNF() {
+
genericPNF = setupGenericTypeMock(GENERIC_PNF_NAME);
- when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_PNF_NAME))
- .thenReturn(Either.left(genericPNF));
+ when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_PNF_NAME)).thenReturn(Either.left(genericPNF));
Resource resource = createResourceObject(true);
resource.setDerivedFrom(null);
resource.setResourceType(ResourceTypeEnum.PNF);
when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
- AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericPNF));
+ when(genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericPNF)).thenCallRealMethod();
+ when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericPNF.getProperties(), resource.getUniqueId())).thenCallRealMethod();
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
return createResponse.left().value();
}
+
- private Resource setupGenericTypeMock(String toscaName) {
-
+
+ private Resource setupGenericTypeMock(String toscaName) {
+
Resource genericType = createResourceObject(true);
genericType.setVersion("1.0");
genericType.setToscaResourceName(toscaName);
- String[] propNames = { "nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming",
- "availability_zone_max_count", "min_instances", "max_instances" };
- String[] propTypes = { "string", "string", "string", "string", "org.openecomp.datatypes.Naming", "integer",
- "integer", "integer" };
+ String[] propNames = {"nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count", "min_instances", "max_instances"};
+ String[] propTypes = {"string", "string", "string", "string", "org.openecomp.datatypes.Naming", "integer", "integer", "integer"};
List<PropertyDefinition> genericProps = new ArrayList<>();
- for (int i = 0; i < 8; ++i) {
+ for(int i = 0; i < 8; ++i){
PropertyDefinition prop = new PropertyDefinition();
prop.setName(propNames[i]);
prop.setType(propTypes[i]);
@@ -1951,427 +1727,6 @@ public class ResourceBusinessLogicTest {
return genericType;
}
- private ResourceBusinessLogic createTestSubject() {
- return new ResourceBusinessLogic();
- }
-
- @Test
- public void testGetCsarOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- CsarOperation result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCsarOperation();
- }
-
- @Test
- public void testSetCsarOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- CsarOperation csarOperation = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCsarOperation(csarOperation);
- }
-
-
- @Test
- public void testGetLifecycleBusinessLogic() throws Exception {
- ResourceBusinessLogic testSubject;
- LifecycleBusinessLogic result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLifecycleBusinessLogic();
- }
-
-
- @Test
- public void testSetLifecycleManager() throws Exception {
- ResourceBusinessLogic testSubject;
- LifecycleBusinessLogic lifecycleBusinessLogic = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLifecycleManager(lifecycleBusinessLogic);
- }
-
-
- @Test
- public void testGetElementDao() throws Exception {
- ResourceBusinessLogic testSubject;
- IElementOperation result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getElementDao();
- }
-
-
- @Test
- public void testSetElementDao() throws Exception {
- ResourceBusinessLogic testSubject;
- IElementOperation elementDao = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setElementDao(elementDao);
- }
-
-
- @Test
- public void testGetUserAdmin() throws Exception {
- ResourceBusinessLogic testSubject;
- IUserBusinessLogic result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserAdmin();
- }
-
-
- @Test
- public void testSetUserAdmin() throws Exception {
- ResourceBusinessLogic testSubject;
- UserBusinessLogic userAdmin = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUserAdmin(userAdmin);
- }
-
-
- @Test
- public void testGetComponentsUtils() throws Exception {
- ResourceBusinessLogic testSubject;
- ComponentsUtils result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getComponentsUtils();
- }
-
-
- @Test
- public void testSetComponentsUtils() throws Exception {
- ResourceBusinessLogic testSubject;
- ComponentsUtils componentsUtils = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setComponentsUtils(componentsUtils);
- }
-
-
- @Test
- public void testGetArtifactsManager() throws Exception {
- ResourceBusinessLogic testSubject;
- ArtifactsBusinessLogic result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifactsManager();
- }
-
-
- @Test
- public void testSetArtifactsManager() throws Exception {
- ResourceBusinessLogic testSubject;
- ArtifactsBusinessLogic artifactsManager = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setArtifactsManager(artifactsManager);
- }
-
-
- @Test
- public void testSetPropertyOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- IPropertyOperation propertyOperation = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setPropertyOperation(propertyOperation);
- }
-
-
- @Test
- public void testGetApplicationDataTypeCache() throws Exception {
- ResourceBusinessLogic testSubject;
- ApplicationDataTypeCache result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getApplicationDataTypeCache();
- }
-
-
- @Test
- public void testSetApplicationDataTypeCache() throws Exception {
- ResourceBusinessLogic testSubject;
- ApplicationDataTypeCache applicationDataTypeCache = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setApplicationDataTypeCache(applicationDataTypeCache);
- }
-
- @Test
- public void testSetDeploymentArtifactsPlaceHolder() throws Exception {
- ResourceBusinessLogic testSubject;
- Component component = new Resource() {
- };
- User user = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDeploymentArtifactsPlaceHolder(component, user);
- }
-
-
-
- @Test
- public void testValidateVendorReleaseName_1() throws Exception {
- ResourceBusinessLogic testSubject;
- String vendorRelease = "";
- Either<Boolean, ResponseFormat> result;
-
- // test 1
- testSubject = createTestSubject();
- vendorRelease = null;
- result = testSubject.validateVendorReleaseName(vendorRelease);
- Assert.assertEquals(false, result.left().value());
-
- }
-
-
-
-
-
-
- @Test
- public void testGetCapabilityTypeOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- ICapabilityTypeOperation result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCapabilityTypeOperation();
- }
-
-
- @Test
- public void testSetCapabilityTypeOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- ICapabilityTypeOperation capabilityTypeOperation = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCapabilityTypeOperation(capabilityTypeOperation);
- }
-
-
- @Test
- public void testValidatePropertiesDefaultValues() throws Exception {
- ResourceBusinessLogic testSubject;
- Resource resource = new Resource();
- Either<Boolean, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validatePropertiesDefaultValues(resource);
- }
-
-
- @Test
- public void testGetComponentInstanceBL() throws Exception {
- ResourceBusinessLogic testSubject;
- ComponentInstanceBusinessLogic result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getComponentInstanceBL();
- }
-
-
-
- @Test
- public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception {
- ResourceBusinessLogic testSubject;
- String componentId = "";
- ComponentTypeEnum componentTypeEnum = null;
- String userId = "";
- String searchText = "";
- Either<List<ComponentInstance>, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getComponentInstancesFilteredByPropertiesAndInputs(componentId, componentTypeEnum, userId,
- searchText);
- }
-
-
-
- @Test
- public void testGetCacheManagerOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- ICacheMangerOperation result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCacheManagerOperation();
- }
-
-
- @Test
- public void testSetCacheManagerOperation() throws Exception {
- ResourceBusinessLogic testSubject;
- ICacheMangerOperation cacheManagerOperation = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCacheManagerOperation(cacheManagerOperation);
- }
-
-
- @Test
- public void testGetElementDao_1() throws Exception {
- ResourceBusinessLogic testSubject;IElementOperation result;
-
- // default test
- testSubject=createTestSubject();result=testSubject.getElementDao();
- }
-
-
- @Test
- public void testGetAllCertifiedResources() throws Exception {
- ResourceBusinessLogic testSubject;boolean getAbstract = false;
- HighestFilterEnum highestFilter = null;
- String userId = "";
- Either<List<Resource>,ResponseFormat> result;
-
- // default test
- }
-
-
- @Test
- public void testValidateResourceNameExists() throws Exception {
- ResourceBusinessLogic testSubject;String resourceName = "";
- ResourceTypeEnum resourceTypeEnum = null;
- String userId = "";
- Either<Map<String,Boolean>,ResponseFormat> result;
-
- // default test
- }
-
-
- @Test
- public void testCreateResource() throws Exception {
- ResourceBusinessLogic testSubject;Resource resource = null;
- AuditingActionEnum auditingAction = null;
- User user = null;
- Map<String,byte[]> csarUIPayload = null;
- String payloadName = "";
- Either<Resource,ResponseFormat> result;
-
- // test 1
- testSubject=createTestSubject();payloadName = null;
-
- // test 2
- testSubject=createTestSubject();payloadName = "";
- }
-
-
- @Test
- public void testValidateAndUpdateResourceFromCsar() throws Exception {
- ResourceBusinessLogic testSubject;Resource resource = null;
- User user = null;
- Map<String,byte[]> csarUIPayload = null;
- String payloadName = "";
- String resourceUniqueId = "";
- Either<Resource,ResponseFormat> result;
-
- // test 1
- testSubject=createTestSubject();payloadName = null;
-
- // test 2
- testSubject=createTestSubject();payloadName = "";
- }
-
-
-
-
-
-
-
-
-
-
-
- @Test
- public void testCreateResourceFromCsar() throws Exception {
- ResourceBusinessLogic testSubject;Resource resource = null;
- User user = null;
- Either<Map<String,byte[]>,StorageOperationStatus> csarUIPayload = null;
- String csarUUID = "";
- Either<Resource,ResponseFormat> result;
-
- // test 1
- testSubject=createTestSubject();csarUIPayload = null;
- }
-
-
-
-
-
-
-
- @Test
- public void testCreateResourcesFromYamlNodeTypesList() throws Exception {
- ResourceBusinessLogic testSubject;String yamlName = "";
- Resource resource = null;
- Map<String,Object> mappedToscaTemplate = null;
- boolean needLock = false;
- Map<String,EnumMap<ArtifactOperationEnum,List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = null;
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = null;
- Map<String,NodeTypeInfo> nodeTypesInfo = null;
- CsarInfo csarInfo = null;
- Either<Map<String,Resource>,ResponseFormat> result;
-
- // default test
- }
-
-
-
-
-
-
- @Test
- public void testValidateResourceCreationFromNodeType() throws Exception {
- ResourceBusinessLogic testSubject;Resource resource = null;
- User creator = null;
- Either<Boolean,ResponseFormat> result;
-
- // default test
- }
-
-
- @Test
- public void testCreateResourceFromNodeType() throws Exception {
- ResourceBusinessLogic testSubject;String nodeTypeYaml = "";
- UploadResourceInfo resourceMetaData = null;
- User creator = null;
- boolean isInTransaction = false;
- boolean needLock = false;
- Map<ArtifactOperationEnum,List<ArtifactDefinition>> nodeTypeArtifactsToHandle = null;
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = null;
- boolean forceCertificationAllowed = false;
- CsarInfo csarInfo = null;
- Either<ImmutablePair<Resource,ActionStatus>,ResponseFormat> result;
-
- // default test
- }
-
+
+
}
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 a3022330a1..581adb28df 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
@@ -20,7 +20,16 @@
package org.openecomp.sdc.be.components.impl;
-import fj.data.Either;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -52,13 +61,7 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.*;
+import fj.data.Either;
public class ResourceInstanceBusinessLogicTest {
@@ -141,8 +144,8 @@ public class ResourceInstanceBusinessLogicTest {
StorageOperationStatus status = StorageOperationStatus.OK;
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(Map.class))).thenReturn(status);
- Mockito.when(toscaOperationFacade.addGroupInstancesToComponentInstance(Mockito.any(Component.class), Mockito.any(ComponentInstance.class), Mockito.any(List.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);
}
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
new file mode 100644
index 0000000000..309689af45
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
@@ -0,0 +1,97 @@
+package org.openecomp.sdc.be.components.impl.generic;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.List;
+
+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.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class GenericTypeBusinessLogicTest {
+
+ @InjectMocks
+ private GenericTypeBusinessLogic testInstance;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacadeMock;
+
+ @Before
+ public void setUp() throws Exception {
+ testInstance = new GenericTypeBusinessLogic();
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @Test
+ public void fetchDerivedFromGenericType_cvfv_getGenericResourceTypeFromDerivedFrom() throws Exception {
+ Resource cvfc = new Resource();
+ cvfc.setResourceType(ResourceTypeEnum.CVFC);
+ cvfc.setDerivedFrom(Arrays.asList("genericType", "someOtherType"));
+ Resource genericResource = new Resource();
+ when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName("genericType")).thenReturn(Either.left(genericResource));
+ Either<Resource, ResponseFormat> fetchedGenericType = testInstance.fetchDerivedFromGenericType(cvfc);
+ assertEquals(genericResource, fetchedGenericType.left().value());
+ }
+
+ @Test
+ public void fetchDerivedFromGenericType_getGenericResourceTypeFromConfiguration() throws Exception {
+ Resource resource = Mockito.mock(Resource.class);
+ when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VF);
+ when(resource.fetchGenericTypeToscaNameFromConfig()).thenReturn("genericType");
+ Resource genericResource = new Resource();
+ when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName("genericType")).thenReturn(Either.left(genericResource));
+ Either<Resource, ResponseFormat> fetchedGenericType = testInstance.fetchDerivedFromGenericType(resource);
+ assertEquals(genericResource, fetchedGenericType.left().value());
+ }
+
+ @Test
+ public void generateInputsFromGenericTypeProperties() throws Exception {
+ Resource genericNodeType = new Resource();
+ genericNodeType.setUniqueId("genericUid");
+ PropertyDefinition propertyDefinition = generatePropDefinition("prop1");
+ PropertyDefinition propertyDefinition2 = generatePropDefinition("prop2");
+
+ genericNodeType.setProperties(Arrays.asList(propertyDefinition, propertyDefinition2));
+
+ List<InputDefinition> genericInputs = testInstance.generateInputsFromGenericTypeProperties(genericNodeType);
+ assertEquals(2, genericInputs.size());
+ assertInput(genericInputs.get(0), propertyDefinition);
+ assertInput(genericInputs.get(1), propertyDefinition2);
+ }
+
+ @Test
+ public void generateInputsFromGenericTypeProperties_genericHasNoProps() throws Exception {
+ Resource genericNodeType = new Resource();
+ assertTrue(testInstance.generateInputsFromGenericTypeProperties(genericNodeType).isEmpty());
+ }
+
+ private void assertInput(InputDefinition inputDefinition, PropertyDefinition propertyDefinition) {
+ assertEquals(inputDefinition.getOwnerId(), "genericUid");
+ assertEquals(inputDefinition.getValue(), propertyDefinition.getValue());
+ assertEquals(inputDefinition.getName(), propertyDefinition.getName());
+ }
+
+ private PropertyDefinition generatePropDefinition(String name) {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName(name);
+ propertyDefinition.setValue(name + "value");
+ return propertyDefinition;
+ }
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java
index 72c58c02f0..31c795478a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java
@@ -22,23 +22,16 @@ package org.openecomp.sdc.be.components.lifecycle;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
-import org.openecomp.sdc.be.components.lifecycle.CertificationChangeTransition;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -51,11 +44,8 @@ public class CertificationChangeTransitionTest extends LifecycleTestBase {
private CertificationChangeTransition certificationFailObj = null;
private ComponentsUtils componentsUtils = new ComponentsUtils();
- private String resourceName = "myResource";
private User owner = null;
- protected ArtifactsBusinessLogic artifactsManager = Mockito.mock(ArtifactsBusinessLogic.class);
-
Resource resource;
@SuppressWarnings("unchecked")
@@ -79,8 +69,7 @@ public class CertificationChangeTransitionTest extends LifecycleTestBase {
owner = new User("cs0008", "Carlos", "Santana", "cs@sdc.com", "DESIGNER", null);
- when(artifactsManager.deleteAllComponentArtifactsIfNotOnGraph(Mockito.anyList())).thenReturn(StorageOperationStatus.OK);
- resource = createResourceObject(false);
+ resource = createResourceObject();
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java
index 6bfd64be41..5530d4c0f5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java
@@ -20,13 +20,20 @@
package org.openecomp.sdc.be.components.lifecycle;
-import fj.data.Either;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -44,46 +51,40 @@ import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
-import org.openecomp.sdc.be.tosca.ToscaError;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
-import org.openecomp.sdc.be.tosca.ToscaRepresentation;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
+import fj.data.Either;
+@RunWith(MockitoJUnitRunner.Silent.class)
public class CertificationRequestTest extends LifecycleTestBase {
private ComponentsUtils componentsUtils = new ComponentsUtils();
+ @Mock
+ private ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder;
+ @Mock
+ private ServiceBusinessLogic serviceBusinessLogic;
+ @Mock
+ private CapabilityOperation capabilityOperation;
+ @Mock
+ private ToscaExportHandler toscaExportUtils;
- protected ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder = Mockito.mock(ServiceDistributionArtifactsBuilder.class);
- protected ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
- protected CapabilityOperation capabilityOperation = Mockito.mock(CapabilityOperation.class);
- protected ToscaExportHandler toscaExportUtils = Mockito.mock(ToscaExportHandler.class);
- @InjectMocks
- private CertificationRequestTransition rfcObj = new CertificationRequestTransition(componentsUtils, toscaElementLifecycleOperation, serviceDistributionArtifactsBuilder, serviceBusinessLogic, capabilityOperation, toscaExportUtils, toscaOperationFacade, titanDao);
+ private CertificationRequestTransition rfcObj;
- protected ToscaRepresentation toscaRepresentation = Mockito.mock(ToscaRepresentation.class);
@Before
public void setup() {
- MockitoAnnotations.initMocks(this);
super.setup();
-
+ rfcObj = new CertificationRequestTransition(componentsUtils, toscaElementLifecycleOperation, serviceDistributionArtifactsBuilder, serviceBusinessLogic, capabilityOperation, toscaExportUtils, toscaOperationFacade, titanDao);
// checkout transition object
- rfcObj.setLifeCycleOperation(toscaElementLifecycleOperation);
+// rfcObj.setLifeCycleOperation(toscaElementLifecycleOperation);
// checkoutObj.setAuditingManager(iAuditingManager);
rfcObj.setConfigurationManager(configurationManager);
componentsUtils.Init();
- Either<ToscaRepresentation, ToscaError> either = Either.left(toscaRepresentation);
- when(toscaExportUtils.exportComponent(Mockito.anyObject())).thenReturn(either);
-
+// Either<ToscaRepresentation, ToscaError> either = Either.left(toscaRepresentation);
+// when(toscaExportUtils.exportComponent(Mockito.any())).thenReturn(either);
}
@Test
@@ -109,7 +110,7 @@ public class CertificationRequestTest extends LifecycleTestBase {
@Test
public void testCheckoutStateValidation() {
Either<? extends Component, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
Either<User, ResponseFormat> ownerResponse = rfcObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -130,7 +131,7 @@ public class CertificationRequestTest extends LifecycleTestBase {
@Test
public void testAlreadyRfc() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
Either<User, ResponseFormat> ownerResponse = rfcObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -146,7 +147,7 @@ public class CertificationRequestTest extends LifecycleTestBase {
@Test
public void testCertificationInProgress() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
Either<User, ResponseFormat> ownerResponse = rfcObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -162,7 +163,7 @@ public class CertificationRequestTest extends LifecycleTestBase {
@Test
public void testAlreadyCertified() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
Either<User, ResponseFormat> ownerResponse = rfcObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java
index 6a009d06c5..21111ef59e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java
@@ -25,9 +25,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
-import org.openecomp.sdc.be.components.lifecycle.CheckinTransition;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -59,7 +57,7 @@ public class CheckinTest extends LifecycleTestBase {
@Test
public void testSimpleCheckin() {
Either<Boolean, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
Either<User, ResponseFormat> ownerResponse = checkinObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -87,7 +85,7 @@ public class CheckinTest extends LifecycleTestBase {
@Test
public void testCheckinTwiceValidation() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
Either<User, ResponseFormat> owner = checkinObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -122,7 +120,7 @@ public class CheckinTest extends LifecycleTestBase {
@Test
public void testCheckoutByAnotherUserValidation() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
User modifier = new User();
modifier.setUserId("modifier");
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 4a10bbfba4..1e3f6f6ce8 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
@@ -27,7 +27,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
-import org.openecomp.sdc.be.components.lifecycle.CheckoutTransition;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -57,13 +56,15 @@ public class CheckoutTest extends LifecycleTestBase {
checkoutObj.setLifeCycleOperation(toscaElementLifecycleOperation);
checkoutObj.setConfigurationManager(configurationManager);
componentsUtils.Init();
+ bl.setToscaOperationFacade(toscaOperationFacade);
+ bl.setComponentsUtils(componentsUtils);
}
@Test
public void testCheckoutStateValidation() {
Either<? extends Component, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -81,7 +82,7 @@ public class CheckoutTest extends LifecycleTestBase {
@Test
public void testAlreadyCheckout() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -99,7 +100,7 @@ public class CheckoutTest extends LifecycleTestBase {
@Test
public void testCertificationInProgress() {
Either<? extends Component, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -119,7 +120,7 @@ public class CheckoutTest extends LifecycleTestBase {
@Test
public void testReadyForCertification() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
@@ -159,7 +160,7 @@ public class CheckoutTest extends LifecycleTestBase {
@Test
public void testRoles() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
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 ff5c618138..bc131ff39a 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,6 +27,7 @@ import java.util.List;
import javax.servlet.ServletContext;
+import org.junit.BeforeClass;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -39,7 +40,6 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
@@ -67,11 +67,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
import fj.data.Either;
-import junit.framework.Assert;
public class LifecycleTestBase {
private static Logger log = LoggerFactory.getLogger(LifecycleTestBase.class.getName());
@@ -86,19 +82,22 @@ public class LifecycleTestBase {
protected User user = null;
protected Resource resourceResponse;
protected Service serviceResponse;
- protected ConfigurationManager configurationManager = null;
+ protected static ConfigurationManager configurationManager = null;
protected ResponseFormatManager responseManager = null;
protected TitanDao titanDao = Mockito.mock(TitanDao.class);
protected ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- public void setup() {
-
+ @BeforeClass
+ public static void setupClass() {
ExternalConfiguration.setAppName("catalog-be");
// Init Configuration
String appConfigDir = "src/test/resources/config/catalog-be";
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
configurationManager = new ConfigurationManager(configurationSource);
+ }
+
+ public void setup() {
// Auditing
iAuditingManager = new AuditingMockManager("lll");
@@ -124,7 +123,7 @@ public class LifecycleTestBase {
// getCount
// createResource
- resourceResponse = createResourceObject(true);
+ resourceResponse = createResourceObject();
Either<ToscaElement, StorageOperationStatus> eitherComponent = Either.left(ModelConverter.convertToToscaElement(resourceResponse));
when(toscaElementLifecycleOperation.checkoutToscaElement(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class)))
.thenAnswer(createAnswer(eitherComponent));
@@ -137,7 +136,10 @@ public class LifecycleTestBase {
Either<User, StorageOperationStatus> getOwnerResult = Either.left(user);
when(toscaElementLifecycleOperation.getToscaElementOwner(Mockito.anyString())).thenReturn(getOwnerResult);
-
+
+ Either<Component, StorageOperationStatus> eitherlatestDerived = Either.right(StorageOperationStatus.OK);
+ when(toscaOperationFacade.shouldUpgradeToLatestDerived(Mockito.any(Resource.class))).thenReturn(eitherlatestDerived);
+
responseManager = ResponseFormatManager.getInstance();
}
@@ -153,9 +155,10 @@ public class LifecycleTestBase {
return dummy;
}
- protected Resource createResourceObject(boolean afterCreate) {
+ protected Resource createResourceObject() {
Resource resource = new Resource();
resource.setName("MyResourceName");
+ resource.setUniqueId("uid");
resource.addCategory("VoIP", "INfra");
resource.setDescription("My short description");
List<String> tgs = new ArrayList<String>();
@@ -179,6 +182,7 @@ public class LifecycleTestBase {
ComponentMetadataDefinition cMetadataDataDefinition = new ComponentMetadataDefinition(rMetadataDataDefinition) ;
Resource resource = new Resource(cMetadataDataDefinition);
+ resource.setUniqueId("rid");
resource.setName("MyResourceVFCMTName");
resource.addCategory("VoIP", "INfra");
resource.setDescription("My short description");
@@ -200,6 +204,7 @@ public class LifecycleTestBase {
protected Service createServiceObject(boolean b) {
Service service = new Service();
service.setName("MyServiceName");
+ service.setUniqueId("sid");
service.addCategory("VoIP", null);
service.setDescription("My short description");
List<String> tgs = new ArrayList<String>();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java
index 6761721636..11913ad31a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
-import org.openecomp.sdc.be.components.lifecycle.UndoCheckoutTransition;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -58,7 +57,7 @@ public class UndoCheckoutTest extends LifecycleTestBase {
@Test
public void testResourceNotCheckedOutValidation() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
Either<User, ResponseFormat> ownerResponse = undoCheckoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE);
@@ -102,7 +101,7 @@ public class UndoCheckoutTest extends LifecycleTestBase {
@Test
public void testDifferentResourceOwnerValidation() {
Either<Resource, ResponseFormat> changeStateResult;
- Resource resource = createResourceObject(false);
+ Resource resource = createResourceObject();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
User modifier = new User();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java
new file mode 100644
index 0000000000..ab2e865ae0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java
@@ -0,0 +1,86 @@
+package org.openecomp.sdc.be.components.merge;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+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.components.impl.generic.GenericTypeBusinessLogic;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+import com.google.common.collect.Sets;
+
+import fj.data.Either;
+
+public class GlobalInputsFilteringBusinessLogicTest {
+
+ private static final String GENERIC_TOSCA_TYPE = "myGenericType";
+
+ @InjectMocks
+ private GlobalInputsFilteringBusinessLogic testInstance;
+
+ @Mock
+ private GenericTypeBusinessLogic genericTypeBusinessLogicMock;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacadeMock;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testFilterGlobalInputs() throws Exception {
+ Resource mockResource = Mockito.mock(Resource.class);
+ String myGenericType = GENERIC_TOSCA_TYPE;
+ String[] genericProperties = {"property1", "property2"};
+ String[] allInputs = {"property1", "property2", "property3", "property4"};
+ when(mockResource.fetchGenericTypeToscaNameFromConfig()).thenReturn(myGenericType);
+ when(mockResource.getInputs()).thenReturn(ObjectGenerator.buildInputs(allInputs));
+ Resource genericNodeType = ObjectGenerator.buildResourceWithProperties(genericProperties);
+ when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName(myGenericType)).thenReturn(Either.left(genericNodeType));
+ when(genericTypeBusinessLogicMock.generateInputsFromGenericTypeProperties(genericNodeType)).thenReturn(ObjectGenerator.buildInputs(genericProperties));
+ Either<List<InputDefinition>, ActionStatus> globalInputsEither = testInstance.filterGlobalInputs(mockResource);
+ verifyFilteredOnlyGlobalInputs(globalInputsEither, genericProperties);
+ }
+
+ @Test
+ public void testFilterGlobalInputs_errorGettingGenericType_convertToActionStatusAndReturn() throws Exception {
+ Resource mockResource = Mockito.mock(Resource.class);
+ when(mockResource.fetchGenericTypeToscaNameFromConfig()).thenReturn(GENERIC_TOSCA_TYPE);
+ when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_TOSCA_TYPE)).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ Either<List<InputDefinition>, ActionStatus> globalInputsEither = testInstance.filterGlobalInputs(mockResource);
+ assertTrue(globalInputsEither.isRight());
+ assertEquals(ActionStatus.GENERAL_ERROR, globalInputsEither.right().value());
+ verifyZeroInteractions(genericTypeBusinessLogicMock);
+ }
+
+ private void verifyFilteredOnlyGlobalInputs(Either<List<InputDefinition>, ActionStatus> globalInputsEither, String[] genericProperties) {
+ assertTrue(globalInputsEither.isLeft());
+ List<InputDefinition> globalInputs = globalInputsEither.left().value();
+ assertEquals(2, globalInputs.size());
+ Set<String> actualGlobalInputNames = globalInputs.stream().map(InputDefinition::getName).collect(Collectors.toSet());
+ assertEquals(Sets.newHashSet(genericProperties), actualGlobalInputNames);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java
new file mode 100644
index 0000000000..a00b0b8e8a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java
@@ -0,0 +1,62 @@
+package org.openecomp.sdc.be.components.merge;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.components.utils.ObjectGenerator.buildResourceWithInputs;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.merge.input.ComponentInputsMergeBL;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.Resource;
+
+import fj.data.Either;
+
+public class GlobalTypesMergeBusinessLogicTest {
+
+ @InjectMocks
+ private GlobalTypesMergeBusinessLogic testInstance;
+
+ @Mock
+ private ComponentInputsMergeBL resourceInputsMergeBLMock;
+
+ @Mock
+ private GlobalInputsFilteringBusinessLogic globalInputsFilteringBusinessLogic;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeInstancePropsAndInputs_mergeOnlyNewResourceGenericGlobalTypes() {
+ Resource oldResource = buildResourceWithInputs("input1", "input2");
+ Resource newResource = buildResourceWithInputs("input1", "input2", "global1", "global2");
+ List<InputDefinition> globalInputs = Arrays.asList(newResource.getInputs().get(2), newResource.getInputs().get(3));
+ when(globalInputsFilteringBusinessLogic.filterGlobalInputs(newResource)).thenReturn(Either.left(globalInputs));
+ when(resourceInputsMergeBLMock.mergeComponentInputs(oldResource, newResource, globalInputs)).thenReturn(ActionStatus.OK);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.OK, actionStatus);
+
+ }
+
+ @Test
+ public void mergeInstancePropsAndInputs_failedToFilterGlobalInputs() throws Exception {
+ Resource oldResource = buildResourceWithInputs("input1", "input2");
+ Resource newResource = buildResourceWithInputs("input1", "input2", "global1", "global2");
+ when(globalInputsFilteringBusinessLogic.filterGlobalInputs(newResource)).thenReturn(Either.right(ActionStatus.GENERAL_ERROR));
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(actionStatus, ActionStatus.GENERAL_ERROR);
+ verifyZeroInteractions(resourceInputsMergeBLMock);
+ }
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java
new file mode 100644
index 0000000000..773b068cd7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java
@@ -0,0 +1,112 @@
+package org.openecomp.sdc.be.components.merge;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.components.utils.RelationsBuilder;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.Resource;
+
+public class RelationsComparatorTest {
+
+ public static final String INSTANCE1 = "instance1";
+ public static final String INSTANCE2 = "instance2";
+ RelationsComparator testInstance;
+
+ private RequirementCapabilityRelDef relation1, relation2, relation3, relation4;
+ private ComponentInstance componentInstance1, componentInstance2;
+
+ @Before
+ public void setUp() {
+ testInstance = new RelationsComparator();
+ componentInstance1 = new ComponentInstanceBuilder().setName(INSTANCE1).setId(INSTANCE1).build();
+ componentInstance2 = new ComponentInstanceBuilder().setName(INSTANCE2).setId(INSTANCE2).build();
+ buildRelations();
+ }
+
+ @Test
+ public void isRelationsChanged_sameRelationships() throws Exception {
+ Resource oldResource = ObjectGenerator.buildResourceWithRelationships(relation1, relation2, relation3, relation4);
+ oldResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ Resource newResource = ObjectGenerator.buildResourceWithRelationships(relation4, relation3, relation1, relation2);
+ newResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ assertFalse(testInstance.isRelationsChanged(oldResource, newResource));
+ }
+
+ @Test
+ public void isRelationsChanged_notSameAmountOfRelations() {
+ Resource oldResource = ObjectGenerator.buildResourceWithRelationships(relation1, relation2);
+ oldResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ Resource newResource = ObjectGenerator.buildResourceWithRelationships(relation1, relation2, relation3);
+ newResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ assertTrue(testInstance.isRelationsChanged(oldResource, newResource));
+ }
+
+ @Test
+ public void isRelationsChanged_notSameFromNode() throws Exception {
+ RequirementCapabilityRelDef relation2DifType = buildRelation("2", INSTANCE1);
+ relation2DifType.setFromNode(INSTANCE2);
+ isRelationsChangedTest(relation2DifType);
+ }
+
+ @Test
+ public void isRelationsChanged_notSameType() throws Exception {
+ RequirementCapabilityRelDef relation2DifType = buildRelation("2", INSTANCE1);
+ relation2DifType.getSingleRelationship().getRelation().getRelationship().setType("someDiffType");
+ isRelationsChangedTest(relation2DifType);
+ }
+
+ @Test
+ public void isRelationsChanged_notSameCapability() throws Exception {
+ RequirementCapabilityRelDef relation2DifType = buildRelation("2", INSTANCE1);
+ relation2DifType.getSingleRelationship().getRelation().setCapabilityUid("someDiffUid");
+ isRelationsChangedTest(relation2DifType);
+ }
+
+ @Test
+ public void isRelationsChanged_notSameReqName() throws Exception {
+ RequirementCapabilityRelDef relation2DifType = buildRelation("2", INSTANCE1);
+ relation2DifType.getSingleRelationship().getRelation().setRequirement("someDiffReq");
+ isRelationsChangedTest(relation2DifType);
+ }
+
+ @Test
+ public void isRelationsChanged_notSameToNode() throws Exception {
+ RequirementCapabilityRelDef relation2DifType = buildRelation("2", INSTANCE1);
+ relation2DifType.setToNode("someDiffNode");
+ isRelationsChangedTest(relation2DifType);
+ }
+
+ private void isRelationsChangedTest(RequirementCapabilityRelDef relation2DifType) {
+ Resource oldResource = ObjectGenerator.buildResourceWithRelationships(relation1, relation2);
+ oldResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ Resource newResource = ObjectGenerator.buildResourceWithRelationships(relation1, relation2DifType);
+ newResource.setComponentInstances(Arrays.asList(componentInstance1, componentInstance2));
+ assertTrue(testInstance.isRelationsChanged(oldResource, newResource));
+ }
+
+
+ private void buildRelations() {
+ relation1 = buildRelation("1", INSTANCE1);
+ relation2 = buildRelation("2", INSTANCE1);
+ relation3 = buildRelation("3", INSTANCE2);
+ relation4 = buildRelation("4", INSTANCE2);
+ }
+
+ private RequirementCapabilityRelDef buildRelation(String postFix, String instance) {
+ return new RelationsBuilder()
+ .setFromNode(instance)
+ .setCapabilityUID("cap" + postFix)
+ .setRelationType("type" + postFix)
+ .setRequirementName("req" + postFix)
+ .setToNode(instance)
+ .build();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java
new file mode 100644
index 0000000000..3b1ed52550
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java
@@ -0,0 +1,119 @@
+package org.openecomp.sdc.be.components.merge;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+import fj.data.Either;
+
+public class TopologyComparatorTest {
+
+ @InjectMocks
+ private TopologyComparator testInstance;
+
+ @Mock
+ private RelationsComparator relationsComparator;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void compareTopologies_NotSameNumOfInstances() throws Exception {
+ Resource resourceWith2Instances = ObjectGenerator.buildResourceWithComponentInstance("inst1", "inst2");
+ Resource resourceWith1Instances = ObjectGenerator.buildResourceWithComponentInstance("inst1");
+ Resource resourceWithNoInstances = new Resource();
+ assertTrue(testInstance.isTopologyChanged(resourceWithNoInstances, resourceWith2Instances).left().value());
+ assertTrue(testInstance.isTopologyChanged(resourceWithNoInstances, resourceWith1Instances).left().value());
+ assertTrue(testInstance.isTopologyChanged(resourceWith1Instances, resourceWith2Instances).left().value());
+ }
+
+ @Test
+ public void compareTopologies_notSameInstanceNames() throws Exception {
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstance("inst1", "inst2");
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstance("inst1", "inst3");
+ assertTrue(testInstance.isTopologyChanged(resource1, resource2).left().value());
+ }
+
+ @Test
+ public void compareTopologies_notSameInstanceTypes_notSameOriginInstanceTypes() throws Exception {
+ ComponentInstance inst1 = new ComponentInstanceBuilder().setName("inst1").setComponentUid("inst1").setToscaName("a.b.c").build();
+ ComponentInstance inst2 = new ComponentInstanceBuilder().setName("inst2").setComponentUid("inst2").setToscaName("a.b.c.d").build();
+ ComponentInstance inst2DiffType = new ComponentInstanceBuilder().setName("inst2").setComponentUid("inst2DiffType").setToscaName("a.b.c.d.e").build();
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2DiffType);
+ Resource inst2OriginResource = new ResourceBuilder().setInvariantUUid("inst2Invariant").build();
+ Resource inst2DiffTypeOriginResource = new ResourceBuilder().setInvariantUUid("inst2DiffTypeInvariant").build();
+ when(toscaOperationFacade.getToscaElement(inst2.getComponentUid())).thenReturn(Either.left(inst2OriginResource));
+ when(toscaOperationFacade.getToscaElement(inst2DiffType.getComponentUid())).thenReturn(Either.left(inst2DiffTypeOriginResource));
+ assertTrue(testInstance.isTopologyChanged(resource1, resource2).left().value());
+ }
+
+ @Test
+ public void compareTopologies_notSameInstanceTypes_failToFetchOriginComponent() throws Exception {
+ ComponentInstance inst1 = new ComponentInstanceBuilder().setName("inst1").setComponentUid("inst1").setToscaName("a.b.c").build();
+ ComponentInstance inst1DiffOriginCmpt = new ComponentInstanceBuilder().setName("inst1").setComponentUid("inst1Diff").setToscaName("a.b.c.d").build();
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstances(inst1);
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstances(inst1DiffOriginCmpt);
+ when(toscaOperationFacade.getToscaElement(inst1.getComponentUid())).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ assertEquals(ActionStatus.GENERAL_ERROR, testInstance.isTopologyChanged(resource1, resource2).right().value());
+ }
+
+ @Test
+ public void compareTopologies_notSameRelations() throws Exception {
+ ComponentInstance inst1 = new ComponentInstanceBuilder().setName("inst1").setToscaName("a.b.c").build();
+ ComponentInstance inst2 = new ComponentInstanceBuilder().setName("inst2").setToscaName("a.b.c.d").build();
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ when(relationsComparator.isRelationsChanged(resource1, resource2)).thenReturn(true);
+ assertTrue(testInstance.isTopologyChanged(resource1, resource2).left().value());
+ }
+
+ @Test
+ public void compareTopologies_sameInstances_sameRelations_noTopologyChange() throws Exception {
+ ComponentInstance inst1 = new ComponentInstanceBuilder().setName("inst1").setToscaName("a.b.c").build();
+ ComponentInstance inst2 = new ComponentInstanceBuilder().setName("inst2").setToscaName("a.b.c.d").build();
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ when(relationsComparator.isRelationsChanged(resource1, resource2)).thenReturn(false);
+ assertFalse(testInstance.isTopologyChanged(resource1, resource2).left().value());
+ }
+
+ @Test
+ public void compareTopologies_sameInstancesInvariant_sameRelations_noTopologyChange() throws Exception {
+ ComponentInstance inst1 = new ComponentInstanceBuilder().setName("inst1").setComponentUid("inst1").setToscaName("a.b.c").build();
+ ComponentInstance inst2 = new ComponentInstanceBuilder().setName("inst2").setComponentUid("inst2").setToscaName("a.b.c.d").build();
+ ComponentInstance inst2DiffType = new ComponentInstanceBuilder().setName("inst2").setComponentUid("inst2DiffType").setToscaName("a.b.c.d.e").build();
+ Resource resource1 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2);
+ Resource resource2 = ObjectGenerator.buildResourceWithComponentInstances(inst1, inst2DiffType);
+ Resource inst2OriginResource = new ResourceBuilder().setInvariantUUid("inst2Invariant").build();
+ when(toscaOperationFacade.getToscaElement(inst2.getComponentUid())).thenReturn(Either.left(inst2OriginResource));
+ when(toscaOperationFacade.getToscaElement(inst2DiffType.getComponentUid())).thenReturn(Either.left(inst2OriginResource));
+ when(relationsComparator.isRelationsChanged(resource1, resource2)).thenReturn(false);
+ assertFalse(testInstance.isTopologyChanged(resource1, resource2).left().value());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java
new file mode 100644
index 0000000000..bcdd08e95b
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java
@@ -0,0 +1,112 @@
+package org.openecomp.sdc.be.components.merge.heat;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.components.utils.ArtifactBuilder;
+import org.openecomp.sdc.be.components.utils.HeatParameterBuilder;
+import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
+
+public class HeatEnvArtifactsMergeBusinessLogicTest {
+
+ private HeatEnvArtifactsMergeBusinessLogic testInstance;
+
+ @Before
+ public void setUp() throws Exception {
+ testInstance = new HeatEnvArtifactsMergeBusinessLogic();
+ }
+
+ @Test
+ public void mergeHeatEnvParameter_diffArtifactLabel_noMerging() throws Exception {
+ HeatParameterDefinition newHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1NewValue");
+ HeatParameterDefinition prevHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1PrevValue");
+
+ ArtifactDefinition oldArtifact = buildHeatArtifact("artifact1", prevHeatParam1);
+ ArtifactDefinition newArtifact = buildHeatArtifact("artifact2", newHeatParam1);
+ List<ArtifactDefinition> mergedArtifacts = testInstance.mergeInstanceHeatEnvArtifacts(Collections.singletonList(oldArtifact), Collections.singletonList(newArtifact));
+ assertEquals(0, mergedArtifacts.size());
+ assertEquals("param1NewValue", newArtifact.getHeatParameters().get(0).getCurrentValue());
+ }
+
+ @Test
+ public void mergeHeatEnvParameter_diffHeatParamName_noMerge() throws Exception {
+ HeatParameterDefinition newHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1NewValue");
+ HeatParameterDefinition prevHeatParam1 = buildHeatParameterDefinition("param2", "type1", "param1PrevValue");
+ ArtifactDefinition oldArtifact = buildHeatArtifact("artifact1", prevHeatParam1);
+ ArtifactDefinition newArtifact = buildHeatArtifact("artifact1", newHeatParam1);
+ List<ArtifactDefinition> mergedArtifacts = testInstance.mergeInstanceHeatEnvArtifacts(Collections.singletonList(oldArtifact), Collections.singletonList(newArtifact));
+ assertEquals(0, mergedArtifacts.size());
+ assertEquals("param1NewValue", newArtifact.getHeatParameters().get(0).getCurrentValue());
+ }
+
+ @Test
+ public void mergeHeatEnvParameter_diffHeatParamType_noMerge() throws Exception {
+ HeatParameterDefinition newHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1NewValue");
+ HeatParameterDefinition prevHeatParam1 = buildHeatParameterDefinition("param1", "type2", "param1PrevValue");
+ ArtifactDefinition oldArtifact = buildHeatArtifact("artifact1", prevHeatParam1);
+ ArtifactDefinition newArtifact = buildHeatArtifact("artifact1", newHeatParam1);
+ List<ArtifactDefinition> mergedArtifacts = testInstance.mergeInstanceHeatEnvArtifacts(Collections.singletonList(oldArtifact), Collections.singletonList(newArtifact));
+ assertEquals(0, mergedArtifacts.size());
+ assertEquals("param1NewValue", newArtifact.getHeatParameters().get(0).getCurrentValue());
+ }
+
+ @Test
+ public void mergeHeatEnvParameter__diffOldAndNewValues_overrideNewValueWithOldValue() throws Exception {
+ HeatParameterDefinition newHeatParam1 = buildHeatParameterDefinition("param1", "type1", null);
+ HeatParameterDefinition newHeatParam2 = buildHeatParameterDefinition("param2", "type1", "param2value");
+
+ HeatParameterDefinition prevHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1PrevValue");
+ HeatParameterDefinition prevHeatParam2 = buildHeatParameterDefinition("param2", "type1", "param2PrevValue");
+
+ ArtifactDefinition oldArtifact = buildHeatArtifact("artifact1", prevHeatParam1, prevHeatParam2);
+ ArtifactDefinition newArtifact = buildHeatArtifact("artifact1", newHeatParam1, newHeatParam2);
+
+ List<ArtifactDefinition> mergedArtifacts = testInstance.mergeInstanceHeatEnvArtifacts(Collections.singletonList(oldArtifact), Collections.singletonList(newArtifact));
+ assertEquals(1, mergedArtifacts.size());
+ List<HeatParameterDataDefinition> heatParameters = mergedArtifacts.get(0).getHeatParameters();
+ assertEquals("param1PrevValue", heatParameters.get(0).getCurrentValue());
+ assertEquals("param2PrevValue", heatParameters.get(1).getCurrentValue());
+ }
+
+ @Test
+ public void mergeHeatEnvParameter_multipleArtifacts() throws Exception {
+ HeatParameterDefinition newHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1Newvalue");
+ HeatParameterDefinition newHeatParam2 = buildHeatParameterDefinition("param2", "type1", "param2Newvalue");
+ HeatParameterDefinition newHeatParam3 = buildHeatParameterDefinition("param2", "type1", "param3Newvalue");
+
+ HeatParameterDefinition prevHeatParam1 = buildHeatParameterDefinition("param1", "type1", "param1PrevValue");
+ HeatParameterDefinition prevHeatParam2 = buildHeatParameterDefinition("param2", "type1", "param2PrevValue");
+ HeatParameterDefinition prevHeatParam3 = buildHeatParameterDefinition("param3", "type2", "param3PrevValue");
+
+ ArtifactDefinition oldArtifact1 = buildHeatArtifact("artifact1", prevHeatParam1);
+ ArtifactDefinition oldArtifact2 = buildHeatArtifact("artifact2", prevHeatParam2);
+ ArtifactDefinition oldArtifact3 = buildHeatArtifact("artifact3", prevHeatParam3);
+
+ ArtifactDefinition newArtifact1 = buildHeatArtifact("artifact1", newHeatParam1);
+ ArtifactDefinition newArtifact2 = buildHeatArtifact("artifact2New", newHeatParam2);
+ ArtifactDefinition newArtifact3 = buildHeatArtifact("artifact3", newHeatParam3);
+
+ List<ArtifactDefinition> mergedArtifacts = testInstance.mergeInstanceHeatEnvArtifacts(Arrays.asList(oldArtifact1, oldArtifact2, oldArtifact3), Arrays.asList(newArtifact1, newArtifact2, newArtifact3));
+ assertEquals(1, mergedArtifacts.size());//artifact 2 not merged as it has different label, artifact 3 not merged as the heat parameter has diff types
+ assertEquals("artifact1", mergedArtifacts.get(0).getArtifactLabel());
+ }
+
+ private HeatParameterDefinition buildHeatParameterDefinition(String name, String type, String val) {
+ return new HeatParameterBuilder().setName(name).setType(type).setCurrentValue(val).build();
+ }
+
+ private ArtifactDefinition buildHeatArtifact(String label, HeatParameterDefinition ... heatParameterDefinitions) {
+ ArtifactBuilder artifactBuilder = new ArtifactBuilder().setLabel(label);
+ Stream.of(heatParameterDefinitions).forEach(artifactBuilder::addHeatParam);
+ return artifactBuilder.build();
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java
new file mode 100644
index 0000000000..26b6782918
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java
@@ -0,0 +1,94 @@
+package org.openecomp.sdc.be.components.merge.input;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections.ListUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+
+import fj.data.Either;
+
+public class ComponentInputsMergeBLTest {
+
+ @InjectMocks
+ private ComponentInputsMergeBL testInstance;
+
+ @Mock
+ private InputsValuesMergingBusinessLogic inputsValuesMergingBusinessLogicMock;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeComponentInputs() {
+ Resource oldResource = new ResourceBuilder()
+ .addInput("input1")
+ .addInput("input2")
+ .build();
+
+ Resource newResource = new Resource();
+
+ List<InputDefinition> inputsToMerge = ObjectGenerator.buildInputs("input1", "input2", "input3");
+
+ when(toscaOperationFacade.updateInputsToComponent(inputsToMerge, newResource.getUniqueId())).thenReturn(Either.left(inputsToMerge));
+ ActionStatus actionStatus = testInstance.mergeComponentInputs(oldResource, newResource, inputsToMerge);
+ assertEquals(ActionStatus.OK, actionStatus);
+ verifyCallToMergeComponentInputs(oldResource, inputsToMerge);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void mergeAndRedeclareComponentInputs() throws Exception {
+ Resource oldResource = new ResourceBuilder()
+ .addInput("input1")
+ .addInput("input2")
+ .build();
+
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ List<InputDefinition> inputsToMerge = ObjectGenerator.buildInputs("input1", "input2", "input3");
+ List<InputDefinition> inputsToRedeclare = ObjectGenerator.buildInputs("input4");
+ List<InputDefinition> expectedInputsToUpdate = ListUtils.union(inputsToMerge, inputsToRedeclare);
+ when(inputsValuesMergingBusinessLogicMock.getPreviouslyDeclaredInputsToMerge(oldResource, newResource)).thenReturn(inputsToRedeclare);
+ when(toscaOperationFacade.updateInputsToComponent(expectedInputsToUpdate, newResource.getUniqueId())).thenReturn(Either.left(inputsToMerge));
+ ActionStatus actionStatus = testInstance.mergeAndRedeclareComponentInputs(oldResource, newResource, inputsToMerge);
+ assertEquals(ActionStatus.OK, actionStatus);
+ }
+
+ @Test
+ public void redeclareResourceInputsForInstance() throws Exception {
+ List<InputDefinition> oldInputs = ObjectGenerator.buildInputs("input1", "input2");
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ List<InputDefinition> inputsToRedeclare = ObjectGenerator.buildInputs("input1");
+ when(inputsValuesMergingBusinessLogicMock.getPreviouslyDeclaredInputsToMerge(oldInputs, newResource, "inst1")).thenReturn(inputsToRedeclare);
+ when(toscaOperationFacade.updateInputsToComponent(inputsToRedeclare, newResource.getUniqueId())).thenReturn(Either.left(inputsToRedeclare));
+ ActionStatus actionStatus = testInstance.redeclareComponentInputsForInstance(oldInputs, newResource, "inst1");
+ }
+
+ private void verifyCallToMergeComponentInputs(Resource oldResource, List<InputDefinition> inputsToMerge) {
+ Map<String, InputDefinition> oldInputsByName = oldResource.getInputs().stream().collect(Collectors.toMap(InputDefinition::getName, Function.identity()));
+ Map<String, InputDefinition> inputsToMergeByName = inputsToMerge.stream().collect(Collectors.toMap(InputDefinition::getName, Function.identity()));
+ verify(inputsValuesMergingBusinessLogicMock).mergeComponentInputs(oldInputsByName, inputsToMergeByName);
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java
new file mode 100644
index 0000000000..b0124e4e44
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java
@@ -0,0 +1,186 @@
+package org.openecomp.sdc.be.components.merge.input;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.utils.MapUtil;
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.Resource;
+
+public class InputsValuesMergingBusinessLogicTest {
+
+ public static final String INPUT_DEFUALT_TYPE = "string";
+ public static final String INPUT1_ID = "input1";
+ public static final String INPUT2_ID = "input2";
+ public static final String INPUT3_ID = "input3";
+ public static final String INPUT4_ID = "input4";
+ private InputsValuesMergingBusinessLogic testInstance;
+
+ @Before
+ public void setUp() throws Exception {
+ testInstance = new InputsValuesMergingBusinessLogic();
+ }
+
+ @Test
+ public void testMergeInputs_inputsOfDifferentType_dontCopyOldValue() throws Exception {
+ InputDefinition oldInput = createUserDefinedInputDefinition(INPUT1_ID, "oldVal1");
+
+ InputDefinition newInput = createInputDefinition(INPUT1_ID, null);
+ newInput.setType("int");
+
+
+ Map<String, InputDefinition> updatedInputs = Collections.singletonMap(newInput.getName(), newInput);
+ Map<String, InputDefinition> oldInputs = Collections.singletonMap(oldInput.getName(), oldInput);
+ testInstance.mergeComponentInputs(oldInputs, updatedInputs);
+
+ assertNull(updatedInputs.get(INPUT1_ID).getDefaultValue());
+ }
+
+ @Test
+ public void testMergeInputs_newInputsHaveNoValue_copyOldValues() throws Exception {
+ InputDefinition oldInputWithCsarDefaultValue = createInputDefinition(INPUT1_ID, "oldVal1");
+ InputDefinition oldInputWithUserDefinedValue = createUserDefinedInputDefinition(INPUT2_ID, "oldVal2");
+ InputDefinition oldInputNotExistOnNew = createUserDefinedInputDefinition(INPUT3_ID, null);
+
+ InputDefinition newInput1 = createInputDefinition(INPUT1_ID, "");
+ InputDefinition newInput2 = createUserDefinedInputDefinition(INPUT2_ID, null);
+
+ Map<String, InputDefinition> updatedInputs = mapInputsByName(Arrays.asList(newInput1, newInput2));
+ Map<String, InputDefinition> oldInputs = mapInputsByName(Arrays.asList(oldInputWithCsarDefaultValue, oldInputWithUserDefinedValue, oldInputNotExistOnNew));
+ testInstance.mergeComponentInputs(oldInputs, updatedInputs);
+
+ assertEquals(oldInputWithCsarDefaultValue.getDefaultValue(), updatedInputs.get(INPUT1_ID).getDefaultValue());
+ assertEquals(oldInputWithUserDefinedValue.getDefaultValue(), updatedInputs.get(INPUT2_ID).getDefaultValue());
+ assertNull(updatedInputs.get(INPUT3_ID));
+ }
+
+ @Test
+ public void testMergeInputs_newInputsHaveValue_dontOverrideNewValue() throws Exception {
+ InputDefinition oldInputWithCsarDefaultValue = createInputDefinition(INPUT1_ID, "oldVal1");
+ InputDefinition oldInputWithUserDefinedValue = createUserDefinedInputDefinition(INPUT2_ID, "oldVal2");
+ InputDefinition oldInputWithNoValue = createUserDefinedInputDefinition(INPUT3_ID, null);
+
+ InputDefinition newInput1 = createInputDefinition(INPUT1_ID, "newVal1");
+ InputDefinition newInput2 = createUserDefinedInputDefinition(INPUT2_ID, "newVal2");
+ InputDefinition newInput3 = createUserDefinedInputDefinition(INPUT3_ID, "newVal3");
+ InputDefinition newInput4 = createUserDefinedInputDefinition(INPUT4_ID, "newVal4");
+
+ Map<String, InputDefinition> updatedInputs = mapInputsByName(Arrays.asList(newInput1, newInput2, newInput3, newInput4));
+ Map<String, InputDefinition> oldInputs = mapInputsByName(Arrays.asList(oldInputWithCsarDefaultValue, oldInputWithUserDefinedValue, oldInputWithNoValue));
+ testInstance.mergeComponentInputs(oldInputs, updatedInputs);
+
+ assertEquals(updatedInputs.get(INPUT1_ID).getDefaultValue(), newInput1.getDefaultValue());
+ assertEquals(updatedInputs.get(INPUT2_ID).getDefaultValue(), newInput2.getDefaultValue());
+ assertEquals(updatedInputs.get(INPUT3_ID).getDefaultValue(), newInput3.getDefaultValue());
+ assertEquals(updatedInputs.get(INPUT4_ID).getDefaultValue(), newInput4.getDefaultValue());
+ }
+
+ @Test
+ public void getPrevoislyDeclaredInputsToMerge() throws Exception {
+ PropertyDataDefinition declaredInputProp1 = new PropertyDataDefinitionBuilder().addGetInputValue(INPUT1_ID).addGetInputValue(INPUT3_ID).setUniqueId("prevDeclaredPropId").build();
+ PropertyDataDefinition declaredInputProp2 = new PropertyDataDefinitionBuilder().addGetInputValue(INPUT4_ID).setUniqueId("prevDeclaredPropId2").build();
+
+ Resource prevResource = new ResourceBuilder().addInput(INPUT1_ID).addInput(INPUT2_ID).addInput(INPUT3_ID).addInput(INPUT4_ID).build();
+
+ Resource currentResource = new ResourceBuilder()
+ .addInput(INPUT2_ID)
+ .addInstanceProperty("inst1", new ComponentInstanceProperty(declaredInputProp1))
+ .addInstanceInput("inst2", new ComponentInstanceInput(declaredInputProp2))
+ .build();
+
+ List<InputDefinition> previouslyDeclaredInputs = testInstance.getPreviouslyDeclaredInputsToMerge(prevResource, currentResource);
+ assertEquals(3, previouslyDeclaredInputs.size());
+
+ assertInput(previouslyDeclaredInputs.get(0), INPUT1_ID, declaredInputProp1.getUniqueId(), "inst1");
+ assertInput(previouslyDeclaredInputs.get(1), INPUT3_ID, declaredInputProp1.getUniqueId(), "inst1");
+ assertInput(previouslyDeclaredInputs.get(2), INPUT4_ID, declaredInputProp2.getUniqueId(), "inst2");
+ }
+
+ private void assertInput(InputDefinition inputDefinition, String expectedInputId, String expectedPropertyId, String expectedInstanceUniqueId) {
+ assertEquals(expectedInputId, inputDefinition.getUniqueId());
+ assertEquals(expectedPropertyId, inputDefinition.getPropertyId());
+ assertEquals(inputDefinition.getInstanceUniqueId(), expectedInstanceUniqueId);
+ }
+
+ private Map<String, InputDefinition> mapInputsByName(List<InputDefinition> inputs) {
+ return MapUtil.toMap(inputs, InputDefinition::getName);
+ }
+
+ private InputDefinition createInputDefinition(String name, String value) {
+ InputDefinition inputDef = new InputDefinition();
+ inputDef.setName(name);
+ inputDef.setDefaultValue(value);
+ inputDef.setType(INPUT_DEFUALT_TYPE);
+ return inputDef;
+ }
+
+ private InputDefinition createUserDefinedInputDefinition(String name, String value) {
+ InputDefinition inputDef = createInputDefinition(name, value);
+ inputDef.setOwnerId("owner");
+ return inputDef;
+ }
+
+ private void addInstanceProperty(Resource resource, ComponentInstanceProperty prop, String instanceId) {
+ addInstancePropDefinition(resource.getComponentInstancesProperties(), prop, instanceId);
+ }
+
+ private void addInstanceInput(Resource resource, ComponentInstanceInput prop, String instanceId) {
+ addInstancePropDefinition(resource.getComponentInstancesInputs(), prop, instanceId);
+ }
+
+ private <T extends PropertyDataDefinition> void addInstancePropDefinition(Map<String, List<T>> propsDefinitions, T propDef, String instanceId) {
+ propsDefinitions.computeIfAbsent(instanceId, id -> new ArrayList<>()).add(propDef);
+ }
+
+ private Resource createResourceWithInputs(String ... inputsIds) {
+ Resource resource = new Resource();
+ List<InputDefinition> inputs = new ArrayList<>();
+ for (String inputId : inputsIds) {
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setOwnerId("cs0008");
+ inputDefinition.setUniqueId(inputId);
+ inputs.add(inputDefinition);
+ }
+ resource.setInputs(inputs);
+ return resource;
+ }
+
+
+ private ComponentInstanceProperty createGetInputComponentProperty(String ... declaredToInputId) {
+ ComponentInstanceProperty prevDeclaredProperty = new ComponentInstanceProperty();
+ for (String inputId : declaredToInputId) {
+ addGetInputValueOnProp(inputId, prevDeclaredProperty);
+ }
+
+ return prevDeclaredProperty;
+ }
+
+ private void addGetInputValueOnProp(String declaredToInputId, PropertyDataDefinition declaredProperty) {
+ GetInputValueDataDefinition getInputDef = new GetInputValueDataDefinition();
+ getInputDef.setInputId(declaredToInputId);
+ if (declaredProperty.getGetInputValues() == null) {
+ declaredProperty.setGetInputValues(new ArrayList<>());
+ }
+ declaredProperty.getGetInputValues().add(getInputDef);
+ }
+
+ private ComponentInstanceInput createGetInputComponentInstanceInput(String declaredToInputId) {
+ ComponentInstanceInput prevDeclaredProp = new ComponentInstanceInput();
+ addGetInputValueOnProp(declaredToInputId, prevDeclaredProp);
+ return prevDeclaredProp;
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java
new file mode 100644
index 0000000000..be16bc3621
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java
@@ -0,0 +1,88 @@
+package org.openecomp.sdc.be.components.merge.instance;
+
+import static junit.framework.TestCase.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.Resource;
+
+
+public class ComponentInstanceArtifactsMergeTest {
+
+ @InjectMocks
+ private ComponentInstanceArtifactsMerge testInstance;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testDeploymentArtifactSaveData() throws Exception {
+
+ Component containerComponent = new Resource();
+ Component originComponent = buildOriginalComponentWithOneArtifact();
+ ComponentInstance componentInstance = buildComponentInstanceWithTwoArtifacts();
+
+ DataForMergeHolder dataForMergeHolder = new DataForMergeHolder();
+ testInstance.saveDataBeforeMerge(dataForMergeHolder, containerComponent, componentInstance, originComponent);
+ Map<String, ArtifactDefinition> originalComponentDeploymentArtifactsCreatedOnTheInstance = dataForMergeHolder.getOrigComponentDeploymentArtifactsCreatedOnTheInstance();
+
+ assertEquals(originalComponentDeploymentArtifactsCreatedOnTheInstance.size() , 1);
+ assert(originalComponentDeploymentArtifactsCreatedOnTheInstance.containsKey("artifactTwo"));
+ }
+
+ @Test
+ public void testInformationalArtifactSaveData() throws Exception {
+
+ Component containerComponent = new Resource();
+ Component originComponent = buildOriginalComponentWithOneArtifact();
+ ComponentInstance componentInstance = buildComponentInstanceWithTwoArtifacts();
+
+ DataForMergeHolder dataForMergeHolder = new DataForMergeHolder();
+ testInstance.saveDataBeforeMerge(dataForMergeHolder, containerComponent, componentInstance, originComponent);
+ Map<String, ArtifactDefinition> originalComponentInformationalArtifactsCreatedOnTheInstance = dataForMergeHolder.getOrigComponentInformationalArtifactsCreatedOnTheInstance();
+
+ assertEquals(originalComponentInformationalArtifactsCreatedOnTheInstance.size() , 1);
+ assert(originalComponentInformationalArtifactsCreatedOnTheInstance.containsKey("artifactTwo"));
+ }
+
+ private ComponentInstance buildComponentInstanceWithTwoArtifacts(){
+ ArtifactDefinition artifactFromTheOriginalResource = new ArtifactDefinition();
+ artifactFromTheOriginalResource.setArtifactLabel("artifactOne");
+ ArtifactDefinition artifactCreatedOnTheInstance = new ArtifactDefinition();
+ artifactCreatedOnTheInstance.setArtifactLabel("artifactTwo");
+
+ Map<String, ArtifactDefinition> componentInstanceArtifacts = new HashMap<>();
+ componentInstanceArtifacts.put(artifactFromTheOriginalResource.getArtifactLabel(), artifactFromTheOriginalResource);
+ componentInstanceArtifacts.put(artifactCreatedOnTheInstance.getArtifactLabel(), artifactCreatedOnTheInstance);
+
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setDeploymentArtifacts(componentInstanceArtifacts);
+ componentInstance.setArtifacts(componentInstanceArtifacts);
+ return componentInstance;
+ }
+
+ private Component buildOriginalComponentWithOneArtifact() {
+ ArtifactDefinition artifactFromTheOriginalResource = new ArtifactDefinition();
+ artifactFromTheOriginalResource.setArtifactLabel("artifactOne");
+
+ Map<String, ArtifactDefinition> originComponentArtifacts = new HashMap<>();
+ originComponentArtifacts.put(artifactFromTheOriginalResource.getArtifactLabel(), artifactFromTheOriginalResource);
+ Component originComponent = new Resource();
+ originComponent.setDeploymentArtifacts(originComponentArtifacts);
+ originComponent.setArtifacts(originComponentArtifacts);
+ return originComponent;
+ }
+
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceDataMergingTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceDataMergingTest.java
new file mode 100644
index 0000000000..c9310dc1dc
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceDataMergingTest.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.be.components.merge.instance;
+
+import org.junit.Test;
+
+/**
+ * Created by chaya on 9/19/2017.
+ */
+public class ComponentInstanceDataMergingTest {
+
+ ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL;
+
+ @Test
+ public void testMergeInstanceInputs() {
+ //compInstMergeDataBL.mergeComponentUserOrigData();
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java
new file mode 100644
index 0000000000..2101ea49ab
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java
@@ -0,0 +1,101 @@
+package org.openecomp.sdc.be.components.merge.instance;
+
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+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.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.merge.heat.HeatEnvArtifactsMergeBusinessLogic;
+import org.openecomp.sdc.be.components.utils.ArtifactBuilder;
+import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+
+import fj.data.Either;
+
+public class ComponentInstanceHeatEnvMergeTest {
+
+ @InjectMocks
+ private ComponentInstanceHeatEnvMerge testInstance;
+
+ @Mock
+ private ArtifactsBusinessLogic artifactsBusinessLogicMock;
+
+ @Mock
+ private HeatEnvArtifactsMergeBusinessLogic heatEnvArtifactsMergeBusinessLogicMock;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ private static final User USER = new User();
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeDataAfterCreate_mergeAndPersistArtifacts() throws Exception {
+ Map<String, ArtifactDefinition> nodeTypeArtifactsByName = buildMapOfHeatArtifacts("artifact1", "artifact2");
+ DataForMergeHolder dataHolder = new DataForMergeHolder();
+ dataHolder.setOrigComponentDeploymentArtifactsCreatedOnTheInstance(nodeTypeArtifactsByName);
+ String instanceId = "instance1";
+ Resource resource = buildResourceWithHeatArtifacts(instanceId, "heatArtifact1", "heatArtifact2");
+ List<ArtifactDefinition> mergedArtifacts = buildListOfArtifacts("artifact1, heatArtifact1");
+ when(heatEnvArtifactsMergeBusinessLogicMock.mergeInstanceHeatEnvArtifacts(dataHolder.getOrigComponentInstanceHeatEnvArtifacts(), resource.safeGetComponentInstanceHeatArtifacts(instanceId)))
+ .thenReturn(mergedArtifacts);
+ expectMergedArtifactsToBePersisted(mergedArtifacts, instanceId, resource);
+ testInstance.mergeDataAfterCreate(USER, dataHolder, resource, instanceId);
+ }
+
+ private void expectMergedArtifactsToBePersisted(List<ArtifactDefinition> mergedArtifacts, String instanceId, Resource resource) {
+ for (ArtifactDefinition mergedArtifact : mergedArtifacts) {
+ Map<String, Object> json = new HashMap<>();
+ when(artifactsBusinessLogicMock.buildJsonForUpdateArtifact(mergedArtifact, ArtifactGroupTypeEnum.DEPLOYMENT, null)).thenReturn(json);
+ ArtifactsBusinessLogic.ArtifactOperationInfo artifactUpdateOperation = artifactsBusinessLogicMock.new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.Update);
+ when(artifactsBusinessLogicMock.updateResourceInstanceArtifactNoContent(Mockito.eq(instanceId), Mockito.eq(resource),
+ Mockito.eq(USER), Mockito.eq(json),
+ Mockito.refEq(artifactUpdateOperation),
+ Mockito.isNull(ArtifactDefinition.class)))
+ .thenReturn(Either.left(Either.left(new ArtifactDefinition())));
+ }
+ }
+
+ private Resource buildResourceWithHeatArtifacts(String instanceId, String ... artifacts) {
+ ComponentInstanceBuilder componentInstanceBuilder = new ComponentInstanceBuilder().setId(instanceId);
+ for (String artifact : artifacts) {
+ ArtifactDefinition heatArtifact = new ArtifactBuilder().setType(ArtifactTypeEnum.HEAT_ARTIFACT.getType()).setName(artifact).build();
+ componentInstanceBuilder.addDeploymentArtifact(heatArtifact);
+ }
+ return new ResourceBuilder().addComponentInstance(componentInstanceBuilder.build()).build();
+ }
+
+ private Map<String, ArtifactDefinition> buildMapOfHeatArtifacts(String ... artifacts) {
+ Map<String, ArtifactDefinition> artifactsByName = new HashMap<>();
+ for (String artifact : artifacts) {
+ ArtifactDefinition heatArtifact = new ArtifactBuilder().setType(ArtifactTypeEnum.HEAT_ARTIFACT.getType()).setName(artifact).build();
+ artifactsByName.put(artifact, heatArtifact);
+ }
+ return artifactsByName;
+ }
+
+ private List<ArtifactDefinition> buildListOfArtifacts(String ... artifacts) {
+ return Stream.of(artifacts).map(artifact -> new ArtifactBuilder().setName(artifact).build()).collect(Collectors.toList());
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java
new file mode 100644
index 0000000000..bc3efe423d
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java
@@ -0,0 +1,115 @@
+package org.openecomp.sdc.be.components.merge.instance;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+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.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class ComponentInstanceMergeDataBusinessLogicTest {
+
+ @InjectMocks
+ private ComponentInstanceMergeDataBusinessLogic testInstance;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ @Mock
+ private ComponentInstanceMergeInterface componentInstanceMergeInterfaceMock1;
+
+ @Mock
+ private ComponentInstanceMergeInterface componentInstanceMergeInterfaceMock2;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ testInstance.setComponentInstancesMergeBLs(Arrays.asList(componentInstanceMergeInterfaceMock1, componentInstanceMergeInterfaceMock2));
+ }
+
+ @Test
+ public void saveAllDataBeforeDeleting_allInstanceMergeInterfacesAreCalled() throws Exception {
+ Component container = new Service();
+ ComponentInstance instance = new ComponentInstance();
+ Component instanceOriginResource = new Resource();
+ DataForMergeHolder dataForMergeHolder = testInstance.saveAllDataBeforeDeleting(container, instance, instanceOriginResource);
+ verify(componentInstanceMergeInterfaceMock1).saveDataBeforeMerge(dataForMergeHolder, container, instance, instanceOriginResource);
+ verify(componentInstanceMergeInterfaceMock2).saveDataBeforeMerge(dataForMergeHolder, container, instance, instanceOriginResource);
+ }
+
+ @Test
+ public void mergeComponentUserOrigData_allInstanceMergeInterfacesAreCalled() throws Exception {
+ ArgumentCaptor<ComponentParametersView> componentsFilterCapture = ArgumentCaptor.forClass(ComponentParametersView.class);
+ Service persistedService = new Service();
+ User user = new User();
+ DataForMergeHolder dataHolder = new DataForMergeHolder();
+ when(toscaOperationFacade.getToscaElement(Mockito.eq("newContainerId"), componentsFilterCapture.capture())).thenReturn(Either.left(persistedService));
+ when(componentInstanceMergeInterfaceMock1.mergeDataAfterCreate(user, dataHolder, persistedService, "instId")).thenReturn(Either.left(persistedService));
+ when(componentInstanceMergeInterfaceMock2.mergeDataAfterCreate(user, dataHolder, persistedService, "instId")).thenReturn(Either.left(persistedService));
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeComponentUserOrigData(user, dataHolder, new Service(), "newContainerId", "instId");
+ assertEquals(persistedService, mergeResult.left().value());
+ assertComponentFilter(componentsFilterCapture.getValue());
+ }
+
+ @Test
+ public void mergeComponentUserOrigData_failToGetPersistedComponent_doNotTryToMerge() throws Exception {
+ User user = new User();
+ DataForMergeHolder dataHolder = new DataForMergeHolder();
+ ResponseFormat rf = new ResponseFormat();
+ Resource container = new ResourceBuilder().setComponentType(ComponentTypeEnum.SERVICE).build();
+ when(toscaOperationFacade.getToscaElement(Mockito.eq("newContainerId"), Mockito.any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR, ComponentTypeEnum.SERVICE)).thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(rf);
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeComponentUserOrigData(user, dataHolder, container, "newContainerId", "instId");
+ assertEquals(rf, mergeResult.right().value());
+ verifyZeroInteractions(componentInstanceMergeInterfaceMock1, componentInstanceMergeInterfaceMock2);
+ }
+
+ @Test
+ public void mergeComponentUserOrigData_failOnOneMerge_doNotCallOtherMerge() throws Exception {
+ Service persistedService = new Service();
+ User user = new User();
+ DataForMergeHolder dataHolder = new DataForMergeHolder();
+ ResponseFormat rf = new ResponseFormat();
+ when(toscaOperationFacade.getToscaElement(Mockito.eq("newContainerId"), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(persistedService));
+ when(componentInstanceMergeInterfaceMock1.mergeDataAfterCreate(user, dataHolder, persistedService, "instId")).thenReturn(Either.right(rf));
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeComponentUserOrigData(user, dataHolder, new Service(), "newContainerId", "instId");
+ assertEquals(rf, mergeResult.right().value());
+ verifyZeroInteractions(componentInstanceMergeInterfaceMock2);
+ }
+
+ private void assertComponentFilter(ComponentParametersView value) {
+ assertFalse(value.isIgnoreComponentInstances());
+ assertFalse(value.isIgnoreComponentInstancesProperties());
+ assertFalse(value.isIgnoreComponentInstancesInputs());
+ assertFalse(value.isIgnoreArtifacts());
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java
new file mode 100644
index 0000000000..cb3d506bfc
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java
@@ -0,0 +1,154 @@
+package org.openecomp.sdc.be.components.merge.instance;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyListOf;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.merge.input.ComponentInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstanceInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstancePropertiesMergeBL;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.InputDefinition;
+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.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class ComponentInstancePropsAndInputsMergeTest {
+
+ private static final String INSTANCE_ID1 = "inst1";
+ private static final User USER = new User();
+
+ @InjectMocks
+ private ComponentInstancePropsAndInputsMerge testInstance;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ @Mock
+ private ComponentInstancePropertiesMergeBL componentInstancePropertiesMergeBL;
+
+ @Mock
+ private ComponentInstanceInputsMergeBL componentInstanceInputsMergeBL;
+
+ @Mock
+ private ComponentInputsMergeBL componentInputsMergeBL;
+
+ private Resource resourceToUpdate;
+
+ private DataForMergeHolder oldDataHolder;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ resourceToUpdate = new ResourceBuilder().addInstanceInput(INSTANCE_ID1, "instInput1")
+ .addInstanceInput(INSTANCE_ID1, "instInput2")
+ .addInstanceProperty(INSTANCE_ID1, "instProp1")
+ .addInstanceProperty(INSTANCE_ID1, "instProp2")
+ .addInput("input1")
+ .addInput("input2")
+ .setUniqueId("resourceId").build();
+
+ List<InputDefinition> oldInputs = ObjectGenerator.buildInputs("input1");
+ List<ComponentInstanceProperty> oldInstProps = ObjectGenerator.buildInstanceProperties("instProp1", "instProp3");
+ List<ComponentInstanceInput> oldInstInputs = ObjectGenerator.buildInstanceInputs("instInput1", "instInput3");
+
+ oldDataHolder = new DataForMergeHolder();
+ oldDataHolder.setOrigComponentInputs(oldInputs);
+ oldDataHolder.setOrigComponentInstanceProperties(oldInstProps);
+ oldDataHolder.setOrigComponentInstanceInputs(oldInstInputs);
+ }
+
+ @Test
+ public void mergeDataAfterCreate() throws Exception {
+ List<InputDefinition> oldInputs = ObjectGenerator.buildInputs("input1");
+ List<ComponentInstanceProperty> oldInstProps = ObjectGenerator.buildInstanceProperties("instProp1", "instProp3");
+ List<ComponentInstanceInput> oldInstInputs = ObjectGenerator.buildInstanceInputs("instInput1", "instInput3");
+
+ DataForMergeHolder dataForMergeHolder = new DataForMergeHolder();
+ dataForMergeHolder.setOrigComponentInputs(oldInputs);
+ dataForMergeHolder.setOrigComponentInstanceProperties(oldInstProps);
+ dataForMergeHolder.setOrigComponentInstanceInputs(oldInstInputs);
+
+ ArgumentCaptor<ComponentParametersView> parametersViewCaptor = ArgumentCaptor.forClass(ComponentParametersView.class);
+
+ when(toscaOperationFacade.getToscaElement(Mockito.eq("resourceId"), parametersViewCaptor.capture())).thenReturn(Either.left(resourceToUpdate));
+ when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(oldInstInputs, oldInputs, resourceToUpdate, INSTANCE_ID1)).thenReturn(ActionStatus.OK);
+ when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(oldInstProps, oldInputs, resourceToUpdate, INSTANCE_ID1)).thenReturn(ActionStatus.OK);
+ when(componentInputsMergeBL.redeclareComponentInputsForInstance(oldInputs, resourceToUpdate, INSTANCE_ID1)).thenReturn(ActionStatus.OK);
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeDataAfterCreate(USER, dataForMergeHolder, resourceToUpdate, INSTANCE_ID1);
+ assertEquals(mergeResult.left().value(), resourceToUpdate);
+ assertComponentFilter(parametersViewCaptor.getValue());
+ }
+
+ @Test
+ public void mergeDataAfterCreate_failedToMergeComponentInstanceInputs() throws Exception {
+ ResponseFormat errorResponse = new ResponseFormat();
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
+ when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyListOf(ComponentInstanceInput.class), anyListOf(InputDefinition.class), any(Component.class), anyString())).thenReturn(ActionStatus.GENERAL_ERROR);
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeDataAfterCreate(USER, new DataForMergeHolder(), new Service(), "inst1");
+ assertEquals(errorResponse, mergeResult.right().value());
+ verifyZeroInteractions(componentInputsMergeBL, componentInstancePropertiesMergeBL, toscaOperationFacade);
+ }
+
+ @Test
+ public void mergeDataAfterCreate_failedToMergeComponentInstProps() throws Exception {
+ ResponseFormat errorResponse = new ResponseFormat();
+ when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
+ when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeDataAfterCreate(USER, new DataForMergeHolder(), new Service(), "inst1");
+ assertEquals(errorResponse, mergeResult.right().value());
+ verifyZeroInteractions(componentInputsMergeBL, toscaOperationFacade);
+ }
+
+ @Test
+ public void mergeDataAfterCreate_mergeInputs_FailedToFetchResource() throws Exception {
+ ResponseFormat errorResponse = new ResponseFormat();
+ when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
+ when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
+ when(toscaOperationFacade.getToscaElement(any(), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
+ DataForMergeHolder dataHolder = new DataForMergeHolder();
+ dataHolder.setOrigComponentInputs(ObjectGenerator.buildInputs("input1", "input2"));
+ Either<Component, ResponseFormat> mergeResult = testInstance.mergeDataAfterCreate(USER, dataHolder, new Service(), "inst1");
+ assertEquals(errorResponse, mergeResult.right().value());
+ verifyZeroInteractions(componentInputsMergeBL);
+ }
+
+ private void assertComponentFilter(ComponentParametersView value) {
+ assertFalse(value.isIgnoreComponentInstances());
+ assertFalse(value.isIgnoreComponentInstancesProperties());
+ assertFalse(value.isIgnoreComponentInstancesInputs());
+ assertFalse(value.isIgnoreArtifacts());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java
new file mode 100644
index 0000000000..0a858c9a29
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java
@@ -0,0 +1,120 @@
+package org.openecomp.sdc.be.components.merge.property;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+import fj.data.Either;
+
+public class ComponentInstanceInputsMergeBLTest {
+
+ public static final String INSTANCE1 = "instance1";
+ public static final String INSTANCE2 = "instance2";
+ @InjectMocks
+ private ComponentInstanceInputsMergeBL testInstance;
+
+ @Mock
+ private DataDefinitionsValuesMergingBusinessLogic propertyValuesMergingBusinessLogic;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ private Resource oldResource, newResource;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ ComponentInstance instance1 = new ComponentInstanceBuilder().setId(INSTANCE1).setName(INSTANCE1).build();
+ ComponentInstance instance2 = new ComponentInstanceBuilder().setId(INSTANCE2).setName(INSTANCE2).build();
+
+ oldResource = new ResourceBuilder()
+ .addInstanceInput(INSTANCE1, "property1")
+ .addInstanceInput(INSTANCE1, "property2")
+ .addInstanceInput(INSTANCE2, "property3")
+ .addComponentInstance(instance1)
+ .addComponentInstance(instance2)
+ .addInput("input1")
+ .addInput("input2").build();
+
+ newResource = new ResourceBuilder()
+ .addInstanceInput(INSTANCE1, "property11")
+ .addInstanceInput(INSTANCE1, "property12")
+ .addInstanceInput(INSTANCE2, "property13")
+ .addComponentInstance(instance1)
+ .addComponentInstance(instance2)
+ .addInput("input11")
+ .addInput("input12").build();
+ }
+
+ @Test
+ public void mergeInstancesInputs() throws Exception {
+ when(toscaOperationFacade.updateComponentInstanceInputsToComponent(newResource.getComponentInstancesInputs(), newResource.getUniqueId())).thenReturn(Either.left(Collections.emptyMap()));
+ ActionStatus actionStatus = testInstance.mergeComponentInstancesInputs(oldResource, newResource);
+ assertEquals(actionStatus, ActionStatus.OK);
+ verifyMergeBLCalled(oldResource, newResource);
+ }
+
+ @Test
+ public void mergeInstancesInputs_failure() throws Exception {
+ when(toscaOperationFacade.updateComponentInstanceInputsToComponent(newResource.getComponentInstancesInputs(), newResource.getUniqueId())).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ verifyNoMoreInteractions(toscaOperationFacade, propertyValuesMergingBusinessLogic);
+ ActionStatus actionStatus = testInstance.mergeComponentInstancesInputs(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ }
+
+ @Test
+ public void mergeInstanceProps() throws Exception {
+ List<ComponentInstanceInput> newInstanceInputs = newResource.safeGetComponentInstanceInput(INSTANCE1);
+ List<ComponentInstanceInput> oldInstInputs = oldResource.safeGetComponentInstanceInput(INSTANCE1);
+ when(toscaOperationFacade.updateComponentInstanceInputs(newResource, INSTANCE1, newInstanceInputs))
+ .thenReturn(StorageOperationStatus.OK);
+ ActionStatus actionStatus = testInstance.mergeComponentInstanceInputs(oldInstInputs, oldResource.getInputs(), newResource, INSTANCE1);
+ assertEquals(actionStatus, ActionStatus.OK);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(oldInstInputs, oldResource.getInputs(), newInstanceInputs, newResource.getInputs());
+ }
+
+ @Test
+ public void mergeInstanceProps_failure() throws Exception {
+ List<ComponentInstanceInput> newInstanceInputs = newResource.safeGetComponentInstanceInput(INSTANCE1);
+ List<ComponentInstanceInput> oldInstInputs = oldResource.safeGetComponentInstanceInput(INSTANCE1);
+ when(toscaOperationFacade.updateComponentInstanceInputs(newResource, INSTANCE1, newInstanceInputs))
+ .thenReturn(StorageOperationStatus.GENERAL_ERROR);
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeComponentInstanceInputs(oldInstInputs, oldResource.getInputs(), newResource, INSTANCE1);
+ assertEquals(actionStatus, ActionStatus.GENERAL_ERROR);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(oldInstInputs, oldResource.getInputs(), newInstanceInputs, newResource.getInputs());
+ }
+
+ private void verifyMergeBLCalled(Resource oldResource, Resource newResource) {
+ List<ComponentInstanceInput> instance1oldInputs = oldResource.getComponentInstancesInputs().get(INSTANCE1);
+ List<ComponentInstanceInput> instance1newInputs = newResource.getComponentInstancesInputs().get(INSTANCE1);
+ List<ComponentInstanceInput> instance2oldInputs = oldResource.getComponentInstancesInputs().get(INSTANCE2);
+ List<ComponentInstanceInput> instance2newInputs = newResource.getComponentInstancesInputs().get(INSTANCE2);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(instance1oldInputs, oldResource.getInputs(), instance1newInputs, newResource.getInputs());
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(instance2oldInputs, oldResource.getInputs(), instance2newInputs, newResource.getInputs());
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java
new file mode 100644
index 0000000000..7948ab8a3d
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java
@@ -0,0 +1,114 @@
+package org.openecomp.sdc.be.components.merge.property;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.ResourceBuilder;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+import fj.data.Either;
+
+public class ComponentInstancePropertiesMergeBLTest {
+
+ private static final String INSTANCE1 = "instance1";
+ private static final String INSTANCE2 = "instance2";
+
+ @InjectMocks
+ private ComponentInstancePropertiesMergeBL testInstance;
+
+ @Mock
+ private DataDefinitionsValuesMergingBusinessLogic propertyValuesMergingBusinessLogic;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+
+ private Resource oldResource, newResource;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ oldResource = new ResourceBuilder()
+ .addInstanceProperty(INSTANCE1, "property1")
+ .addInstanceProperty(INSTANCE1, "property2")
+ .addInstanceProperty(INSTANCE2, "property3")
+ .addInput("input1")
+ .addInput("input2").build();
+
+ newResource = new ResourceBuilder()
+ .addInstanceProperty(INSTANCE1, "property11")
+ .addInstanceProperty(INSTANCE1, "property12")
+ .addInstanceProperty(INSTANCE2, "property13")
+ .addInput("input11")
+ .addInput("input12").build();
+ }
+
+ @Test
+ public void mergeInstancesPropsAndInputs_mergeInstanceProps() throws Exception {
+ when(toscaOperationFacade.updateComponentInstancePropsToComponent(newResource.getComponentInstancesProperties(), newResource.getUniqueId()))
+ .thenReturn(Either.left(Collections.emptyMap()));
+ ActionStatus actionStatus = testInstance.mergeComponentInstancesProperties(oldResource, newResource);
+ assertEquals(actionStatus, ActionStatus.OK);
+ verifyMergeBLCalled(oldResource, newResource);
+ }
+
+ @Test
+ public void mergeInstancesProps_failure() throws Exception {
+ when(toscaOperationFacade.updateComponentInstancePropsToComponent(newResource.getComponentInstancesProperties(), newResource.getUniqueId()))
+ .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ verifyNoMoreInteractions(toscaOperationFacade, propertyValuesMergingBusinessLogic);
+ ActionStatus actionStatus = testInstance.mergeComponentInstancesProperties(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ }
+
+ @Test
+ public void mergeInstanceProps() throws Exception {
+ List<ComponentInstanceProperty> newInstanceProps = newResource.safeGetComponentInstanceProperties(INSTANCE1);
+ List<ComponentInstanceProperty> oldInstProps = oldResource.safeGetComponentInstanceProperties(INSTANCE1);
+ when(toscaOperationFacade.updateComponentInstanceProperties(newResource, INSTANCE1, newInstanceProps))
+ .thenReturn(StorageOperationStatus.OK);
+ ActionStatus actionStatus = testInstance.mergeComponentInstanceProperties(oldInstProps, oldResource.getInputs(), newResource, INSTANCE1);
+ assertEquals(actionStatus, ActionStatus.OK);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(oldInstProps, oldResource.getInputs(), newInstanceProps, newResource.getInputs());
+ }
+
+ @Test
+ public void mergeInstanceProps_failure() throws Exception {
+ List<ComponentInstanceProperty> newInstanceProps = newResource.safeGetComponentInstanceProperties(INSTANCE1);
+ List<ComponentInstanceProperty> oldInstProps = oldResource.safeGetComponentInstanceProperties(INSTANCE1);
+ when(toscaOperationFacade.updateComponentInstanceProperties(newResource, INSTANCE1, newInstanceProps))
+ .thenReturn(StorageOperationStatus.GENERAL_ERROR);
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeComponentInstanceProperties(oldInstProps, oldResource.getInputs(), newResource, INSTANCE1);
+ assertEquals(actionStatus, ActionStatus.GENERAL_ERROR);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(oldInstProps, oldResource.getInputs(), newInstanceProps, newResource.getInputs());
+ }
+
+ private void verifyMergeBLCalled(Resource oldResource, Resource newResource) {
+ List<ComponentInstanceProperty> instance1oldProps = oldResource.getComponentInstancesProperties().get(INSTANCE1);
+ List<ComponentInstanceProperty> instance1newProps = newResource.getComponentInstancesProperties().get(INSTANCE1);
+ List<ComponentInstanceProperty> instance2oldProps = oldResource.getComponentInstancesProperties().get(INSTANCE2);
+ List<ComponentInstanceProperty> instance2newProps = newResource.getComponentInstancesProperties().get(INSTANCE2);
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(instance1oldProps, oldResource.getInputs(), instance1newProps, newResource.getInputs());
+ verify(propertyValuesMergingBusinessLogic).mergeInstanceDataDefinitions(instance2oldProps, oldResource.getInputs(), instance2newProps, newResource.getInputs());
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java
new file mode 100644
index 0000000000..8669a781b4
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java
@@ -0,0 +1,122 @@
+package org.openecomp.sdc.be.components.merge.property;
+
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+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.components.utils.PropertyDataDefinitionBuilder;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+
+public class DataDefinitionsValuesMergingBusinessLogicTest {
+
+ private static final String DEFAULT_PROP_TYPE = "string";
+
+ @InjectMocks
+ private DataDefinitionsValuesMergingBusinessLogic testInstance;
+
+ @Mock
+ private PropertyDataValueMergeBusinessLogic propertyDataValueMergeBusinessLogicMock;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergePropDataDefinition_propertiesNotOfSameType_dontMerge() throws Exception {
+ PropertyDataDefinition oldProp1 = createPropertyDataDefinition("prop1", "oldVal1");
+
+ PropertyDataDefinition newProp1 = createPropertyDataDefinition("prop1", null);
+ newProp1.setType("int");
+
+ testInstance.mergeInstanceDataDefinitions(Collections.singletonList(oldProp1), Collections.emptyList(), Collections.singletonList(newProp1), Collections.emptyList());
+ Mockito.verifyZeroInteractions(propertyDataValueMergeBusinessLogicMock);
+ }
+
+ @Test
+ public void mergePropDataDefinition_propertiesInnerTypesNotSame_dontMerge() throws Exception {
+ PropertyDataDefinition oldProp1 = new PropertyDataDefinitionBuilder()
+ .setName("prop1")
+ .setType("list")
+ .setSchemaType("string")
+ .setValue("val1").build();
+
+ PropertyDataDefinition newProp1 = new PropertyDataDefinitionBuilder()
+ .setName("prop1")
+ .setType("list")
+ .setSchemaType("int")
+ .setValue("val1").build();
+
+ testInstance.mergeInstanceDataDefinitions(Collections.singletonList(oldProp1), Collections.emptyList(), Collections.singletonList(newProp1), Collections.emptyList());
+ Mockito.verifyZeroInteractions(propertyDataValueMergeBusinessLogicMock);
+ }
+
+ @Test
+ public void mergePropDataDefinition_getInputsToMerge_mergeInputsThatExistInNewVersion_mergeInputsThatDeclaredByUserInPrevVersion() throws Exception {
+ PropertyDataDefinition userDeclaredGetInput = createGetInputPropertyDataDefinition("prop1", "input1");
+ PropertyDataDefinition nonUserDeclaredGetInput = createGetInputPropertyDataDefinition("prop2", "input2", "input3");
+
+ PropertyDataDefinition newProp1 = createPropertyDataDefinition("prop1", "");
+ PropertyDataDefinition newProp2 = createPropertyDataDefinition("prop2", null);
+
+ InputDefinition oldDeclaredByUserInput1 = new InputDefinition();
+ oldDeclaredByUserInput1.setName("input1");
+ oldDeclaredByUserInput1.setInstanceUniqueId("instanceId");
+
+ InputDefinition oldNotDeclaredByUserInput2 = new InputDefinition();
+ oldNotDeclaredByUserInput2.setName("input2");
+
+ InputDefinition oldNotDeclaredByUserInput3 = new InputDefinition();
+ oldNotDeclaredByUserInput3.setName("input3");
+
+ InputDefinition newInput3 = new InputDefinition();
+ newInput3.setName("input3");
+
+ List<PropertyDataDefinition> oldProps = Arrays.asList(userDeclaredGetInput, nonUserDeclaredGetInput);
+ List<PropertyDataDefinition> newProps = Arrays.asList(newProp1, newProp2);
+
+ List<InputDefinition> oldInputs = Arrays.asList(oldDeclaredByUserInput1, oldNotDeclaredByUserInput2, oldNotDeclaredByUserInput3);
+ List<InputDefinition> newInputs = Collections.singletonList(newInput3);
+
+ testInstance.mergeInstanceDataDefinitions(oldProps, oldInputs, newProps, newInputs);
+ //get input prop was declared by user - ok to merge it although its input not exist (it will be added later)
+ verify(propertyDataValueMergeBusinessLogicMock).mergePropertyValue(userDeclaredGetInput, newProp1, Collections.singletonList("input1"));
+ //input 2 not exist in new version - dont merge it, input 3 exist in new version - ok to merge it
+ verify(propertyDataValueMergeBusinessLogicMock).mergePropertyValue(nonUserDeclaredGetInput, newProp2, Collections.singletonList("input3"));
+ }
+
+ @Test
+ public void mergePropDataDefinition_dontMergeOldPropsIfNotExistInNewVersion() throws Exception {
+ PropertyDataDefinition oldProp = createPropertyDataDefinition("prop1", "oldVal1");
+ PropertyDataDefinition newProp = createPropertyDataDefinition("prop2", null);
+ testInstance.mergeInstanceDataDefinitions(Collections.singletonList(oldProp), Collections.emptyList(), Collections.singletonList(newProp), Collections.emptyList());
+ Mockito.verifyZeroInteractions(propertyDataValueMergeBusinessLogicMock);
+ }
+
+ private PropertyDataDefinition createPropertyDataDefinition(String name, String value) {
+ return new PropertyDataDefinitionBuilder()
+ .setName(name)
+ .setType(DEFAULT_PROP_TYPE)
+ .setValue(value).build();
+ }
+
+ private PropertyDataDefinition createGetInputPropertyDataDefinition(String name, String ... inputsNames) {
+ PropertyDataDefinitionBuilder propertyBuilder = new PropertyDataDefinitionBuilder()
+ .setName(name)
+ .setType(DEFAULT_PROP_TYPE);
+ for (String inputName : inputsNames) {
+ propertyBuilder.addGetInputValue(inputName);
+ }
+ return propertyBuilder.build();
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
new file mode 100644
index 0000000000..6faee487f4
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
@@ -0,0 +1,253 @@
+package org.openecomp.sdc.be.components.merge.property;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
+
+import fj.data.Either;
+
+public class PropertyDataValueMergeBusinessLogicTest {
+
+ @InjectMocks
+ private PropertyDataValueMergeBusinessLogic testInstance;
+
+ @Mock
+ private ApplicationDataTypeCache applicationDataTypeCache;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeProperties_emptyOldAndNewValues() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, null);
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, null);
+ testMergeProps(oldProp, newProp, null);
+ }
+
+ @Test
+ public void mergeProperties_emptyOldValue() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, null);
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, "newVal");
+ testMergeProps(oldProp, newProp, "newVal");
+ }
+
+ @Test
+ public void mergeSimpleStringType_copyOldValueIfNoNewValue() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, "val1");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, null);
+ testMergeProps(oldProp, newProp, "val1");
+ }
+
+ @Test
+ public void mergeSimpleStringType_dontCopyOldValIfHasNewVal() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, "val1");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, "newVal");
+ testMergeProps(oldProp, newProp, "newVal");
+ }
+
+ @Test
+ public void mergeSimpleIntType_copyOldValueIfNoNewValue() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.INTEGER.getType(), null, "44");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, null);
+ testMergeProps(oldProp, newProp, "44");
+ }
+
+ @Test
+ public void mergeSimpleIntType_dontCopyOldValIfHasNewVal() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.INTEGER.getType(), null, "44");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.STRING.getType(), null, "45");
+ testMergeProps(oldProp, newProp, "45");
+ }
+
+ @Test
+ public void mergeSimpleBooleanType_copyOldValueIfNoNewValue() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.BOOLEAN.getType(), null, "false");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.BOOLEAN.getType(), null, null);
+ testMergeProps(oldProp, newProp, "false");
+ }
+
+ @Test
+ public void mergeSimpleBooleanType_dontCopyOldValIfHasNewVal() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.BOOLEAN.getType(), null, "false");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.BOOLEAN.getType(), null, "true");
+ testMergeProps(oldProp, newProp, "true");
+ }
+
+ @Test
+ public void mergeSimpleListType_copyOldValuesByIndex() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.LIST.getType(), "string", "[\"a\", \"b\", \"c\"]");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.LIST.getType(), "string", "[\"x\", \"\"]");
+ testMergeProps(oldProp, newProp, "[\"x\",\"b\",\"c\"]");
+ }
+
+ @Test
+ public void mergeSimpleListType_jsonList() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", ToscaPropertyType.LIST.getType(), "json", "[[\"a\", \"b\"], \"c\"]");
+ PropertyDataDefinition newProp = createProp("prop1", ToscaPropertyType.LIST.getType(), "json", "[[\"a\"], \"\"]");
+ testMergeProps(oldProp, newProp, "[[\"a\"],\"c\"]");
+ }
+
+ @Test
+ public void mergeComplexType() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", "myType", null, "{\"mac_range_plan\":\"y\", \"mac_count_required\":{\"is_required\":true,\"count\":44}}");
+ PropertyDataDefinition newProp = createProp("prop1", "myType", null, "{\"mac_count_required\":{\"is_required\":false, \"mac_address\":\"myAddress\"}}");
+ testMergeProps(oldProp, newProp, "{\"mac_range_plan\":\"y\",\"mac_count_required\":{\"is_required\":false,\"mac_address\":\"myAddress\",\"count\":44}}");
+ }
+
+ @Test
+ public void mergeListOfComplexType() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", "list", "myType", "[{\"prop1\":\"val1\", \"prop2\":{\"prop3\":true,\"prop4\":44}}, " +
+ "{\"prop1\":\"val2\", \"prop2\":{\"prop3\":true}}]");
+ PropertyDataDefinition newProp = createProp("prop1", "list", "myType", "[{\"prop2\":{\"prop3\":false}}]");
+
+ Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
+ when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
+ String expectedValue = "[{\"prop2\":{\"prop4\":44,\"prop3\":false},\"prop1\":\"\\\"val1\\\"\"}," +
+ "{\"prop2\":{\"prop3\":true},\"prop1\":\"\\\"val2\\\"\"}]";
+
+ assertEquals(expectedValue, newProp.getValue());
+ }
+
+ @Test
+ public void mergeMapType() throws Exception {
+ PropertyDataDefinition oldProp = createProp("prop1", "map", "string", "{\"prop1\":\"val1\", \"prop2\":\"val2\", \"prop3\":\"val3\"}");
+ PropertyDataDefinition newProp = createProp("prop1", "map", "string", "{\"prop1\":\"newVal1\", \"prop2\":\"\"}");
+ testMergeProps(oldProp, newProp, "{\"prop2\":\"val2\",\"prop1\":\"newVal1\",\"prop3\":\"val3\"}");
+ }
+
+ @Test
+ public void mergeGetInputValue() throws Exception {
+ PropertyDataDefinition oldProp = createGetInputProp("prop1", "string", null, "input1");
+ PropertyDataDefinition newProp = createProp("prop1", "string", null, null);
+ testMergeProps(oldProp, newProp, oldProp.getValue(), Collections.singletonList("input1"));
+ assertGetInputValues(newProp, "input1");
+ }
+
+ @Test
+ public void mergeGetInputValue_inputNotForMerging() throws Exception {
+ PropertyDataDefinition oldProp = createGetInputProp("prop1", "string", null, "input1");
+ PropertyDataDefinition newProp = createProp("prop1", "string", null, null);
+ testMergeProps(oldProp, newProp,null, Collections.singletonList("input2"));
+ assertTrue(newProp.getGetInputValues().isEmpty());
+ }
+
+ @Test
+ public void mergeComplexGetInputValue_moreThanOneGetInput_copyOnlyInputsForMerging() throws Exception {
+ PropertyDataDefinition oldProp = new PropertyDataDefinitionBuilder().addGetInputValue("input1").addGetInputValue("input2").setName("prop1").setType("myType").setValue("{\"mac_range_plan\":{\"get_input\": \"input1\"}, \"mac_count_required\":{\"is_required\":true,\"count\":{\"get_input\": \"input2\"}}}").build();
+ PropertyDataDefinition newProp = createProp("prop1", "myType", null, "{\"mac_count_required\":{\"is_required\":true}}");
+ testMergeProps(oldProp, newProp,"{\"mac_range_plan\":{},\"mac_count_required\":{\"is_required\":true,\"count\":{\"get_input\":\"input2\"}}}", Collections.singletonList("input2"));
+ assertGetInputValues(newProp, "input2");
+ }
+
+ @Test
+ public void mergeListValueWithMultipleGetInputs() throws Exception {
+ PropertyDataDefinition oldProp = new PropertyDataDefinitionBuilder()
+ .addGetInputValue("input1").addGetInputValue("input2").addGetInputValue("input3")
+ .setName("prop1")
+ .setType("list").setSchemaType("string")
+ .setValue("[{\"get_input\": \"input2\"},{\"get_input\": \"input3\"},{\"get_input\": \"input1\"}]")
+ .build();
+
+ PropertyDataDefinition newProp = new PropertyDataDefinitionBuilder()
+ .addGetInputValue("input3")
+ .setName("prop1")
+ .setType("list").setSchemaType("string")
+ .setValue("[\"\", {\"get_input\": \"input3\"}]")
+ .build();
+
+ testMergeProps(oldProp, newProp,"[{},{\"get_input\":\"input3\"},{\"get_input\":\"input1\"}]", Arrays.asList("input3", "input1"));
+ assertGetInputValues(newProp, "input3", "input1");
+ }
+
+ private void assertGetInputValues(PropertyDataDefinition newProp, String ... expectedInputNames) {
+ assertTrue(newProp.isGetInputProperty());
+ assertEquals(newProp.getGetInputValues().size(), expectedInputNames.length);
+ for (int i = 0; i < expectedInputNames.length; i++) {
+ String expectedInputName = expectedInputNames[i];
+ GetInputValueDataDefinition getInputValueDataDefinition = newProp.getGetInputValues().get(i);
+ assertEquals(getInputValueDataDefinition.getInputName(), expectedInputName);
+ }
+ }
+
+ private void testMergeProps(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, String expectedValue) {
+ testMergeProps(oldProp, newProp, expectedValue, Collections.emptyList());
+ }
+
+ private void testMergeProps(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, String expectedValue, List<String> getInputsToMerge) {
+ when(applicationDataTypeCache.getAll()).thenReturn(Either.left(Collections.emptyMap()));
+ testInstance.mergePropertyValue(oldProp, newProp, getInputsToMerge);
+ assertEquals(expectedValue, newProp.getValue());
+ }
+
+ private PropertyDataDefinition createProp(String name, String type, String innerType, String val) {
+ return new PropertyDataDefinitionBuilder()
+ .setType(type)
+ .setSchemaType(innerType)
+ .setValue(val)
+ .setName(name)
+ .build();
+ }
+
+ private PropertyDataDefinition createGetInputProp(String name, String type, String innerType, String inputName) {
+ String val = String.format("{\"get_input\":\"%s\"}", inputName);
+ return new PropertyDataDefinitionBuilder()
+ .setType(type)
+ .setSchemaType(innerType)
+ .setValue(val)
+ .addGetInputValue(inputName)
+ .setName(name)
+ .build();
+
+ }
+
+ private Map<String, DataTypeDefinition> buildDataTypes() {
+ DataTypeDefinition myType = new DataTypeDefinition();
+ myType.setName("myType");
+ DataTypeDefinition myInnerType = new DataTypeDefinition();
+ myInnerType.setName("myInnerType");
+
+ PropertyDefinition prop1 = new PropertyDefinition();
+ prop1.setName("prop1");
+
+ PropertyDefinition prop2 = new PropertyDefinition();
+ prop2.setName("prop2");
+ prop2.setType("myInnerType");
+
+ PropertyDefinition prop3 = new PropertyDefinition();
+ prop3.setName("prop3");
+
+ PropertyDefinition prop4 = new PropertyDefinition();
+ prop4.setName("prop4");
+
+ myType.setProperties(Arrays.asList(prop1, prop2));
+ myInnerType.setProperties(Arrays.asList(prop3, prop4));
+
+ return Stream.of(myType, myInnerType).collect(Collectors.toMap(DataTypeDefinition::getName, Function.identity()));
+ }
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
new file mode 100644
index 0000000000..8e7949f108
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
@@ -0,0 +1,82 @@
+package org.openecomp.sdc.be.components.merge.resource;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.merge.input.ComponentInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstanceInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstancePropertiesMergeBL;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.Resource;
+
+public class ResourceDataMergeBusinessLogicTest {
+
+ @InjectMocks
+ private ResourceDataMergeBusinessLogic testInstance;
+
+ @Mock
+ private ComponentInstanceInputsMergeBL instanceInputsValueMergeBLMock;
+
+ @Mock
+ private ComponentInstancePropertiesMergeBL instancePropertiesValueMergeBLMock;
+
+ @Mock
+ private ComponentInputsMergeBL inputsValueMergeBLMock;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeResourceInputs_allMergeClassesAreCalled() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(inputsValueMergeBLMock.mergeAndRedeclareComponentInputs(oldResource, newResource, Collections.emptyList())).thenReturn(ActionStatus.OK);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.OK, actionStatus);
+ }
+
+ @Test
+ public void mergeResourceInputs_failToMergeProperties_dontCallOtherMergeMethods() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ verifyZeroInteractions(instanceInputsValueMergeBLMock, inputsValueMergeBLMock);
+ }
+
+ @Test
+ public void mergeResourceInputs_failToMergeInstanceInputs_dontCallOtherMergeMethods() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ verifyZeroInteractions(inputsValueMergeBLMock);
+ }
+
+ @Test
+ public void mergeResourceInputs_failedToMergeInputs() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(inputsValueMergeBLMock.mergeAndRedeclareComponentInputs(oldResource, newResource, Collections.emptyList())).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java
new file mode 100644
index 0000000000..55a119e078
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java
@@ -0,0 +1,42 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.ArrayList;
+
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
+
+public class ArtifactBuilder {
+
+ private ArtifactDefinition artifactDefinition;
+
+ public ArtifactBuilder() {
+ this.artifactDefinition = new ArtifactDefinition();
+ }
+
+ public ArtifactBuilder setType(String type) {
+ this.artifactDefinition.setArtifactType(type);
+ return this;
+ }
+
+ public ArtifactBuilder setName(String name) {
+ this.artifactDefinition.setArtifactName(name);
+ return this;
+ }
+
+ public ArtifactBuilder setLabel(String label) {
+ this.artifactDefinition.setArtifactLabel(label);
+ return this;
+ }
+
+ public ArtifactBuilder addHeatParam(HeatParameterDefinition heatParam) {
+ if (this.artifactDefinition.getHeatParameters() == null) {
+ this.artifactDefinition.setHeatParameters(new ArrayList<>());
+ }
+ this.artifactDefinition.getHeatParameters().add(heatParam);
+ return this;
+ }
+
+ public ArtifactDefinition build() {
+ return artifactDefinition;
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java
new file mode 100644
index 0000000000..a99f08c20d
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java
@@ -0,0 +1,49 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.ComponentInstance;
+
+public class ComponentInstanceBuilder {
+
+ private ComponentInstance componentInstance;
+
+ public ComponentInstanceBuilder() {
+ componentInstance = new ComponentInstance();
+ }
+
+ public ComponentInstanceBuilder setName(String name) {
+ componentInstance.setName(name);
+ return this;
+ }
+
+ public ComponentInstanceBuilder setComponentUid(String componentUid) {
+ componentInstance.setComponentUid(componentUid);
+ return this;
+ }
+
+ public ComponentInstanceBuilder setId(String id) {
+ componentInstance.setUniqueId(id);
+ return this;
+ }
+
+ public ComponentInstanceBuilder setToscaName(String toscaName) {
+ componentInstance.setToscaComponentName(toscaName);
+ return this;
+ }
+
+ public ComponentInstanceBuilder addDeploymentArtifact(ArtifactDefinition artifactDefinition) {
+ Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
+ if (deploymentArtifacts == null) {
+ componentInstance.setDeploymentArtifacts(new HashMap<>());
+ }
+ componentInstance.getDeploymentArtifacts().put(artifactDefinition.getArtifactName(), artifactDefinition);
+ return this;
+ }
+
+ public ComponentInstance build() {
+ return componentInstance;
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/HeatParameterBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/HeatParameterBuilder.java
new file mode 100644
index 0000000000..d32dc65876
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/HeatParameterBuilder.java
@@ -0,0 +1,36 @@
+package org.openecomp.sdc.be.components.utils;
+
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
+
+public class HeatParameterBuilder {
+
+ private HeatParameterDefinition heatParameterDefinition;
+
+ public HeatParameterBuilder() {
+ heatParameterDefinition = new HeatParameterDefinition();
+ }
+
+ public HeatParameterBuilder setName(String name) {
+ heatParameterDefinition.setName(name);
+ return this;
+ }
+
+ public HeatParameterBuilder setType(String type) {
+ heatParameterDefinition.setType(type);
+ return this;
+ }
+
+ public HeatParameterBuilder setCurrentValue(String value) {
+ heatParameterDefinition.setCurrentValue(value);
+ return this;
+ }
+
+ public HeatParameterBuilder setDefaultValue(String value) {
+ heatParameterDefinition.setDefaultValue(value);
+ return this;
+ }
+
+ public HeatParameterDefinition build() {
+ return heatParameterDefinition;
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java
new file mode 100644
index 0000000000..3a99d54ffa
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java
@@ -0,0 +1,101 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.Resource;
+
+public class ObjectGenerator {
+
+ public static Resource buildResourceWithInputs(String ... inputNames) {
+ Resource resource = buildBasicResource();
+ resource.setInputs(ObjectGenerator.buildInputs(inputNames));
+ return resource;
+ }
+
+ public static Resource buildResourceWithProperties(String ... propertiesNames) {
+ ResourceBuilder resourceBuilder = new ResourceBuilder();
+ resourceBuilder.setUniqueId("id");
+ for (String propertyName : propertiesNames) {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName(propertyName);
+ resourceBuilder.addProperty(propertyDefinition);
+ }
+ return resourceBuilder.build();
+ }
+
+ public static List<ComponentInstanceProperty> buildInstanceProperties(String ... propertiesNames) {
+ return Stream.of(propertiesNames).map(name -> {
+ ComponentInstanceProperty instProp = new ComponentInstanceProperty();
+ instProp.setName(name);
+ return instProp;
+ }).collect(Collectors.toList());
+ }
+
+ public static List<ComponentInstanceInput> buildInstanceInputs(String ... inputsNames) {
+ return Stream.of(inputsNames).map(name -> {
+ ComponentInstanceInput instProp = new ComponentInstanceInput();
+ instProp.setName(name);
+ return instProp;
+ }).collect(Collectors.toList());
+ }
+
+ public static List<InputDefinition> buildInputs(String ... inputNames) {
+ List<InputDefinition> inputs = new ArrayList<>();
+ for (String inputName : inputNames) {
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setName(inputName);
+ inputs.add(inputDefinition);
+ }
+ return inputs;
+ }
+
+ public static Resource buildResourceWithComponentInstance(String ... instanceNames) {
+ List<ComponentInstance> instances = new ArrayList<>();
+ for (String instanceName : instanceNames) {
+ ComponentInstance componentInstance = new ComponentInstanceBuilder().setName(instanceName).setComponentUid(instanceName).build();
+ instances.add(componentInstance);
+ }
+ return buildResourceWithComponentInstances(instances);
+ }
+
+ public static Resource buildResourceWithComponentInstances(List<ComponentInstance> instances) {
+ Resource resource = buildBasicResource();
+ resource.setComponentInstances(instances);
+ return resource;
+ }
+
+ public static Resource buildResourceWithComponentInstances(ComponentInstance ... instances) {
+ return buildResourceWithComponentInstances(Arrays.asList(instances));
+ }
+
+ public static Resource buildResourceWithRelationships(RequirementCapabilityRelDef ... relations) {
+ Resource resource = buildBasicResource();
+ ResourceBuilder resourceBuilder = new ResourceBuilder(resource);
+ for (RequirementCapabilityRelDef relation : relations) {
+ resourceBuilder.addRelationship(relation);
+ }
+ return resourceBuilder.build();
+ }
+
+ public static Resource buildBasicResource() {
+ Resource resource = new Resource();
+ resource.setUniqueId("id");
+ return resource;
+ }
+
+ public static HeatParameterDefinition buildHeatParam(String defaultVal, String currValue) {
+ return new HeatParameterBuilder().setDefaultValue(defaultVal).setCurrentValue(currValue).build();
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java
new file mode 100644
index 0000000000..e7ed170414
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java
@@ -0,0 +1,68 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.ArrayList;
+
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+
+public class PropertyDataDefinitionBuilder {
+
+ private PropertyDefinition propertyDefinition;
+
+ public PropertyDataDefinitionBuilder() {
+ propertyDefinition = new PropertyDefinition();
+ }
+
+ public PropertyDataDefinitionBuilder setUniqueId(String id) {
+ this.propertyDefinition.setUniqueId(id);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder setName(String name) {
+ this.propertyDefinition.setName(name);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder setValue(String value) {
+ this.propertyDefinition.setValue(value);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder setDefaultValue(String value) {
+ this.propertyDefinition.setDefaultValue(value);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder setType(String type) {
+ this.propertyDefinition.setType(type);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder setSchemaType(String type) {
+ if (propertyDefinition.getSchema() == null) {
+ propertyDefinition.setSchema(new SchemaDefinition());
+ }
+ if (propertyDefinition.getSchema().getProperty() == null) {
+ propertyDefinition.getSchema().setProperty(new PropertyDataDefinition());
+ }
+ propertyDefinition.getSchema().getProperty().setType(type);
+ return this;
+ }
+
+ public PropertyDataDefinitionBuilder addGetInputValue(String inputName) {
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ getInputValueDataDefinition.setInputName(inputName);
+ getInputValueDataDefinition.setInputId(inputName);
+ if (propertyDefinition.getGetInputValues() == null) {
+ propertyDefinition.setGetInputValues(new ArrayList<>());
+ }
+ propertyDefinition.getGetInputValues().add(getInputValueDataDefinition);
+ return this;
+ }
+
+ public PropertyDefinition build() {
+ return propertyDefinition;
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java
new file mode 100644
index 0000000000..8c457f153f
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.Collections;
+
+import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
+import org.openecomp.sdc.be.model.RelationshipImpl;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+
+public class RelationsBuilder {
+
+ private RequirementCapabilityRelDef relation;
+
+ public RelationsBuilder() {
+ relation = new RequirementCapabilityRelDef();
+ RelationshipInfo requirementAndRelationshipPair = new RelationshipInfo();
+ RelationshipImpl relationship = new RelationshipImpl();
+ requirementAndRelationshipPair.setRelationships(relationship);
+ CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
+ capReqRel.setRelation(requirementAndRelationshipPair);
+ relation.setRelationships(Collections.singletonList(capReqRel));
+ }
+
+ public RelationsBuilder setFromNode(String fromNode) {
+ relation.setFromNode(fromNode);
+ return this;
+ }
+
+ public RelationsBuilder setRequirementName(String reqName) {
+ relation.getSingleRelationship().getRelation().setRequirement(reqName);
+ return this;
+ }
+
+ public RelationsBuilder setRelationType(String type) {
+ relation.getSingleRelationship().getRelation().getRelationship().setType(type);
+ return this;
+ }
+
+ public RelationsBuilder setCapabilityUID(String uid) {
+ relation.getSingleRelationship().getRelation().setCapabilityUid(uid);
+ return this;
+ }
+
+ public RelationsBuilder setToNode(String toNode) {
+ relation.setToNode(toNode);
+ return this;
+ }
+
+ public RequirementCapabilityRelDef build() {
+ return relation;
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java
new file mode 100644
index 0000000000..3d4a29da71
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java
@@ -0,0 +1,126 @@
+package org.openecomp.sdc.be.components.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.Resource;
+
+public class ResourceBuilder {
+
+ private Resource resource;
+
+ public ResourceBuilder() {
+ this.resource = new Resource();
+ }
+
+ public ResourceBuilder(Resource resource) {
+ this.resource = resource;
+ }
+
+ public ResourceBuilder setUniqueId(String id) {
+ resource.setUniqueId(id);
+ return this;
+ }
+
+ public ResourceBuilder setInvariantUUid(String invariantUUid) {
+ resource.setInvariantUUID(invariantUUid);
+ return this;
+ }
+
+ public ResourceBuilder setName(String name) {
+ resource.setName(name);
+ return this;
+ }
+
+ public ResourceBuilder setComponentType(ComponentTypeEnum type) {
+ resource.setComponentType(type);
+ return this;
+ }
+
+ public ResourceBuilder setSystemName(String systemName) {
+ resource.setSystemName(systemName);
+ return this;
+ }
+
+ public ResourceBuilder addComponentInstance(ComponentInstance componentInstance) {
+ if (resource.getComponentInstances() == null) {
+ resource.setComponentInstances(new ArrayList<>());
+ }
+ resource.getComponentInstances().add(componentInstance);
+ return this;
+ }
+
+ public ResourceBuilder addInput(InputDefinition input) {
+ if (resource.getInputs() == null) {
+ resource.setInputs(new ArrayList<>());
+ }
+ resource.getInputs().add(input);
+ return this;
+ }
+
+ public ResourceBuilder addInput(String inputName) {
+ InputDefinition inputDefinition = new InputDefinition();
+ inputDefinition.setName(inputName);
+ inputDefinition.setUniqueId(inputName);
+ this.addInput(inputDefinition);
+ return this;
+ }
+
+ public ResourceBuilder addProperty(PropertyDefinition propertyDefinition) {
+ if (resource.getProperties() == null) {
+ resource.setProperties(new ArrayList<>());
+ }
+ resource.getProperties().add(propertyDefinition);
+ return this;
+ }
+
+ public ResourceBuilder addInstanceProperty(String instanceId, ComponentInstanceProperty prop) {
+ if (resource.getComponentInstancesProperties() == null) {
+ resource.setComponentInstancesProperties(new HashMap<>());
+ }
+ resource.getComponentInstancesProperties().computeIfAbsent(instanceId, key -> new ArrayList<>()).add(prop);
+ return this;
+ }
+
+ public ResourceBuilder addInstanceProperty(String instanceId, String propName) {
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
+ componentInstanceProperty.setName(propName);
+ this.addInstanceProperty(instanceId, componentInstanceProperty);
+ return this;
+ }
+
+ public ResourceBuilder addInstanceInput(String instanceId, ComponentInstanceInput prop) {
+ if (resource.getComponentInstancesInputs() == null) {
+ resource.setComponentInstancesInputs(new HashMap<>());
+ }
+ resource.getComponentInstancesInputs().computeIfAbsent(instanceId, key -> new ArrayList<>()).add(prop);
+ return this;
+ }
+
+ public ResourceBuilder addInstanceInput(String instanceId, String propName) {
+ ComponentInstanceInput componentInstanceInput = new ComponentInstanceInput();
+ componentInstanceInput.setName(propName);
+ this.addInstanceInput(instanceId, componentInstanceInput);
+ return this;
+ }
+
+ public ResourceBuilder addRelationship(RequirementCapabilityRelDef requirementCapabilityRelDef) {
+ if (resource.getComponentInstancesRelations() == null) {
+ resource.setComponentInstancesRelations(new ArrayList<>());
+ }
+ resource.getComponentInstancesRelations().add(requirementCapabilityRelDef);
+ return this;
+ }
+
+
+ public Resource build() {
+ return resource;
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java
index 104cd14e7a..290a5f4d1d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java
@@ -37,8 +37,6 @@ import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler;
import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineInitTask;
import org.openecomp.sdc.be.components.distribution.engine.SubscriberTypeEnum;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
-import org.openecomp.sdc.be.distribution.AuditHandler;
-import org.openecomp.sdc.be.distribution.DistributionBusinessLogic;
import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus;
import org.openecomp.sdc.be.distribution.api.client.RegistrationRequest;
import org.openecomp.sdc.be.distribution.api.client.TopicRegistrationResponse;
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 1c84cf6ca6..4e27c30f8a 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
@@ -26,6 +26,8 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+
import org.junit.Test;
import org.mockito.InjectMocks;
import org.openecomp.sdc.be.components.BaseConfDependentTest;
@@ -33,6 +35,7 @@ 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.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
public class ServiceDistributionArtifactsBuilderTest extends BaseConfDependentTest {
@@ -63,12 +66,25 @@ public class ServiceDistributionArtifactsBuilderTest extends BaseConfDependentTe
toscaTemplateArtifact.setArtifactType(ArtifactTypeEnum.TOSCA_TEMPLATE.getType());
toscaTemplateArtifact.setArtifactLabel(artifactLabel);
toscaTemplateArtifact.setEsId(esArtifactId);
+ toscaTemplateArtifact.setUniqueId(esArtifactId);
toscaTemplateArtifact.setPayload(payload);
Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
toscaArtifacts.put(artifactLabel, toscaTemplateArtifact);
service.setToscaArtifacts(toscaArtifacts);
+ ArtifactDefinition deploymentArtifact = new ArtifactDefinition();
+ deploymentArtifact.setArtifactName("deployment.yaml");
+ deploymentArtifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ deploymentArtifact.setArtifactType(ArtifactTypeEnum.OTHER.getType());
+ deploymentArtifact.setArtifactLabel("deployment");
+ deploymentArtifact.setEsId("deployment007");
+ deploymentArtifact.setUniqueId("deployment007");
+ deploymentArtifact.setPayload(payload);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ deploymentArtifacts.put("deployment", deploymentArtifact);
+ service.setDeploymentArtifacts(deploymentArtifacts);
+
Class<ServiceDistributionArtifactsBuilder> targetClass = ServiceDistributionArtifactsBuilder.class;
String methodName = "convertServiceArtifactsToArtifactInfo";
Object[] argObjects = {service};
@@ -79,8 +95,9 @@ public class ServiceDistributionArtifactsBuilderTest extends BaseConfDependentTe
List<ArtifactInfoImpl> convertServiceArtifactsToArtifactInfoRes =
(List<ArtifactInfoImpl>) method.invoke(serviceDistributionArtifactsBuilder, argObjects);
assertTrue(convertServiceArtifactsToArtifactInfoRes != null);
- assertTrue(convertServiceArtifactsToArtifactInfoRes.size() == 1);
- assertTrue(convertServiceArtifactsToArtifactInfoRes.get(0).getArtifactName().equals(artifactName));
+ assertTrue(convertServiceArtifactsToArtifactInfoRes.size() == 2);
+ List<String> artifactsNames = convertServiceArtifactsToArtifactInfoRes.stream().map(a->a.getArtifactName()).collect(Collectors.toList());
+ assertTrue(artifactsNames.contains(artifactName) && artifactsNames.contains("deployment.yaml"));
}
catch (Exception e) {
e.printStackTrace();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java
new file mode 100644
index 0000000000..74f0eac5ad
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.sdc.be.distribution;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler;
+import org.openecomp.sdc.be.components.distribution.engine.INotificationData;
+import org.openecomp.sdc.be.components.distribution.engine.NotificationDataImpl;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+public class TestQueue {
+
+ public static void main(String[] args) {
+ ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder();
+ threadFactoryBuilder.setNameFormat("distribution-notification-thread");
+ ThreadFactory threadFactory = threadFactoryBuilder.build();
+ // TODO: add the package of google to the pom
+
+ ExecutorService executorService = new ThreadPoolExecutor(0, 10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory);
+ // ExecutorService executorService = new ThreadPoolExecutor(0, 2, 60L,
+ // TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20));
+
+ // 2 threads are always up and they handle the tasks. in case core size
+ // is 0, only one is handles the tasks.
+ // ExecutorService executorService = new ThreadPoolExecutor(0, 2, 60L,
+ // TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20));
+
+ // TODO : check what happen when the number of threads are full. Throw
+ // RejectedExecutionException
+ // TODO : check what happen whether the pool is full and the size of
+ // pool
+
+ ExecutorService newCachedThreadPool = Executors.newCachedThreadPool(threadFactory);
+ Runnable task = new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ System.out.println("iN SLEEP" + Thread.currentThread());
+ Thread.sleep(10 * 1000);
+ System.out.println("OUT SLEEP");
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ for (int i = 0; i < 4; i++) {
+ try {
+ executorService.submit(task);
+ } catch (RejectedExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+
+ newCachedThreadPool.submit(task);
+ System.out.println("After submitting the task");
+
+ MyWorker[] watchThreads = new MyWorker[1];
+ BlockingQueue<String> queue = new ArrayBlockingQueue<>(5);
+ for (int i = 0; i < watchThreads.length; i++) {
+ MyWorker myWorker = new MyWorker(queue);
+ myWorker.start();
+ }
+
+ for (int i = 0; i < 1; i++) {
+ try {
+ queue.put("message " + i);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public static class MyTimerTask extends TimerTask {
+
+ AtomicBoolean state;
+ Thread thread;
+
+ public MyTimerTask(AtomicBoolean state, Thread thread) {
+ super();
+ this.state = state;
+ this.thread = thread;
+
+ System.out.println("After create timer");
+ }
+
+ @Override
+ public void run() {
+ System.out.println("In running of Timer task");
+ if (state.get() == false) {
+ System.out.println("In running of Timer task. Going to interrupt thread");
+ // thread.interrupt();
+ } else {
+ System.out.println("In running of Timer task. Finished.");
+ }
+ }
+
+ }
+
+ public static class MyWorker extends Thread {
+
+ boolean active = true;
+ private final BlockingQueue<String> queue;
+
+ public MyWorker(BlockingQueue<String> queue) {
+ this.queue = queue;
+ }
+
+ Timer timer = new Timer();
+
+ public void run() {
+ try {
+ while (active) {
+ String s = queue.take();
+ System.out.println("Thread " + Thread.currentThread() + " fecthed a message " + s);
+
+ AtomicBoolean atomicBoolean = new AtomicBoolean(false);
+ MyTimerTask myTimerTask = new MyTimerTask(atomicBoolean, this);
+ timer.schedule(myTimerTask, 10 * 1000);
+ doWork(s);
+ atomicBoolean.set(true);
+
+ }
+ } catch (InterruptedException ie) {
+
+ System.out.println("Interrupted our thread");
+ ie.printStackTrace();
+ }
+ }
+
+ private void doWork(String s) {
+ // TODO Auto-generated method stub
+
+ CambriaHandler cambriaHandler = new CambriaHandler();
+ INotificationData data = new NotificationDataImpl();
+ List<String> servers = new ArrayList<>();
+ servers.add("aaaaaaa");
+ cambriaHandler.sendNotification("topicName", "uebPublicKey", "uebSecretKey", servers, data);
+
+ System.out.println("IN WORK " + s);
+ try {
+ Thread.sleep(1 * 1000);
+ } catch (InterruptedException e) {
+
+ for (int i = 0; i < 10; i++) {
+ System.out.println("*************************************************");
+ }
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java
index d6274ad90e..3aa143a389 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java
@@ -46,7 +46,6 @@ import org.openecomp.sdc.be.distribution.AuditHandler;
import org.openecomp.sdc.be.distribution.DistributionBusinessLogic;
import org.openecomp.sdc.be.distribution.api.client.RegistrationRequest;
import org.openecomp.sdc.be.distribution.api.client.TopicRegistrationResponse;
-import org.openecomp.sdc.be.distribution.servlet.DistributionServlet;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.common.api.Constants;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java
index e4f46dd4dd..1df88c3686 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java
@@ -20,21 +20,19 @@
package org.openecomp.sdc.be.ecomp;
-import java.io.File;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
-import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.common.config.EcompClassification;
import org.openecomp.sdc.common.config.EcompErrorCode;
import org.openecomp.sdc.common.config.EcompErrorEnum;
import org.openecomp.sdc.common.config.generation.GenerateEcompErrorsCsv;
-import static org.junit.Assert.assertTrue;
-
public class GenerateEcompErrorFileTest {
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
index 640a9d2cf6..810da4c10b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
@@ -43,9 +43,7 @@ import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
@@ -58,10 +56,8 @@ import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.Resource;
-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.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
@@ -115,7 +111,7 @@ public class AssetsDataServletTest extends JerseyTest {
when(resource.getName()).thenReturn("MockVFCMT");
when(resource.getSystemName()).thenReturn("mockvfcmt");
Either<Resource, ResponseFormat> eitherRet = Either.left(resource);
- when(componentsUtils.convertJsonToObjectUsingObjectMapper(Mockito.anyString(), Mockito.any(User.class), Mockito.eq(Resource.class), Mockito.any(AuditingActionEnum.class), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
+ when(componentsUtils.convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class), Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
@@ -123,7 +119,7 @@ public class AssetsDataServletTest extends JerseyTest {
when(subCategoryDefinition.getName()).thenReturn("Monitoring Template");
when(categoryDefinition.getSubcategories()).thenReturn(Arrays.asList(subCategoryDefinition));
when(elementBusinessLogic.getAllResourceCategories()).thenReturn(Either.left(Arrays.asList(categoryDefinition)));
- when(resourceBusinessLogic.createResource(Mockito.eq(resource), Mockito.any(AuditingActionEnum.class), Mockito.any(User.class), Mockito.anyMap(), Mockito.anyString())).thenReturn(Either.left(resource));
+ when(resourceBusinessLogic.createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(Either.left(resource));
when(webApplicationContext.getBean(AssetMetadataConverter.class)).thenReturn(assetMetadataConverter);
Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter).convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
@@ -136,22 +132,21 @@ public class AssetsDataServletTest extends JerseyTest {
private static void mockResponseFormat() {
- when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Matchers.<String>anyVararg())).thenAnswer(new Answer<ResponseFormat>(){
- public ResponseFormat answer(InvocationOnMock invocation) throws Throwable {
- ResponseFormat ret;
- final ActionStatus actionStatus = invocation.getArgumentAt(0, ActionStatus.class);
- switch( actionStatus ){
- case CREATED :{
- ret = new ResponseFormat(HttpStatus.SC_CREATED);
- break;
- }
- default :{
- ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- break;
- }
- }
- return ret;
- }});
+ when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class))).thenAnswer((Answer<ResponseFormat>) invocation -> {
+ ResponseFormat ret;
+ final ActionStatus actionStatus = invocation.getArgument(0);
+ switch( actionStatus ){
+ case CREATED :{
+ ret = new ResponseFormat(HttpStatus.SC_CREATED);
+ break;
+ }
+ default :{
+ ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ break;
+ }
+ }
+ return ret;
+ });
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadataTest.java
index 673964e264..a2eb5336ed 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadataTest.java
index 1102dea900..f471e4971a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadataTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadataTest.java
index 0d931e15df..669f58c675 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadataTest.java
index 83d048ae6b..b66341b8dd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadataTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
public class ResourceAssetDetailedMetadataTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadataTest.java
index d0d784f5a8..e1d276c839 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadataTest.java
index ba9897c7dc..cd8439e34a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadataTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadataTest.java
index 29825a6e60..7279436d10 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadataTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadataTest.java
index 6a4a38a02f..f6022263bd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
index b726bee926..811a3031ae 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
@@ -1,31 +1,15 @@
package org.openecomp.sdc.be.impl;
import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.codehaus.jackson.map.module.SimpleModule;
import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.auditing.api.IAuditingManager;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
-import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ConsumerDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.PolicyTypeDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -34,10 +18,6 @@ import org.openecomp.sdc.be.tosca.ToscaError;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.openecomp.sdc.exception.ResponseFormat;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-import fj.data.Either;
-
public class ComponentsUtilsTest {
private ComponentsUtils createTestSubject() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
index 096bb4dca2..4bff2ecdeb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
index 2164b91542..4c8da955ae 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
index a9b9352673..b73874ea3a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.ArtifactDefinition;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
index 379959628c..e16540f523 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
@@ -1,8 +1,7 @@
package org.openecomp.sdc.be.info;
-import static org.junit.Assert.*;
-import java.util.*;
-import org.junit.Assert;
+import java.util.List;
+
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
index 4010d9bf86..1474d9433b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.ArtifactType;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
index ad8e21bb84..e39e5819d3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
index dd8a3e6eee..329743f4a7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
index db4d735a7e..488cb31a55 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
public class DistributionStatusListResponseTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
index 62b1bcbe0f..23abecb67d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
index 830292a66f..4a5964aaf6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
index b2895d099c..662b96ccbf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
@@ -2,12 +2,8 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.GroupProperty;
-import java.util.*;
-import org.junit.Assert;
public class GroupDefinitionInfoTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
index 727a1f25d4..a77c1385a7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java
index 569b04d982..e8c9374447 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java
index 2b5e97e86d..d609f8090f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
public class ServiceVersionInfoTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java
index 085583aa2d..ca0006d43c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java
index 43144113ea..9b0c5fc453 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.info;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java
index c96f71b8fd..c2a1e82564 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java
index 80ae443afe..67b0cdfd33 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.info;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
index 27963fa8cb..cee856d905 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
@@ -23,43 +23,26 @@ package org.openecomp.sdc.be.servlets;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.glassfish.grizzly.servlet.ServletUtils;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.servlets.ResourceUploadServlet.ResourceAuthorityTypeEnum;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
-import com.google.common.base.Supplier;
-import com.google.gson.Gson;
-
-import aj.org.objectweb.asm.Type;
import fj.data.Either;
public class AbstractValidationsServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java
index 0cb9906dc4..dbb1f59f62 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java
@@ -1,13 +1,9 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.AdditionalInformationBusinessLogic;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class AdditionalInformationServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java
index 2dda0f5d14..6ef8091921 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java
@@ -31,7 +31,6 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.MultiPart;
import org.glassfish.jersey.server.ResourceConfig;
import org.mockito.Mockito;
-import org.openecomp.sdc.be.servlets.ResourceUploadServlet;
public class ApplicationConfig extends Application {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java
index b4d04f92a9..e546fcca55 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java
@@ -1,12 +1,9 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
public class ArtifactServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java
index 34a475882a..692158b881 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
index 52ee33fd74..97b1fe2a81 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
@@ -1,309 +1,136 @@
package org.openecomp.sdc.be.servlets;
-import java.util.List;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
-import javax.annotation.Generated;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.tinkerpop.gremlin.structure.T;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.components.impl.ServiceComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.VFComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.web.context.WebApplicationContext;
import fj.data.Either;
-public class ComponentInstanceServletTest {
-
- private ComponentInstanceServlet createTestSubject() {
- return new ComponentInstanceServlet();
- }
-
-
- @Test
- public void testCreateComponentInstance() throws Exception {
- ComponentInstanceServlet testSubject;
- String data = "";
- String containerComponentId = "";
- String containerComponentType = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateComponentInstanceMetadata() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String componentInstanceId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateMultipleComponentInstance() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- String componentInstanceJsonArray = "";
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testDeleteResourceInstance() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String resourceInstanceId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testAssociateRIToRI() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String userId = "";
- String data = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testDissociateRIFromRI() throws Exception {
- ComponentInstanceServlet testSubject;
- String containerComponentType = "";
- String componentId = "";
- String userId = "";
- String data = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testCreateAndAssociateRIToRI() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateResourceInstanceProperty() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String componentInstanceId = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateResourceInstanceInput() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String componentInstanceId = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateResourceInstanceAttribute() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String componentInstanceId = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testDeleteResourceInstanceProperty() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String componentInstanceId = "";
- String propertyId = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testChangeResourceInstanceVersion() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String componentInstanceId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testUpdateGroupInstanceProperty() throws Exception {
- ComponentInstanceServlet testSubject;
- String componentId = "";
- String containerComponentType = "";
- String componentInstanceId = "";
- String groupInstanceId = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testGetGroupArtifactById() throws Exception {
- ComponentInstanceServlet testSubject;
- String containerComponentType = "";
- String componentId = "";
- String componentInstanceId = "";
- String groupInstId = "";
- HttpServletRequest request = null;
- String userId = "";
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testGetInstancePropertiesById() throws Exception {
- ComponentInstanceServlet testSubject;
- String containerComponentType = "";
- String containerComponentId = "";
- String componentInstanceUniqueId = "";
- HttpServletRequest request = null;
- String userId = "";
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testCreateServiceProxy() throws Exception {
- ComponentInstanceServlet testSubject;
- String data = "";
- String containerComponentId = "";
- String containerComponentType = "";
- String userId = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testDeleteServiceProxy() throws Exception {
- ComponentInstanceServlet testSubject;
- String containerComponentId = "";
- String serviceProxyId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
- @Test
- public void testChangeServiceProxyVersion() throws Exception {
- ComponentInstanceServlet testSubject;
- String containerComponentId = "";
- String serviceProxyId = "";
- String containerComponentType = "";
- HttpServletRequest request = null;
- Response result;
-
- // default test
- testSubject = createTestSubject();
-
- }
-
-
-
-} \ No newline at end of file
+/**
+ * The test suite designed for test functionality of ComponentInstanceServlet class
+ */
+public class ComponentInstanceServletTest extends JerseyTest {
+
+ private final static String USER_ID = "jh0003";
+ private static HttpServletRequest request;
+ private static HttpSession session;
+ private static ServletContext servletContext;
+ private static WebAppContextWrapper webAppContextWrapper;
+ private static WebApplicationContext webApplicationContext;
+ private static VFComponentInstanceBusinessLogic vfBusinessLogic;
+ private static ServiceComponentInstanceBusinessLogic serviceBusinessLogic;
+ private static ComponentsUtils componentsUtils;
+ private static ServletUtils servletUtils;
+ private static ResponseFormat responseFormat;
+
+ @BeforeClass
+ public static void setup() {
+ createMocks();
+ stubMethods();
+ }
+
+ @Test
+ public void testGetRelationByIdSuccess(){
+
+ String containerComponentType = "resources";
+ String componentId = "componentId";
+ String relationId = "relationId";
+ String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/" + relationId + "/relationId";
+ Either<RequirementCapabilityRelDef, ResponseFormat> successResponse = Either.left(new RequirementCapabilityRelDef());
+ when(vfBusinessLogic.getRelationById(eq(componentId), eq(relationId), eq(USER_ID), eq(ComponentTypeEnum.RESOURCE))).thenReturn(successResponse);
+ when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200.getStatusCode());
+ when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
+ Response response = target()
+ .path(path)
+ .request(MediaType.APPLICATION_JSON)
+ .header("USER_ID", USER_ID)
+ .get( Response.class);
+
+ assertTrue(response.getStatus() == HttpStatus.OK_200.getStatusCode());
+ }
+
+ @Test
+ public void testGetRelationByIdFailure(){
+
+ String containerComponentType = "unknown_type";
+ String componentId = "componentId";
+ String relationId = "relationId";
+ String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/" + relationId + "/relationId";
+ when(responseFormat.getStatus()).thenReturn(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ when(componentsUtils.getResponseFormat(eq(ActionStatus.UNSUPPORTED_ERROR), eq(containerComponentType))).thenReturn(responseFormat);
+ Response response = target()
+ .path(path)
+ .request(MediaType.APPLICATION_JSON)
+ .header("USER_ID", USER_ID)
+ .get( Response.class);
+
+ assertTrue(response.getStatus() == HttpStatus.BAD_REQUEST_400.getStatusCode());
+ }
+
+ @Override
+ protected Application configure() {
+
+ ResourceConfig resourceConfig = new ResourceConfig(ComponentInstanceServlet.class);
+ forceSet(TestProperties.CONTAINER_PORT, "0");
+
+ resourceConfig.register(new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(request).to(HttpServletRequest.class);
+ }
+ });
+ return resourceConfig;
+ }
+
+ private static void createMocks() {
+ request = Mockito.mock(HttpServletRequest.class);
+ session = Mockito.mock(HttpSession.class);
+ servletContext = Mockito.mock(ServletContext.class);
+ webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+ webApplicationContext = Mockito.mock(WebApplicationContext.class);
+ vfBusinessLogic = Mockito.mock(VFComponentInstanceBusinessLogic.class);
+ serviceBusinessLogic = Mockito.mock(ServiceComponentInstanceBusinessLogic.class);
+ componentsUtils = Mockito.mock(ComponentsUtils.class);
+ servletUtils = Mockito.mock(ServletUtils.class);
+ responseFormat = Mockito.mock(ResponseFormat.class);
+ }
+
+ private static void stubMethods() {
+ when(request.getSession()).thenReturn(session);
+ when(session.getServletContext()).thenReturn(servletContext);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
+ when(webApplicationContext.getBean(VFComponentInstanceBusinessLogic.class)).thenReturn(vfBusinessLogic);
+ when(webApplicationContext.getBean(ServiceComponentInstanceBusinessLogic.class)).thenReturn(serviceBusinessLogic);
+ when(request.getHeader("USER_ID")).thenReturn(USER_ID);
+ when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
+ when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
index 3e97aa4cb0..7159f2e035 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.be.servlets;
import java.util.List;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java
index 4f2ca19986..4c7caa63e6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java
@@ -1,9 +1,7 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
-import org.junit.Assert;
import org.junit.Test;
import com.datastax.driver.core.Configuration;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java
index adc996eb4c..2593474f2b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java
index 6360c5a76e..14b34a206e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
index e80016a678..930fe88339 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
@@ -1,15 +1,9 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.junit.Test;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-
-import ch.qos.logback.classic.Logger;
-import java.util.*;
-import org.junit.Assert;
public class CsarBuildServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java
index 2233b4ebac..d022faabcd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
index 2fe68d3a90..31068ccd17 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.be.servlets;
import java.util.List;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java
index 85b835076b..95f5174580 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
index 9cc13d32de..9ff55c22f0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java
index f92e439c9a..8ea39b7443 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java
index 2376ceea32..66208daaf7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java
index dd31364868..fe147b19a9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.be.servlets;
import java.util.Map;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
@@ -13,8 +12,6 @@ import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import com.google.common.collect.Multiset.Entry;
-
import fj.data.Either;
public class PropertyServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java
index c56fd474b4..f82fdfc1ef 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
-
import org.apache.tinkerpop.gremlin.structure.T;
import org.junit.Test;
import org.openecomp.sdc.be.model.ArtifactDefinition;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java
index 4407ec6577..a7c23732ee 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java
index b88a097412..319e59a5eb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
index 107163c520..7e0c6b7647 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
@@ -53,7 +53,6 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.servlets.ResourcesServlet;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
index 252e9d8fbc..ff69241263 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
@@ -20,8 +20,8 @@
package org.openecomp.sdc.be.servlets;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import java.io.File;
@@ -58,7 +58,6 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.resources.api.IResourceUploader;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.servlets.ResourceUploadServlet;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java
index 1844cfe188..841254e4dc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java
@@ -3,11 +3,9 @@ package org.openecomp.sdc.be.servlets;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
-import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java
index 7a21a231d8..2b4ddfb7b4 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java
index 94aaee2afc..e512d98ca9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.be.servlets;
-import javax.annotation.Generated;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
index 8f4f57e836..37a493de37 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
@@ -35,8 +35,6 @@ import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.T;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.client.ClientConfig;
@@ -61,15 +59,11 @@ import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.ConsumerTwoParam;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.web.context.WebApplicationContext;
-import com.google.common.base.Equivalence.Wrapper;
-import com.google.common.base.Supplier;
-
import fj.data.Either;
public class TypesUploadServletTest extends JerseyTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
index 6fd930c684..afa0907f25 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
@@ -35,7 +35,6 @@ import javax.ws.rs.core.Response;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java
index f93819c0a1..0562a1a80c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.switchover.detector;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java
index dec4e78008..92fc2fd4cf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.tosca;
import java.util.List;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.generator.data.ArtifactType;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
index 8acfe6cfea..7348156923 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
@@ -32,13 +32,10 @@ import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.openecomp.sdc.exception.ResponseFormat;
import fj.data.Either;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
index c77c0f10f3..139de137d9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
@@ -1,11 +1,13 @@
package org.openecomp.sdc.be.tosca;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -13,6 +15,7 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
@@ -31,7 +34,7 @@ public class PropertyConvertorTest {
property = new PropertyDefinition();
property.setName("myProperty");
property.setType(ToscaPropertyType.INTEGER.getType());
- dataTypes = new HashMap<String, DataTypeDefinition>();
+ dataTypes = new HashMap();
dataTypes.put(property.getName(), new DataTypeDefinition());
}
@@ -49,7 +52,7 @@ public class PropertyConvertorTest {
property.setDefaultValue(def);
ToscaProperty result = PropertyConvertor.getInstance().convertProperty(dataTypes, property, false);
assertNotNull(result);
- assertEquals(Integer.valueOf(def).intValue(), result.getDefaultp());
+ assertEquals(Integer.valueOf(def), result.getDefaultp());
}
@Test
@@ -60,7 +63,7 @@ public class PropertyConvertorTest {
property1.setDefaultValue("2");
dataTypes.put(property1.getName(), new DataTypeDefinition());
Resource resource = new Resource();
- List<PropertyDefinition> properties = new ArrayList<PropertyDefinition>();
+ List<PropertyDefinition> properties = new ArrayList();
properties.add(property);
properties.add(property1);
resource.setProperties(properties);
@@ -86,7 +89,7 @@ public class PropertyConvertorTest {
property.setDefaultValue("1");
dataTypes.put(property1.getName(), new DataTypeDefinition());
Resource resource = new Resource();
- List<PropertyDefinition> properties = new ArrayList<PropertyDefinition>();
+ List<PropertyDefinition> properties = new ArrayList();
properties.add(property);
properties.add(property1);
resource.setProperties(properties);
@@ -106,7 +109,7 @@ public class PropertyConvertorTest {
property1.setType(ToscaPropertyType.INTEGER.getType());
dataTypes.put(property1.getName(), new DataTypeDefinition());
Resource resource = new Resource();
- List<PropertyDefinition> properties = new ArrayList<PropertyDefinition>();
+ List<PropertyDefinition> properties = new ArrayList();
properties.add(property);
properties.add(property1);
resource.setProperties(properties);
@@ -118,4 +121,25 @@ public class PropertyConvertorTest {
assertNull(prop.getDefaultp());
}
}
+
+ @Test
+ public void convertPropertyWhichStartsWithSemiColon() throws Exception {
+ PropertyDefinition property1 = new PropertyDataDefinitionBuilder()
+ .setDefaultValue("::")
+ .setType(ToscaPropertyType.STRING.getType())
+ .build();
+ ToscaProperty toscaProperty = PropertyConvertor.getInstance().convertProperty(Collections.emptyMap(), property1, false);
+ assertThat(toscaProperty.getDefaultp()).isEqualTo("::");
+ }
+
+ @Test
+ public void convertPropertyWhichStartsWithSlash() throws Exception {
+ PropertyDefinition property1 = new PropertyDataDefinitionBuilder()
+ .setDefaultValue("/")
+ .setType(ToscaPropertyType.STRING.getType())
+ .build();
+ ToscaProperty toscaProperty = PropertyConvertor.getInstance().convertProperty(Collections.emptyMap(), property1, false);
+ assertThat(toscaProperty.getDefaultp()).isEqualTo("/");
+ }
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java
index fdfd1c725f..acfeaf1abc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java
@@ -20,7 +20,8 @@
package org.openecomp.sdc.be.tosca;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.IOException;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 7cb2ef7cf8..4399408c5c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.tosca;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java
new file mode 100644
index 0000000000..4c22cf3599
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java
@@ -0,0 +1,124 @@
+package org.openecomp.sdc.be.tosca;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.ServiceComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.VFComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class ToscaExportUtilsTest {
+ private static Logger log = LoggerFactory.getLogger(ToscaExportUtilsTest.class.getName());
+ @javax.annotation.Resource
+ private VFComponentInstanceBusinessLogic componentInstanceBusinessLogic;
+ @javax.annotation.Resource
+ private ServiceComponentInstanceBusinessLogic serviceInstanceBusinessLogic;
+ @Autowired
+ private ToscaExportHandler exportUtils;
+ @Autowired
+ private ComponentInstanceOperation componentInstanceOperation;
+
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+ @Test
+ public void testExportService() {
+ /* Resource resource1 = ResourceTestUtils.prepareResource(0);
+ resource1.setResourceType(ResourceTypeEnum.VF);
+ Either<Resource, ResponseFormat> createResource1 = resourceBusinessLogic.createResource(resource1, getAdminUser(), null, null);
+ assertTrue(createResource1.isLeft());
+ Resource certifiedVFC1 = changeResourceStateToCertify(createResource1.left().value());
+
+ Resource resource2 = ResourceTestUtils.prepareResource(1);
+ resource2.setResourceType(ResourceTypeEnum.VF);
+ Either<Resource, ResponseFormat> createResource2 = resourceBusinessLogic.createResource(resource2, getAdminUser(), null, null);
+ assertTrue(createResource2.isLeft());
+ Resource certifiedVFC2 = changeResourceStateToCertify(createResource2.left().value());
+
+ Service service = ResourceTestUtils.prepareService(0);
+ Either<Service, ResponseFormat> createService = serviceBusinessLogic.createService(service, getAdminUser());
+ assertTrue(createService.isLeft());
+
+ // add VFC instance to VF
+ ComponentInstance vfcResourceInstance1 = new ComponentInstance();
+ vfcResourceInstance1.setDescription("VFC instance 1");
+ vfcResourceInstance1.setName(certifiedVFC1.getName());
+ vfcResourceInstance1.setComponentUid(certifiedVFC1.getUniqueId());
+
+ Either<ComponentInstance, ResponseFormat> createResourceVfcInstance1 = serviceInstanceBusinessLogic.createComponentInstance(ComponentTypeEnum.SERVICE_PARAM_NAME, createService.left().value().getUniqueId(), adminUser.getAttuid(),
+ vfcResourceInstance1);
+ assertTrue(createResourceVfcInstance1.isLeft());
+
+ ComponentInstance vfcResourceInstance2 = new ComponentInstance();
+ vfcResourceInstance2.setDescription("VFC instance 2");
+ vfcResourceInstance2.setName(certifiedVFC2.getName());
+ vfcResourceInstance2.setComponentUid(certifiedVFC2.getUniqueId());
+ Either<ComponentInstance, ResponseFormat> createResourceVfcInstance2 = serviceInstanceBusinessLogic.createComponentInstance(ComponentTypeEnum.SERVICE_PARAM_NAME, createService.left().value().getUniqueId(), adminUser.getAttuid(),
+ vfcResourceInstance2);
+ assertTrue(createResourceVfcInstance2.isLeft());
+
+ Either<Service, ResponseFormat> serviceFetch = serviceBusinessLogic.getService(createService.left().value().getUniqueId(), adminUser);
+ assertTrue(serviceFetch.isLeft());
+
+ List<ComponentInstance> componentInstances = serviceFetch.left().value().getComponentInstances();
+ String ciname1 = null;
+ String ciname2 = null;
+
+ for (ComponentInstance ci : componentInstances) {
+ if (ci.getComponentUid().equals(certifiedVFC1.getUniqueId())) {
+ ciname1 = ci.getName();
+ }
+ if (ci.getComponentUid().equals(certifiedVFC2.getUniqueId())) {
+ ciname2 = ci.getName();
+ }
+ }
+
+ Either<ToscaRepresentation, ToscaError> result = exportUtils.exportComponent(serviceFetch.left().value());
+ assertTrue(result.isLeft());
+
+ String mainYaml = result.left().value().getMainYaml();
+ assertNotNull(mainYaml);
+
+ YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+ assertTrue(yamlToObjectConverter.isValidYaml(mainYaml.getBytes()));
+ log.debug(mainYaml);
+
+ Yaml yaml = new Yaml();
+
+ InputStream inputStream = new ByteArrayInputStream(mainYaml.getBytes());
+ Map<String, Object> load = (Map<String, Object>) yaml.load(inputStream);
+ Map<String, Object> imports = (Map<String, Object>) load.get("imports");
+ assertNotNull(imports);
+ assertEquals("Validate imports size in yml", 2, imports.size());
+
+ Map<String, Object> metadata = (Map<String, Object>) load.get("metadata");
+ assertNotNull(metadata);
+ validateMetadata(metadata, serviceFetch.left().value(), false);
+
+ Map<String, Object> vf1 = (Map<String, Object>) imports.get(certifiedVFC1.getName());
+ String fileName = (String) vf1.get(ToscaExportHandler.IMPORTS_FILE_KEY);
+ ArtifactDefinition artifactDefinition = certifiedVFC1.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE);
+ assertEquals("Validate 1 file name", artifactDefinition.getArtifactName(), fileName);
+
+ Map<String, Object> topology_template = (Map<String, Object>) load.get("topology_template");
+ Map<String, Object> node_templates = (Map<String, Object>) topology_template.get("node_templates");
+ Map<String, Object> inst1 = (Map<String, Object>) node_templates.get(ciname1);
+ Map<String, Object> inst2 = (Map<String, Object>) node_templates.get(ciname2);
+
+ Map<String, Object> inst1MD = (Map<String, Object>) inst1.get("metadata");
+ Map<String, Object> inst2MD = (Map<String, Object>) inst2.get("metadata");
+
+ validateMetadata(inst1MD, certifiedVFC1, true);
+
+ Map<String, Object> vf2 = (Map<String, Object>) imports.get(certifiedVFC2.getName());
+ fileName = (String) vf2.get(ToscaExportHandler.IMPORTS_FILE_KEY);
+ artifactDefinition = certifiedVFC2.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE);
+ assertEquals("Validate 2 file name", artifactDefinition.getArtifactName(), fileName);
+
+ validateMetadata(inst2MD, certifiedVFC2, true);*/
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java
index 9af90bb9e4..f7c6f72932 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.tosca;
import java.util.List;
-import javax.annotation.Generated;
-
import org.apache.commons.lang3.tuple.Triple;
import org.junit.Test;
import org.openecomp.sdc.be.model.Component;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java
index c3a993596c..a9c87f7f61 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.be.model.Component;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java
index ca3cd411dc..f57d17d164 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/EntrySchemaTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.tosca.model;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java
index f2e3e167df..661b8ca446 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/SubstitutionMappingTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java
index 01d65939d2..ba4526a68d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaCapabilityTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java
index 06ff881988..a62c480505 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplateTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
index 6a4dc4583d..b7b7ba6514 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.tosca.model;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java
index 599f118b32..4dab33ce14 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplateTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java
index b4cccbdbf5..3bd04f1b92 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTypeTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java
index 75bf7ddd75..52806cc6e6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.tosca.model;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java
index 639f634d7f..9f93675252 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaRequirementTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java
index 788361862b..224c3084ad 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateCapabilityTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java
index 5ae2a37b37..a29be8a56f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateRequirementTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java
index 3c60e96ffb..613c7ed457 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateTest.java
@@ -3,8 +3,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java
index 71fe9ce8e4..5b5ac82572 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaTopolgyTemplateTest.java
@@ -2,8 +2,6 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.Map;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java
index 90be98bc9c..62fb750108 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/VfModuleToscaMetadataTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.be.tosca.model;
-import javax.annotation.Generated;
-
import org.junit.Test;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java
index 6558b140c7..9124aa3c45 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.common.transaction.mngr;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.common.transaction.api.RollbackHandler;
import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java
index bf87033bfe..2984d25e20 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java
@@ -49,8 +49,6 @@ import org.openecomp.sdc.common.transaction.api.TransactionUtils.ESActionTypeEnu
import org.openecomp.sdc.common.transaction.api.TransactionUtils.LogMessages;
import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionCodeEnum;
import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionStatusEnum;
-import org.openecomp.sdc.common.transaction.mngr.CommitManager;
-import org.openecomp.sdc.common.transaction.mngr.TransactionSdncImpl;
import org.slf4j.Logger;
import fj.data.Either;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java
index aca9db39c0..a2259acf02 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.common.transaction.mngr;
-import javax.annotation.Generated;
-
import org.junit.Test;
import org.openecomp.sdc.common.transaction.api.ITransactionSdnc;
import org.openecomp.sdc.common.transaction.api.TransactionUtils.ActionTypeEnum;