Create resource definition and Create Source Node Type definitions for Input, default, db, mdsal and component sources.
Change-Id: Icc49cb4be2e8700b61c281ff2d01c365321bb311
Issue-ID: CCSDK-487
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*\r
* @author Brinda Santh\r
*/\r
-class OrchestratorException : Exception {\r
+class BluePrintProcessorException : Exception {\r
var code: Int = 100\r
\r
constructor(message: String, cause: Throwable) : super(message, cause)\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import com.fasterxml.jackson.databind.JsonNode\r
import com.fasterxml.jackson.databind.node.NullNode\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
-import org.onap.ccsdk.apps.controllerblueprints.core.OrchestratorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition\r
val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
\r
val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)\r
- ?: throw OrchestratorException(String.format("failed to get artifat definition {} from the node template"\r
+ ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"\r
, artifactName))\r
val propertyAssignmentExpression = PropertyAssignmentService( context, this)\r
return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
--- /dev/null
+{
+ "description": "This is Custom Java Component Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "default" : "DYNAMIC",
+ "constraints": [
+ {
+ "validValues": [
+ "DYNAMIC"
+ ]
+ }
+ ]
+ },
+ "class-name": {
+ "required": true,
+ "type": "string",
+ "description" : "Fully Qualified Class Name ( <Package Name> + . + <Class Name> )"
+ },
+ "key-dependencies": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Database Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string",
+ "constraints": [
+ {
+ "validValues": [
+ "SQL",
+ "PLSQL"
+ ]
+ }
+ ]
+ },
+ "query": {
+ "required": true,
+ "type": "string"
+ },
+ "input-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Default Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "key": {
+ "required": false,
+ "type": "string"
+ },
+ "key-dependencies": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Input Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "key": {
+ "required": false,
+ "type": "string"
+ },
+ "key-dependencies": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Rest Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "default": "JSON",
+ "constraints": [
+ {
+ "validValues": [
+ "XML",
+ "JSON"
+ ]
+ }
+ ]
+ },
+ "url-path": {
+ "required": true,
+ "type": "string"
+ },
+ "path": {
+ "required": true,
+ "type": "string"
+ },
+ "expression-type": {
+ "required": false,
+ "type": "string",
+ "default": "JSON_PATH",
+ "constraints": [
+ {
+ "validValues": [
+ "JSON_PATH",
+ "JSON_POINTER"
+ ]
+ }
+ ]
+ },
+ "input-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "TOSCA base type for Resource Sources",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+}
\ No newline at end of file
{\r
"name": "bundle-id",\r
- "description": "name of the ",\r
+ "property" :{\r
+ "description": "name of the ",\r
+ "type": "string"\r
+ },\r
"resource-type": "ONAP",\r
"resource-path": "vnf/bundle-id",\r
"updated-by": "brindasanth@onap.com",\r
- "data-type": "String",\r
"tags": "bundle-id, brindasanth@onap.com",\r
- "source": {\r
+ "sources": {\r
"db": {\r
- "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "db-country": "country",\r
- "db-state": "state"\r
+ "type": "source-db",\r
+ "properties": {\r
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
+ "input-key-mapping": {\r
+ "profile_name": "profile_name"\r
+ },\r
+ "output-key-mapping": {\r
+ "db-country": "country",\r
+ "db-state": "state"\r
+ }\r
}\r
}\r
},\r
{\r
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
- "name": "v4-ip-type",\r
- "description": "To be provided",\r
- "updated-by": "brindasanth@onap.com",\r
- "resource-type": "ONAP",\r
- "resource-path": "vnf/v4-ip-type",\r
- "data-type": "string",\r
- "source": {\r
- "default": {\r
- \r
- }\r
- }\r
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
+ "name": "v4-ip-type",\r
+ "property" :{\r
+ "description": "name of the ",\r
+ "type": "string"\r
+ },\r
+ "updated-by": "brindasanth@onap.com",\r
+ "resource-type": "ONAP",\r
+ "resource-path": "vnf/v4-ip-type",\r
+ "sources": {\r
+ "default": {\r
+ "type": "source-default",\r
+ "properties": {\r
+ }\r
+ }\r
+ }\r
}
\ No newline at end of file
{\r
"name": "action-name",\r
+ "property" :{\r
+ "description": "name of the ",\r
+ "type": "string"\r
+ },\r
"resource-path": "action-name",\r
"resource-type": "ONAP",\r
- "description": "To be provided",\r
- "valid-values": null,\r
- "sample-value": null,\r
"updated-by": "brindasanth@onap.com",\r
"tags": null,\r
- "default": null,\r
- "data-type": "string",\r
- "source": {\r
+ "sources": {\r
"input": {\r
- "key": "action-name"\r
+ "type": "source-input",\r
+ "properties": {\r
+ "key": "action-name"\r
+ }\r
}\r
}\r
}
\ No newline at end of file
{\r
- "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com",\r
+ "tags": "oam-local-ipv4-address",\r
"name": "oam-local-ipv4-address",\r
- "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",\r
- "updated-by": "st1848@att.com",\r
+ "property" :{\r
+ "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",\r
+ "type": "string"\r
+ },\r
+ "updated-by": "brindasanth@onap.com",\r
"resource-type": "ATT",\r
"resource-path": "vnf/oam-local-ipv4-address",\r
- "data-type": "string",\r
- "source": {\r
+ "sources": {\r
"mdsal": {\r
- "base": "sdnc-gc",\r
- "type": "JSON",\r
- "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",\r
- "path": "/v4-assigned-ip-list/0/v4-ip-prefix",\r
- "input-key-mapping": {\r
- "service-instance-id": "service-instance-id",\r
- "network-role": "network-role",\r
- "v4-ip-type": "v4-ip-type",\r
- "vm-type": "vm-type"\r
- },\r
- "output-key-mapping": {\r
- "oam-local-ipv4-address": "v4-ip-prefix"\r
+ "type": "source-rest",\r
+ "properties": {\r
+ "type": "JSON",\r
+ "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",\r
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",\r
+ "input-key-mapping": {\r
+ "service-instance-id": "service-instance-id",\r
+ "network-role": "network-role",\r
+ "v4-ip-type": "v4-ip-type",\r
+ "vm-type": "vm-type"\r
+ },\r
+ "output-key-mapping": {\r
+ "oam-local-ipv4-address": "v4-ip-prefix"\r
+ },\r
+ "key-dependency": [\r
+ "service-instance-id",\r
+ "network-role",\r
+ "v4-ip-type",\r
+ "vm-type"\r
+ ]\r
}\r
}\r
- },\r
- "candidate-dependency": {\r
- "mdsal": {\r
- "names": [\r
- "service-instance-id",\r
- "network-role",\r
- "v4-ip-type",\r
- "vm-type"\r
- ]\r
- }\r
}\r
}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict;\r
-\r
-import com.fasterxml.jackson.annotation.JsonFormat;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-/**\r
- * ResourceAssignment.java Purpose: Provide ResourceAssignment Custom TOSCO Model POJO bean.\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-public class ResourceAssignment {\r
- @JsonProperty(value = "name", required = true)\r
- private String name;\r
-\r
- @JsonProperty(value = "property", required = true)\r
- private PropertyDefinition property;\r
-\r
- @JsonProperty("input-param")\r
- private Boolean inputParameter;\r
-\r
- @JsonProperty("dictionary-name")\r
- private String dictionaryName;\r
-\r
- @JsonProperty("dictionary-source")\r
- private String dictionarySource;\r
-\r
- @JsonProperty("dependencies")\r
- private List<String> dependencies;\r
-\r
- @JsonProperty("version")\r
- private int version;\r
-\r
- @JsonProperty("status")\r
- private String status;\r
-\r
- @JsonProperty("message")\r
- private String message;\r
-\r
- @JsonProperty("updated-date")\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
- private Date updatedDate;\r
-\r
- @JsonProperty("updated-by")\r
- private String updatedBy;\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder("[");\r
- builder.append("name = " + name);\r
- builder.append(", source = " + dictionarySource);\r
- if (dependencies != null) {\r
- builder.append(", dependencies = " + dependencies);\r
- }\r
- builder.append("]");\r
- return builder.toString();\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public PropertyDefinition getProperty() {\r
- return property;\r
- }\r
-\r
- public void setProperty(PropertyDefinition property) {\r
- this.property = property;\r
- }\r
-\r
- public Boolean getInputParameter() {\r
- return inputParameter;\r
- }\r
-\r
- public void setInputParameter(Boolean inputParameter) {\r
- this.inputParameter = inputParameter;\r
- }\r
-\r
- public String getDictionaryName() {\r
- return dictionaryName;\r
- }\r
-\r
- public void setDictionaryName(String dictionaryName) {\r
- this.dictionaryName = dictionaryName;\r
- }\r
-\r
- public String getDictionarySource() {\r
- return dictionarySource;\r
- }\r
-\r
- public void setDictionarySource(String dictionarySource) {\r
- this.dictionarySource = dictionarySource;\r
- }\r
-\r
- public List<String> getDependencies() {\r
- return dependencies;\r
- }\r
-\r
- public void setDependencies(List<String> dependencies) {\r
- this.dependencies = dependencies;\r
- }\r
-\r
- public int getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(int version) {\r
- this.version = version;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public Date getUpdatedDate() {\r
- return updatedDate;\r
- }\r
-\r
- public void setUpdatedDate(Date updatedDate) {\r
- this.updatedDate = updatedDate;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
-}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* DictionaryDefinition.java Purpose:\r
* @author Brinda Santh\r
*/\r
+@Deprecated\r
public class DictionaryDefinition {\r
@JsonProperty(value = "name", required = true)\r
private String name;\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* DictionaryDependency\r
* @author Brinda Santh\r
*/\r
+@Deprecated\r
public class DictionaryDependency {\r
private List<String> names;\r
\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* SourceDb\r
* @author Brinda Santh\r
*/\r
+@Deprecated\r
public class SourceDb implements ResourceSource{\r
@JsonProperty(value = "base", required = true)\r
private String base;\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* SourceDefault\r
* @author Brinda Santh\r
*/\r
+@Deprecated\r
public class SourceDefault implements ResourceSource {\r
\r
private String key;\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import java.io.IOException;\r
import java.util.HashMap;\r
import java.util.Map;\r
-\r
+@Deprecated\r
public class SourceDeserializer extends JsonDeserializer<Map<String, ResourceSource>> {\r
\r
private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class);\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* SourceInput\r
* @author Brinda Santh\r
*/\r
+@Deprecated\r
public class SourceInput implements ResourceSource {\r
\r
private String key;\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
\r
import java.util.Map;\r
-\r
+@Deprecated\r
public class SourceMdsal implements ResourceSource {\r
\r
@JsonProperty(value = "base", required = true)\r
--- /dev/null
+/*
+ * Copyright © 2018 IBM.
+ *
+ * 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
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+
+interface ResourceAssignmentProcessor {
+
+ @Throws(BluePrintProcessorException::class)
+ fun validate(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun process(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun errorHandle(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun reTrigger(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2018 IBM.
+ *
+ * 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
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.annotation.JsonProperty
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DecryptionRule
+import java.io.Serializable
+import java.util.*
+
+open class ResourceDefinition{
+
+ @JsonProperty(value = "name", required = true)
+ lateinit var name: String
+
+ @JsonProperty(value = "property", required = true)
+ lateinit var property : PropertyDefinition
+
+ var tags: String? = null
+
+ @JsonProperty(value = "updated-by")
+ lateinit var updatedBy: String
+
+ @JsonProperty(value = "resource-type", required = true)
+ lateinit var resourceType: String
+
+ @JsonProperty(value = "resource-path", required = true)
+ lateinit var resourcePath: String
+
+ @JsonProperty(value = "sources", required = true)
+ var sources: MutableMap<String, NodeTemplate>? = null
+
+ @JsonProperty("decryption-rules")
+ var decryptionRules: MutableList<DecryptionRule>? = null
+
+}
+
+open class ResourceAssignment {
+
+ @JsonProperty(value = "name", required = true)
+ lateinit var name: String
+
+ @JsonProperty(value = "property")
+ var property: PropertyDefinition? = null
+
+ @JsonProperty("input-param")
+ var inputParameter: Boolean = false
+
+ @JsonProperty("dictionary-name")
+ var dictionaryName: String? = null
+
+ @JsonProperty("dictionary-source")
+ var dictionarySource: String? = null
+
+ @JsonProperty("dependencies")
+ var dependencies: MutableList<String>? = null
+
+ @JsonProperty("version")
+ var version: Int = 0
+
+ @JsonProperty("status")
+ var status: String? = null
+
+ @JsonProperty("message")
+ var message: String? = null
+
+ @JsonProperty("updated-date")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ var updatedDate: Date? = null
+
+ @JsonProperty("updated-by")
+ var updatedBy: String? = null
+}
+
+/**
+ * Interface for Source Definitions (ex Input Source,
+ * Default Source, Database Source, Rest Sources, etc)
+ */
+interface ResourceSource : Serializable
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;\r
\r
import org.junit.Assert;\r
-import org.junit.Before;\r
import org.junit.Test;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
-public class DictionaryDefinitionTest {\r
- private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class);\r
+public class ResourceDefinitionTest {\r
+ private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class);\r
String basePath = "load/resource_dictionary";\r
\r
- @Before\r
- public void setup(){\r
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);\r
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);\r
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);\r
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);\r
- }\r
-\r
@Test\r
public void testDictionaryDefinitionInputSource(){\r
\r
String fileName = basePath + "/input-source.json";\r
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
- Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition);\r
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);\r
}\r
\r
@Test\r
public void testDictionaryDefinitionDefaultSource(){\r
\r
String fileName = basePath + "/default-source.json";\r
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
- Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition);\r
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);\r
}\r
\r
@Test\r
public void testDictionaryDefinitionDBSource(){\r
\r
String fileName = basePath + "/db-source.json";\r
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
- Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition);\r
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);\r
}\r
\r
@Test\r
public void testDictionaryDefinitionMDSALSource(){\r
String fileName = basePath + "/mdsal-source.json";\r
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
- Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition);\r
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);\r
}\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import org.junit.Assert;\r
import org.junit.Test;\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
@Test\r
public void validateSingleInputSource() {\r
try {\r
- log.info(" **************** Validating validateSingleSource *****************");\r
ResourceAssignment resourceAssignment = new ResourceAssignment();\r
resourceAssignment.setName("test-input-key");\r
+ PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+ propertyDefinition.setType("string");\r
+ resourceAssignment.setProperty(propertyDefinition);\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
@Test\r
public void validateSingleDbSource() {\r
try {\r
- log.info(" **************** Validating validateSingleSource *****************");\r
ResourceAssignment resourceAssignment = new ResourceAssignment();\r
resourceAssignment.setName("test-db-key");\r
+ PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+ propertyDefinition.setType("string");\r
+ resourceAssignment.setProperty(propertyDefinition);\r
+\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
public void testSourceDefault() {\r
ResourceAssignment resourceAssignment = new ResourceAssignment();\r
resourceAssignment.setName("test-input-key");\r
+ PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+ propertyDefinition.setType("string");\r
+ resourceAssignment.setProperty(propertyDefinition);\r
\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
public void testSourceMdsal() {\r
ResourceAssignment resourceAssignment = new ResourceAssignment();\r
resourceAssignment.setName("test-input-key");\r
+ PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+ propertyDefinition.setType("string");\r
+ resourceAssignment.setProperty(propertyDefinition);\r
+\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r