diff options
113 files changed, 6283 insertions, 3738 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java index eafec8bf60..9b1e3dc227 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java @@ -20,11 +20,26 @@ package org.openecomp.sdc.asdctool.impl; -import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import fj.data.Either; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Type; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.EnumMap; +import java.util.Map; +import java.util.TimeZone; + import org.apache.commons.lang.SystemUtils; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -40,25 +55,34 @@ import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; import org.openecomp.sdc.be.dao.cassandra.schema.Table; import org.openecomp.sdc.be.dao.es.ElasticSearchClient; import org.openecomp.sdc.be.resources.data.ESArtifactData; -import org.openecomp.sdc.be.resources.data.auditing.*; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGetUebClusterEvent; +import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; +import org.openecomp.sdc.be.resources.data.auditing.AuthEvent; +import org.openecomp.sdc.be.resources.data.auditing.CategoryEvent; +import org.openecomp.sdc.be.resources.data.auditing.ConsumerEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionDownloadEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionEngineEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent; +import org.openecomp.sdc.be.resources.data.auditing.GetCategoryHierarchyEvent; +import org.openecomp.sdc.be.resources.data.auditing.GetUsersListEvent; +import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; +import org.openecomp.sdc.be.resources.data.auditing.UserAccessEvent; +import org.openecomp.sdc.be.resources.data.auditing.UserAdminEvent; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.io.*; -import java.lang.reflect.Type; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.EnumMap; -import java.util.Map; -import java.util.TimeZone; +import com.carrotsearch.hppc.cursors.ObjectCursor; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import fj.data.Either; /** * Created by mlando on 5/16/2016. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java index 1ce976dbe5..23019b9b15 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java @@ -21,10 +21,6 @@ package org.openecomp.sdc.asdctool.impl; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -32,6 +28,11 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; + /** * simple util class to verify that the titan export json graph is not corrupted */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/PopulateComponentCache.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/PopulateComponentCache.java index eac972660f..b67bfc8097 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/PopulateComponentCache.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/PopulateComponentCache.java @@ -20,9 +20,7 @@ package org.openecomp.sdc.asdctool.impl; -import java.io.IOException; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; @@ -36,9 +34,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.cache.ComponentCache; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java index 9f15c83dd8..7ed8b17907 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java @@ -20,18 +20,19 @@ package org.openecomp.sdc.asdctool.impl; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanVertex; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanVertex; /** * Created by mlando on 2/23/2016. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/RestUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/RestUtils.java index c2ebc24d49..355780cfc6 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/RestUtils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/RestUtils.java @@ -20,17 +20,16 @@ package org.openecomp.sdc.asdctool.impl; +import java.io.IOException; + import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpUriRequest; - import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; - /** * Created by mlando on 2/23/2016. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java index a57a237e76..e373107081 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java @@ -1,5 +1,7 @@ package org.openecomp.sdc.asdctool.impl.validator; +import java.util.List; + import org.openecomp.sdc.asdctool.impl.validator.executers.ValidatorExecuter; import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.slf4j.Logger; @@ -7,8 +9,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.*; - /** * Created by chaya on 7/3/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java index 0e6b2c7d16..3b81ba81e4 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.asdctool.impl.validator.config; +import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; +import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; +import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; -import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; -import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; import org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson.ModuleJsonTask; import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.openecomp.sdc.be.dao.DAOTitanStrategy; @@ -15,7 +15,16 @@ import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; import org.openecomp.sdc.be.dao.titan.TitanGraphClient; import org.openecomp.sdc.be.model.DerivedNodeTypeResolver; -import org.openecomp.sdc.be.model.jsontitan.operations.*; +import org.openecomp.sdc.be.model.jsontitan.operations.ArtifactsOperations; +import org.openecomp.sdc.be.model.jsontitan.operations.ByToscaNameDerivedNodeTypeResolver; +import org.openecomp.sdc.be.model.jsontitan.operations.CategoryOperation; +import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation; +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.ToscaDataOperation; +import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation; +import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java index 817ab15418..b64fdde8d7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java @@ -1,5 +1,8 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; +import java.util.ArrayList; +import java.util.List; + import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -7,8 +10,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.*; - /** * Created by chaya on 7/4/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java index 15f25738c0..04f014fbc9 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java @@ -1,6 +1,12 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; -import fj.data.Either; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask; import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult; @@ -12,12 +18,11 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation; -import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.*; +import fj.data.Either; /** * Created by chaya on 7/3/2017. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java index 8281d1f353..519a900ec9 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java @@ -1,10 +1,5 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; -import org.openecomp.sdc.asdctool.impl.validator.utils.ElementTypeEnum; -import org.openecomp.sdc.be.model.Component; - -import java.util.List; - /** * Created by chaya on 7/3/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java index 913a36fbd4..b4f333dab3 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java @@ -1,12 +1,13 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; +import java.util.ArrayList; +import java.util.List; + import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.springframework.beans.factory.annotation.Autowired; -import java.util.*; - /** * Created by chaya on 7/3/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java index faccd647c2..90d8f8639c 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java @@ -1,6 +1,11 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts; -import fj.data.Either; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; + import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -14,7 +19,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.springframework.beans.factory.annotation.Autowired; -import java.util.*; +import fj.data.Either; /** * Created by chaya on 7/6/2017. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java index c010148644..c82a7b9d4f 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts; -import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult; - import java.util.HashSet; import java.util.Set; +import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult; + /** * Created by chaya on 7/25/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java index 187359f127..78045a56a6 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java @@ -1,7 +1,13 @@ package org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson; -import fj.data.Either; -import org.apache.cassandra.cql3.CQL3Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask; import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager; import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult; @@ -18,8 +24,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.springframework.beans.factory.annotation.Autowired; -import java.util.*; -import java.util.stream.Collectors; +import fj.data.Either; /** * Created by chaya on 7/18/2017. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java index 245d38c853..e6a09ee875 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; -import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; - import java.util.ArrayList; import java.util.List; +import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; + /** * Created by chaya on 7/4/2017. */ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java index 64bea12957..4a4af15fdf 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java @@ -1,14 +1,18 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; -import org.apache.commons.lang.text.StrBuilder; -import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import org.apache.commons.lang.text.StrBuilder; +import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; /** * Created by chaya on 7/5/2017. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResult.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResult.java index 8fad932941..d1d1c261f7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResult.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ValidationTaskResult.java @@ -1,7 +1,6 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.model.Component; /** * Created by chaya on 7/5/2017. diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationTool.java index e2691dc7f8..21671a67a9 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationTool.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationTool.java @@ -1,5 +1,7 @@ package org.openecomp.sdc.asdctool.migration.core; +import java.util.List; + import org.openecomp.sdc.asdctool.migration.core.execution.MigrationExecutionResult; import org.openecomp.sdc.asdctool.migration.core.execution.MigrationExecutorImpl; import org.openecomp.sdc.asdctool.migration.core.task.Migration; @@ -9,8 +11,6 @@ import org.openecomp.sdc.asdctool.migration.service.SdcRepoService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - public class SdcMigrationTool { private static final Logger LOGGER = LoggerFactory.getLogger(SdcMigrationTool.class); diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/AppTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/AppTest.java deleted file mode 100644 index ae23b73d7d..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/AppTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============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.asdctool; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest extends TestCase { - /** - * Create the test case - * - * @param testName - * name of the test case - */ - public AppTest(String testName) { - super(testName); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() { - return new TestSuite(AppTest.class); - } - - /** - * Rigourous Test :-) - */ - public void testApp() { - assertTrue(true); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java new file mode 100644 index 0000000000..c3f7874c12 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/servlets/EntryPointTest.java @@ -0,0 +1,24 @@ +package org.openecomp.sdc.asdctool.servlets; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class EntryPointTest { + + private EntryPoint createTestSubject() { + return new EntryPoint(); + } + + + @Test + public void testTest() throws Exception { + EntryPoint testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.test(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..be55cbd12a --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/clean/AsdcComponentsCleanerTaskTest.java @@ -0,0 +1,66 @@ +package org.openecomp.sdc.be.components.clean; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class AsdcComponentsCleanerTaskTest { + + private AsdcComponentsCleanerTask createTestSubject() { + return new AsdcComponentsCleanerTask(); + } + + + @Test + public void testInit() throws Exception { + AsdcComponentsCleanerTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.init(); + } + + + @Test + public void testDestroy() throws Exception { + AsdcComponentsCleanerTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.destroy(); + } + + + @Test + public void testStartTask() throws Exception { + AsdcComponentsCleanerTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.startTask(); + } + + + @Test + public void testStopTask() throws Exception { + AsdcComponentsCleanerTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.stopTask(); + } + + + + + + @Test + public void testRun() throws Exception { + AsdcComponentsCleanerTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.run(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..f2053535ad --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java @@ -0,0 +1,188 @@ +package org.openecomp.sdc.be.components.impl; + +import java.util.List; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo; +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; +import org.openecomp.sdc.be.model.AdditionalInformationDefinition; +import org.openecomp.sdc.be.model.operations.api.IElementOperation; +import org.openecomp.sdc.exception.ResponseFormat; + +import fj.data.Either; + + +public class AdditionalInformationBusinessLogicTest { + + private AdditionalInformationBusinessLogic createTestSubject() { + return new AdditionalInformationBusinessLogic(); + } + + + @Test + public void testGetElementDao() throws Exception { + Class<IElementOperation> class1 = null; + ServletContext context = null; + IElementOperation result; + + // default test + } + + + @Test + public void testCreateAdditionalInformation() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String additionalInformationUid = ""; + String userId = ""; + Either<AdditionalInfoParameterInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateAndConvertValue() throws Exception { + AdditionalInformationBusinessLogic testSubject; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String context = ""; + ResponseFormat result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateAndConvertKey() throws Exception { + AdditionalInformationBusinessLogic testSubject; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String context = ""; + ResponseFormat result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateMaxSizeNotReached() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String componentId = ""; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + ResponseFormat result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateValue() throws Exception { + AdditionalInformationBusinessLogic testSubject; + String value = ""; + Either<String, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testFindAdditionInformationKey() throws Exception { + AdditionalInformationBusinessLogic testSubject;List<AdditionalInfoParameterInfo> parameters = null; + String key = ""; + AdditionalInfoParameterInfo result; + + // default test + } + + + @Test + public void testValidateAndNormalizeKey() throws Exception { + AdditionalInformationBusinessLogic testSubject; + String key = ""; + Either<String, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateAdditionalInformation() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String additionalInformationUid = ""; + String userId = ""; + Either<AdditionalInfoParameterInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteAdditionalInformation() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String additionalInformationUid = ""; + String userId = ""; + Either<AdditionalInfoParameterInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAdditionalInformation() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + AdditionalInfoParameterInfo additionalInfoParameterInfo = null; + String additionalInformationUid = ""; + String userId = ""; + Either<AdditionalInfoParameterInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAllAdditionalInformation() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + String additionalInformationUid = ""; + String userId = ""; + Either<AdditionalInformationDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testVerifyCanWorkOnComponent() throws Exception { + AdditionalInformationBusinessLogic testSubject; + NodeTypeEnum nodeType = null; + String resourceId = ""; + String userId = ""; + ResponseFormat result; + + // default test + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java new file mode 100644 index 0000000000..e10c3b41ba --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java @@ -0,0 +1,85 @@ +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; + +import fj.data.Either; + + +public class AttributeBusinessLogicTest { + + private AttributeBusinessLogic createTestSubject() { + return new AttributeBusinessLogic(); + } + + + @Test + public void testCreateAttribute() throws Exception { + AttributeBusinessLogic testSubject; + String resourceId = ""; + PropertyDefinition newAttributeDef = null; + String userId = ""; + Either<PropertyDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testIsAttributeExist() throws Exception { + AttributeBusinessLogic testSubject;List<PropertyDefinition> attributes = null; + String resourceUid = ""; + String propertyName = ""; + boolean result; + + // test 1 + testSubject=createTestSubject();attributes = null; + } + + + @Test + public void testGetAttribute() throws Exception { + AttributeBusinessLogic testSubject; + String resourceId = ""; + String attributeId = ""; + String userId = ""; + Either<PropertyDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateAttribute() throws Exception { + AttributeBusinessLogic testSubject; + String resourceId = ""; + String attributeId = ""; + PropertyDefinition newAttDef = null; + String userId = ""; + Either<PropertyDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteAttribute() throws Exception { + AttributeBusinessLogic testSubject; + String resourceId = ""; + String attributeId = ""; + String userId = ""; + Either<PropertyDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..259d47befa --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java @@ -0,0 +1,87 @@ +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; + + +public class ConsumerBusinessLogicTest { + + private ConsumerBusinessLogic createTestSubject() { + return new ConsumerBusinessLogic(); + } + + + @Test + public void testCreateConsumer() throws Exception { + ConsumerBusinessLogic testSubject; + User user = null; + ConsumerDefinition consumer = null; + Either<ConsumerDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + + + + @Test + public void testGetConsumer() throws Exception { + ConsumerBusinessLogic testSubject; + String consumerId = ""; + User user = null; + Either<ConsumerDefinition, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + user = null; + } + + + @Test + public void testGetConsumer_1() throws Exception { + ConsumerBusinessLogic testSubject; + String consumerId = ""; + Either<ConsumerDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteConsumer() throws Exception { + ConsumerBusinessLogic testSubject; + String consumerId = ""; + User user = null; + Either<ConsumerDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateConsumer() throws Exception { + ConsumerBusinessLogic testSubject; + ConsumerDefinition consumer = null; + User modifier = null; + boolean isCreateRequest = false; + Either<ConsumerDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..7722c1fdea --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java @@ -0,0 +1,357 @@ +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 { + + private ElementBusinessLogic createTestSubject() { + return new ElementBusinessLogic(); + } + + + @Test + public void testGetFollowed() throws Exception { + ElementBusinessLogic testSubject; + User user = null; + Either<Map<String, List<? extends Component>>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + + + @Test + public void testGetAllResourceCategories() throws Exception { + ElementBusinessLogic testSubject; + Either<List<CategoryDefinition>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAllServiceCategories() throws Exception { + ElementBusinessLogic testSubject; + Either<List<CategoryDefinition>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testCreateCategory() throws Exception { + ElementBusinessLogic testSubject; + CategoryDefinition category = null; + String componentTypeParamName = ""; + String userId = ""; + Either<CategoryDefinition, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + category = null; + } + + + @Test + public void testCreateSubCategory() throws Exception { + ElementBusinessLogic testSubject; + SubCategoryDefinition subCategory = null; + String componentTypeParamName = ""; + String parentCategoryId = ""; + String userId = ""; + Either<SubCategoryDefinition, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + subCategory = null; + } + + + @Test + public void testCreateGrouping() throws Exception { + ElementBusinessLogic testSubject; + GroupingDefinition grouping = null; + String componentTypeParamName = ""; + String grandParentCategoryId = ""; + String parentSubCategoryId = ""; + String userId = ""; + Either<GroupingDefinition, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + grouping = null; + } + + + @Test + public void testGetAllCategories() throws Exception { + ElementBusinessLogic testSubject; + String componentType = ""; + String userId = ""; + Either<List<CategoryDefinition>, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + userId = null; + + // test 2 + testSubject = createTestSubject(); + userId = ""; + } + + + @Test + public void testGetAllCategories_1() throws Exception { + ElementBusinessLogic testSubject; + String userId = ""; + Either<UiCategories, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteCategory() throws Exception { + ElementBusinessLogic testSubject; + String categoryId = ""; + String componentTypeParamName = ""; + String userId = ""; + Either<CategoryDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteSubCategory() throws Exception { + ElementBusinessLogic testSubject; + String grandParentCategoryId = ""; + String parentSubCategoryId = ""; + String componentTypeParamName = ""; + String userId = ""; + Either<SubCategoryDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteGrouping() throws Exception { + ElementBusinessLogic testSubject; + String grandParentCategoryId = ""; + String parentSubCategoryId = ""; + String groupingId = ""; + String componentTypeParamName = ""; + String userId = ""; + Either<GroupingDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + + + @Test + public void testGetAllPropertyScopes() throws Exception { + ElementBusinessLogic testSubject; + String userId = ""; + Either<List<PropertyScope>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAllArtifactTypes() throws Exception { + ElementBusinessLogic testSubject; + String userId = ""; + Either<List<ArtifactType>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAllDeploymentArtifactTypes() throws Exception { + ElementBusinessLogic testSubject; + Either<Map<String, Object>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetDefaultHeatTimeout() throws Exception { + ElementBusinessLogic testSubject; + Either<Integer, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetCatalogComponents() throws Exception { + ElementBusinessLogic testSubject; + String userId = ""; + List<OriginTypeEnum> excludeTypes = null; + Either<Map<String, List<? extends Component>>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetFilteredCatalogComponents() throws Exception { + ElementBusinessLogic testSubject; + String assetType = ""; + Map<FilterKeyEnum, String> filters = null; + String query = ""; + Either<List<? extends Component>, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + query = null; + + // test 2 + testSubject = createTestSubject(); + query = ""; + + // test 3 + testSubject = createTestSubject(); + filters = null; + } + + + + + @Test + public void testGetCatalogComponentsByUuidAndAssetType() throws Exception { + ElementBusinessLogic testSubject; + String assetType = ""; + String uuid = ""; + Either<List<? extends Component>, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + assetType = null; + + // test 2 + testSubject = createTestSubject(); + assetType = ""; + + // test 3 + testSubject = createTestSubject(); + assetType = null; + + // test 4 + testSubject = createTestSubject(); + assetType = ""; + } + + + @Test + public void testGetAllComponentTypesParamNames() throws Exception { + ElementBusinessLogic testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllComponentTypesParamNames(); + } + + + @Test + public void testGetAllSupportedRoles() throws Exception { + ElementBusinessLogic testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllSupportedRoles(); + } + + + @Test + public void testGetResourceTypesMap() throws Exception { + ElementBusinessLogic testSubject; + Either<Map<String, String>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + + + + @Test + public void testGetFilteredResouces() throws Exception { + ElementBusinessLogic testSubject; + Map<FilterKeyEnum, String> filters = null; + boolean inTransaction = false; + Either<List<Component>, StorageOperationStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..df2d2e7fdc --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java @@ -0,0 +1,769 @@ +package org.openecomp.sdc.be.components.impl; + +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; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.info.ArtifactTemplateInfo; +import org.openecomp.sdc.be.info.GroupDefinitionInfo; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.GroupInstance; +import org.openecomp.sdc.be.model.GroupInstanceProperty; +import org.openecomp.sdc.be.model.GroupProperty; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.exception.ResponseFormat; + +import com.google.common.base.Function; + +import fj.data.Either; + + +public class GroupBusinessLogicTest { + + private GroupBusinessLogic createTestSubject() { + return new GroupBusinessLogic(); + } + + + @Test + public void testGetComponentTypeForResponse() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + String result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testVerifyArtifactsBelongsToComponent() throws Exception { + GroupBusinessLogic testSubject;Component component = null; + List<String> artifacts = null; + String context = ""; + Either<Boolean,ResponseFormat> result; + + // test 1 + testSubject=createTestSubject();artifacts = null; + + + } + + + @Test + public void testVerifyComponentInstancesAreValidMembers() throws Exception { + GroupBusinessLogic testSubject;Component component = null; + ComponentTypeEnum componentType = null; + String groupName = ""; + String groupType = ""; + Map<String,String> groupMembers = null; + List<String> memberToscaTypes = null; + Either<Boolean,ResponseFormat> result; + + // test 1 + testSubject=createTestSubject();groupMembers = null; + + + + // test 2 + testSubject=createTestSubject();memberToscaTypes = null; + + + } + + + @Test + public void testValidateAndUpdateGroupMetadata() throws Exception { + GroupBusinessLogic testSubject; + String componentId = ""; + User user = null; + ComponentTypeEnum componentType = null; + GroupDefinition updatedGroup = null; + boolean inTransaction = false; + boolean shouldLock = false; + Either<GroupDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateGroupMetadata() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + GroupDefinition currentGroup = null; + GroupDefinition updatedGroup = null; + Either<GroupDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateGroup() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + GroupDefinition updatedGroup = null; + String currentGroupName = ""; + Either<GroupDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateGroupProperties() throws Exception { + GroupBusinessLogic testSubject; + String componentId = ""; + String groupUniqueId = ""; + User user = null; + ComponentTypeEnum componentType = null; + List<GroupProperty> groupPropertiesToUpdate = null; + boolean inTransaction = false; + Either<List<GroupProperty>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testResetEmptyValueWithDefaults() throws Exception { + GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null; + GroupDefinition originalGroup = null; + + + // default test + } + + + @Test + public void testValidateGroupPropertyAndResetEmptyValue() throws Exception { + GroupBusinessLogic testSubject;GroupDefinition originalGroup = null; + List<GroupProperty> groupPropertiesToUpdate = null; + Either<List<GroupProperty>,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidatePropertyBusinessLogic() throws Exception { + GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null; + GroupDefinition originalGroup = null; + Either<List<GroupProperty>,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testPrepareMapWithOriginalProperties() throws Exception { + GroupBusinessLogic testSubject; + GroupDefinition originalGroup = null; + Map<PropertyNames, String> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateOnlyValueChanged() throws Exception { + GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null; + GroupDefinition originalGroup = null; + Either<List<GroupProperty>,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testIsOnlyGroupPropertyValueChanged() throws Exception { + GroupBusinessLogic testSubject; + GroupProperty groupProperty = null; + GroupProperty groupProperty2 = null; + boolean result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateGroupMetadata_1() throws Exception { + GroupBusinessLogic testSubject; + GroupDefinition currentGroup = null; + GroupDefinition groupUpdate = null; + Either<GroupDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateGroupName() throws Exception { + GroupBusinessLogic testSubject; + GroupDefinition currentGroup = null; + GroupDefinition groupUpdate = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateGroupName() throws Exception { + GroupBusinessLogic testSubject; + String currentGroupName = ""; + String groupUpdateName = ""; + boolean isforceNameModification = false; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetGroupWithArtifactsById() throws Exception { + GroupBusinessLogic testSubject; + ComponentTypeEnum componentType = null; + String componentId = ""; + String groupId = ""; + String userId = ""; + boolean inTransaction = false; + Either<GroupDefinitionInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testFindGroupOnComponent() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + String groupId = ""; + Either<GroupDefinition, StorageOperationStatus> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateGroupsBeforeUpdate() throws Exception { + GroupBusinessLogic testSubject;String componentId = ""; + String userId = ""; + ComponentTypeEnum componentType = null; + List<GroupDefinition> groups = null; + boolean inTransaction = false; + Either<org.openecomp.sdc.be.model.Component,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidateGroupsInComponentByFunc() throws Exception { + GroupBusinessLogic testSubject;List<GroupDefinition> groups = null; + Component component = null; + Function<GroupDefinition,String> getByParam = null; + ResponseFormat result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testGetAsString() throws Exception { + GroupBusinessLogic testSubject; + List<String> list = null; + String result; + + // test 1 + testSubject = createTestSubject(); + list = null; + + + } + + + @Test + public void testUpdateGroupPropertiesValue() throws Exception { + GroupBusinessLogic testSubject;String componentId = ""; + GroupDefinition currentGroup = null; + List<GroupProperty> groupPropertyToUpdate = null; + boolean inTransaction = false; + Either<List<GroupProperty>,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidateGenerateVfModuleGroupNames() throws Exception { + GroupBusinessLogic testSubject; + List<ArtifactTemplateInfo> allGroups = null; + String resourceSystemName = ""; + int startGroupCounter = 0; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateGenerateVfModuleGroupName() throws Exception { + GroupBusinessLogic testSubject; + String resourceSystemName = ""; + String description = ""; + int groupCounter = 0; + Either<String, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + resourceSystemName = null; + description = null; + + + + // test 2 + testSubject = createTestSubject(); + resourceSystemName = ""; + description = null; + + + + // test 3 + testSubject = createTestSubject(); + description = null; + resourceSystemName = null; + + + + // test 4 + testSubject = createTestSubject(); + description = ""; + resourceSystemName = null; + + + } + + + @Test + public void testValidateUpdateVfGroupNames() throws Exception { + GroupBusinessLogic testSubject; + Map<String, GroupDefinition> groups = null; + String resourceSystemName = ""; + Either<Map<String, GroupDefinition>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetNextVfModuleNameCounter() throws Exception { + GroupBusinessLogic testSubject; + Map<String, GroupDefinition> groups = null; + int result; + + // test 1 + testSubject = createTestSubject(); + groups = null; + + + } + + + @Test + public void testGetNextVfModuleNameCounter_1() throws Exception { + GroupBusinessLogic testSubject; + Collection<GroupDefinition> groups = null; + int result; + + // test 1 + testSubject = createTestSubject(); + groups = null; + + + } + + + @Test + public void testValidateUpdateVfGroupNamesOnGraph() throws Exception { + GroupBusinessLogic testSubject; + List<GroupDefinition> groups = null; + Component component = null; + boolean inTransaction = false; + Either<List<GroupDefinition>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetGroupInstWithArtifactsById() throws Exception { + GroupBusinessLogic testSubject; + ComponentTypeEnum componentType = null; + String componentId = ""; + String componentInstanceId = ""; + String groupInstId = ""; + String userId = ""; + boolean inTransaction = false; + Either<GroupDefinitionInfo, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testFindComponentInstanceAndGroupInstanceOnComponent() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + String componentInstanceId = ""; + String groupInstId = ""; + Either<ImmutablePair<ComponentInstance, GroupInstance>, StorageOperationStatus> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetLatestIntProperty() throws Exception { + GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null; + Map<PropertyNames,String> parentValues = null; + PropertyNames propertyKey = null; + int result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testIsPropertyChanged() throws Exception { + GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null; + Map<PropertyNames,String> parentValues = null; + PropertyNames minInstances = null; + boolean result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidateMinMaxAndInitialCountPropertyLogicVF() throws Exception { + GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null; + Map<PropertyNames,String> parentValues = null; + Either<Boolean,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidateMinMaxAndInitialCountPropertyLogic() throws Exception { + GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null; + Map<PropertyNames,String> currValues = null; + Map<PropertyNames,String> parentValues = null; + Either<Boolean,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testValidateValueInRange() throws Exception { + GroupBusinessLogic testSubject;ImmutablePair<PropertyNames,String> newValue = null; + ImmutablePair<PropertyNames,String> min = null; + ImmutablePair<PropertyNames,String> max = null; + Either<Boolean,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testParseIntValue() throws Exception { + GroupBusinessLogic testSubject; + String value = ""; + PropertyNames propertyName = null; + int result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateGroupInstancePropertyValues() throws Exception { + GroupBusinessLogic testSubject; + String componentId = ""; + String instanceId = ""; + GroupInstance oldGroupInstance = null; + List<GroupInstanceProperty> newProperties = null; + boolean inTransaction = false; + Either<GroupInstance, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateReduceGroupInstancePropertiesBeforeUpdate() throws Exception { + GroupBusinessLogic testSubject;GroupInstance oldGroupInstance = null; + List<GroupInstanceProperty> newProperties = null; + Either<List<GroupInstanceProperty>,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testFillValuesAndParentValuesFromExistingProperties() throws Exception { + GroupBusinessLogic testSubject;Map<String,GroupInstanceProperty> existingProperties = null; + Map<PropertyNames,String> propertyValues = null; + Map<PropertyNames,String> parentPropertyValues = null; + + + // default test + } + + + @Test + public void testHandleAndAddProperty() throws Exception { + GroupBusinessLogic testSubject;List<GroupInstanceProperty> reducedProperties = null; + Map<PropertyNames,String> newPropertyValues = null; + GroupInstanceProperty currNewProperty = null; + GroupInstanceProperty currExistingProperty = null; + Either<Boolean,ResponseFormat> result; + + // default test + testSubject=createTestSubject(); + } + + + @Test + public void testIsUpdatable() throws Exception { + GroupBusinessLogic testSubject; + PropertyNames updatablePropertyName = null; + boolean result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testAddPropertyUpdatedValues() throws Exception { + GroupBusinessLogic testSubject;List<GroupInstanceProperty> reducedProperties = null; + PropertyNames propertyName = null; + Map<PropertyNames,String> newPropertyValues = null; + GroupInstanceProperty newProperty = null; + GroupInstanceProperty existingProperty = null; + + + // default test + } + + + @Test + public void testIsEmptyMinInitialCountValue() throws Exception { + GroupBusinessLogic testSubject; + PropertyNames propertyName = null; + String newValue = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testConvertIfUnboundMax() throws Exception { + GroupBusinessLogic testSubject; + String value = ""; + int result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdatePropertyValue() throws Exception { + GroupBusinessLogic testSubject; + GroupInstanceProperty newProperty = null; + GroupInstanceProperty existingProperty = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateImmutableProperty() throws Exception { + GroupBusinessLogic testSubject; + GroupProperty oldProperty = null; + GroupProperty newProperty = null; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testCreateGroups() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + User user = null; + ComponentTypeEnum componentType = null; + List<GroupDefinition> groupDefinitions = null; + Either<List<GroupDefinition>, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + groupDefinitions = null; + + + } + + + @Test + public void testAddGroups() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + User user = null; + ComponentTypeEnum componentType = null; + List<GroupDefinition> groupDefinitions = null; + Either<List<GroupDefinition>, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + groupDefinitions = null; + + + } + + + @Test + public void testDeleteGroups() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + User user = null; + ComponentTypeEnum componentType = null; + List<GroupDefinition> groupDefinitions = null; + Either<List<GroupDefinition>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateGroups() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + ComponentTypeEnum componentType = null; + List<GroupDefinition> groupDefinitions = null; + Either<List<GroupDefinition>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testHandleGroup() throws Exception { + GroupBusinessLogic testSubject; + Component component = null; + User user = null; + ComponentTypeEnum componentType = null; + GroupDefinition groupDefinition = null; + Map<String, DataTypeDefinition> allDAtaTypes = null; + Either<GroupDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testHandleProperty() throws Exception { + GroupBusinessLogic testSubject; + GroupProperty groupProperty = null; + PropertyDefinition prop = null; + Integer index = 0; + Map<String, DataTypeDefinition> allDataTypes = null; + Either<GroupProperty, TitanOperationStatus> result; + + // test 1 + testSubject = createTestSubject(); + prop = null; + + + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..222bba53d2 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogicTest.java @@ -0,0 +1,387 @@ +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; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; +import org.openecomp.sdc.exception.ResponseFormat; + +import fj.data.Either; + + +public class ProductBusinessLogicTest { + + private ProductBusinessLogic createTestSubject() { + return new ProductBusinessLogic(); + } + + @Test + public void testValidateProductNameExists() throws Exception { + ProductBusinessLogic testSubject; + String productName = ""; + String userId = ""; + Either<Map<String, Boolean>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + @Test + public void testSetDeploymentArtifactsPlaceHolder() throws Exception { + ProductBusinessLogic testSubject; + Component component = null; + User user = null; + + // default test + testSubject = createTestSubject(); + testSubject.setDeploymentArtifactsPlaceHolder(component, user); + } + + @Test + public void testDeleteMarkedComponents() throws Exception { + ProductBusinessLogic testSubject; + Either<List<String>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + @Test + public void testGetComponentInstanceBL() throws Exception { + ProductBusinessLogic testSubject; + ComponentInstanceBusinessLogic result; + + // default test + testSubject = createTestSubject(); + + } + + @Test + public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception { + ProductBusinessLogic testSubject; + String componentId = ""; + ComponentTypeEnum componentTypeEnum = null; + String userId = ""; + String searchText = ""; + Either<List<ComponentInstance>, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + @Test + public void testGetCacheManagerOperation() throws Exception { + ProductBusinessLogic testSubject; + ICacheMangerOperation result; + + // default test + testSubject = createTestSubject(); + + } + + @Test + public void testSetCacheManagerOperation() throws Exception { + ProductBusinessLogic testSubject; + ICacheMangerOperation cacheManagerOperation = null; + + // default test + testSubject = createTestSubject(); + testSubject.setCacheManagerOperation(cacheManagerOperation); + } + + @Test + public void testGetUiComponentDataTransferByComponentId() throws Exception { + ProductBusinessLogic testSubject; + String componentId = ""; + List<String> dataParamsToReturn = null; + Either<UiComponentDataTransfer, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testCreateProduct() throws Exception { + ProductBusinessLogic testSubject; + Product product = null; + User user = null; + Either<Product, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + product = null; + + } + + + @Test + public void testCheckUnupdatableProductFields() throws Exception { + ProductBusinessLogic testSubject; + Product product = null; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateProductBeforeCreate() throws Exception { + ProductBusinessLogic testSubject; + Product product = null; + User user = null; + AuditingActionEnum actionEnum = null; + Either<Product, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateProductFieldsBeforeCreate() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateProductContactsList() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateGrouping() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetProduct() throws Exception { + ProductBusinessLogic testSubject; + String productId = ""; + User user = null; + Either<Product, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteProduct() throws Exception { + ProductBusinessLogic testSubject; + String productId = ""; + User user = null; + Either<Product, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateProductFullNameAndCleanup() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateProductNameAndCleanup() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateTagsListAndRemoveDuplicates() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product product = null; + String oldProductName = ""; + AuditingActionEnum actionEnum = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateProductMetadata() throws Exception { + ProductBusinessLogic testSubject; + String productId = ""; + Product updatedProduct = null; + User user = null; + Either<Product, ResponseFormat> result; + + // test 1 + testSubject = createTestSubject(); + updatedProduct = null; + } + + + @Test + public void testValidateAndUpdateProductMetadata() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Product, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateProductName() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateFullName() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateCategory() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateContactList() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateAndUpdateTags() throws Exception { + ProductBusinessLogic testSubject; + User user = null; + Product currentProduct = null; + Product updatedProduct = null; + Either<Boolean, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateTagPattern() throws Exception { + ProductBusinessLogic testSubject; + String tag = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetProductByNameAndVersion() throws Exception { + ProductBusinessLogic testSubject; + String productName = ""; + String productVersion = ""; + String userId = ""; + Either<Product, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } +}
\ No newline at end of file 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 796a426e26..0e27636901 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 @@ -51,6 +51,7 @@ 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.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -62,25 +63,32 @@ 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.ComponentMetadataDefinition; +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; @@ -121,6 +129,8 @@ 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; @@ -2225,5 +2235,143 @@ public class ResourceBusinessLogicTest { 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/info/ArtifactTypesInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java new file mode 100644 index 0000000000..4010d9bf86 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java @@ -0,0 +1,60 @@ +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; + + +public class ArtifactTypesInfoTest { + + private ArtifactTypesInfo createTestSubject() { + return new ArtifactTypesInfo(); + } + + + @Test + public void testGetArtifactTypes() throws Exception { + ArtifactTypesInfo testSubject; + List<ArtifactType> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactTypes(); + } + + + @Test + public void testSetArtifactTypes() throws Exception { + ArtifactTypesInfo testSubject; + List<ArtifactType> artifactTypes = null; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactTypes(artifactTypes); + } + + + @Test + public void testGetHeatDefaultTimeout() throws Exception { + ArtifactTypesInfo testSubject; + Integer result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHeatDefaultTimeout(); + } + + + @Test + public void testSetHeatDefaultTimeout() throws Exception { + ArtifactTypesInfo testSubject; + Integer heatDefaultTimeout = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setHeatDefaultTimeout(heatDefaultTimeout); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..db4d735a7e --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java @@ -0,0 +1,36 @@ +package org.openecomp.sdc.be.info; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; + +public class DistributionStatusListResponseTest { + + private DistributionStatusListResponse createTestSubject() { + return new DistributionStatusListResponse(); + } + + + @Test + public void testGetDistributionStatusList() throws Exception { + DistributionStatusListResponse testSubject; + List<DistributionStatusInfo> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDistributionStatusList(); + } + + + @Test + public void testSetDistributionStatusList() throws Exception { + DistributionStatusListResponse testSubject; + List<DistributionStatusInfo> distribStatusInfoList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setDistributionStatusList(distribStatusInfoList); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..830292a66f --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.be.info; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class DistributionStatusOfServiceListResponceTest { + + private DistributionStatusOfServiceListResponce createTestSubject() { + return new DistributionStatusOfServiceListResponce(); + } + + + @Test + public void testGetDistributionStatusOfServiceList() throws Exception { + DistributionStatusOfServiceListResponce testSubject; + List<DistributionStatusOfServiceInfo> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDistributionStatusOfServiceList(); + } + + + @Test + public void testSetDistributionStatusOfServiceList() throws Exception { + DistributionStatusOfServiceListResponce testSubject; + List<DistributionStatusOfServiceInfo> distribStatusOfServiceInfoList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setDistributionStatusOfServiceList(distribStatusOfServiceInfoList); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..085583aa2d --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.be.info; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class ServicesWrapperTest { + + private ServicesWrapper createTestSubject() { + return new ServicesWrapper(); + } + + + @Test + public void testGetServices() throws Exception { + ServicesWrapper testSubject; + List<ServiceInfo> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServices(); + } + + + @Test + public void testSetServices() throws Exception { + ServicesWrapper testSubject; + List<ServiceInfo> services = null; + + // default test + testSubject = createTestSubject(); + testSubject.setServices(services); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..80ae443afe --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.be.info; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class ToscaNodeTypeInterfaceTest { + + private ToscaNodeTypeInterface createTestSubject() { + return new ToscaNodeTypeInterface(); + } + + + @Test + public void testGetScripts() throws Exception { + ToscaNodeTypeInterface testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getScripts(); + } + + + @Test + public void testSetScripts() throws Exception { + ToscaNodeTypeInterface testSubject; + List<String> scripts = null; + + // default test + testSubject = createTestSubject(); + testSubject.setScripts(scripts); + } +}
\ No newline at end of file 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 2b33fbd704..27963fa8cb 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 @@ -20,31 +20,51 @@ package org.openecomp.sdc.be.servlets; -import fj.data.Either; -import org.apache.commons.codec.binary.Base64; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.sdc.be.model.UploadResourceInfo; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.common.datastructure.Wrapper; -import org.openecomp.sdc.exception.ResponseFormat; -import org.slf4j.Logger; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; -import javax.ws.rs.core.Response; +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 static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; +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 { - private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() {}; + private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() { + }; private static final String BASIC_TOSCA_TEMPLATE = "tosca_definitions_version: tosca_simple_yaml_%s"; @@ -53,6 +73,7 @@ public class AbstractValidationsServletTest { servlet.initLog(mock(Logger.class)); } + @SuppressWarnings("unchecked") @Test public void testGetScarFromPayload() { @@ -71,10 +92,12 @@ public class AbstractValidationsServletTest { resourceInfo.setPayloadName(payloadName); resourceInfo.setPayloadData(payloadData); Method privateMethod = null; - privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getScarFromPayload", UploadResourceInfo.class); + privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getScarFromPayload", + UploadResourceInfo.class); privateMethod.setAccessible(true); returnValue = (Either<Map<String, byte[]>, ResponseFormat>) privateMethod.invoke(servlet, resourceInfo); - } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } assertTrue(returnValue.isLeft()); @@ -87,13 +110,12 @@ public class AbstractValidationsServletTest { Stream.of("1_0", "1_0_0", "1_1", "1_1_0").forEach(this::testValidToscaVersion); } - - private void testValidToscaVersion(String version) { + private void testValidToscaVersion(String version) { Wrapper<Response> responseWrapper = new Wrapper<>(); - servlet.validatePayloadIsTosca(responseWrapper, new UploadResourceInfo(), new User(), String.format(BASIC_TOSCA_TEMPLATE, version)); + servlet.validatePayloadIsTosca(responseWrapper, new UploadResourceInfo(), new User(), + String.format(BASIC_TOSCA_TEMPLATE, version)); assertTrue(responseWrapper.isEmpty()); } - - + } 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 new file mode 100644 index 0000000000..0cb9906dc4 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java @@ -0,0 +1,171 @@ +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 { + + private AdditionalInformationServlet createTestSubject() { + return new AdditionalInformationServlet(); + } + + + @Test + public void testCreateResourceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String resourceId = ""; + String data = ""; + HttpServletRequest request = null; + String userUserId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testCreateServiceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String serviceId = ""; + String data = ""; + HttpServletRequest request = null; + String userUserId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateResourceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String resourceId = ""; + String labelId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateServiceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String serviceId = ""; + String labelId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateResourceAdditionalInformationLabel_1() throws Exception { + AdditionalInformationServlet testSubject; + String resourceId = ""; + String labelId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteServiceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String serviceId = ""; + String labelId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetResourceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String resourceId = ""; + String labelId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetServiceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String serviceId = ""; + String labelId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetAllResourceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String resourceId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetAllServiceAdditionalInformationLabel() throws Exception { + AdditionalInformationServlet testSubject; + String serviceId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..b4d04f92a9 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java @@ -0,0 +1,340 @@ +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 { + + private ArtifactServlet createTestSubject() { + return new ArtifactServlet(); + } + + + @Test + public void testLoadArtifact() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateArtifact() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteArtifact() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testLoadInformationArtifact() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateInformationArtifact() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateApiArtifact() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + String origMd5 = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteApiArtifact() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + String userId = ""; + String origMd5 = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteInformationalArtifact() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDownloadServiceArtifactBase64() throws Exception { + ArtifactServlet testSubject; + String serviceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDownloadResourceArtifactBase64() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDownloadResourceInstanceArtifactBase64() throws Exception { + ArtifactServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testLoadArtifactToInterface() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String interfaceType = ""; + String operation = ""; + String userId = ""; + String origMd5 = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteArtifactToInterface() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String interfaceType = ""; + String operation = ""; + String artifactId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateArtifactToInterface() throws Exception { + ArtifactServlet testSubject; + String resourceId = ""; + String interfaceType = ""; + String operation = ""; + String artifactId = ""; + String userId = ""; + String origMd5 = ""; + HttpServletRequest request = null; + String data = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateRIArtifact() throws Exception { + ArtifactServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateComponentInstanceArtifact() throws Exception { + ArtifactServlet testSubject; + String userId = ""; + String origMd5 = ""; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testLoadComponentInstanceArtifact() throws Exception { + ArtifactServlet testSubject; + String userId = ""; + String origMd5 = ""; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteComponentInstanceArtifact() throws Exception { + ArtifactServlet testSubject; + String userId = ""; + String origMd5 = ""; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String artifactId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetComponentArtifacts() throws Exception { + ArtifactServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String artifactGroupType = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetComponentInstanceArtifacts() throws Exception { + ArtifactServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String componentInstanceId = ""; + String artifactGroupType = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..34a475882a --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java @@ -0,0 +1,72 @@ +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.model.PropertyDefinition; +import org.openecomp.sdc.exception.ResponseFormat; + +import com.google.common.base.Equivalence.Wrapper; + +public class AttributeServletTest { + + private AttributeServlet createTestSubject() { + return new AttributeServlet(); + } + + + @Test + public void testCreateAttribute() throws Exception { + AttributeServlet testSubject; + String resourceId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateAttribute() throws Exception { + AttributeServlet testSubject; + String resourceId = ""; + String attributeId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteAttribute() throws Exception { + AttributeServlet testSubject; + String resourceId = ""; + String attributeId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testBuildAttributeFromString() throws Exception { + AttributeServlet testSubject;String data = ""; + Wrapper<PropertyDefinition> attributesWrapper = null; + Wrapper<ResponseFormat> errorWrapper = null; + + + // default test + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..52ee33fd74 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java @@ -0,0 +1,309 @@ +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; + +import org.apache.tinkerpop.gremlin.structure.T; +import org.junit.Test; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; +import org.openecomp.sdc.exception.ResponseFormat; + +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 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 new file mode 100644 index 0000000000..3e97aa4cb0 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java @@ -0,0 +1,144 @@ +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; + +import org.junit.Test; + +public class ComponentServletTest { + + private ComponentServlet createTestSubject() { + return new ComponentServlet(); + } + + + @Test + public void testConformanceLevelValidation() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + String componentUuid = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetRequirementAndCapabilities() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + String componentId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetLatestVersionNotAbstractCheckoutComponents() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + HttpServletRequest request = null; + String internalComponentType = ""; + List<String> componentUids = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetLatestVersionNotAbstractCheckoutComponentsByBody() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + HttpServletRequest request = null; + String internalComponentType = ""; + String userId = ""; + List<String> data = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetLatestVersionNotAbstractCheckoutComponentsIdesOnly() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + HttpServletRequest request = null; + String internalComponentType = ""; + String userId = ""; + String data = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + String componentId = ""; + HttpServletRequest request = null; + String searchText = ""; + String userId = ""; + String data = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetComponentDataFilteredByParams() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + String componentId = ""; + List<String> dataParamsToReturn = null; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetFilteredComponentInstanceProperties() throws Exception { + ComponentServlet testSubject; + String componentType = ""; + String componentId = ""; + String propertyNameFragment = ""; + List<String> resourceTypes = null; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..4f2ca19986 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java @@ -0,0 +1,84 @@ +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; + +public class ConfigMgrServletTest { + + private ConfigMgrServlet createTestSubject() { + return new ConfigMgrServlet(); + } + + + @Test + public void testGetConfig() throws Exception { + ConfigMgrServlet testSubject; + HttpServletRequest request = null; + String type = ""; + String result; + + // test 1 + testSubject = createTestSubject(); + type = null; + + + // test 2 + testSubject = createTestSubject(); + type = ""; + + // test 3 + testSubject = createTestSubject(); + type = "configuration"; + } + + + @Test + public void testSetConfig1() throws Exception { + ConfigMgrServlet testSubject; + HttpServletRequest request = null; + Configuration configuration = null; + String result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testSetConfig2() throws Exception { + ConfigMgrServlet testSubject; + HttpServletRequest request = null; + Configuration configuration = null; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testSetConfig3() throws Exception { + ConfigMgrServlet testSubject; + HttpServletRequest request = null; + Configuration configuration = null; + String result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testSetConfig4() throws Exception { + ConfigMgrServlet testSubject; + HttpServletRequest request = null; + Configuration configuration = null; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..adc996eb4c --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java @@ -0,0 +1,24 @@ +package org.openecomp.sdc.be.servlets; + +import javax.annotation.Generated; +import javax.servlet.http.HttpServletRequest; + +import org.junit.Test; + +public class ConfigServletTest { + + private ConfigServlet createTestSubject() { + return new ConfigServlet(); + } + + + @Test + public void testGetConfig() throws Exception { + ConfigServlet testSubject; + HttpServletRequest request = null; + String result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..6360c5a76e --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java @@ -0,0 +1,85 @@ +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.ConsumerBusinessLogic; +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; + +public class ConsumerServletTest { + + private ConsumerServlet createTestSubject() { + return new ConsumerServlet(); + } + + + @Test + public void testCreateConsumer() throws Exception { + ConsumerServlet testSubject; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetConsumer() throws Exception { + ConsumerServlet testSubject; + String consumerId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteConsumer() throws Exception { + ConsumerServlet testSubject; + String consumerId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetConsumerBL() throws Exception { + ConsumerServlet testSubject; + ServletContext context = null; + ConsumerBusinessLogic result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testConvertJsonToObject() throws Exception { + ConsumerServlet testSubject; + String data = ""; + User user = null; + AuditingActionEnum actionEnum = null; + Either<ConsumerDefinition, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 daacb79de5..e80016a678 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 @@ -8,6 +8,8 @@ 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 new file mode 100644 index 0000000000..2233b4ebac --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java @@ -0,0 +1,63 @@ +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.DistributionMonitoringBusinessLogic; + +public class DistributionServiceServletTest { + + private DistributionServiceServlet createTestSubject() { + return new DistributionServiceServlet(); + } + + + @Test + public void testGetServiceById() throws Exception { + DistributionServiceServlet testSubject; + String serviceUUID = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetListOfDistributionStatuses() throws Exception { + DistributionServiceServlet testSubject; + String did = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testInit() throws Exception { + DistributionServiceServlet testSubject; + HttpServletRequest request = null; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetDistributionBL() throws Exception { + DistributionServiceServlet testSubject; + ServletContext context = null; + DistributionMonitoringBusinessLogic result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..2fe68d3a90 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java @@ -0,0 +1,244 @@ +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; + +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; + +public class ElementServletTest { + + private ElementServlet createTestSubject() { + return new ElementServlet(); + } + + + @Test + public void testGetComponentCategories() throws Exception { + ElementServlet testSubject; + String componentType = ""; + String userId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetAllCategories() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testCreateComponentCategory() throws Exception { + ElementServlet testSubject; + String componentType = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteComponentCategory() throws Exception { + ElementServlet testSubject; + String categoryUniqueId = ""; + String componentType = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testCreateComponentSubCategory() throws Exception { + ElementServlet testSubject; + String componentType = ""; + String categoryId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteComponentSubCategory() throws Exception { + ElementServlet testSubject; + String categoryUniqueId = ""; + String subCategoryUniqueId = ""; + String componentType = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testCreateComponentGrouping() throws Exception { + ElementServlet testSubject; + String componentType = ""; + String grandParentCategoryId = ""; + String parentSubCategoryId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteComponentGrouping() throws Exception { + ElementServlet testSubject; + String grandParentCategoryUniqueId = ""; + String parentSubCategoryUniqueId = ""; + String groupingUniqueId = ""; + String componentType = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetTags() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetPropertyScopes() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetArtifactTypes() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetConfiguration() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetFollowedResourcesServices() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetCatalogComponents() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + List<OriginTypeEnum> excludeTypes = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteMarkedResources() throws Exception { + ElementServlet testSubject; + String componentType = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetListOfCsars() throws Exception { + ElementServlet testSubject; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..85b835076b --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java @@ -0,0 +1,44 @@ +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; + +public class GroupServletTest { + + private GroupServlet createTestSubject() { + return new GroupServlet(); + } + + + @Test + public void testGetGroupArtifactById() throws Exception { + GroupServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String groupId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + } + + + @Test + public void testUpdateGroupMetadata() throws Exception { + GroupServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String groupUniqueId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..9cc13d32de --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java @@ -0,0 +1,167 @@ +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.InputsBusinessLogic; +import org.openecomp.sdc.be.model.ComponentInstInputsMap; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.exception.ResponseFormat; + +import fj.data.Either; + +public class InputsServletTest { + + private InputsServlet createTestSubject() { + return new InputsServlet(); + } + + + @Test + public void testGetComponentInputs() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + HttpServletRequest request = null; + String fromName = ""; + int amount = 0; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateComponentInputs() throws Exception { + InputsServlet testSubject; + String containerComponentType = ""; + String componentId = ""; + String data = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetComponentInstanceInputs() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + String instanceId = ""; + String originComonentUid = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetInputPropertiesForComponentInstance() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + String instanceId = ""; + String inputId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetInputsForComponentInput() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + String inputId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetInputsAndPropertiesForComponentInput() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + String inputId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testParseToComponentInstanceMap() throws Exception { + InputsServlet testSubject; + String serviceJson = ""; + User user = null; + Either<ComponentInstInputsMap, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testCreateMultipleInputs() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + HttpServletRequest request = null; + String userId = ""; + String componentInstInputsMapObj = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteInput() throws Exception { + InputsServlet testSubject; + String componentType = ""; + String componentId = ""; + String inputId = ""; + HttpServletRequest request = null; + String userId = ""; + String componentInstInputsMapObj = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetInputBL() throws Exception { + InputsServlet testSubject; + ServletContext context = null; + InputsBusinessLogic result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..f92e439c9a --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java @@ -0,0 +1,46 @@ +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.model.LifeCycleTransitionEnum; +import org.openecomp.sdc.be.model.User; + +import fj.data.Either; + +public class LifecycleServletTest { + + private LifecycleServlet createTestSubject() { + return new LifecycleServlet(); + } + + + @Test + public void testChangeResourceState() throws Exception { + LifecycleServlet testSubject; + String jsonChangeInfo = ""; + String componentCollection = ""; + String lifecycleTransition = ""; + String componentId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateTransitionEnum() throws Exception { + LifecycleServlet testSubject; + String lifecycleTransition = ""; + User user = null; + Either<LifeCycleTransitionEnum, Response> result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..2376ceea32 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java @@ -0,0 +1,93 @@ +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; + +public class ProductServletTest { + + private ProductServlet createTestSubject() { + return new ProductServlet(); + } + + + @Test + public void testCreateProduct() throws Exception { + ProductServlet testSubject; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetProductById() throws Exception { + ProductServlet testSubject; + String productId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetServiceByNameAndVersion() throws Exception { + ProductServlet testSubject; + String productName = ""; + String productVersion = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteProduct() throws Exception { + ProductServlet testSubject; + String productId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateProductMetadata() throws Exception { + ProductServlet testSubject; + String productId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateServiceName() throws Exception { + ProductServlet testSubject; + String productName = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..dd31364868 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java @@ -0,0 +1,119 @@ +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; + +import org.codehaus.jettison.json.JSONObject; +import org.junit.Test; +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 { + + private PropertyServlet createTestSubject() { + return new PropertyServlet(); + } + + + @Test + public void testCreateProperty() throws Exception { + PropertyServlet testSubject; + String resourceId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetProperty() throws Exception { + PropertyServlet testSubject; + String resourceId = ""; + String propertyId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testDeleteProperty() throws Exception { + PropertyServlet testSubject; + String resourceId = ""; + String propertyId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateProperty() throws Exception { + PropertyServlet testSubject; + String resourceId = ""; + String propertyId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetPropertyModel() throws Exception { + PropertyServlet testSubject; + String resourceId = ""; + String data = ""; + Either<Map<String, PropertyDefinition>, ActionStatus> result; + + // default test + testSubject = createTestSubject(); + } + + + + + + @Test + public void testGetPropertyDefinitionJSONObject() throws Exception { + PropertyServlet testSubject; + PropertyDefinition propertyDefinition = null; + JSONObject result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetPropertyBL() throws Exception { + PropertyServlet testSubject; + ServletContext context = null; + PropertyBusinessLogic result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..4407ec6577 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java @@ -0,0 +1,29 @@ +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; + +public class RequirementsServletTest { + + private RequirementsServlet createTestSubject() { + return new RequirementsServlet(); + } + + + @Test + public void testUpdateRequirement() throws Exception { + RequirementsServlet testSubject; + String resourceId = ""; + String requirementId = ""; + String requirementData = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..b88a097412 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java @@ -0,0 +1,54 @@ +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 ch.qos.logback.classic.Logger; + +public class ResourceArtifactDownloadServletTest { + + private ResourceArtifactDownloadServlet createTestSubject() { + return new ResourceArtifactDownloadServlet(); + } + + + @Test + public void testGetResourceArtifactByName() throws Exception { + ResourceArtifactDownloadServlet testSubject; + String resourceName = ""; + String resourceVersion = ""; + String artifactName = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetResourceArtifactMetadata() throws Exception { + ResourceArtifactDownloadServlet testSubject; + String resourceName = ""; + String resourceVersion = ""; + String artifactName = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetLogger() throws Exception { + ResourceArtifactDownloadServlet testSubject; + Logger result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..1844cfe188 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java @@ -0,0 +1,242 @@ +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; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.exception.ResponseFormat; + +import com.google.common.base.Equivalence.Wrapper; + +import fj.data.Either; + +public class ResourcesServletTest { + + private ResourcesServlet createTestSubject() { + return new ResourcesServlet(); + } + + + @Test + public void testCreateResource() throws Exception { + ResourcesServlet testSubject; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testIsUIImport() throws Exception { + ResourcesServlet testSubject; + String data = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testPerformUIImport() throws Exception { + ResourcesServlet testSubject;Wrapper<Response> responseWrapper = null; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + String resourceUniqueId = ""; + + + // default test + } + + + @Test + public void testParseToResource() throws Exception { + ResourcesServlet testSubject; + String resourceJson = ""; + User user = null; + Either<Resource, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testParseToLightResource() throws Exception { + ResourcesServlet testSubject; + String resourceJson = ""; + User user = null; + Either<Resource, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteResource() throws Exception { + ResourcesServlet testSubject; + String resourceId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteResourceByNameAndVersion() throws Exception { + ResourcesServlet testSubject; + String resourceName = ""; + String version = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetResourceById() throws Exception { + ResourcesServlet testSubject; + String resourceId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetResourceByNameAndVersion() throws Exception { + ResourcesServlet testSubject; + String resourceName = ""; + String resourceVersion = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testValidateResourceName() throws Exception { + ResourcesServlet testSubject; + String resourceName = ""; + String resourceType = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetCertifiedAbstractResources() throws Exception { + ResourcesServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetCertifiedNotAbstractResources() throws Exception { + ResourcesServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateResourceMetadata() throws Exception { + ResourcesServlet testSubject; + String resourceId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateResource() throws Exception { + ResourcesServlet testSubject; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + String resourceId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testConvertMapToList() throws Exception { + Map<String, PropertyDefinition> properties = null; + List<PropertyDefinition> result; + + // test 1 + properties = null; + + } + + + @Test + public void testGetResourceFromCsar() throws Exception { + ResourcesServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + String csarUUID = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..7a21a231d8 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java @@ -0,0 +1,266 @@ +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.lifecycle.LifecycleChangeInfoWithAction; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.exception.ResponseFormat; + +import com.google.common.base.Equivalence.Wrapper; +import com.google.common.util.concurrent.Service; + +import fj.data.Either; + +public class ServiceServletTest { + + private ServiceServlet createTestSubject() { + return new ServiceServlet(); + } + + + @Test + public void testCreateService() throws Exception { + ServiceServlet testSubject; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testParseToService() throws Exception { + ServiceServlet testSubject; + String serviceJson = ""; + User user = null; + Either<Service, ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testValidateServiceName() throws Exception { + ServiceServlet testSubject; + String serviceName = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetComponentAuditRecords() throws Exception { + ServiceServlet testSubject; + String componentType = ""; + String componentUniqueId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testFillUUIDAndVersion() throws Exception { + ServiceServlet testSubject;Wrapper<Response> responseWrapper = null; + Wrapper<String> uuidWrapper = null; + Wrapper<String> versionWrapper = null; + User user = null; + ComponentTypeEnum componentTypeEnum = null; + String componentUniqueId = ""; + ServletContext context = null; + + + // default test + } + + + @Test + public void testDeleteService() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDeleteServiceByNameAndVersion() throws Exception { + ServiceServlet testSubject; + String serviceName = ""; + String version = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateServiceMetadata() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateGroupInstancePropertyValues() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + String componentInstanceId = ""; + String groupInstanceId = ""; + String data = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetServiceById() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testGetServiceByNameAndVersion() throws Exception { + ServiceServlet testSubject; + String serviceName = ""; + String serviceVersion = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testUpdateServiceDistributionState() throws Exception { + ServiceServlet testSubject; + LifecycleChangeInfoWithAction jsonChangeInfo = null; + String serviceId = ""; + String state = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testActivateDistribution() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + String env = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testMarkDistributionAsDeployed() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + String did = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testTempUrlToBeDeleted() throws Exception { + ServiceServlet testSubject; + String serviceId = ""; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testDownloadServiceArtifact() throws Exception { + ServiceServlet testSubject; + String artifactName = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + + } + + + @Test + public void testExecuteCommand() throws Exception { + ServiceServlet testSubject; + String artifactName = ""; + Either<byte[], ResponseFormat> result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..94aaee2afc --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java @@ -0,0 +1,39 @@ +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.PropertyBusinessLogic; + +public class TypesFetchServletTest { + + private TypesFetchServlet createTestSubject() { + return new TypesFetchServlet(); + } + + + @Test + public void testGetAllDataTypesServlet() throws Exception { + TypesFetchServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetPropertyBL() throws Exception { + TypesFetchServlet testSubject; + ServletContext context = null; + PropertyBusinessLogic result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 420cbcca6b..8f4f57e836 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,6 +35,8 @@ 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; @@ -55,16 +57,19 @@ import org.openecomp.sdc.be.impl.ServletUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.servlets.TypesUploadServlet; 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 { @@ -83,7 +88,8 @@ public class TypesUploadServletTest extends JerseyTest { @BeforeClass public static void setup() { ExternalConfiguration.setAppName("catalog-be"); - 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(webApplicationContext); when(webApplicationContext.getBean(CapabilityTypeImportManager.class)).thenReturn(importManager); when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils); @@ -106,11 +112,13 @@ public class TypesUploadServletTest extends JerseyTest { List<CapabilityTypeDefinition> emptyList = new ArrayList<CapabilityTypeDefinition>(); Either<List<CapabilityTypeDefinition>, ResponseFormat> either = Either.left(emptyList); when(importManager.createCapabilityTypes(Mockito.anyString())).thenReturn(either); - FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip")); + FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", + new File("src/test/resources/types/capabilityTypes.zip")); MultiPart multipartEntity = new FormDataMultiPart(); multipartEntity.bodyPart(filePart); - Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON).post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class); + Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON) + .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class); assertTrue(response.getStatus() == HttpStatus.CREATED_201.getStatusCode()); @@ -137,7 +145,8 @@ public class TypesUploadServletTest extends JerseyTest { when(request.getSession()).thenReturn(session); when(session.getServletContext()).thenReturn(servletContext); 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); for (String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) { @@ -145,10 +154,96 @@ public class TypesUploadServletTest extends JerseyTest { } - when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); + when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)) + .thenReturn(configurationManager); } }); return resourceConfig; } + + private TypesUploadServlet createTestSubject() { + return new TypesUploadServlet(); + } + + + @Test + public void testUploadCapabilityType() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUploadInterfaceLifecycleType() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUploadCategories() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUploadDataTypes() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUploadGroupTypes() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUploadPolicyTypes() throws Exception { + TypesUploadServlet testSubject; + File file = null; + HttpServletRequest request = null; + String creator = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + } 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 ed69f104d2..6fd930c684 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 @@ -30,19 +30,21 @@ 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.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; import org.openecomp.sdc.be.auditing.impl.AuditingManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.utils.UserStatusEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.servlets.UserAdminServlet; import org.openecomp.sdc.be.user.UserBusinessLogic; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.api.UserRoleEnum; @@ -75,7 +77,8 @@ public class UserAdminServletTest extends JerseyTest { ExternalConfiguration.setAppName("catalog-be"); when(session.getServletContext()).thenReturn(servletContext); - 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(webApplicationContext); when(webApplicationContext.getBean(UserBusinessLogic.class)).thenReturn(userAdminManager); @@ -97,26 +100,52 @@ public class UserAdminServletTest extends JerseyTest { } /* - * @Test public void deactivateUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID); Either<User, ActionStatus> eitherActiveUser = buildEitherUser(userToDeleteUserId, true); - * User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId); + * @Test public void deactivateUserSuccessfullyTest(){ String + * userToDeleteUserId = "admin1"; User adminUser = new User(); + * adminUser.setUserId(ADMIN_ATT_UID); Either<User, ActionStatus> + * eitherActiveUser = buildEitherUser(userToDeleteUserId, true); User + * userToDelete = eitherActiveUser.left().value(); + * doReturn(eitherActiveUser).when(userAdminManager).getUser( + * userToDeleteUserId); * - * Either<User, ActionStatus> eitherInactiveUser = buildEitherUser(userToDeleteUserId, false); doReturn(eitherInactiveUser).when(userAdminManager).deActivateUser( adminUser, userToDelete.getUserId()); + * Either<User, ActionStatus> eitherInactiveUser = + * buildEitherUser(userToDeleteUserId, false); + * doReturn(eitherInactiveUser).when(userAdminManager).deActivateUser( + * adminUser, userToDelete.getUserId()); * * - * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(1)).deActivateUser(adminUser, userToDelete.getUserId()); } + * Response response = + * target().path("/v1/user/"+userToDeleteUserId).request().delete(); + * assertTrue(response.getStatus() == HttpStatus.OK.value()); + * verify(userAdminManager, times(1)).deActivateUser(adminUser, + * userToDelete.getUserId()); } * * - * @Test public void forceDeleteUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; when(request.getHeader(User.FORCE_DELETE_HEADER_FLAG)).thenReturn(User. FORCE_DELETE_HEADER_FLAG); + * @Test public void forceDeleteUserSuccessfullyTest(){ String + * userToDeleteUserId = "admin1"; + * when(request.getHeader(User.FORCE_DELETE_HEADER_FLAG)).thenReturn(User. + * FORCE_DELETE_HEADER_FLAG); * * User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID); * - * Either<User, ActionStatus> eitherActiveUser = buildEitherUser(userToDeleteUserId, true); User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId); + * Either<User, ActionStatus> eitherActiveUser = + * buildEitherUser(userToDeleteUserId, true); User userToDelete = + * eitherActiveUser.left().value(); + * doReturn(eitherActiveUser).when(userAdminManager).getUser( + * userToDeleteUserId); * - * Either<User, ActionStatus> eitherUser = buildEitherUser(userToDeleteUserId, true); doReturn(eitherUser).when(userAdminManager).deleteUser(userToDelete. getUserId()); + * Either<User, ActionStatus> eitherUser = + * buildEitherUser(userToDeleteUserId, true); + * doReturn(eitherUser).when(userAdminManager).deleteUser(userToDelete. + * getUserId()); * * - * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(0)).deActivateUser(adminUser, userToDelete.getUserId()); - * verify(userAdminManager, times(1)).deleteUser(userToDelete.getUserId()); } + * Response response = + * target().path("/v1/user/"+userToDeleteUserId).request().delete(); + * assertTrue(response.getStatus() == HttpStatus.OK.value()); + * verify(userAdminManager, times(0)).deActivateUser(adminUser, + * userToDelete.getUserId()); verify(userAdminManager, + * times(1)).deleteUser(userToDelete.getUserId()); } */ @Override @@ -145,4 +174,117 @@ public class UserAdminServletTest extends JerseyTest { return Either.left(user); } + private UserAdminServlet createTestSubject() { + return new UserAdminServlet(); + } + + + @Test + public void testGet() throws Exception { + UserAdminServlet testSubject; + String userId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetRole() throws Exception { + UserAdminServlet testSubject; + String userId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testUpdateUserRole() throws Exception { + UserAdminServlet testSubject; + String userIdUpdateUser = ""; + HttpServletRequest request = null; + String data = ""; + String modifierUserId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testCreateUser() throws Exception { + UserAdminServlet testSubject; + HttpServletRequest request = null; + String newUserData = ""; + String modifierAttId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testAuthorize() throws Exception { + UserAdminServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + String firstName = ""; + String lastName = ""; + String email = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetAdminsUser() throws Exception { + UserAdminServlet testSubject; + String userId = ""; + HttpServletRequest request = null; + Response result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetUsersList() throws Exception { + UserAdminServlet testSubject; + HttpServletRequest request = null; + String userId = ""; + String roles = ""; + Response result; + + // test 1 + testSubject = createTestSubject(); + roles = null; + + // test 2 + testSubject = createTestSubject(); + roles = ""; + } + + + @Test + public void testDeActivateUser() throws Exception { + UserAdminServlet testSubject; + String userId = ""; + HttpServletRequest request = null; + String userIdHeader = ""; + Response result; + + // default test + testSubject = createTestSubject(); + } + } 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 new file mode 100644 index 0000000000..f93819c0a1 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetectorTest.java @@ -0,0 +1,38 @@ +package org.openecomp.sdc.be.switchover.detector; + +import javax.annotation.Generated; + +import org.junit.Test; + + +public class SwitchoverDetectorTest { + + private SwitchoverDetector createTestSubject() { + return new SwitchoverDetector(); + } + + + @Test + public void testGetSiteMode() throws Exception { + SwitchoverDetector testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSiteMode(); + } + + + @Test + public void testSetSiteMode() throws Exception { + SwitchoverDetector testSubject; + String mode = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setSiteMode(mode); + } + + + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..e6f1ac82fb --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java @@ -0,0 +1,71 @@ +package org.openecomp.sdc.be.tosca; + +import java.util.Map; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.tosca.model.ToscaNodeType; +import org.openecomp.sdc.be.tosca.model.ToscaProperty; + +import fj.data.Either; + +public class PropertyConvertorTest { + + private PropertyConvertor createTestSubject() { + return new PropertyConvertor(); + } + + + @Test + public void testGetInstance() throws Exception { + PropertyConvertor result; + + // default test + result = PropertyConvertor.getInstance(); + } + + + @Test + public void testConvertProperties() throws Exception { + PropertyConvertor testSubject; + Component component = null; + ToscaNodeType toscaNodeType = null; + Map<String, DataTypeDefinition> dataTypes = null; + Either<ToscaNodeType, ToscaError> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.convertProperties(component, toscaNodeType, dataTypes); + } + + + @Test + public void testConvertProperty() throws Exception { + PropertyConvertor testSubject; + Map<String, DataTypeDefinition> dataTypes = null; + PropertyDefinition property = null; + boolean isCapabiltyProperty = false; + ToscaProperty result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testConvertToToscaObject() throws Exception { + PropertyConvertor testSubject; + String propertyType = ""; + String value = ""; + String innerType = ""; + Map<String, DataTypeDefinition> dataTypes = null; + Object result; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..7cb2ef7cf8 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -0,0 +1,36 @@ +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; + +import fj.data.Either; + +public class ToscaExportHandlerTest { + + private ToscaExportHandler createTestSubject() { + return new ToscaExportHandler(); + } + + + @Test + public void testGetDependencies() throws Exception { + ToscaExportHandler testSubject; + Component component = null; + Either<ToscaTemplate, ToscaError> result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetInterfaceFilename() throws Exception { + String artifactName = ""; + String result; + + // default test + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..c3a993596c --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java @@ -0,0 +1,56 @@ +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; + +import com.datastax.driver.core.UserType.Field; + +public class ToscaUtilsTest { + + private ToscaUtils createTestSubject() { + return new ToscaUtils(); + } + + + @Test + public void testIsAtomicType() throws Exception { + Component component = null; + boolean result; + + // default test + } + + + @Test + public void testIsComplexVfc() throws Exception { + Component component = null; + boolean result; + + // default test + } + + + @Test + public void testObjectToMap() throws Exception { + Object objectToConvert = null; + Class clazz = null; + Map<String, Object> result; + + // default test + } + + + @Test + public void testGetAllFields() throws Exception { + List<Field> fields = null; + Class<?> type = null; + List<Field> result; + + // default test + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java deleted file mode 100644 index 4b01b4fd61..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============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.user; - -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.mockito.Mockito; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.api.IUsersDAO; -import org.openecomp.sdc.be.dao.impl.Neo4jUsersDAO; -import org.openecomp.sdc.be.resources.data.UserData; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import fj.data.Either; - -public class UserAdminManagerTest { - - final IUsersDAO usersDao = Mockito.mock(Neo4jUsersDAO.class); - Gson gson; - - @Before - public void setup() { - Either<UserData, ActionStatus> eitherOk = Either.right(ActionStatus.OK); - gson = new GsonBuilder().setPrettyPrinting().create(); - when(usersDao.getUserData(anyString())).thenReturn(eitherOk); - when(usersDao.saveUserData((UserData) anyObject())).thenReturn(ActionStatus.OK); - when(usersDao.updateUserData((UserData) anyObject())).thenReturn(ActionStatus.OK); - when(usersDao.deleteUserData(anyString())).thenReturn(ActionStatus.OK); - } - - // @Test - // public void testCreateUser() { - // String json = "{\"firstName\": \"James\",\"lastName\": - // \"Brown\",\"userId\": \"jb1234u\",\"email\": - // \"jb1234u@sdc.com\",\"role\": \"ADMIN\"}"; - // UserData user = gson.fromJson(json, UserData.class); - // Either<UserData,ActionStatus> either = - // UserAdminManager.getInstance().createUser(user); - // assertTrue(either.isRight()); - // assertEquals(ActionStatus.OK, either.right().value()); - // } - // - // - // @Test - // public void testCreateUserInvalidEmail() { - // String json = "{\"firstName\": \"James\",\"lastName\": - // \"Brown\",\"userId\": \"jb1234u\",\"email\": \"@sdc.com\",\"role\": - // \"ADMIN\"}"; - // UserData user = gson.fromJson(json, UserData.class); - // Either<UserData,ActionStatus> either = - // UserAdminManager.getInstance().createUser(user); - // assertTrue(either.isRight()); - // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value()); - // } - // - // @Test - // public void testCreateUserInvalidRole() { - // String json = "{\"firstName\": \"James\",\"lastName\": - // \"Brown\",\"userId\": \"jb1234u\",\"email\": - // \"jb1234u@sdc.com\",\"role\": \"MIN\"}"; - // UserData user = gson.fromJson(json, UserData.class); - // Either<UserData,ActionStatus> either = - // UserAdminManager.getInstance().createUser(user); - // assertTrue(either.isRight()); - // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value()); - // } - -} 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 new file mode 100644 index 0000000000..6558b140c7 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java @@ -0,0 +1,47 @@ +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; +import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBTypeEnum; +import org.openecomp.sdc.common.util.MethodActivationStatusEnum; + +import fj.data.Either; + +public class RollbackManagerTest { + + private RollbackManager createTestSubject() { + return new RollbackManager(null, "", "", null); + } + + + @Test + public void testTransactionRollback() throws Exception { + RollbackManager testSubject; + DBActionCodeEnum result; + + // default test + } + + + @Test + public void testAddRollbackHandler() throws Exception { + RollbackManager testSubject; + RollbackHandler rollbackHandler = null; + Either<RollbackHandler, MethodActivationStatusEnum> result; + + // default test + } + + + @Test + public void testGetRollbackHandler() throws Exception { + RollbackManager testSubject; + DBTypeEnum dbType = null; + Either<RollbackHandler, MethodActivationStatusEnum> result; + + // default test + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..aca9db39c0 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java @@ -0,0 +1,54 @@ +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; + +public class TransactionManagerTest { + + private TransactionManager createTestSubject() { + return new TransactionManager(); + } + + + @Test + public void testGetTransaction() throws Exception { + TransactionManager testSubject; + String userId = ""; + ActionTypeEnum actionType = null; + ITransactionSdnc result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGenerateTransactionID() throws Exception { + TransactionManager testSubject; + Integer result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testResetTransactionId() throws Exception { + TransactionManager testSubject; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testInit() throws Exception { + TransactionManager testSubject; + + // default test + testSubject = createTestSubject(); + } +}
\ No newline at end of file diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java deleted file mode 100644 index 3e6e7706cb..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============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.dao.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.impl.Neo4jResourceDAO; -import org.openecomp.sdc.be.dao.neo4j.BatchBuilder; -import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fj.data.Either; - -public abstract class BasicDao implements IBasicDAO { - - Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder(); - - Neo4jClient neo4jClient; - - private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName()); - - public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable, - Class<T> clazz, NodeTypeEnum nodeType) { - - if (graphNeighbourTable != null) { - - Either<BatchBuilder, Neo4jOperationStatus> bbResult = graphBatchBuilder - .buildBatchBuilderFromTable(graphNeighbourTable); - - if (bbResult.isLeft()) { - - BatchBuilder batchBuilder = bbResult.left().value(); - // Neo4jOperationStatus neo4jOperationStatus = - // neo4jClient.execute(batchBuilder); - Either<List<List<GraphElement>>, Neo4jOperationStatus> executeResult = neo4jClient - .execute(batchBuilder); - - if (executeResult.isRight()) { - return Either.right(executeResult.right().value()); - } - - T result = null; - List<List<GraphElement>> listOfResults = executeResult.left().value(); - if (listOfResults != null) { - for (List<GraphElement> listOfElements : listOfResults) { - if (listOfElements != null && false == listOfElements.isEmpty()) { - for (GraphElement element : listOfElements) { - logger.debug("element {} was returned after running batch operation {}", - element, batchBuilder); - if (element instanceof GraphNode) { - GraphNode neo4jNode = (GraphNode) element; - if (NodeTypeEnum.getByName(neo4jNode.getLabel()) == nodeType) { - result = clazz.cast(neo4jNode); - } - } - } - } - } - } - - return Either.left(result); - - } else { - return Either.right(bbResult.right().value()); - } - - } else { - logger.error("The table sent in order to create resource is empty."); - return Either.right(Neo4jOperationStatus.BAD_REQUEST); - } - - } - - @Override - public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String uniqueid, Class<T> clazz, - NodeTypeEnum nodeTypeEnum) { - - MatchFilter filter = new MatchFilter(); - filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), uniqueid); - - return getNodeData(filter, clazz, nodeTypeEnum); - - } - - @Override - public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String uniqueid, - Class<T> clazz, NodeTypeEnum nodeTypeEnum) { - - MatchFilter filter = new MatchFilter(); - filter.addToMatch(keyName, uniqueid); - - return getNodeData(filter, clazz, nodeTypeEnum); - - } - - private <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(MatchFilter filter, Class<T> clazz, - NodeTypeEnum nodeTypeEnum) { - - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - nodeTypeEnum.getName(), filter); - - if (status.isRight()) { - return Either.right(status.right().value()); - } else { - List<GraphElement> value = status.left().value(); - if (value == null || value.isEmpty()) { - return Either.right(Neo4jOperationStatus.NOT_FOUND); - } else { - return Either.left(clazz.cast(value.get(0))); - } - } - } - - @Override - public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData( - Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum) { - - MatchFilter filter = new MatchFilter(); - if (propertiesToMatch != null) { - for (Entry<String, Object> property : propertiesToMatch.entrySet()) { - filter.addToMatch(property.getKey(), property.getValue()); - } - } - - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - nodeTypeEnum.getName(), filter); - - if (status.isRight()) { - return Either.right(status.right().value()); - } else { - List<GraphElement> value = status.left().value(); - if (value == null || value.isEmpty()) { - return Either.right(Neo4jOperationStatus.NOT_FOUND); - } else { - List<T> list = new ArrayList<T>(); - for (GraphElement element : value) { - list.add(clazz.cast(element)); - } - return Either.left(list); - } - } - } - - public Neo4jClient getNeo4jClient() { - return neo4jClient; - } - - public void setNeo4jClient(Neo4jClient neo4jClient) { - this.neo4jClient = neo4jClient; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java deleted file mode 100644 index 3a2bfb34e8..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============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.dao.api; - -import java.util.List; -import java.util.Map; - -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; - -import fj.data.Either; - -public interface IBasicDAO { - - /** - * add the content of the graph neighbour table to the graph. - * - * @param graphNeighbourTable - * @param clazz - * - the type of the object to be returned - * @param nodeType - * - label of the node - * @return Neo4jNode implementation - */ - public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable, - Class<T> clazz, NodeTypeEnum nodeType); - - /** - * return the node data by unique id. - * - * @param id - * - unique id of the node - * @param clazz - * @param nodeType - * @return - */ - public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String id, Class<T> clazz, - NodeTypeEnum nodeType); - - public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String id, Class<T> clazz, - NodeTypeEnum nodeType); - - public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData( - Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum); -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java deleted file mode 100644 index 17bded535c..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============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.dao.api; - -public interface IPropertyDAO extends IBasicDAO { - - // Either<PropertyData, Neo4jOperationStatus> - // createPropertyData(GraphNeighbourTable graphNeighbourTable); - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java deleted file mode 100644 index 47bbcbcb11..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============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.dao.api; - -import java.util.List; -import java.util.Map; - -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.resources.data.ResourceMetadataData; - -import fj.data.Either; - -public interface IResourceDAO extends IBasicDAO { - - Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id); - - // Either<ResourceData, Neo4jOperationStatus> - // createResourceData(GraphNeighbourTable graphNeighbourTable); - - /** - * the method retrieves all the resources according to the supplied - * properties, if none or null is supplied all the resources will be - * returned. - * - * @param propertiesToMatch - * a map of properties to match. - * @return - */ - Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData(Map<String, Object> propertiesToMatch); - - // ActionStatus updateUserData(UserData userData); - // - // ActionStatus deleteUserData(String id); - - void setNeo4jClient(Neo4jClient client); - - Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name); -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java deleted file mode 100644 index d6b8d2eed8..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============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.dao.impl; - -import java.util.List; - -import javax.annotation.Resource; - -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.api.IElementDAO; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import fj.data.Either; - -//@Component("elements-dao") -public class Neo4jElementDAO implements IElementDAO { - - // @Resource - Neo4jClient neo4jClient; - - private static Logger logger = LoggerFactory.getLogger(Neo4jElementDAO.class.getName()); - - @Override - public Either<List<GraphElement>, ActionStatus> getAllCategories() { - MatchFilter filter = new MatchFilter(); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.ResourceCategory.getName(), filter); - if (status.isRight()) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - List<GraphElement> value = status.left().value(); - if (value == null || value.isEmpty()) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - return Either.left(value); - } - } - } - - @Override - public Either<List<GraphElement>, ActionStatus> getAllTags() { - MatchFilter filter = new MatchFilter(); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.Tag.getName(), filter); - if (status.isRight()) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - List<GraphElement> value = status.left().value(); - if (value == null) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - return Either.left(value); - } - } - } - - @Override - public Either<GraphElement, ActionStatus> getCategory(String name) { - MatchFilter filter = new MatchFilter(); - filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.ResourceCategory.getName(), filter); - if (status.isRight()) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - List<GraphElement> value = status.left().value(); - if (value == null) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - return Either.left(value.get(0)); - } - } - - } - - /** - * FOR TEST ONLY - * - * @param neo4jClient - */ - public void setNeo4jClient(Neo4jClient neo4jClient) { - this.neo4jClient = neo4jClient; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java deleted file mode 100644 index c9fcbab0de..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============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.dao.impl; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; - -import org.openecomp.sdc.be.dao.api.BasicDao; -import org.openecomp.sdc.be.dao.api.IPropertyDAO; -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -//@Component("neo4j-property-dao") -public class Neo4jPropertyDAO extends BasicDao implements IPropertyDAO { - - // @Resource - Neo4jClient neo4jClient; - - private static Logger logger = LoggerFactory.getLogger(Neo4jPropertyDAO.class.getName()); - - Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder(); - - public Neo4jPropertyDAO() { - - } - - @PostConstruct - public void init() { - setNeo4jClient(neo4jClient); - } -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java deleted file mode 100644 index 8d961b10ec..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * ============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.dao.impl; - -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.openecomp.sdc.be.dao.api.BasicDao; -import org.openecomp.sdc.be.dao.api.IResourceDAO; -import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; -import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint; -import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.resources.data.ResourceMetadataData; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fj.data.Either; - -//@Component("neo4j-resource-dao") -public class Neo4jResourceDAO extends BasicDao implements IResourceDAO { - - // @Resource - Neo4jClient neo4jClient; - - private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName()); - - Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder(); - - public Neo4jResourceDAO() { - - } - - @PostConstruct - public void init() { - super.setNeo4jClient(neo4jClient); - } - - private String findResourceDataIdFromNodes(List<GraphNode> nodes) { - - if (nodes != null) { - - for (GraphNode neo4jNode : nodes) { - String label = neo4jNode.getLabel(); - if (label.equals(NodeTypeEnum.Resource.getName())) { - return neo4jNode.getUniqueId().toString(); - } - } - } - - return null; - } - - private GraphRelation addStateRelation(RelationEndPoint from, RelationEndPoint to, GraphEdgeLabels edgeLabel, - String value) { - - GraphRelation relationState = new GraphRelation(); - relationState.setFrom(from); - relationState.setTo(to); - relationState.setType(edgeLabel.name()); - relationState.setAction(ActionEnum.Create); - return relationState; - } - - // private ActionStatus convertNeo4jOperationStatusToActionStatus( - // Neo4jOperationStatus value) { - // - // if (value == null) { - // return ActionStatus.GENERAL_ERROR; - // } - // - // switch (value) { - // case NOT_FOUND: - // return ActionStatus.RESOURCE_NOT_FOUND; - // case ERROR: - // return ActionStatus.GENERAL_ERROR; - // case NOT_SUPPORTED: - // return ActionStatus.INVALID_CONTENT; - // case WRONG_INPUT: - // return ActionStatus.INVALID_CONTENT; - // case OK: - // return ActionStatus.OK; - // default: - // return ActionStatus.GENERAL_ERROR; - // } - // - // } - - @Override - public Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id) { - - MatchFilter filter = new MatchFilter(); - filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), id); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.Resource.getName(), filter); - - if (status.isRight()) { - return Either.right(status.right().value()); - } else { - List<GraphElement> value = status.left().value(); - if (value == null || value.isEmpty()) { - return Either.right(Neo4jOperationStatus.NOT_FOUND); - } else { - return Either.left((ResourceMetadataData) value.get(0)); - } - } - } - - @Override - public Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name) { - - MatchFilter filter = new MatchFilter(); - filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.Resource.getName(), filter); - - if (status.isRight() || (status.left().value() == null)) { - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } else { - List<GraphElement> value = status.left().value(); - return Either.left(value.size()); - } - } - - @Override - public void setNeo4jClient(Neo4jClient client) { - this.neo4jClient = client; - super.setNeo4jClient(client); - } - - @Override - public Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData( - Map<String, Object> propertiesToMatch) { - - RecursiveFilter filter = new RecursiveFilter(NodeTypeEnum.Resource); - // filter.addRelationType("typeof").addRelationType("belong").setProperties(propertiesToMatch); - - Either<List<List<GraphElement>>, Neo4jOperationStatus> ret = neo4jClient.executeGet(filter); - if (ret.isRight()) { - return Either.right(ret.right().value()); - } - List<List<GraphElement>> listOfListOfNeo4jElement = ret.left().value(); - - for (List<GraphElement> row : listOfListOfNeo4jElement) { - - for (GraphElement elem : row) { - - } - } - return Either.right(null); - - /* - * MatchFilter filter = new MatchFilter(); if(propertiesToMatch != - * null){ for (Entry<String,Object> propertie : - * propertiesToMatch.entrySet()){ filter.addToMatch(propertie.getKey(), - * propertie.getValue()); } } Either<List<GraphElement>, - * Neo4jOperationStatus> status = - * neo4jClient.getByFilter(GraphElementTypeEnum.Node, - * NodeTypeEnum.Resource.getName(), filter); if (status.isRight()) { - * return Either.right(status.right().value()); } else { - * List<GraphElement> value = status.left().value(); if (value == null - * || value.isEmpty()) { return - * Either.right(Neo4jOperationStatus.NOT_FOUND); } else { - * List<ResourceData> result=new ArrayList<>(); for(GraphElement element - * : value ){ result.add((ResourceData)element); } return - * Either.left(result); } } - */ - } - - // @Override - // public ActionStatus updateUserData(UserData userData) { - // UpdateFilter filter = new UpdateFilter(); - // filter.addToMatch("userId", userData.getUserId()); - // filter.setToUpdate(userData.toMap()); - // Neo4jOperationStatus status = - // neo4jClient.updateElement(Neo4JElementTypeEnum.Node, - // NodeTypeEnum.User.getName(), filter); - // if (status.equals(Neo4jOperationStatus.OK)) { - // return ActionStatus.OK; - // } else { - // return ActionStatus.GENERAL_ERROR; - // } - // } - // - // @Override - // public ActionStatus deleteUserData(String id) { - // MatchFilter filter = new MatchFilter(); - // filter.addToMatch("userId", id); - // Neo4jOperationStatus status = - // neo4jClient.deleteElement(Neo4JElementTypeEnum.Node, - // NodeTypeEnum.User.getName(), filter); - // if (status.equals(Neo4jOperationStatus.OK)) { - // return ActionStatus.OK; - // } else { - // return ActionStatus.GENERAL_ERROR; - // } - // } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java deleted file mode 100644 index 14489ef04b..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============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.dao.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; - -import org.openecomp.sdc.be.config.ConfigurationManager; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.api.IUsersDAO; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum; -import org.openecomp.sdc.be.dao.neo4j.Neo4jClient; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.resources.data.UserData; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import fj.data.Either; - -//@Component("users-dao") -public class Neo4jUsersDAO implements IUsersDAO { - - // @Resource - Neo4jClient neo4jClient; - - private static Logger logger = LoggerFactory.getLogger(Neo4jUsersDAO.class.getName()); - - public Neo4jUsersDAO() { - - } - - @PostConstruct - public void init() { - } - - private void createIndexesAndConstraints() { - Either<Map<String, List<String>>, Neo4jOperationStatus> statusInd = neo4jClient - .getIndexes(NodeTypeEnum.User.getName()); - if (statusInd.isRight()) { - logger.error("Failed to get indexes from Neo4j graph"); - throw new RuntimeException("Failed to initialize Neo4jUsersDAO - Failed to get indexes from Neo4j graph"); - } - Map<String, List<String>> indexes = statusInd.left().value(); - if (indexes == null || indexes.isEmpty()) { - logger.info("Define users indexes in Neo4j"); - List<String> propertyNames = new ArrayList<String>(); - propertyNames.add("firstName"); - propertyNames.add("lastName"); - propertyNames.add("email"); - propertyNames.add("role"); - logger.info("Start create Users indexes in Neo4jGraph"); - Neo4jOperationStatus createIndexStatus = neo4jClient.createIndex(NodeTypeEnum.User.getName(), - propertyNames); - if (createIndexStatus.equals(Neo4jOperationStatus.OK)) { - logger.info("Users indexes created in Neo4j"); - List<String> propertyUnique = new ArrayList<String>(); - propertyUnique.add("userId"); - - logger.info("Start create Users constraints in Neo4jGraph"); - Neo4jOperationStatus createUniquenessStatus = neo4jClient - .createUniquenessConstraints(NodeTypeEnum.User.getName(), propertyUnique); - if (createUniquenessStatus.equals(Neo4jOperationStatus.OK)) { - logger.info("Users constraints creatyed in Neo4j"); - } else { - logger.error("Failed to create constraints in Neo4j graph [{}]", createUniquenessStatus); - throw new RuntimeException( - "Failed to initialize Neo4jUsersDAO - Failed to create constraints in Neo4j graph"); - } - } else { - logger.error("Failed to create indexes in Neo4j graph [{}]", createIndexStatus); - throw new RuntimeException( - "Failed to initialize Neo4jUsersDAO - Failed to create indexes in Neo4j graph"); - } - } else { - logger.info("Users indexes already defined in Neo4j"); - } - } - - @Override - public Either<UserData, ActionStatus> getUserData(String id) { - MatchFilter filter = new MatchFilter(); - filter.addToMatch("userId", id); - Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node, - NodeTypeEnum.User.getName(), filter); - if (status.isRight()) { - return Either.right(ActionStatus.GENERAL_ERROR); - } else { - List<GraphElement> value = status.left().value(); - if (value == null || value.isEmpty()) { - return Either.right(ActionStatus.USER_NOT_FOUND); - } else { - return Either.left((UserData) value.get(0)); - } - } - } - - @Override - public ActionStatus saveUserData(UserData userData) { - Neo4jOperationStatus status = neo4jClient.createElement(userData); - if (status.equals(Neo4jOperationStatus.OK)) { - return ActionStatus.OK; - } else { - return ActionStatus.GENERAL_ERROR; - } - } - - @Override - public ActionStatus updateUserData(UserData userData) { - UpdateFilter filter = new UpdateFilter(); - filter.addToMatch("userId", userData.getUserId()); - filter.setToUpdate(userData.toGraphMap()); - Neo4jOperationStatus status = neo4jClient.updateElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(), - filter); - if (status.equals(Neo4jOperationStatus.OK)) { - return ActionStatus.OK; - } else { - return ActionStatus.GENERAL_ERROR; - } - } - - @Override - public ActionStatus deleteUserData(String id) { - MatchFilter filter = new MatchFilter(); - filter.addToMatch("userId", id); - Neo4jOperationStatus status = neo4jClient.deleteElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(), - filter); - if (status.equals(Neo4jOperationStatus.OK)) { - return ActionStatus.OK; - } else { - return ActionStatus.GENERAL_ERROR; - } - } - - public Neo4jClient getNeo4jClient() { - return neo4jClient; - } - - public void setNeo4jClient(Neo4jClient neo4jClient) { - this.neo4jClient = neo4jClient; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java deleted file mode 100644 index 0177d0bd70..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; - -public class BatchBuilder { - // private Map<String, List<Neo4jNode>> nodes; - // private List<Neo4jRelation> relations; - // - private List<GraphElement> elements; - - // TODO add filter - - protected BatchBuilder() { - // nodes = new HashMap<String, List<Neo4jNode>>(); - // relations = new ArrayList<Neo4jRelation>(); - elements = new ArrayList<GraphElement>(); - } - - public static BatchBuilder getBuilder() { - return new BatchBuilder(); - } - - public BatchBuilder add(GraphElement element) { - elements.add(element); - return this; - } - - public List<GraphElement> getElements() { - return elements; - } - - // public BatchBuilder add( Neo4jNode element ){ - // String label = element.getLabel(); - // List<Neo4jNode> list = nodes.get(label); - // if ( list == null ){ - // list = new ArrayList<Neo4jNode>(); - // } - // list.add(element); - // nodes.put(label, list); - - // return this; - // } - // public BatchBuilder add( Neo4jRelation relation ){ - // relations.add(relation); - // return this; - // } - // - // public Map<String, List<Neo4jNode>> getNodes() { - // return nodes; - // } - // - // public List<Neo4jRelation> getRelations() { - // return relations; - // } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java deleted file mode 100644 index b0b2cc20bb..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============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.dao.neo4j; - -public interface CypherTemplates { - - public static final String CypherUrlTemplate = "http://$host$:$port$/db/data/transaction/commit"; - public static final String batchTemplate = "http://$host$:$port$/db/data/batch"; - public static final String getAllIndexsTemplate = "http://$host$:$port$/db/data/schema/index"; - - public static final String CypherCreateNodeTemplate = "{\n\"statements\" : [ {\n \"statement\" : \"CREATE (n:$label$ { props } ) RETURN n\",\n \"parameters\" : { \n \"props\" : $props$ \n } } ] }"; - - public static final String CypherMatchTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) RETURN ($type$) \" }]}"; - - public static final String CypherUpdateTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) SET n += {props} RETURN ($type$) \",\"parameters\" : {\"props\" : {$props$}}}]}"; - public static final String CypherDeleteNodeTemplate = "{\"statements\": [{\"statement\": \"MATCH ( n:$label$ {$filter$} ) DELETE n \" }]}"; - - public static final String BatchTemplate = "{ \"statements\" : [ $statementList$ ] }"; - - public static final String RegularStatementTemplate = "{ \"statement\" : $statement$ }"; - - public static final String CreateSingleNodeTemplate = " \"CREATE (n:$label$ { props } ) RETURN n, labels(n)\", \"parameters\" : { \"props\" : $props$ }"; - - public static final String CreateRelationTemplate = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ { props } ]->(b) RETURN a, labels(a), b, labels(b), r, type(r)\", \"parameters\": {\"props\": $props$ } "; - - public static final String CreateRelationTemplateNoProps = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ ]->(b) RETURN a,labels(a), b, labels(b), r, type(r)\""; - - public static final String UpdateNodeStatementTemplate = "\"MATCH (n:$label$ {$filter$}) SET n += {props} \",\"parameters\" : {\"props\" : $props$}"; - - public static final String GetNodeRecursiveTemplate = "\"MATCH (m:$label$ {$filter$} )-[f$typesList$]->l RETURN m, labels(m), l, labels(l),f, type(f)\""; - - public static final String GetByRelationNodeRecursiveTemplate = "\"MATCH (n:$labelNode$ ($propsNode$} )-[r:$type$ {$propsRel$}]->(m:$labelSrc$)-[f$typesList$]->l RETURN n, labels(n), r, type(r), m, labels(m), l, labels(l),f, type(f)\""; - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java deleted file mode 100644 index e1409b3bb1..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java +++ /dev/null @@ -1,251 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; -import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveByRelationFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter; -import org.openecomp.sdc.be.dao.utils.DaoUtils; - -public class CypherTranslator { - - public String translate(BatchBuilder builder) { - String json = null; - StringBuilder statementList = new StringBuilder(); - - List<GraphElement> elements = builder.getElements(); - int statementCounter = 0; - for (GraphElement element : elements) { - String singleStatementBody = null; - switch (element.getElementType()) { - case Node: - singleStatementBody = prepareNodeStatement(element); - break; - case Relationship: - singleStatementBody = prepareRelationStatement(element); - break; - } - if (singleStatementBody != null && !singleStatementBody.isEmpty()) { - - String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$", - singleStatementBody); - - statementList.append(singleStatement); - } - ++statementCounter; - if (statementCounter < elements.size() && singleStatementBody != null) { - statementList.append(","); - } - - } - json = CypherTemplates.BatchTemplate.replace("$statementList$", statementList.toString()); - return json; - } - - private String prepareNodeStatement(GraphElement element) { - if (element instanceof GraphNode) { - GraphNode node = (GraphNode) element; - - switch (node.getAction()) { - case Create: - return createNodeStatement(node); - case Update: - return updateNodeStatement(node); - case Delete: - // TODO - break; - default: - break; - } - } - return null; - } - - private String updateNodeStatement(GraphNode node) { - String singleStatement = CypherTemplates.UpdateNodeStatementTemplate.replace("$label$", node.getLabel()); - String filter = prepareKeyValueFilter(node); - - singleStatement = singleStatement.replace("$filter$", filter); - - singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap())); - - return singleStatement; - } - - private String createNodeStatement(GraphNode node) { - String singleStatement = CypherTemplates.CreateSingleNodeTemplate.replace("$label$", node.getLabel()); - - singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap())); - return singleStatement; - } - - private String prepareRelationStatement(GraphElement element) { - if (element instanceof GraphRelation) { - - GraphRelation relation = (GraphRelation) element; - - switch (relation.getAction()) { - case Create: - return createRelationStatement(relation); - case Update: - return updateRelationStatement(relation); - case Delete: - // TODO - break; - default: - break; - } - } - return null; - } - - private String createRelationStatement(GraphRelation relation) { - RelationEndPoint from = relation.getFrom(); - String singleStatement; - - Map<String, Object> props = relation.toGraphMap(); - if (props == null || props.isEmpty()) { - singleStatement = CypherTemplates.CreateRelationTemplateNoProps.replace("$labelFrom$", - from.getLabel().getName()); - } else { - singleStatement = CypherTemplates.CreateRelationTemplate.replace("$labelFrom$", from.getLabel().getName()); - singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(props)); - } - - singleStatement = singleStatement.replace("$idNameFrom$", from.getIdName()); - singleStatement = singleStatement.replace("$idValueFrom$", from.getIdValue().toString()); - - RelationEndPoint to = relation.getTo(); - singleStatement = singleStatement.replace("$labelTo$", to.getLabel().getName()); - singleStatement = singleStatement.replace("$idNameTo$", to.getIdName()); - singleStatement = singleStatement.replace("$idvalueTo$", to.getIdValue().toString()); - - singleStatement = singleStatement.replace("$type$", relation.getType()); - return singleStatement; - } - - private String updateRelationStatement(GraphRelation relation) { - // TODO - return null; - } - - private String prepareKeyValueFilter(GraphNode node) { - StringBuilder sb = new StringBuilder(); - - ImmutablePair<String, Object> keyValueId = node.getKeyValueId(); - - sb.append(keyValueId.getKey()).append(":"); - if (keyValueId.getValue() instanceof String) { - sb.append("'"); - } - sb.append(keyValueId.getValue()); - - if (keyValueId.getValue() instanceof String) { - sb.append("'"); - } - - return sb.toString(); - } - - public String translateGet(RecursiveFilter filter) { - String requestJson = null; - String statement; - - if (filter instanceof RecursiveByRelationFilter) { - RecursiveByRelationFilter byRelationFilter = (RecursiveByRelationFilter) filter; - - statement = CypherTemplates.GetByRelationNodeRecursiveTemplate.replace("$labelNode$", - byRelationFilter.getNode().getLabel()); - String keyValueId = prepareKeyValueFilter(byRelationFilter.getNode()); - - statement = statement.replace("$propsNode$", keyValueId); - - statement = statement.replace("$type$", byRelationFilter.getRelationType()); - - String relationProps = prepareFilterBody(filter); - statement = statement.replace("$propsRel$", relationProps); - statement = statement.replace("$labelSrc$", filter.getNodeType().getName()); - - } else { - - statement = CypherTemplates.GetNodeRecursiveTemplate.replace("$label$", filter.getNodeType().getName()); - - // replace filter - if (filter.getProperties().isEmpty()) { - // get all records by label - statement = statement.replace("{$filter$}", ""); - } else { - String filterStr = prepareFilterBody(filter); - statement = statement.replace("$filter$", filterStr); - } - } - - if (filter.getChildRelationTypes() == null || filter.getChildRelationTypes().isEmpty()) { - statement = statement.replace("$typesList$", ""); - - } else { - StringBuilder typesList = new StringBuilder(); - int count = 0; - for (String type : filter.getChildRelationTypes()) { - typesList.append(":").append(type); - ++count; - if (count < filter.getChildRelationTypes().size()) { - typesList.append("|"); - } - } - statement = statement.replace("$typesList$", typesList.toString()); - } - String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$", statement); - requestJson = CypherTemplates.BatchTemplate.replace("$statementList$", singleStatement); - - return requestJson; - } - - public static String prepareFilterBody(MatchFilter filter) { - StringBuilder sb = new StringBuilder(); - int count = 0; - int size = filter.getProperties().entrySet().size(); - for (Map.Entry<String, Object> entry : filter.getProperties().entrySet()) { - sb.append(entry.getKey()).append(":"); - if (entry.getValue() instanceof String) { - sb.append("'"); - } - sb.append(entry.getValue()); - if (entry.getValue() instanceof String) { - sb.append("'"); - } - ++count; - if (count < size) { - sb.append(","); - } - } - return sb.toString(); - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java deleted file mode 100644 index ccfb57b145..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; - -public class GraphNeighbourTable { - - List<GraphNode> nodes = new ArrayList<GraphNode>(); - - List<NodeRelation> directedEdges = new ArrayList<NodeRelation>(); - - public List<GraphNode> getNodes() { - return nodes; - } - - public void setNodes(List<GraphNode> nodes) { - this.nodes = nodes; - } - - public List<NodeRelation> getDirectedEdges() { - return directedEdges; - } - - public void setDirectedEdges(List<NodeRelation> directedEdges) { - this.directedEdges = directedEdges; - } - - public int addNode(GraphNode node) { - this.nodes.add(node); - return this.nodes.size() - 1; - } - - public void addEdge(NodeRelation directedEdge) { - this.directedEdges.add(directedEdge); - } - - @Override - public String toString() { - return "GraphNeighbourTable [nodes=" + nodes + ", directedEdges=" + directedEdges + "]"; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java deleted file mode 100644 index eb279cda3d..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java +++ /dev/null @@ -1,1003 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.AuthCache; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.auth.BasicScheme; -import org.apache.http.impl.client.BasicAuthCache; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.BasicResponseHandler; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.util.EntityUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.openecomp.sdc.be.config.ConfigurationManager; -import org.openecomp.sdc.be.dao.graph.GraphElementFactory; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter; -import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter; -import org.openecomp.sdc.be.dao.utils.DaoUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import fj.data.Either; - -//@Component("neo4j-client") -public class Neo4jClient { - private CloseableHttpClient httpClient; - private JSONParser jsonParser; - - private CypherTranslator cypherTranslator; - - private static Logger logger = LoggerFactory.getLogger(Neo4jClient.class.getName()); - - private static final String getServiceRoot = "http://$host$:$port$/db/data/"; - // Error's Classification templates - private static final String ClientError = "ClientError"; - private static final String DatabaseError = "DatabaseError"; - private static final String TransientError = "TransientError"; - - // Error's Category templates - private static final String General = "General"; - private static final String LegacyIndex = "LegacyIndex"; - private static final String Request = "Request"; - private static final String Schema = "Schema"; - private static final String Security = "Security"; - private static final String Statement = "Statement"; - private static final String Transaction = "Transaction"; - - // Error's Title templates - private static final String EntityNotFound = "EntityNotFound"; - private static final String ConstraintViolation = "ConstraintViolation"; - - @PostConstruct - public void init() { - - PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); - connectionManager.setMaxTotal(100); - connectionManager.setDefaultMaxPerRoute(20); - connectionManager.setValidateAfterInactivity(15000); - this.httpClient = HttpClients.custom().setConnectionManager(connectionManager).build(); - jsonParser = new JSONParser(); - cypherTranslator = new CypherTranslator(); - - } - - @PreDestroy - public void shutdown() { - try { - httpClient.close(); - logger.debug("Http client to Neo4j Graph closed"); - } catch (Exception e) { - logger.info("Failed to close http client", e); - } - } - - /** - * - * @param builder - * @return - */ - public Either<List<List<GraphElement>>, Neo4jOperationStatus> execute(BatchBuilder builder) { - - String json = cypherTranslator.translate(builder); - logger.debug("Try to execute cypher request [{}]", json); - - Either<String, Neo4jOperationStatus> result = sendPostCypher(json); - if (result.isRight()) { - return Either.right(result.right().value()); - } - List<List<GraphElement>> batchResult; - try { - batchResult = parseResult(result.left().value(), false); - } catch (ParseException e) { - logger.error("Failed to parse batchresponse", e); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - - return Either.left(batchResult); - } - - public Either<List<List<GraphElement>>, Neo4jOperationStatus> executeGet(RecursiveFilter filter) { - String json = cypherTranslator.translateGet(filter); - logger.debug("Try to execute cypher request [{}]", json); - - Either<String, Neo4jOperationStatus> result = sendPostCypher(json); - if (result.isRight()) { - return Either.right(result.right().value()); - } - List<List<GraphElement>> batchResult; - try { - batchResult = parseResult(result.left().value(), true); - } catch (ParseException e) { - logger.error("Failed to parse batchresponse", e); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - - return Either.left(batchResult); - - } - - /** - * - * @param element - * @param ip - * @param user - * @param password - * @return - */ - public Neo4jOperationStatus createElement(GraphElement element) { - Neo4jOperationStatus result = Neo4jOperationStatus.OK; - switch (element.getElementType()) { - case Node: - Either<String, Neo4jOperationStatus> status = createNode(element); - if (status.isRight()) { - result = status.right().value(); - } - break; - case Relationship: - // TODO - break; - - default: - break; - } - - return result; - } - - public Either<GraphElement, Neo4jOperationStatus> createSingleElement(GraphElement element) { - switch (element.getElementType()) { - case Node: - Either<String, Neo4jOperationStatus> status = createNode(element); - if (status.isRight()) { - return Either.right(status.right().value()); - } - // parse response - String response = status.left().value(); - try { - List<GraphElement> listElements = parseGetResponse(element.getElementType(), - ((GraphNode) element).getLabel(), response); - if (listElements == null || listElements.isEmpty()) { - return Either.right(Neo4jOperationStatus.NOT_FOUND); - } else { - return Either.left(listElements.get(0)); - } - } catch (Exception e) { - logger.error("Failed to parse fetched data from graph", e); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - case Relationship: - // TODO - break; - - default: - break; - } - - return Either.right(Neo4jOperationStatus.NOT_SUPPORTED); - } - - /** - * - * @param type - * @param label - * @param filter - * @param ip - * @param user - * @param password - * @return - */ - public Either<List<GraphElement>, Neo4jOperationStatus> getByFilter(GraphElementTypeEnum type, String label, - MatchFilter filter) { - - List<GraphElement> result = null; - - String requestJson; - // replace return type - if (type.equals(GraphElementTypeEnum.Node)) { - requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "n"); - } else { - requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "r"); - } - // replace label - if (label != null && !label.isEmpty()) { - requestJson = requestJson.replace("$label$", label); - } else { - requestJson = requestJson.replace("$label$", ""); - } - - // replace filter - if (filter.getProperties().isEmpty()) { - // get all records by label - requestJson = requestJson.replace("{$filter$}", ""); - } else { - String filterStr = CypherTranslator.prepareFilterBody(filter); - requestJson = requestJson.replace("$filter$", filterStr); - } - logger.debug("Try to perform request []", requestJson); - - Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson); - if (status.isRight()) { - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - // parse response - String response = status.left().value(); - try { - result = parseGetResponse(type, label, response); - } catch (Exception e) { - logger.error("Failed to parse fetched data from graph", e); - Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - - return Either.left(result); - } - - /** - * - * @param type - * @param label - * @param toMatch - * @param toUpdate - * @param ip - * @param user - * @param password - * @return - */ - public Neo4jOperationStatus updateElement(GraphElementTypeEnum type, String label, UpdateFilter toUpdate) { - - String requestJson; - // replace return type - if (type.equals(GraphElementTypeEnum.Node)) { - requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "n"); - } else { - requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "r"); - } - // replace label - if (label != null && !label.isEmpty()) { - requestJson = requestJson.replace("$label$", label); - } else { - requestJson = requestJson.replace("$label$", ""); - } - - // replace filter - if (toUpdate.getProperties().isEmpty()) { - // get all records by label - requestJson = requestJson.replace("{$filter$}", ""); - } else { - String filterStr = CypherTranslator.prepareFilterBody(toUpdate); - requestJson = requestJson.replace("$filter$", filterStr); - } - String props = preparePropertiesInStatement(toUpdate.getToUpdate()); - requestJson = requestJson.replace("$props$", props); - - logger.debug("Try to perform request [{}]", requestJson); - - Either<String, Neo4jOperationStatus> result = sendPostCypher(requestJson); - if (result.isRight()) { - return Neo4jOperationStatus.GENERAL_ERROR; - } - return Neo4jOperationStatus.OK; - } - - /** - * - * @param type - * @param label - * @param response - * @return - * @throws ParseException - */ - - private List<GraphElement> parseGetResponse(GraphElementTypeEnum type, String label, String response) - throws ParseException { - List<GraphElement> result = new ArrayList<GraphElement>(); - JSONObject responseData = (JSONObject) jsonParser.parse(response); - JSONArray results = (JSONArray) responseData.get("results"); - Iterator<JSONObject> iteratorResults = results.iterator(); - while (iteratorResults.hasNext()) { - JSONObject elementResult = iteratorResults.next(); - // JSONArray data = (JSONArray) elementResult.get("row"); - JSONArray data = (JSONArray) elementResult.get("data"); - - Iterator<JSONObject> iterator = data.iterator(); - JSONObject element; - while (iterator.hasNext()) { - element = (JSONObject) iterator.next(); - JSONArray row = (JSONArray) element.get("row"); - - Iterator<JSONObject> iteratorRow = row.iterator(); - while (iteratorRow.hasNext()) { - JSONObject rowElement = iteratorRow.next(); - - Map<String, Object> props = new HashMap<String, Object>(); - - for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) rowElement.entrySet()) { - // props.put(entry.getKey(), - // rowElement.get(entry.getValue())); - props.put(entry.getKey(), entry.getValue()); - } - GraphElement newElement = GraphElementFactory.createElement(label, type, props); - result.add(newElement); - } - } - } - return result; - } - - private List<List<GraphElement>> parseResult(String response, boolean storeRelationNode) throws ParseException { - - List<List<GraphElement>> batchList = new ArrayList<List<GraphElement>>(); - - JSONObject responseData = (JSONObject) jsonParser.parse(response); - JSONArray results = (JSONArray) responseData.get("results"); - Iterator<JSONObject> iteratorResults = results.iterator(); - - while (iteratorResults.hasNext()) { - JSONObject elementResult = iteratorResults.next(); - JSONArray data = (JSONArray) elementResult.get("data"); - JSONArray columns = (JSONArray) elementResult.get("columns"); - Iterator<JSONObject> iteratorData = data.iterator(); - List<GraphElement> singleDataList = new ArrayList<GraphElement>(); - while (iteratorData.hasNext()) { - - JSONObject singleData = iteratorData.next(); - JSONArray row = (JSONArray) singleData.get("row"); - if (columns.size() == 2) { - // node - JSONArray labelArray = (JSONArray) row.get(1); - JSONObject node = (JSONObject) row.get(0); - - Map<String, Object> props = jsonObjectToMap(node); - // get only first label on node. Now single label supported - GraphElement newElement = GraphElementFactory.createElement((String) labelArray.get(0), - GraphElementTypeEnum.Node, props); - singleDataList.add(newElement); - } - if (columns.size() == 10) { - // relation - JSONObject startNode = (JSONObject) row.get(0); - JSONArray startNodeArray = (JSONArray) row.get(1); - - JSONObject relationFromStart = (JSONObject) row.get(2); - String relationFromStartType = (String) row.get(3); - - JSONObject nodeFrom = (JSONObject) row.get(4); - JSONArray labelFromArray = (JSONArray) row.get(5); - - JSONObject nodeTo = (JSONObject) row.get(6); - JSONArray labelToArray = (JSONArray) row.get(7); - - JSONObject relation = (JSONObject) row.get(8); - String type = (String) row.get(9); - - Map<String, Object> propsStartNode = jsonObjectToMap(startNode); - Map<String, Object> propsRelationStartNode = jsonObjectToMap(relationFromStart); - - Map<String, Object> propsFrom = jsonObjectToMap(nodeFrom); - Map<String, Object> propsTo = jsonObjectToMap(nodeTo); - Map<String, Object> propsRelation = jsonObjectToMap(relation); - - GraphNode startN = (GraphNode) GraphElementFactory.createElement((String) startNodeArray.get(0), - GraphElementTypeEnum.Node, propsStartNode); - - GraphNode from = (GraphNode) GraphElementFactory.createElement((String) labelFromArray.get(0), - GraphElementTypeEnum.Node, propsFrom); - GraphNode to = (GraphNode) GraphElementFactory.createElement((String) labelToArray.get(0), - GraphElementTypeEnum.Node, propsTo); - - singleDataList.add(startN); - - GraphElement relationFromStartNode = GraphElementFactory.createRelation(type, - propsRelationStartNode, startN, from); - singleDataList.add(relationFromStartNode); - - singleDataList.add(from); - singleDataList.add(to); - // get only first type on relationship. Now single type - // supported - GraphElement newElement = GraphElementFactory.createRelation(type, propsRelation, from, to); - singleDataList.add(newElement); - } - if (columns.size() == 8) { - - } - } - batchList.add(singleDataList); - } - return batchList; - } - - private Map<String, Object> jsonObjectToMap(JSONObject node) { - Map<String, Object> props = new HashMap<String, Object>(); - - for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) node.entrySet()) { - props.put(entry.getKey(), entry.getValue()); - } - return props; - } - - private String preparePropertiesInStatement(Map<String, Object> properties) { - StringBuilder sb = new StringBuilder(); - int count = 0; - int size = properties.entrySet().size(); - for (Map.Entry<String, Object> entry : properties.entrySet()) { - sb.append("\"").append(entry.getKey()).append("\"").append(":"); - if (entry.getValue() instanceof String) { - sb.append("\""); - } - sb.append(entry.getValue()); - if (entry.getValue() instanceof String) { - sb.append("\""); - } - ++count; - if (count < size) { - sb.append(","); - } - } - return sb.toString(); - } - - private Either<String, Neo4jOperationStatus> createNode(GraphElement element) { - Either<String, Neo4jOperationStatus> status; - if (element instanceof GraphNode) { - GraphNode node = (GraphNode) element; - String json = prepareCreateNodeBody(node); - - logger.debug("Try to save Node [{}] on graph", json); - - status = sendPostCypher(json); - - return status; - - } else { - return Either.right(Neo4jOperationStatus.WRONG_INPUT); - } - } - - private Either<String, Neo4jOperationStatus> sendPostCypher(String json) { - Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j(); - String host = (String) neo4jParams.get("host"); - Integer port = (Integer) neo4jParams.get("port"); - String user = (String) neo4jParams.get("user"); - String password = (String) neo4jParams.get("password"); - - String uri = CypherTemplates.CypherUrlTemplate.replace("$host$", host); - uri = uri.replace("$port$", port.toString()); - - HttpClientContext context = creatClientContext(host, user, password); - CloseableHttpResponse response = null; - - HttpPost post = new HttpPost(uri); - try { - StringEntity input = new StringEntity(json); - input.setContentType("application/json"); - post.setEntity(input); - - response = httpClient.execute(post, context); - - int status = response.getStatusLine().getStatusCode(); - String responseString; - responseString = new BasicResponseHandler().handleResponse(response); - logger.debug("response [{}]", responseString); - - if (status == 200 || status == 201) { - logger.debug("cypher request [{}] was succeeded", json); - Neo4jOperationStatus responseStatus = checkResponse(responseString); - if (Neo4jOperationStatus.OK.equals(responseStatus)) { - return Either.left(responseString); - } else { - return Either.right(responseStatus); - } - } else { - logger.debug("cypher request [{}] was failed : [{}]", json, responseString); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - - } catch (HttpResponseException e) { - logger.debug("failed to perform cypher request [{}]", json, e); - if (e.getStatusCode() == 401) { - return Either.right(Neo4jOperationStatus.NOT_AUTHORIZED); - } else { - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } - } catch (ClientProtocolException e) { - logger.debug("failed to perform cypher request [{}]", json, e); - return Either.right(Neo4jOperationStatus.HTTP_PROTOCOL_ERROR); - } catch (IOException e) { - logger.debug("failed to perform cypher request [{}]", json, e); - return Either.right(Neo4jOperationStatus.NOT_CONNECTED); - } finally { - releaseResource(response); - } - } - - private Neo4jOperationStatus checkResponse(String responseString) { - try { - JSONObject response = (JSONObject) jsonParser.parse(responseString); - JSONArray errors = (JSONArray) response.get("errors"); - if (errors.size() == 0) { - return Neo4jOperationStatus.OK; - } else { - Iterator<JSONObject> iterator = errors.iterator(); - JSONObject error; - while (iterator.hasNext()) { - error = (JSONObject) iterator.next(); - String code = (String) error.get("code"); - String message = (String) error.get("message"); - - Neo4jOperationStatus neoError = mapToNeoError(code, message); - return neoError; - } - return Neo4jOperationStatus.GENERAL_ERROR; - } - } catch (ParseException e) { - logger.error("Failed to parse response", e); - return Neo4jOperationStatus.GENERAL_ERROR; - } - } - - private Neo4jOperationStatus mapToNeoError(String code, String message) { - Neo4jOperationStatus error; - - String[] errorCode = code.split("\\."); - if (errorCode.length < 4) { - error = Neo4jOperationStatus.GENERAL_ERROR; - } else { - // by Classification - switch (errorCode[1]) { - case ClientError: - // by Category - switch (errorCode[2]) { - case General: - error = Neo4jOperationStatus.DB_READ_ONLY; - break; - case LegacyIndex: - error = Neo4jOperationStatus.LEGACY_INDEX_ERROR; - break; - case Request: - error = Neo4jOperationStatus.BAD_REQUEST; - break; - case Schema: - if (errorCode[3].equals(ConstraintViolation)) { - error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST; - } else { - error = Neo4jOperationStatus.SCHEMA_ERROR; - } - break; - case Security: - error = Neo4jOperationStatus.NOT_AUTHORIZED; - break; - case Statement: - // by Title - if (errorCode[3].equals(EntityNotFound)) { - error = Neo4jOperationStatus.NOT_FOUND; - } else { - if (errorCode[3].equals(ConstraintViolation)) { - error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST; - } else { - error = Neo4jOperationStatus.BAD_REQUEST; - } - } - break; - case Transaction: - error = Neo4jOperationStatus.TRANSACTION_ERROR; - break; - default: - error = Neo4jOperationStatus.GENERAL_ERROR; - break; - } - break; - case DatabaseError: - // by Category - switch (errorCode[2]) { - case General: - error = Neo4jOperationStatus.GENERAL_ERROR; - break; - case Schema: - error = Neo4jOperationStatus.SCHEMA_ERROR; - break; - case Statement: - error = Neo4jOperationStatus.EXECUTION_FAILED; - break; - case Transaction: - error = Neo4jOperationStatus.TRANSACTION_ERROR; - break; - default: - error = Neo4jOperationStatus.GENERAL_ERROR; - break; - } - break; - case TransientError: - error = Neo4jOperationStatus.DB_NOT_AVAILABLE; - break; - default: - error = Neo4jOperationStatus.GENERAL_ERROR; - break; - } - error.setOriginError(code).setMessage(message); - String errorFromCfg = code.replace(".", "_"); - String helpMessage = ConfigurationManager.getConfigurationManager().getNeo4jErrorsConfiguration() - .getErrorMessage(errorFromCfg); - if (helpMessage != null && !helpMessage.isEmpty()) { - error.setHelpErrorMsg(helpMessage); - } - } - return error; - } - - private String prepareCreateNodeBody(GraphNode node) { - - String body = CypherTemplates.CypherCreateNodeTemplate.replace("$label$", node.getLabel()); - - body = body.replace("$props$", DaoUtils.convertToJson(node.toGraphMap())); - - return body; - } - - /** - * the method returns all the indexes for the given label if no label is - * supplied ( null or "") all indexes will be returned - * - * @param label - * the name of the label - * @param ip - * @param user - * @param password - * @return a map of labels and there properties - */ - public Either<Map<String, List<String>>, Neo4jOperationStatus> getIndexes(String label) { - Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j(); - String host = (String) neo4jParams.get("host"); - Integer port = (Integer) neo4jParams.get("port"); - String user = (String) neo4jParams.get("user"); - String password = (String) neo4jParams.get("password"); - - String uri = null; - if (label == null || "".equals(label)) { - uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host); - } else { - uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host) + "/" + label; - } - uri = uri.replace("$port$", port.toString()); - - HttpClientContext context = creatClientContext(host, user, password); - CloseableHttpResponse response = null; - - HttpGet get = new HttpGet(uri); - get.setHeader("Content-Type", "application/json"); - get.setHeader("Accept", "application/json; charset=UTF-8"); - - try { - - response = httpClient.execute(get, context); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != 200) { - logger.error("failed to get indexes requeste returned {}", statusCode); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } else { - Map<String, List<String>> labels = getLeablesFromJson(response); - return Either.left(labels); - } - } catch (Exception e) { - logger.debug("failed to get indexes ", e); - return Either.right(Neo4jOperationStatus.GENERAL_ERROR); - } finally { - releaseResource(response); - - } - - } - - private Map<String, List<String>> getLeablesFromJson(CloseableHttpResponse response) - throws HttpResponseException, IOException, ParseException { - Map<String, List<String>> labels = new HashMap<>(); - String responseString = new BasicResponseHandler().handleResponse(response); - JSONArray results = (JSONArray) jsonParser.parse(responseString); - Iterator<JSONObject> iteratorResults = results.iterator(); - while (iteratorResults.hasNext()) { - JSONObject elementResult = iteratorResults.next(); - String label = (String) elementResult.get("label"); - List<String> props = labels.get(label); - if (props == null) { - props = new ArrayList<>(); - labels.put(label, props); - } - JSONArray properties = (JSONArray) elementResult.get("property_keys"); - Iterator<String> iterator = properties.iterator(); - while (iterator.hasNext()) { - props.add(iterator.next()); - } - } - return labels; - } - - public Neo4jOperationStatus createIndex(String label, List<String> propertyNames) { - - Neo4jOperationStatus result = Neo4jOperationStatus.OK; - if (propertyNames != null && !propertyNames.isEmpty()) { - - Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration() - .getNeo4j(); - String host = (String) neo4jParams.get("host"); - Integer port = (Integer) neo4jParams.get("port"); - String user = (String) neo4jParams.get("user"); - String password = (String) neo4jParams.get("password"); - - String uri = CypherTemplates.batchTemplate.replace("$host$", host); - uri = uri.replace("$port$", port.toString()); - - String opertionUri = "/schema/index/" + label; - - HttpClientContext context = creatClientContext(host, user, password); - - CloseableHttpResponse response = null; - - HttpPost post = new HttpPost(uri); - - String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames); - - try { - StringEntity input = new StringEntity(json); - input.setContentType("application/json"); - post.setEntity(input); - response = httpClient.execute(post, context); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != 200) { - logger.error("failed to create index for label [{}] with properties:{} requeste returned {}",label,propertyNames,statusCode); - result = Neo4jOperationStatus.GENERAL_ERROR; - } else { - logger.debug("index for label [{}] with properties: {} created", label, propertyNames); - } - } catch (Exception e) { - logger.debug("failed to create index for label [{}] with properties: {}", label, propertyNames); - result = Neo4jOperationStatus.GENERAL_ERROR; - } finally { - - releaseResource(response); - - } - - } - - else { - logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames); - return Neo4jOperationStatus.WRONG_INPUT; - } - - return result; - } - - public Neo4jOperationStatus createUniquenessConstraints(String label, List<String> propertyNames) { - Neo4jOperationStatus result = Neo4jOperationStatus.OK; - if (propertyNames != null && !propertyNames.isEmpty()) { - - Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration() - .getNeo4j(); - String host = (String) neo4jParams.get("host"); - Integer port = (Integer) neo4jParams.get("port"); - String user = (String) neo4jParams.get("user"); - String password = (String) neo4jParams.get("password"); - - String uri = CypherTemplates.batchTemplate.replace("$host$", host); - uri = uri.replace("$port$", port.toString()); - - String opertionUri = "/schema/constraint/" + label + "/uniqueness/"; - - HttpClientContext context = creatClientContext(host, user, password); - - CloseableHttpResponse response = null; - - HttpPost post = new HttpPost(uri); - - String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames); - - try { - StringEntity input = new StringEntity(json); - input.setContentType("application/json"); - post.setEntity(input); - response = httpClient.execute(post, context); - - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != 200) { - logger.error("failed to create uniqueness constraint for label [{}] on properties:{}. request returned ", - label,propertyNames,statusCode); - result = Neo4jOperationStatus.GENERAL_ERROR; - } else { - logger.debug("uniqueness constraint for label [{}] on properties:{} created",label,propertyNames); - } - } catch (Exception e) { - logger.error("failed to create uniqueness constraint [{}] with properties:{}",label,propertyNames,e); - result = Neo4jOperationStatus.GENERAL_ERROR; - } finally { - releaseResource(response); - } - - } - - else { - logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames); - return Neo4jOperationStatus.WRONG_INPUT; - } - - return result; - } - - public Neo4jOperationStatus deleteElement(GraphElementTypeEnum type, String label, MatchFilter filter) { - - String requestJson; - // replace return type - if (type.equals(GraphElementTypeEnum.Node)) { - logger.debug("removing node label: {}", label); - requestJson = createDeleteNodeStatment(label, filter); - - } else { - logger.error(" delete on type {} is not yet supported", type); - throw new RuntimeException(" delete on type " + type + " is not yet supported"); - } - - logger.debug("Try to perform request [{}]", requestJson); - - Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson); - if (status.isRight()) { - logger.error(" delete request failed with: {}", status.right()); - return Neo4jOperationStatus.GENERAL_ERROR; - } else { - return Neo4jOperationStatus.OK; - } - } - - public String getNeo4jVersion() throws Exception { - Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j(); - String host = (String) neo4jParams.get("host"); - Integer port = (Integer) neo4jParams.get("port"); - String user = (String) neo4jParams.get("user"); - String password = (String) neo4jParams.get("password"); - - String uri = getServiceRoot.replace("$host$", host).replace("$port$", port.toString()); - - HttpClientContext context = creatClientContext(host, user, password); - CloseableHttpResponse response = null; - String result = null; - - HttpGet get = new HttpGet(uri); - get.setHeader("Content-Type", "application/json"); - get.setHeader("Accept", "application/json; charset=UTF-8"); - - try { - response = httpClient.execute(get, context); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != 200) { - throw new Exception("Couldn't get Neo4j service root, HTTP status " + statusCode); - } else { - // Parse response - String responseString = new BasicResponseHandler().handleResponse(response); - JSONObject responseData = (JSONObject) jsonParser.parse(responseString); - Object obj = responseData.get("neo4j_version"); - if (obj != null) { - result = (String) obj; - } - return result; - } - } finally { - releaseResource(response); - } - } - - private String createDeleteNodeStatment(String label, MatchFilter filter) { - String requestJson; - requestJson = CypherTemplates.CypherDeleteNodeTemplate; - - if (label != null && !label.isEmpty()) { - requestJson = requestJson.replace("$label$", label); - } else { - requestJson = requestJson.replace("$label$", ""); - } - - // replace filter - if (filter.getProperties().isEmpty()) { - // get all records by label - requestJson = requestJson.replace("{$filter$}", ""); - } else { - String filterStr = CypherTranslator.prepareFilterBody(filter); - requestJson = requestJson.replace("$filter$", filterStr); - } - return requestJson; - } - - /* - * removed do to fortify scan CredentialsProvider cp = new - * BasicCredentialsProvider(); cp.setCredentials(AuthScope.ANY, new - * UsernamePasswordCredentials(user, password)); AuthCache authCache = new - * BasicAuthCache(); BasicScheme basicAuth = new BasicScheme(); - * authCache.put(new HttpHost(ip, 7474, "http"), basicAuth); - * context.setAuthCache(authCache); context.setCredentialsProvider(cp); - * - */ - private HttpClientContext creatClientContext(String ip, String user, String password) { - HttpClientContext context = HttpClientContext.create(); - - return context; - } - - private void releaseResource(CloseableHttpResponse response) { - if (response != null) { - try { - HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); - response.close(); - } catch (Exception e) { - logger.error("failed to close connection exception", e); - } - } - } - - private String createBatchJson(HttpMethod method, String opertionUri, List<String> propertyNames) { - StringBuilder sb = new StringBuilder(); - sb.append("[ "); - for (int i = 0; i < propertyNames.size(); i++) { - sb.append("{ \"method\" : \"" + method + "\" , \"to\" : \"" + opertionUri - + "\" , \"body\" : { \"property_keys\" : [ \"" + propertyNames.get(i) + "\" ] } }"); - if (i + 1 < propertyNames.size()) { - sb.append(","); - } - } - sb.append(" ]"); - String json = sb.toString(); - return json; - } - - enum HttpMethod { - GET, PUT, POST, DELETE - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java deleted file mode 100644 index e8278a9a3e..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.util.Map; - -import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum; - -public class Neo4jEdge { - - private GraphEdgeLabels edgeType; - private Map<String, Object> properties; - private ActionEnum action; - - public Neo4jEdge(GraphEdgeLabels edgeType, Map<String, Object> properties, ActionEnum actionEnum) { - super(); - this.edgeType = edgeType; - this.properties = properties; - this.action = actionEnum; - } - - public GraphEdgeLabels getEdgeType() { - return edgeType; - } - - public void setEdgeType(GraphEdgeLabels edgeType) { - this.edgeType = edgeType; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public ActionEnum getAction() { - return action; - } - - public void setAction(ActionEnum action) { - this.action = action; - } - - @Override - public String toString() { - return "Neo4jEdge [edgeType=" + edgeType + ", properties=" + properties + ", action=" + action + "]"; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java deleted file mode 100644 index 5a6a8fdade..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============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.dao.neo4j; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum; -import org.openecomp.sdc.be.dao.graph.datatype.GraphElement; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; -import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fj.data.Either; - -public class Neo4jGraphBatchBuilder { - - private static Logger logger = LoggerFactory.getLogger(Neo4jGraphBatchBuilder.class.getName()); - - public Either<BatchBuilder, Neo4jOperationStatus> buildBatchBuilderFromTable( - GraphNeighbourTable graphNeighbourTable) { - - logger.debug("The table sent in order to build BatchBuilder is {}", graphNeighbourTable); - - List<GraphNode> nodes = graphNeighbourTable.getNodes(); - if (nodes != null && nodes.size() > 0) { - List<NodeRelation> directedEdges = graphNeighbourTable.getDirectedEdges(); - - List<RelationEndPoint> relationEndPoints = new ArrayList<RelationEndPoint>(nodes.size()); - Set<Integer> nodesInRelations = findDistinctNodesIndex(directedEdges); - - buildRelationEndPoints(nodes, nodesInRelations, relationEndPoints); - - BatchBuilder batchBuilder = BatchBuilder.getBuilder(); - - for (GraphElement neo4jElement : nodes) { - if (neo4jElement.getAction() != ActionEnum.Delete) { - logger.debug("Goint to add node {} to batch builder.", neo4jElement); - batchBuilder.add(neo4jElement); - } - } - - if (directedEdges != null) { - for (NodeRelation nodeRelation : directedEdges) { - GraphRelation relation = buildNeo4jRelation(relationEndPoints, nodeRelation); - logger.debug("Goint to add relation {} to batch builder.", relation); - batchBuilder.add(relation); - } - } - - for (GraphElement neo4jElement : nodes) { - if (neo4jElement.getAction() == ActionEnum.Delete) { - logger.debug("Goint to add node {} to batch builder.", neo4jElement); - batchBuilder.add(neo4jElement); - } - } - - return Either.left(batchBuilder); - - } else { - logger.error("No node was sent in order to create the resource."); - return Either.right(Neo4jOperationStatus.BAD_REQUEST); - } - } - - private Pair<String, String> getUniqueIdKeyValue(GraphNode neo4jNode) { - - // String label = neo4jNode.getLabel(); - // NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getByName(label); - // - return Pair.createPair(neo4jNode.getUniqueIdKey(), neo4jNode.getUniqueId().toString()); - } - - private Set<Integer> findDistinctNodesIndex(List<NodeRelation> directedEdges) { - - HashSet<Integer> nodesIndex = new HashSet<Integer>(); - - if (directedEdges != null) { - for (NodeRelation nodeRelation : directedEdges) { - nodesIndex.add(nodeRelation.getFromIndex()); - nodesIndex.add(nodeRelation.getToIndex()); - } - } - - return nodesIndex; - } - - private String findResourceDataIdFromNodes(List<GraphNode> nodes) { - - if (nodes != null) { - - for (GraphNode neo4jNode : nodes) { - String label = neo4jNode.getLabel(); - if (label.equals(NodeTypeEnum.Resource.getName())) { - return neo4jNode.getUniqueId().toString(); - } - } - } - - return null; - } - - private GraphRelation buildNeo4jRelation(List<RelationEndPoint> relationEndPoints, NodeRelation nodeRelation) { - GraphRelation relation = new GraphRelation(); - int fromIndex = nodeRelation.getFromIndex(); - int toIndex = nodeRelation.getToIndex(); - Neo4jEdge neo4jEdge = nodeRelation.getEdge(); - relation.setFrom(relationEndPoints.get(fromIndex)); - relation.setTo(relationEndPoints.get(toIndex)); - relation.setType(neo4jEdge.getEdgeType().getProperty()); - - // TODO: fix it after change - Map<String, Object> edgeProps = neo4jEdge.getProperties(); - if (edgeProps != null && false == edgeProps.isEmpty()) { - relation.addPropertis(edgeProps); - } - - relation.setAction(neo4jEdge.getAction()); - return relation; - } - - private void buildRelationEndPoints(List<GraphNode> nodes, Set<Integer> nodesInRelations, - List<RelationEndPoint> relationEndPoints) { - - if (nodesInRelations != null) { - for (Integer nodeIndex : nodesInRelations) { - - GraphElement neo4jElement = nodes.get(nodeIndex); - GraphNode neo4jNode = (GraphNode) neo4jElement; - String label = neo4jNode.getLabel(); - Pair<String, String> uniqueKeyValue = getUniqueIdKeyValue(neo4jNode); - - RelationEndPoint endPoint = new RelationEndPoint(NodeTypeEnum.getByName(label), uniqueKeyValue.getKey(), - uniqueKeyValue.getValue()); - relationEndPoints.add(nodeIndex, endPoint); - - } - } - - } - - public static class Pair<K, V> { - - private final K key; - private final V value; - - public static <K, V> Pair<K, V> createPair(K key, V value) { - return new Pair<K, V>(key, value); - } - - public Pair(K key, V value) { - this.key = key; - this.value = value; - } - - public K getKey() { - return key; - } - - public V getValue() { - return value; - } - - } -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java deleted file mode 100644 index 154449b521..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============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.dao.neo4j; - -public enum Neo4jOperationStatus { - - OK, NOT_CONNECTED, NOT_AUTHORIZED, HTTP_PROTOCOL_ERROR, DB_NOT_AVAILABLE, DB_READ_ONLY, BAD_REQUEST, LEGACY_INDEX_ERROR, SCHEMA_ERROR, TRANSACTION_ERROR, EXECUTION_FAILED, ENTITY_ALREADY_EXIST, - - WRONG_INPUT, GENERAL_ERROR, NOT_SUPPORTED, NOT_FOUND; - - private String originError; - private String message; - private String helpErrorMsg; - - private static final String NA = "NA"; - - Neo4jOperationStatus() { - originError = NA; - message = NA; - helpErrorMsg = NA; - } - - public Neo4jOperationStatus setOriginError(String originError) { - this.originError = originError; - return this; - } - - public Neo4jOperationStatus setMessage(String message) { - if (message != null && !message.isEmpty()) { - this.message = message; - } - return this; - } - - public Neo4jOperationStatus setHelpErrorMsg(String helpErrorMsg) { - this.helpErrorMsg = helpErrorMsg; - return this; - } - - public String getOriginError() { - return originError; - } - - public String getMessage() { - return message; - } - - public String getHelpErrorMsg() { - return helpErrorMsg; - } - - public String printError() { - StringBuilder sb = new StringBuilder(); - sb.append("[").append(toString()).append("-").append(originError).append("-").append(helpErrorMsg).append("-") - .append(message).append("]"); - return sb.toString(); - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java deleted file mode 100644 index c1402f402f..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============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.dao.neo4j; - -public class NodeRelation { - - private int fromIndex; - private int toIndex; - private Neo4jEdge edge; - - public NodeRelation(int fromIndex, int toIndex, Neo4jEdge edge) { - super(); - this.fromIndex = fromIndex; - this.toIndex = toIndex; - this.edge = edge; - } - - public int getFromIndex() { - return fromIndex; - } - - public void setFromIndex(int fromIndex) { - this.fromIndex = fromIndex; - } - - public int getToIndex() { - return toIndex; - } - - public void setToIndex(int toIndex) { - this.toIndex = toIndex; - } - - public Neo4jEdge getEdge() { - return edge; - } - - public void setEdge(Neo4jEdge edge) { - this.edge = edge; - } - - @Override - public String toString() { - return "NodeRelation [fromIndex=" + fromIndex + ", toIndex=" + toIndex + ", edge=" + edge + "]"; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java deleted file mode 100644 index 10e93c1f56..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============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.dao.neo4j.filters; - -import java.util.HashMap; -import java.util.Map; - -public class MatchFilter { - private Map<String, Object> toMatchProperties; - - public MatchFilter() { - toMatchProperties = new HashMap<String, Object>(); - } - - public MatchFilter(Map<String, Object> toMatchProperties) { - super(); - this.toMatchProperties = toMatchProperties; - } - - public Map<String, Object> getProperties() { - return toMatchProperties; - } - - public void setProperties(Map<String, Object> properties) { - this.toMatchProperties = properties; - } - - public MatchFilter addToMatch(String propName, Object value) { - toMatchProperties.put(propName, value); - return this; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java deleted file mode 100644 index 698077d45b..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============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.dao.neo4j.filters; - -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; - -public class RecursiveByRelationFilter extends RecursiveFilter { - - private GraphNode node; - private String relationType; - - public RecursiveByRelationFilter() { - super(); - } - - public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node) { - super(nodeType); - this.node = node; - } - - public RecursiveByRelationFilter(NodeTypeEnum nodeType) { - super(nodeType); - } - - public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node, String relationType) { - super(nodeType); - this.node = node; - this.relationType = relationType; - } - - public RecursiveByRelationFilter addNode(GraphNode node) { - this.node = node; - return this; - } - - public RecursiveByRelationFilter addRelation(String relationType) { - this.relationType = relationType; - return this; - } - - public GraphNode getNode() { - return node; - } - - public void setNode(GraphNode node) { - this.node = node; - } - - public String getRelationType() { - return relationType; - } - - public void setRelationType(String relationType) { - this.relationType = relationType; - } - - @Override - public String toString() { - return "RecursiveByRelationFilter [node=" + node + ", relationType=" + relationType + "]"; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java deleted file mode 100644 index fa78539f8f..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============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.dao.neo4j.filters; - -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; - -public class RecursiveFilter extends MatchFilter { - - private List<String> childRelationTypes; - NodeTypeEnum nodeType; - - public RecursiveFilter() { - childRelationTypes = new ArrayList<String>(); - } - - public RecursiveFilter(NodeTypeEnum nodeType) { - childRelationTypes = new ArrayList<String>(); - this.nodeType = nodeType; - } - - public RecursiveFilter addChildRelationType(String type) { - childRelationTypes.add(type); - return this; - } - - public List<String> getChildRelationTypes() { - return childRelationTypes; - } - - public void setChildRelationTypes(List<String> childRelationTypes) { - this.childRelationTypes = childRelationTypes; - } - - public NodeTypeEnum getNodeType() { - return nodeType; - } - - public void setNodeType(NodeTypeEnum nodeType) { - this.nodeType = nodeType; - } - - @Override - public String toString() { - return "RecursiveFilter [childRelationTypes=" + childRelationTypes + ", nodeType=" + nodeType + "]"; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java deleted file mode 100644 index 3abfdeb70e..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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.dao.neo4j.filters; - -import java.util.HashMap; -import java.util.Map; - -public class UpdateFilter extends MatchFilter { - - private Map<String, Object> toUpdate; - - public UpdateFilter(Map<String, Object> toUpdate) { - super(); - this.toUpdate = toUpdate; - } - - public UpdateFilter() { - super(); - toUpdate = new HashMap<String, Object>(); - } - - public UpdateFilter(Map<String, Object> toMatch, Map<String, Object> toUpdate) { - super(toMatch); - this.toUpdate = toUpdate; - } - - public Map<String, Object> getToUpdate() { - return toUpdate; - } - - public void setToUpdate(Map<String, Object> toUpdate) { - this.toUpdate = toUpdate; - } - - public void addToUpdate(String property, Object value) { - toUpdate.put(property, value); - } -} diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/AccountTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/AccountTest.java index 81a2b41946..414748a416 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/AccountTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/AccountTest.java @@ -1,17 +1,13 @@ package org.openecomp.sdc.be.dao; -import javax.annotation.Generated; - import org.junit.Test; - public class AccountTest { private Account createTestSubject() { return new Account(); } - @Test public void testGetName() throws Exception { Account testSubject; @@ -22,7 +18,6 @@ public class AccountTest { result = testSubject.getName(); } - @Test public void testSetName() throws Exception { Account testSubject; @@ -33,7 +28,6 @@ public class AccountTest { testSubject.setName(name); } - @Test public void testGetEmail() throws Exception { Account testSubject; @@ -44,7 +38,6 @@ public class AccountTest { result = testSubject.getEmail(); } - @Test public void testSetEmail() throws Exception { Account testSubject; @@ -55,7 +48,6 @@ public class AccountTest { testSubject.setEmail(email); } - @Test public void testEquals() throws Exception { Account testSubject; @@ -67,7 +59,6 @@ public class AccountTest { result = testSubject.equals(other); } - @Test public void testHashCode() throws Exception { Account testSubject; diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java deleted file mode 100644 index 529f642fb2..0000000000 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.openecomp.sdc.be.dao.neo4j.filters; - -import java.util.Map; - -import javax.annotation.Generated; - -import org.junit.Test; - - -public class MatchFilterTest { - - private MatchFilter createTestSubject() { - return new MatchFilter(); - } - - - @Test - public void testGetProperties() throws Exception { - MatchFilter testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - - @Test - public void testSetProperties() throws Exception { - MatchFilter testSubject; - Map<String, Object> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } - - - @Test - public void testAddToMatch() throws Exception { - MatchFilter testSubject; - String propName = ""; - Object value = null; - MatchFilter result; - - // default test - testSubject = createTestSubject(); - result = testSubject.addToMatch(propName, value); - } -}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java deleted file mode 100644 index 76b36d2a97..0000000000 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.openecomp.sdc.be.dao.neo4j.filters; - -import javax.annotation.Generated; - -import org.junit.Test; -import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; - - -public class RecursiveByRelationFilterTest { - - private RecursiveByRelationFilter createTestSubject() { - return new RecursiveByRelationFilter(); - } - - - @Test - public void testAddNode() throws Exception { - RecursiveByRelationFilter testSubject; - GraphNode node = null; - RecursiveByRelationFilter result; - - // default test - testSubject = createTestSubject(); - result = testSubject.addNode(node); - } - - - @Test - public void testAddRelation() throws Exception { - RecursiveByRelationFilter testSubject; - String relationType = ""; - RecursiveByRelationFilter result; - - // default test - testSubject = createTestSubject(); - result = testSubject.addRelation(relationType); - } - - - @Test - public void testGetNode() throws Exception { - RecursiveByRelationFilter testSubject; - GraphNode result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode(); - } - - - @Test - public void testSetNode() throws Exception { - RecursiveByRelationFilter testSubject; - GraphNode node = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNode(node); - } - - - @Test - public void testGetRelationType() throws Exception { - RecursiveByRelationFilter testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationType(); - } - - - @Test - public void testSetRelationType() throws Exception { - RecursiveByRelationFilter testSubject; - String relationType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationType(relationType); - } - - - @Test - public void testToString() throws Exception { - RecursiveByRelationFilter testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java deleted file mode 100644 index 990a2b4972..0000000000 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.openecomp.sdc.be.dao.neo4j.filters; - -import java.util.List; - -import javax.annotation.Generated; - -import org.junit.Test; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; - - -public class RecursiveFilterTest { - - private RecursiveFilter createTestSubject() { - return new RecursiveFilter(); - } - - - @Test - public void testAddChildRelationType() throws Exception { - RecursiveFilter testSubject; - String type = ""; - RecursiveFilter result; - - // default test - testSubject = createTestSubject(); - result = testSubject.addChildRelationType(type); - } - - - @Test - public void testGetChildRelationTypes() throws Exception { - RecursiveFilter testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getChildRelationTypes(); - } - - - @Test - public void testSetChildRelationTypes() throws Exception { - RecursiveFilter testSubject; - List<String> childRelationTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setChildRelationTypes(childRelationTypes); - } - - - @Test - public void testGetNodeType() throws Exception { - RecursiveFilter testSubject; - NodeTypeEnum result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNodeType(); - } - - - @Test - public void testSetNodeType() throws Exception { - RecursiveFilter testSubject; - NodeTypeEnum nodeType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNodeType(nodeType); - } - - - @Test - public void testToString() throws Exception { - RecursiveFilter testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java deleted file mode 100644 index 55a9255d31..0000000000 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.openecomp.sdc.be.dao.neo4j.filters; - -import java.util.Map; - -import javax.annotation.Generated; - -import org.junit.Test; - - -public class UpdateFilterTest { - - private UpdateFilter createTestSubject() { - return new UpdateFilter(null); - } - - - @Test - public void testGetToUpdate() throws Exception { - UpdateFilter testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToUpdate(); - } - - - @Test - public void testSetToUpdate() throws Exception { - UpdateFilter testSubject; - Map<String, Object> toUpdate = null; - - // default test - testSubject = createTestSubject(); - testSubject.setToUpdate(toUpdate); - } - - - -}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java new file mode 100644 index 0000000000..5424e712fc --- /dev/null +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/exception/ResourceDAOExceptionTest.java @@ -0,0 +1,36 @@ +package org.openecomp.sdc.be.resources.exception; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.be.dao.api.ResourceUploadStatus; + + +public class ResourceDAOExceptionTest { + + private ResourceDAOException createTestSubject() { + return new ResourceDAOException("", null); + } + + + @Test + public void testGetStatus() throws Exception { + ResourceDAOException testSubject; + ResourceUploadStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getStatus(); + } + + + @Test + public void testSetStatus() throws Exception { + ResourceDAOException testSubject; + ResourceUploadStatus status = null; + + // default test + testSubject = createTestSubject(); + testSubject.setStatus(status); + } +}
\ No newline at end of file diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java new file mode 100644 index 0000000000..b91048dfa1 --- /dev/null +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java @@ -0,0 +1,40 @@ +package org.openecomp.sdc.fe; + +import javax.annotation.Generated; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.junit.Test; + + +public class GzipFilterTest { + + private GzipFilter createTestSubject() { + return new GzipFilter(); + } + + + + + @Test + public void testInit() throws Exception { + GzipFilter testSubject; + FilterConfig filterConfig = null; + + // default test + testSubject = createTestSubject(); + testSubject.init(filterConfig); + } + + + @Test + public void testDestroy() throws Exception { + GzipFilter testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.destroy(); + } +}
\ No newline at end of file diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/client/BackendClientTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/client/BackendClientTest.java new file mode 100644 index 0000000000..d851899f59 --- /dev/null +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/client/BackendClientTest.java @@ -0,0 +1,34 @@ +package org.openecomp.sdc.fe.client; + +import java.util.List; + +import javax.annotation.Generated; +import javax.net.ssl.HostnameVerifier; +import javax.ws.rs.container.AsyncResponse; + +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.eclipse.jetty.http.HttpGenerator.ResponseInfo; +import org.junit.Test; +import org.openecomp.sdc.fe.impl.HttpRequestInfo; + + +public class BackendClientTest { + + private BackendClient createTestSubject() { + return new BackendClient("", "", ""); + } + + + @Test + public void testGetHostnameVerifier() throws Exception { + BackendClient testSubject; + HostnameVerifier result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHostnameVerifier(); + } + + +}
\ No newline at end of file diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java new file mode 100644 index 0000000000..a6885bfe1b --- /dev/null +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java @@ -0,0 +1,30 @@ +package org.openecomp.sdc.fe.listen; + +import javax.annotation.Generated; + +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class MyObjectMapperProviderTest { + + private MyObjectMapperProvider createTestSubject() { + return new MyObjectMapperProvider(); + } + + + @Test + public void testGetContext() throws Exception { + MyObjectMapperProvider testSubject; + Class<?> type = null; + ObjectMapper result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getContext(type); + } + + + +}
\ No newline at end of file diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java new file mode 100644 index 0000000000..25a7c6962d --- /dev/null +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.fe.servlets; + +import java.util.List; + +import javax.annotation.Generated; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; +import org.openecomp.sdc.common.impl.MutableHttpServletRequest; + +import io.netty.handler.codec.http2.Http2FrameReader.Configuration; + + +public class PortalServletTest { + + private PortalServlet createTestSubject() { + return new PortalServlet(); + } + + + @Test + public void testDoGet() throws Exception { + PortalServlet testSubject; + HttpServletRequest request = null; + HttpServletResponse response = null; + + // default test + testSubject = createTestSubject(); + testSubject.doGet(request, response); + } + + + +}
\ No newline at end of file diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java deleted file mode 100644 index 55531fec79..0000000000 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============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.model.operations.impl; - -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; - -public class Neo4jStatusConverter { - - public static StorageOperationStatus convertNeo4jStatusToStorageStatus(Neo4jOperationStatus neo4jStatus) { - - if (neo4jStatus == null) { - return StorageOperationStatus.GENERAL_ERROR; - } - - switch (neo4jStatus) { - - case OK: - return StorageOperationStatus.OK; - - case NOT_CONNECTED: - return StorageOperationStatus.CONNECTION_FAILURE; - - case NOT_AUTHORIZED: - return StorageOperationStatus.PERMISSION_ERROR; - - case HTTP_PROTOCOL_ERROR: - return StorageOperationStatus.HTTP_PROTOCOL_ERROR; - case DB_NOT_AVAILABLE: - return StorageOperationStatus.STORAGE_NOT_AVAILABLE; - case DB_READ_ONLY: - return StorageOperationStatus.READ_ONLY_STORAGE; - case BAD_REQUEST: - return StorageOperationStatus.BAD_REQUEST; - case LEGACY_INDEX_ERROR: - return StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR; - case SCHEMA_ERROR: - return StorageOperationStatus.SCHEMA_ERROR; - case TRANSACTION_ERROR: - return StorageOperationStatus.TRANSACTION_ERROR; - case EXECUTION_FAILED: - return StorageOperationStatus.EXEUCTION_FAILED; - case ENTITY_ALREADY_EXIST: - return StorageOperationStatus.ENTITY_ALREADY_EXISTS; - case WRONG_INPUT: - return StorageOperationStatus.BAD_REQUEST; - case GENERAL_ERROR: - return StorageOperationStatus.GENERAL_ERROR; - case NOT_SUPPORTED: - return StorageOperationStatus.OPERATION_NOT_SUPPORTED; - case NOT_FOUND: - return StorageOperationStatus.NOT_FOUND; - - default: - return StorageOperationStatus.GENERAL_ERROR; - } - - } - -} diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperationTest.java index 339023f9a4..806c22a8fb 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperationTest.java @@ -1,7 +1,14 @@ package org.openecomp.sdc.be.model.jsontitan.operations; -import fj.data.Either; -import org.apache.cassandra.cql3.CQL3Type; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; @@ -21,10 +28,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.*; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; /** * Created by chaya on 6/12/2017. diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java new file mode 100644 index 0000000000..0cea40fcec --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java @@ -0,0 +1,67 @@ +package org.openecomp.sdc.be.model.tosca; + +import javax.annotation.Generated; + +import org.junit.Assert; +import org.junit.Test; + + +public class ToscaTypeTest { + + private ToscaType createTestSubject() { + return ToscaType.BOOLEAN; + } + + + @Test + public void testFromYamlTypeName() throws Exception { + String typeName = ""; + ToscaType result; + + // test 1 + typeName = null; + result = ToscaType.fromYamlTypeName(typeName); + Assert.assertEquals(null, result); + + // test 2 + typeName = ""; + result = ToscaType.fromYamlTypeName(typeName); + Assert.assertEquals(null, result); + } + + + @Test + public void testIsValidValue() throws Exception { + ToscaType testSubject; + String value = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isValidValue(value); + } + + + + @Test + public void testConvert() throws Exception { + ToscaType testSubject; + String value = ""; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.convert(value); + } + + + @Test + public void testToString() throws Exception { + ToscaType testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java new file mode 100644 index 0000000000..8b259f7cb8 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java @@ -0,0 +1,133 @@ +package org.openecomp.sdc.be.model.tosca.version; + +import java.util.StringTokenizer; + +import javax.annotation.Generated; + +import org.junit.Test; + +public class VersionTest { + + private Version createTestSubject() { + return new Version(""); + } + + + @Test + public void testHashCode() throws Exception { + Version testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + Version testSubject; + Object other = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(other); + } + + + @Test + public void testCompareTo() throws Exception { + Version testSubject; + Version otherVersion = null; + int result; + + // default test + testSubject = createTestSubject(); + } + + + @Test + public void testGetMajorVersion() throws Exception { + Version testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMajorVersion(); + } + + + @Test + public void testGetMinorVersion() throws Exception { + Version testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMinorVersion(); + } + + + @Test + public void testGetIncrementalVersion() throws Exception { + Version testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getIncrementalVersion(); + } + + + @Test + public void testGetBuildNumber() throws Exception { + Version testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getBuildNumber(); + } + + + @Test + public void testGetQualifier() throws Exception { + Version testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getQualifier(); + } + + + @Test + public void testParseVersion() throws Exception { + Version testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.parseVersion(version); + } + + + @Test + public void testGetNextIntegerToken() throws Exception { + Integer result; + + // default test + } + + + @Test + public void testToString() throws Exception { + Version testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } +}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java index a01c761072..bb4c569f8a 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java @@ -3,6 +3,8 @@ package org.openecomp.sdc.common.rest.api; import javax.annotation.Generated; import org.junit.Test; +import java.util.*; +import org.junit.Assert; public class RestResponseAsByteArrayTest { diff --git a/onboarding/pom.xml b/onboarding/pom.xml index f0a2edcd75..0582c764af 100644 --- a/onboarding/pom.xml +++ b/onboarding/pom.xml @@ -95,7 +95,7 @@ <woodstox.version>4.4.1</woodstox.version> <ws.rs.version>2.0.1</ws.rs.version> <!-- New version 2.0.1 to fix blackduck violation Failing with comiplation issues--> <zusammen.version>0.2.0</zusammen.version> - <zusammen-state-store.version>0.2.1</zusammen-state-store.version> + <zusammen-state-store.version>0.2.2</zusammen-state-store.version> <skipSA>true</skipSA> <pmd.version>5.8.1</pmd.version> <build.tools.version>${project.version}</build.tools.version> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java index 6bfd50b401..80160bc202 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java @@ -24,14 +24,15 @@ import java.io.Serializable; public enum ActivityType implements Serializable { - CREATE_NEW("Create New"), - CHECKOUT("Check Out"), - CHECKIN("Check In"), - UPLOAD_HEAT("Upload Heat"), + CREATE_NEW("Create New"), + CHECKOUT("Check Out"), + UNDO_CHECKOUT("Undo Check Out"), + CHECKIN("Check In"), + UPLOAD_HEAT("Upload Heat"), UPLOAD_MONITORING_FILE("Upload Monitoring File"), - SUBMIT("Submit"); + SUBMIT("Submit"); - // after collaboration will be added - this will be added: + // after collaboration will be added - this will be added: /* CREATE_NEW, COMMIT, @@ -39,14 +40,14 @@ public enum ActivityType implements Serializable { REMOVE_PERMISSION, */ - private String name; + private String name; - ActivityType(String name) { - this.name = name; - } + ActivityType(String name) { + this.name = name; + } - @Override - public String toString() { - return name; - } + @Override + public String toString() { + return name; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 4167785c02..9e4d3bf51b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -405,58 +405,101 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { List<VersionedVendorSoftwareProductInfo> vspList = Objects.requireNonNull( vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), user)); + int skippedCounter = 0; + final int vspListSizeBefore = vspList.size(); + + for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) { + final VspDetails vspDetails = versionVspInfo.getVspDetails(); + final String vspId = vspDetails.getId(); + final Version latestFinalVersion = + getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion(); + + if (latestFinalVersion.getStatus().equals(VersionStatus.Locked)) { + logger.info("Skipping processing VSP name [{}]/id [{}] due to status LOCKED", vspDetails + .getName(), + vspId); + skippedCounter++; + vspList.remove(versionVspInfo); + } + } + + logger.info("Removed {} VSPs out of {} from processing due to status LOCKED", skippedCounter, + vspListSizeBefore); int healingCounter = 0; int failedCounter = 0; + int totalCounter = 0; - try { - logger.info("Total number of VSPs: {}. Performing healing and " + - "resubmit for all non-Manual VSPs in submitted status.\n No need to pre-set oldVersion " + - "field", vspList.size()); - - for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) { + final int vspListSize = vspList.size(); + logger.info("Total number of VSPs: {}. Performing healing and " + + "resubmit for all non-Manual VSPs in submitted status.\n No need to pre-set oldVersion " + + "field", vspListSize); + for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) { + try { + totalCounter++; + final Version activeVersion = versionVspInfo.getVersionInfo().getActiveVersion(); final VspDetails vspDetails = versionVspInfo.getVspDetails(); final String vspId = vspDetails.getId(); final Version latestFinalVersion = getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion(); + final String vspName = vspDetails.getName(); + logger.info("VSP Name {}, VSP id [{}], Active Version {} , Active Version Status {}," + + "Latest Final Version {} , " + + "Latest Final Version Status {}", vspName, vspId, activeVersion + .toString(), + activeVersion.getStatus(), latestFinalVersion.toString(), + latestFinalVersion.getStatus()); + if (Objects.nonNull(latestFinalVersion) && (!OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod()))) { - reSubmit(vspDetails, user); + reSubmit(vspDetails, user, totalCounter, vspListSize); healingCounter++; } + } catch (Exception e) { + failedCounter++; } - - } catch (Exception e) { - logger.error("Failed during resubmitAll", e); - failedCounter++; - } finally { - logger.info("Finished attempted healing and resubmit for {} VSPs out " + - "of total # of {} submitted VSPs. Failure count during resubmitAll: {}", - healingCounter, vspList.size(), failedCounter); } + logger.info("Total VSPs processed {}. Completed running healing and resubmit for {} VSPs out" + + " " + + "of total # of {} submitted VSPs. Failures count during resubmitAll: {}", + totalCounter, healingCounter, vspListSize, failedCounter); + return Response.ok().build(); } - private void reSubmit(VspDetails vspDetails, String user) throws IOException { + private void reSubmit(VspDetails vspDetails, String user, int currentCount, int total) throws + Exception { final String vspId = vspDetails.getId(); - long startTime = System.currentTimeMillis(); - logger.info("Starting on healing and resubmit for VSP id[{}]", vspId); + final String vspName = vspDetails.getName(); + final Version versionBefore = vspDetails.getVersion(); + Version finalVersion; + + logger.info("Starting on healing and resubmit for VSP [{}], #{} out of total {}", vspName, + currentCount, total); vspDetails.setOldVersion("true"); - vendorSoftwareProductManager.healAndAdvanceFinalVersion(vspId, vspDetails, user); + try { + finalVersion = + vendorSoftwareProductManager.healAndAdvanceFinalVersion(vspId, vspDetails, user); - long endTime = System.currentTimeMillis(); - long seconds = (endTime - startTime) / 1000; + } catch (Exception e) { + + logger.error("Failed during resubmit, VSP [{}] , version before:{}, version after:{}, " + + "status after:{}, with exception:{}", + vspName, versionBefore.toString(), vspDetails.getVersion().toString(), vspDetails + .getVersion().getStatus().name(), e.getMessage()); + throw e; + } - logger.info("Completed healing and resubmit for VSP id [{}], duration: {} seconds", - vspId, seconds); + logger.info("Completed healing and resubmit for VSP [{}], version before:{}, version after:" + + " {}", vspName, versionBefore.toString(), finalVersion); } private static void printAuditForErrors(List<ErrorMessage> errorList, String vspId, diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java index edbf165ec1..e07a13c2e8 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java @@ -24,7 +24,6 @@ import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICE import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.sdc.activityLog.ActivityLogManager; -import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; @@ -41,17 +40,11 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseConstants; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao; -import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory; import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao; -import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory; import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao; -import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory; import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao; -import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory; import org.openecomp.sdc.vendorlicense.dao.LimitDao; -import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory; import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao; -import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; @@ -64,10 +57,8 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder; import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; -import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; import org.openecomp.sdc.versioning.VersioningManager; -import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.VersioningUtil; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionStatus; @@ -151,6 +142,12 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { Version newVersion = versioningManager .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user); + + ActivityLogEntity activityLogEntity = + new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor() + 1), + ActivityType.UNDO_CHECKOUT.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion); mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index 1891cddfd5..be1aaf08e5 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -256,6 +256,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa Version version = getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user) .getActiveVersion(); + + ActivityLogEntity activityLogEntity = + new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(version.getMajor() + 1), + ActivityType.UNDO_CHECKOUT.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + String preVspName = vspInfoDao .get(new VspDetails(vendorSoftwareProductId, version)).getName(); @@ -407,8 +413,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa getFeatureGroupMandatoryErrorBuilder(deploymentlocalFlavor.getModel()); errorCodeList.add(deploymentFlavorErrorBuilder); } - List<ComponentComputeAssociation> componetComputeAssociations = new ArrayList<>(); - componetComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations(); + List<ComponentComputeAssociation> componetComputeAssociations = + deploymentlocalFlavor.getComponentComputeAssociations(); if (CollectionUtils.isEmpty(componetComputeAssociations)) { CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(CompositionEntityType.deployment, deploymentFlavor diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java index fa08ba49a8..deb5ffde35 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java @@ -60,13 +60,12 @@ public class ZusammenConnectorImpl implements ZusammenConnector { @Override public Collection<Item> listItems(SessionContext context) { - Response<Collection<Item>> response = - itemAdaptorFactory.createInterface(context).list(context); - if (response.isSuccessful()) { - return response.getValue(); - } else { - return null; + Response<Collection<Item>> response = itemAdaptorFactory.createInterface(context).list(context); + if (!response.isSuccessful()) { + throw new RuntimeException( + "Failed to list Items. message:" + response.getReturnCode().toString()); } + return response.getValue(); } @Override @@ -76,7 +75,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { return response.getValue(); } else { throw new RuntimeException( - "failed to create Item. message:" + response.getReturnCode().getMessage()); + "failed to create Item. message:" + response.getReturnCode().toString()); } } @@ -87,7 +86,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { if (!response.isSuccessful()) { throw new RuntimeException("failed to update Item . ItemId:" + itemId + "" + - " message:" + response.getReturnCode().getMessage()); + " message:" + response.getReturnCode().toString()); } } @@ -98,7 +97,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { if (!versions.isSuccessful()) { logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ITEM_VERSION_RETRIEVAL, versions .getReturnCode()); - throw new RuntimeException(versions.getReturnCode().getMessage()); // TODO: 3/26/2017 + throw new RuntimeException(versions.getReturnCode().toString()); // TODO: 3/26/2017 } return versions.getValue(); } @@ -114,7 +113,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { throw new RuntimeException("failed to create Item Version. ItemId:" + itemId + " based " + "on:" + baseVersionId + " message:" + response - .getReturnCode().getMessage()); + .getReturnCode().toString()); } } @@ -126,7 +125,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { if (!response.isSuccessful()) { throw new RuntimeException( String.format("failed to create Item Version. ItemId: %s, versionId: %s, message: %s", - itemId.getValue(), versionId.getValue(), response.getReturnCode().getMessage())); + itemId.getValue(), versionId.getValue(), response.getReturnCode().toString())); } } @@ -151,7 +150,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { throw new RuntimeException(String.format( "failed to reset Item Version back to %s. ItemId: %s, versionId: %s, message: %s", changeRef, itemId.getValue(), versionId.getValue(), - response.getReturnCode().getMessage())); + response.getReturnCode().toString())); } } @@ -166,7 +165,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { } else { logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ELEMENT_GET_BY_PROPERTY, elementInfosResponse.getReturnCode()); - throw new RuntimeException(elementInfosResponse.getReturnCode().getMessage()); + throw new RuntimeException(elementInfosResponse.getReturnCode().toString()); } } @@ -187,11 +186,15 @@ public class ZusammenConnectorImpl implements ZusammenConnector { @Override public Optional<Element> saveElement(SessionContext context, ElementContext elementContext, ZusammenElement element, String message) { - Response<Element> saveResponse = elementAdaptorFactory.createInterface(context) + Response<Element> response = elementAdaptorFactory.createInterface(context) .save(context, elementContext, element, message); - return saveResponse.isSuccessful() - ? Optional.of(saveResponse.getValue()) - : Optional.empty(); // TODO: 3/21/2017 error? + if (!response.isSuccessful()) { + throw new RuntimeException(String + .format("Failed to save element %s. ItemId: %s, versionId: %s, message: %s", + element.getElementId().getValue(), elementContext.getItemId().getValue(), + elementContext.getVersionId().getValue(), response.getReturnCode().toString())); + } + return Optional.of(response.getValue()); } private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java index 76b0a900c1..ac103c0fbf 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java @@ -11,17 +11,20 @@ import org.openecomp.core.zusammen.plugin.dao.ElementRepository; import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory; import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity; +import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; +import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getCollaborationElement; import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName; public class ElementCollaborationStore { + private static final String SUB_ELEMENT_NOT_EXIST_ERROR_MSG = + "List sub elements error: item %s, version %s - " + + "element %s, which appears as sub element of element %s, does not exist"; + public Collection<CollaborationElement> listElements(SessionContext context, ElementContext elementContext, Id elementId) { @@ -33,14 +36,26 @@ public class ElementCollaborationStore { } ElementRepository elementRepository = getElementRepository(context); - return elementRepository.get(context, elementEntityContext, new ElementEntity(elementId)) - .map(ElementEntity::getSubElementIds).orElse(new HashSet<>()).stream() - .map(subElementId -> elementRepository - .get(context, elementEntityContext, new ElementEntity(subElementId)).get()) - .filter(Objects::nonNull) - .map(subElement -> ZusammenPluginUtil - .getCollaborationElement(elementEntityContext, subElement)) - .collect(Collectors.toList()); + String elementIdValue = elementId.getValue(); + String versionIdValue = elementContext.getChangeRef() == null + ? elementContext.getVersionId().getValue() + : elementContext.getChangeRef(); + Collection<CollaborationElement> subElements = new ArrayList<>(); + + Optional<ElementEntity> element = + elementRepository.get(context, elementEntityContext, new ElementEntity(elementId)); + if (element.isPresent() && element.get().getSubElementIds() != null) { + for (Id subElementId : element.get().getSubElementIds()) { + ElementEntity subElement = + elementRepository.get(context, elementEntityContext, new ElementEntity(subElementId)) + .orElseThrow( + () -> new IllegalStateException(String.format(SUB_ELEMENT_NOT_EXIST_ERROR_MSG, + elementContext.getItemId().getValue(), versionIdValue, + subElementId.getValue(), elementIdValue))); + subElements.add(getCollaborationElement(elementEntityContext, subElement)); + } + } + return subElements; } public CollaborationElement getElement(SessionContext context, ElementContext elementContext, @@ -49,8 +64,7 @@ public class ElementCollaborationStore { new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext); return getElementRepository(context) .get(context, elementEntityContext, new ElementEntity(elementId)) - .map(elementEntity -> ZusammenPluginUtil - .getCollaborationElement(elementEntityContext, elementEntity)) + .map(elementEntity -> getCollaborationElement(elementEntityContext, elementEntity)) .orElse(null); } @@ -78,7 +92,7 @@ public class ElementCollaborationStore { ZusammenPluginUtil.getElementEntity(element)); } - public boolean checkHealth(SessionContext sessionContext){ + public boolean checkHealth(SessionContext sessionContext) { return getElementRepository(sessionContext).checkHealth(sessionContext); } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java index ae23b6e8a9..db3066c313 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java @@ -14,7 +14,10 @@ import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory; import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity; import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; +import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID; import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName; public class VersionCollaborationStore { @@ -25,46 +28,74 @@ public class VersionCollaborationStore { throw new UnsupportedOperationException( "In this plugin implementation tag is supported only on versionId"); } - copyElements(context, getSpaceName(context, Space.PRIVATE), itemId, versionId, tag.getName()); + String space = getSpaceName(context, Space.PRIVATE); + ElementEntityContext targetContext = new ElementEntityContext(space, itemId, versionId); + targetContext.setChangeRef(tag.getName()); + copyElements(context, new ElementEntityContext(space, itemId, versionId), targetContext, + getElementRepository(context)); } public CollaborationMergeChange resetItemVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef) { ElementRepository elementRepository = getElementRepository(context); - ElementEntityContext elementContext = - new ElementEntityContext(getSpaceName(context, Space.PRIVATE), itemId, versionId); - CollaborationMergeChange resetChange = new CollaborationMergeChange(); + String spaceName = getSpaceName(context, Space.PRIVATE); + ElementEntityContext versionContext = new ElementEntityContext(spaceName, itemId, versionId); - Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext); - versionElements.stream() - .map(elementEntity -> - convertElementEntityToElementChange(elementEntity, elementContext, Action.DELETE)) - .forEach(resetChange.getChangedElements()::add); + Collection<ElementEntity> deletedElements = + deleteElements(context, versionContext, elementRepository); - elementContext.setChangeRef(changeRef); - Collection<ElementEntity> changeRefElements = elementRepository.list(context, elementContext); - changeRefElements.stream() - .map(elementEntity -> - convertElementEntityToElementChange(elementEntity, elementContext, Action.CREATE)) - .forEach(resetChange.getChangedElements()::add); + ElementEntityContext changeRefContext = new ElementEntityContext(spaceName, itemId, versionId); + changeRefContext.setChangeRef(changeRef); - return resetChange; // TODO: 4/19/2017 version change... + Collection<ElementEntity> createdElements = + copyElements(context, changeRefContext, versionContext, elementRepository); + + // TODO: 4/19/2017 version change... + return createCollaborationMergeChange(versionContext, deletedElements, createdElements); } - private void copyElements(SessionContext context, String space, Id itemId, Id sourceVersionId, - String targetTag) { - ElementRepository elementRepository = getElementRepository(context); - ElementEntityContext elementContext = new ElementEntityContext(space, itemId, sourceVersionId); + private Collection<ElementEntity> deleteElements(SessionContext context, + ElementEntityContext elementContext, + ElementRepository elementRepository) { + Collection<ElementEntity> elements = elementRepository.list(context, elementContext); + elements.forEach(element -> elementRepository + .delete(context, elementContext, new ElementEntity(element.getId()))); + elementRepository.delete(context, elementContext, new ElementEntity(ROOT_ELEMENTS_PARENT_ID)); + return elements; + } - Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext); + private Collection<ElementEntity> copyElements(SessionContext context, + ElementEntityContext sourceElementContext, + ElementEntityContext targetElementContext, + ElementRepository elementRepository) { + Collection<ElementEntity> elements = elementRepository.list(context, sourceElementContext); + elements.forEach(elementEntity -> + elementRepository.create(context, targetElementContext, elementEntity)); + return elements; + } + + private CollaborationMergeChange createCollaborationMergeChange( + ElementEntityContext versionContext, + Collection<ElementEntity> deletedElements, + Collection<ElementEntity> createdElements) { + CollaborationMergeChange mergeChange = new CollaborationMergeChange(); + mergeChange.getChangedElements().addAll( + convertToCollaborationElementChanges(versionContext, deletedElements, Action.DELETE)); + mergeChange.getChangedElements().addAll( + convertToCollaborationElementChanges(versionContext, createdElements, Action.CREATE)); + return mergeChange; + } - elementContext.setChangeRef(targetTag); - versionElements - .forEach(elementEntity -> elementRepository.create(context, elementContext, elementEntity)); + private List<CollaborationElementChange> convertToCollaborationElementChanges( + ElementEntityContext elementContext, Collection<ElementEntity> changedElements, + Action action) { + return changedElements.stream() + .map(element -> convertToCollaborationElementChange(element, elementContext, action)) + .collect(Collectors.toList()); } - private CollaborationElementChange convertElementEntityToElementChange( + private CollaborationElementChange convertToCollaborationElementChange( ElementEntity elementEntity, ElementEntityContext elementContext, Action action) { CollaborationElementChange elementChange = new CollaborationElementChange(); elementChange diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java index c19e8799d1..6cc1350444 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java @@ -16,12 +16,6 @@ package org.openecomp.core.zusammen.plugin.dao.impl; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Param; -import com.datastax.driver.mapping.annotations.Query; -import com.google.gson.reflect.TypeToken; import com.amdocs.zusammen.datatypes.Id; import com.amdocs.zusammen.datatypes.Namespace; import com.amdocs.zusammen.datatypes.SessionContext; @@ -29,6 +23,12 @@ import com.amdocs.zusammen.datatypes.item.Info; import com.amdocs.zusammen.datatypes.item.Relation; import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext; import com.amdocs.zusammen.utils.fileutils.json.JsonUtil; +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Row; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Param; +import com.datastax.driver.mapping.annotations.Query; +import com.google.gson.reflect.TypeToken; import org.openecomp.core.zusammen.plugin.dao.ElementRepository; import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity; @@ -38,22 +38,30 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; public class CassandraElementRepository implements ElementRepository { + private static final String VERSION_ELEMENT_NOT_EXIST_ERROR_MSG = + "List version elements error: " + + "element %s, which appears as an element of item %s version %s, does not exist"; + @Override public Collection<ElementEntity> list(SessionContext context, ElementEntityContext elementContext) { Set<String> elementIds = getVersionElementIds(context, elementContext); - return elementIds.stream() - .map(elementId -> get(context, elementContext, new ElementEntity(new Id(elementId))).get()) - .filter(Objects::nonNull) - .collect(Collectors.toList()); + Collection<ElementEntity> elements = new ArrayList<>(); + for (String elementId : elementIds) { + elements.add(get(context, elementContext, new ElementEntity(new Id(elementId))) + .orElseThrow( + () -> new IllegalStateException(String.format(VERSION_ELEMENT_NOT_EXIST_ERROR_MSG, + elementId, elementContext.getItemId().getValue(), + getVersionId(elementContext))))); + } + return elements; } @Override diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java index 16f9c60d7f..1c895ffc6f 100644 --- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java +++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java @@ -92,7 +92,7 @@ public class HealingManagerImpl implements HealingManager { MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode .DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL); - healingFailureMessages.add(e.getMessage()); + healingFailureMessages.add(e.getMessage() + " ,healer name :" + healerImplClassName); } return null; } diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java index 0bbe3f81e7..4a49d5391f 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java @@ -492,11 +492,12 @@ public class VersioningManagerImpl implements VersioningManager { versionInfoEntity.setActiveVersion(userCandidateVersion.getVersion()); versionInfoEntity.getViewableVersions().add(versionInfoEntity.getActiveVersion()); versionInfoEntity.setStatus(VersionStatus.Available); - versionInfoDao.update(versionInfoEntity); closeVersionOnEntity(versionInfoEntity.getEntityType(), versionInfoEntity.getEntityId(), versionInfoEntity.getActiveVersion()); + versionInfoDao.update(versionInfoEntity); + return versionInfoEntity.getActiveVersion(); } diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh index 42c347f4e8..78af19b0f9 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh +++ b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh @@ -22,5 +22,5 @@ else fi echo "Configuration file location: ${CONF_FILE_LOCATION}" -java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=${CONF_FILE_LOCATION} -jar openecomp-zusammen-tools-1.0-SNAPSHOT.jar org.openecomp.core.tools.main.ZusammenMainTool $1 $2 $3 $4 $5 $6 +java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=${CONF_FILE_LOCATION} -jar openecomp-zusammen-tools-1.2.0-SNAPSHOT.jar org.openecomp.core.tools.main.ZusammenMainTool $1 $2 $3 $4 $5 $6 STATUS="${?}" echo "${STATUS}" diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index 6426847cfc..ae3d3932ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -274,8 +274,9 @@ const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {softwarePr const props = { onVersionSwitching: (version, meta) => { + const screenToLoad = !currentComponentId ? screen : enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS; SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); - props.onNavigate({id: getActiveNavigationId(screen, currentComponentId), meta, version}); + props.onNavigate({id: getActiveNavigationId(screenToLoad), meta, version}); }, onToggle: (groups, itemIdToExpand) => groups.map(({items}) => SoftwareProductActionHelper.toggleNavigationItems(dispatch, {items, itemIdToExpand})), onNavigate: ({id, meta, version}) => { |