summaryrefslogtreecommitdiffstats
path: root/catalog-dao
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java5
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java3
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java3
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java54
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ModelDataTest.java70
6 files changed, 135 insertions, 2 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 619f88263c..1ebaeab54f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -51,6 +51,8 @@ public enum ActionStatus {
VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE, RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
// Category related
COMPONENT_MISSING_CATEGORY, COMPONENT_INVALID_CATEGORY, COMPONENT_ELEMENT_INVALID_NAME_FORMAT, COMPONENT_ELEMENT_INVALID_NAME_LENGTH, COMPONENT_CATEGORY_ALREADY_EXISTS, COMPONENT_CATEGORY_NOT_FOUND, COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY, COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY,
+ // Model related
+ MODEL_ALREADY_EXISTS,
// Service API URL
INVALID_SERVICE_API_URL,
// Property related
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
index c3c5e9f704..1c500e722d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
@@ -46,6 +46,7 @@ import org.openecomp.sdc.be.resources.data.HeatParameterValueData;
import org.openecomp.sdc.be.resources.data.InputValueData;
import org.openecomp.sdc.be.resources.data.InputsData;
import org.openecomp.sdc.be.resources.data.InterfaceData;
+import org.openecomp.sdc.be.resources.data.ModelData;
import org.openecomp.sdc.be.resources.data.OperationData;
import org.openecomp.sdc.be.resources.data.PolicyTypeData;
import org.openecomp.sdc.be.resources.data.ProductMetadataData;
@@ -255,6 +256,10 @@ public class GraphElementFactory {
break;
case AnnotationType:
element = clazz.cast(new AnnotationTypeData(properties));
+ break;
+ case Model:
+ element = clazz.cast(new ModelData(properties));
+ break;
default:
break;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
index 33a4391c9f..7fc954e0a8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
@@ -69,7 +69,8 @@ public enum EdgeLabelEnum {
INST_INTERFACES,
NODE_FILTER_TEMPLATE,
SUBSTITUTION_FILTER_TEMPLATE,
- DATA_TYPES;
+ DATA_TYPES,
+ MODEL_ELEMENT;
// @formatter:on
/**
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
index cc8c8bcd87..e9648a3579 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
@@ -92,7 +92,8 @@ public enum VertexTypeEnum {
NODE_FILTER_TEMPLATE ("NodeTemplateFilter", CINodeFilterDataDefinition.class),
SUBSTITUTION_FILTER_TEMPLATE ("substitution_mapping", SubstitutionFilterDataDefinition.class),
INST_INTERFACES ("InstInterfaces", MapInterfaceDataDefinition.class),
- DATA_TYPES ("data_types", DataTypeDataDefinition.class);
+ DATA_TYPES ("data_types", DataTypeDataDefinition.class),
+ MODEL ("model", null);
// @formatter:on
private final String name;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java
new file mode 100644
index 0000000000..026b1d7998
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ModelData.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.resources.data;
+
+import java.util.HashMap;
+import java.util.Map;
+import lombok.Getter;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+
+@Getter
+public class ModelData extends GraphNode {
+
+ private final String name;
+ private final String uniqueId;
+
+ public ModelData(final String name, final String uniqueId) {
+ super(NodeTypeEnum.Model);
+ this.name = name;
+ this.uniqueId = uniqueId;
+ }
+
+ public ModelData(final Map<String, Object> properties) {
+ super(NodeTypeEnum.Model);
+ name = (String) properties.get(GraphPropertiesDictionary.NAME.getProperty());
+ uniqueId = (String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ final Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.NAME, name);
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ return map;
+ }
+
+} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ModelDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ModelDataTest.java
new file mode 100644
index 0000000000..1fb34dd5e6
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ModelDataTest.java
@@ -0,0 +1,70 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.resources.data;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+
+@TestInstance(Lifecycle.PER_CLASS)
+class ModelDataTest {
+
+ private final String modelName = "ETSI-SDC-MODEL-TEST";
+ private final String modelId = UUID.randomUUID().toString();
+ ModelData modelData;
+
+ @BeforeAll
+ void initTestData() {
+ modelData = new ModelData(modelName, modelId);
+ }
+
+ @Test
+ void modelDataTest() {
+ assertThat(modelData).isNotNull();
+ assertThat(modelData.getUniqueId()).isEqualTo(modelId);
+ assertThat(modelData.getName()).isEqualTo(modelName);
+ }
+
+ @Test
+ void modelDataFromPropertiesMapTest() {
+ final Map<String, Object> properties = new HashMap();
+ properties.put("name", modelData.getName());
+ properties.put("uid", modelData.getUniqueId());
+ final ModelData modelDataFromPropertiesMap = new ModelData(properties);
+ assertThat(modelDataFromPropertiesMap).isNotNull();
+ assertThat(modelDataFromPropertiesMap.getUniqueId()).isEqualTo(modelId);
+ assertThat(modelDataFromPropertiesMap.getName()).isEqualTo(modelName);
+ }
+
+ @Test
+ void modelDataToGraphTest() {
+ final var result = modelData.toGraphMap();
+ assertThat(result).isNotNull();
+ assertThat(result).isNotEmpty();
+ assertThat(result.values()).contains(modelId);
+ assertThat(result.values()).contains(modelName);
+ }
+
+}