aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/resource-dict
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-21 04:11:57 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-21 04:11:57 +0000
commit5285007a4e66bc18c69cef96aa32326a139d7642 (patch)
tree898fb3f81a7981c0dc2332dc5d42b87523d15162 /ms/controllerblueprints/modules/resource-dict
parenta3c9519d6aa7eb8e1f450a7d041047f2c0a5cc07 (diff)
Controller Blueprints Microservice
Define Controllerblueprint API DataType and Error definitions for Config model, Service Template, Model Type and Resource Dictionary Services Change-Id: I12d8d87292ec101601b0cfb7ba9670730973e318 Issue-ID: CCSDK-469 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict')
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json31
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json14
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json17
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json36
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java6
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java24
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java11
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java22
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java67
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java10
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java70
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java27
16 files changed, 313 insertions, 32 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
new file mode 100644
index 000000000..8b97cdeb7
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
@@ -0,0 +1,31 @@
+{
+ "name": "bundle-id",
+ "description": "name of the ",
+ "resource-type": "ONAP",
+ "resource-path": "vnf/bundle-id",
+ "updated-by": "brindasanth@onap.com",
+ "data-type": "String",
+ "tags": "bundle-id, brindasanth@onap.com",
+ "source": {
+ "db": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
+ }
+ },
+ "decryption-rules": [
+ {
+ "sources": [
+ "input"
+ ],
+ "path": "/.",
+ "rule": "LOCAL-Decrypt",
+ "decrypt-type": "AES128"
+ }
+ ]
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
new file mode 100644
index 000000000..ac23292ed
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
@@ -0,0 +1,14 @@
+{
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
+ "name": "v4-ip-type",
+ "description": "To be provided",
+ "updated-by": "brindasanth@onap.com",
+ "resource-type": "ONAP",
+ "resource-path": "vnf/v4-ip-type",
+ "data-type": "string",
+ "source": {
+ "default": {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
new file mode 100644
index 000000000..35736b663
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
@@ -0,0 +1,17 @@
+{
+ "name": "action-name",
+ "resource-path": "action-name",
+ "resource-type": "ONAP",
+ "description": "To be provided",
+ "valid-values": null,
+ "sample-value": null,
+ "updated-by": "brindasanth@onap.com",
+ "tags": null,
+ "default": null,
+ "data-type": "string",
+ "source": {
+ "input": {
+ "key": "action-name"
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
new file mode 100644
index 000000000..c103f94dc
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
@@ -0,0 +1,36 @@
+{
+ "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com",
+ "name": "oam-local-ipv4-address",
+ "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
+ "updated-by": "st1848@att.com",
+ "resource-type": "ATT",
+ "resource-path": "vnf/oam-local-ipv4-address",
+ "data-type": "string",
+ "source": {
+ "mdsal": {
+ "base": "sdnc-gc",
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "network-role": "network-role",
+ "v4-ip-type": "v4-ip-type",
+ "vm-type": "vm-type"
+ },
+ "output-key-mapping": {
+ "oam-local-ipv4-address": "v4-ip-prefix"
+ }
+ }
+ },
+ "candidate-dependency": {
+ "mdsal": {
+ "names": [
+ "service-instance-id",
+ "network-role",
+ "v4-ip-type",
+ "vm-type"
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
index 15576b906..f85e5ebcd 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
@@ -30,10 +30,10 @@ import java.util.List;
* @version 1.0
*/
public class ResourceAssignment {
-
+ @JsonProperty(value = "name", required = true)
private String name;
- @JsonProperty("property")
+ @JsonProperty(value = "property", required = true)
private PropertyDefinition property;
@JsonProperty("input-param")
@@ -58,7 +58,7 @@ public class ResourceAssignment {
private String message;
@JsonProperty("updated-date")
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private Date updatedDate;
@JsonProperty("updated-by")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
new file mode 100644
index 000000000..1af42c590
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;
+
+public class ResourceDictionaryConstants {
+ public static final String SOURCE_INPUT= "input";
+ public static final String SOURCE_DEFAULT = "default";
+ public static final String SOURCE_DB = "db";
+ public static final String SOURCE_MDSAL = "mdsal";
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
index 4dc9c89a1..7c2d926f0 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
@@ -17,7 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.List;
import java.util.Map;
@@ -29,6 +29,7 @@ import java.util.Map;
public class DictionaryDefinition {
@JsonProperty(value = "name", required = true)
private String name;
+
@JsonProperty(value = "description")
private String description;
@@ -39,6 +40,7 @@ public class DictionaryDefinition {
private String sampleValue;
private String tags;
+
@JsonProperty(value = "updated-by")
private String updatedBy;
@@ -58,7 +60,8 @@ public class DictionaryDefinition {
private Object defaultValue;
@JsonProperty(value = "source", required = true)
- private Map<String, JsonNode> source;
+ @JsonDeserialize(using = SourceDeserializer.class, keyAs = String.class, contentAs = ResourceSource.class)
+ private Map<String, ResourceSource> source;
@JsonProperty("candidate-dependency")
private Map<String, DictionaryDependency> dependency;
@@ -154,11 +157,11 @@ public class DictionaryDefinition {
this.defaultValue = defaultValue;
}
- public Map<String, JsonNode> getSource() {
+ public Map<String, ResourceSource> getSource() {
return source;
}
- public void setSource(Map<String, JsonNode> source) {
+ public void setSource(Map<String, ResourceSource> source) {
this.source = source;
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
new file mode 100644
index 000000000..735832cb1
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import java.io.Serializable;
+
+public interface ResourceSource extends Serializable {
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
index 23d404605..724d0224e 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
@@ -24,7 +24,7 @@ import java.util.Map;
* SourceDb
* @author Brinda Santh
*/
-public class SourceDb {
+public class SourceDb implements ResourceSource{
@JsonProperty(value = "base", required = true)
private String base;
@JsonProperty(value = "type", required = true)
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
index 0a4351cca..d165192e9 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
@@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceDefault
* @author Brinda Santh
*/
-public class SourceDefault {
+public class SourceDefault implements ResourceSource {
private String key;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
new file mode 100644
index 000000000..86476e1c2
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SourceDeserializer extends JsonDeserializer<Map<String, ResourceSource>> {
+
+ private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class);
+
+ private Class<?> keyAs;
+
+ private Class<?> contentAs;
+
+ private static Map<String, Class<? extends ResourceSource>> registry = new HashMap<String, Class<? extends ResourceSource>>();
+
+ public static void registerSource(String uniqueAttribute, Class<? extends ResourceSource> sourceClass) {
+ registry.put(uniqueAttribute, sourceClass);
+ }
+
+ @Override
+ public Map<String, ResourceSource> deserialize(JsonParser p, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ ObjectMapper mapper = (ObjectMapper) p.getCodec();
+ ObjectNode root = (ObjectNode) mapper.readTree(p);
+ Map<String, ResourceSource> sources = new HashMap();
+ root.fields().forEachRemaining((node) -> {
+ String key = node.getKey();
+ JsonNode valueNode = node.getValue();
+ Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing source key");
+ Preconditions.checkArgument(registry.containsKey(key), key +" source not registered");
+ if (StringUtils.isNotBlank(key) && registry.containsKey(key)) {
+ Class<? extends ResourceSource> sourceClass = registry.get(key);
+ ResourceSource resourceSource = JacksonUtils.readValue(valueNode.toString(), sourceClass);
+ sources.put(key, resourceSource);
+ }
+ });
+ return sources;
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
index 82cb769da..87184f223 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
@@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceInput
* @author Brinda Santh
*/
-public class SourceInput {
+public class SourceInput implements ResourceSource {
private String key;
@@ -33,5 +33,4 @@ public class SourceInput {
}
-
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
index 9eb233e76..8a066e91a 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
-public class SourceMdsal {
+public class SourceMdsal implements ResourceSource {
@JsonProperty(value = "base", required = true)
private String base;
@@ -93,5 +93,4 @@ public class SourceMdsal {
}
-
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
index 9d51d8213..4f9467f05 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
@@ -16,15 +16,15 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;
-import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +63,7 @@ public class ResourceDictionaryUtils {
// Overwrite the Property Definitions from Dictionary
setProperty(resourceAssignment, dictionaryDefinition);
- Map<String, JsonNode> dictionarySource = dictionaryDefinition.getSource();
+ Map<String, ResourceSource> dictionarySource = dictionaryDefinition.getSource();
Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();
if (MapUtils.isNotEmpty(dictionarySource)) {
@@ -82,7 +82,7 @@ public class ResourceDictionaryUtils {
}
}
} else {
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT);
+ resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT);
}
log.info("auto map resourceAssignment : {}", resourceAssignment);
}
@@ -98,7 +98,7 @@ public class ResourceDictionaryUtils {
}
}
- private static String findFirstSource(Map<String, JsonNode> dictionarySource) {
+ private static String findFirstSource(Map<String, ResourceSource> dictionarySource) {
String source = null;
if (MapUtils.isNotEmpty(dictionarySource)) {
source = dictionarySource.keySet().stream().findFirst().get();
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java
new file mode 100644
index 000000000..851ba1256
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DictionaryDefinitionTest {
+ private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class);
+ String basePath = "load/resource_dictionary";
+
+ @Before
+ public void setup(){
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);
+ }
+
+ @Test
+ public void testDictionaryDefinitionInputSource(){
+
+ String fileName = basePath + "/input-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionDefaultSource(){
+
+ String fileName = basePath + "/default-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionDBSource(){
+
+ String fileName = basePath + "/db-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionMDSALSource(){
+ String fileName = basePath + "/mdsal-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition);
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
index 22b01c4a8..0c9a1c5d8 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
@@ -17,13 +17,11 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;
-import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Assert;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
import org.slf4j.Logger;
@@ -45,9 +43,9 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceInput sourceInput = new SourceInput();
- source.put(ConfigModelConstant.SOURCE_INPUT, JacksonUtils.jsonNodeFromObject(sourceInput));
+ source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput);
dictionaryDefinition.setSource(source);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
@@ -72,15 +70,16 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceDb sourceDb = new SourceDb();
- source.put(ConfigModelConstant.SOURCE_DB, JacksonUtils.jsonNodeFromObject(sourceDb));
+ sourceDb.setBase("sdnc_connection");
+ source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyDb = new DictionaryDependency();
dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));
- dependency.put(ConfigModelConstant.SOURCE_DB, dependencyDb);
+ dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb);
dictionaryDefinition.setDependency(dependency);
DecryptionRule decryptionRule = new DecryptionRule();
@@ -115,15 +114,15 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceDefault sourceDefault = new SourceDefault();
- source.put(ConfigModelConstant.SOURCE_DEFAULT, JacksonUtils.jsonNodeFromObject(sourceDefault));
+ source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyDefault = new DictionaryDependency();
dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ConfigModelConstant.SOURCE_DEFAULT, dependencyDefault);
+ dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault);
dictionaryDefinition.setDependency(dependency);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
@@ -143,15 +142,15 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceMdsal sourceMdsal = new SourceMdsal();
- source.put(ConfigModelConstant.SOURCE_MDSAL, JacksonUtils.jsonNodeFromObject(sourceMdsal));
+ source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyMdsal = new DictionaryDependency();
dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ConfigModelConstant.SOURCE_MDSAL, dependencyMdsal);
+ dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal);
dictionaryDefinition.setDependency(dependency);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);