diff options
Diffstat (limited to 'ms')
15 files changed, 414 insertions, 62 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt index 4836cd24..6fed53e6 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -21,22 +22,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode import io.swagger.annotations.ApiModelProperty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-/*
- * 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.
- */
-
/**
* BlueprintProcessorData
* @author Brinda Santh
@@ -49,7 +34,7 @@ open class ResourceResolutionInput { @get:ApiModelProperty(required=true)
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required=true)
- lateinit var resourceAssignments: List<ResourceAssignment>
+ lateinit var resourceAssignments: MutableList<ResourceAssignment>
@get:ApiModelProperty(required=true )
lateinit var payload: ObjectNode
}
@@ -62,7 +47,7 @@ open class ResourceResolutionOutput { @get:ApiModelProperty(required=true)
lateinit var status: Status
@get:ApiModelProperty(required=true)
- lateinit var resourceAssignments: List<ResourceAssignment>
+ lateinit var resourceAssignments: MutableList<ResourceAssignment>
}
open class ExecutionServiceInput {
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt index f42613cc..feacbcab 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -18,12 +19,15 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.stereotype.Service
+/**
+ * ComponentNode
+ *
+ * @author Brinda Santh
+ */
interface ComponentNode {
@Throws(BluePrintProcessorException::class)
@@ -39,8 +43,13 @@ interface ComponentNode { fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
}
+/**
+ * ComponentNodeFactory
+ *
+ * @author Brinda Santh
+ */
@Service
-class ComponentNodeFactory : ApplicationContextAware {
+open class ComponentNodeFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt index 8104c104..01a110d5 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -18,14 +19,17 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.stereotype.Service
+/**
+ * ResourceAssignmentProcessorFactory
+ *
+ * @author Brinda Santh
+ */
@Service
-class ResourceAssignmentProcessorFactory : ApplicationContextAware {
+open class ResourceAssignmentProcessorFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt new file mode 100644 index 00000000..427dc873 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt @@ -0,0 +1,45 @@ +/* + * 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.blueprintsprocessor.services.execution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode +import org.springframework.stereotype.Component + +/** + * JavaScriptExecuteComponent + * + * @author Brinda Santh + */ +@Component("component-javascript-executor") +class JavaScriptExecuteComponent : ComponentNode { + + override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt new file mode 100644 index 00000000..59be1f51 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt @@ -0,0 +1,44 @@ +/* + * 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.blueprintsprocessor.services.execution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode +import org.springframework.stereotype.Component + +/** + * PythonExecuteComponent + * + * @author Brinda Santh + */ +@Component("component-python-executor") +class PythonExecuteComponent : ComponentNode { + override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt index 14ab7842..d442c96b 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -16,9 +17,14 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
import org.springframework.stereotype.Service
/**
@@ -28,7 +34,7 @@ import org.springframework.stereotype.Service */
@Service
-class ResourceResolutionService {
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
val resourceResolutionOutput = ResourceResolutionOutput()
@@ -36,6 +42,10 @@ class ResourceResolutionService { resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
+ val context = hashMapOf<String, Any>()
+
+ process(resourceResolutionOutput.resourceAssignments, context)
+
val status = Status()
status.code = 200
status.message = "Success"
@@ -43,4 +53,28 @@ class ResourceResolutionService { return resourceResolutionOutput
}
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start"}
+ .map { resourceAssignment ->
+ val dictionarySource = resourceAssignment.dictionarySource
+ val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)
+ val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)
+ ?: throw BlueprintProcessorException(format("failed to get resource processor for instance name({}) " +
+ "for resource assignment({})", processorInstanceName, resourceAssignment.name))
+ try {
+ resourceAssignmentProcessor.validate(resourceAssignment, context)
+ resourceAssignmentProcessor.process(resourceAssignment, context)
+ } catch (e: Exception) {
+ resourceAssignmentProcessor.errorHandle(resourceAssignment, context)
+ throw BlueprintProcessorException(e)
+ }
+
+ }
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt index 396ca1d7..9580ca49 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -16,25 +17,33 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
+/**
+ * DefaultResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
@Service("resource-assignment-processor-default")
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
}
override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt index 9d0734e6..05f7d5cd 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -16,25 +17,33 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
+/**
+ * InputResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
@Service("resource-assignment-processor-input")
open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
}
override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt new file mode 100644 index 00000000..9d54cd46 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt @@ -0,0 +1,48 @@ +/* + * 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.blueprintsprocessor.services.resolution.processor + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * MDSALResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-mdsal") +open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor { + private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Re Trigger Resource Assignments") + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt new file mode 100644 index 00000000..4b11f580 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt @@ -0,0 +1,50 @@ +/* + * 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.blueprintsprocessor.services.resolution.processor + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * SdncResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-db") +open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor { + + private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Re Trigger Resource Assignments") + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java index 63359908..0768c609 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -24,6 +25,11 @@ import org.junit.Test; import org.junit.runner.RunWith;
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import org.slf4j.Logger;
@@ -42,7 +48,9 @@ import java.util.List; * @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = ResourceResolutionService.class)
+@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,
+ InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,
+ SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})
public class ResourceResolutionServiceTest {
private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);
@@ -57,8 +65,8 @@ public class ResourceResolutionServiceTest { String resourceResolutionInputContent = FileUtils.readFileToString(
new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());
- ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class );
- Assert.assertNotNull("failed to populate resourceResolutionInput request ",resourceResolutionInput);
+ ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);
+ Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);
String resourceAssignmentContent = FileUtils.readFileToString(
new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());
@@ -68,13 +76,13 @@ public class ResourceResolutionServiceTest { Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));
resourceResolutionInput.setResourceAssignments(batchResourceAssignment);
- ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
- Assert.assertNotNull("failed to populate input payload ",inputContent);
+ ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
+ Assert.assertNotNull("failed to populate input payload ", inputContent);
resourceResolutionInput.setPayload(inputContent);
log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));
ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);
- Assert.assertNotNull("failed to populate output",resourceResolutionOutput);
+ Assert.assertNotNull("failed to populate output", resourceResolutionOutput);
}
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json index 02ce68be..ddcf32ee 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json @@ -1,12 +1,22 @@ [
- {
- "name": "country",
- "input-param": true,
- "property": {
- "type": "string"
- },
- "dictionary-name": "country",
- "dictionary-source": "db",
- "dependencies": []
- }
+ {
+ "name": "country",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "country",
+ "dictionary-source": "db",
+ "dependencies": ["state"]
+ },
+ {
+ "name": "state",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "state",
+ "dictionary-source": "input",
+ "dependencies": []
+ }
]
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java index 4905e6eb..ead6a1b4 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java @@ -40,6 +40,13 @@ import org.springframework.stereotype.Component; @Component @ApplicationPath("/") public class JerseyConfiguration extends ResourceConfig { + + @Autowired + public JerseyConfiguration() { + register(RestServiceImpl.class); + property(ServletProperties.FILTER_FORWARD_ON_404, true); + } + /** * Builds the bean configuring Jackson for JSON serialization. */ @@ -53,10 +60,4 @@ public class JerseyConfiguration extends ResourceConfig { objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); return objectMapper; } - - @Autowired - public JerseyConfiguration() { - register(RestServiceImpl.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java new file mode 100644 index 00000000..26d2ef0e --- /dev/null +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 IBM. 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.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestExternalInterface { + private ExternalInterface externalInterface; + + @Before + public void setUp() { + externalInterface = new ExternalInterface(); + } + + @Test + public void testGetSetExternalInteraceId() { + externalInterface.setExternalInteraceId(1); + Integer expected = 1; + Assert.assertEquals(expected, externalInterface.getExternalInteraceId()); + } + + @Test + public void testGetSetSystem() { + externalInterface.setSystem("testSystem"); + Assert.assertEquals("testSystem", externalInterface.getSystem()); + } + + @Test + public void testGetSetParam() { + externalInterface.setParam("testParam"); + Assert.assertEquals("testParam", externalInterface.getParam()); + } + + @Test + public void testGetSetUrlSuffix() { + externalInterface.setUrlSuffix("testUrlSuffix"); + Assert.assertEquals("testUrlSuffix", externalInterface.getUrlSuffix()); + } + + @Test + public void testGetSetTimeStamp() throws ParseException { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp timeStamp = new Timestamp(time); + externalInterface.setCreatedTime(timeStamp); + Assert.assertEquals(timeStamp, externalInterface.getCreatedTime()); + } + + @Test + public void testGetSetCreatedBy() { + externalInterface.setCreatedBy("testUser"); + Assert.assertEquals("testUser", externalInterface.getCreatedBy()); + } + + @Test + public void testGetSetLastUpdatedTime() throws ParseException { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp timeStamp = new Timestamp(time); + externalInterface.setLastUpdatedTime(timeStamp); + Assert.assertEquals(timeStamp, externalInterface.getLastUpdatedTime()); + } + + @Test + public void testGetSetLastUpdatedBy() { + externalInterface.setLastUpdatedBy("testUser"); + Assert.assertEquals("testUser", externalInterface.getLastUpdatedBy()); + } +} diff --git a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java index bd18a986..00489655 100644 --- a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java +++ b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java @@ -16,7 +16,6 @@ package org.onap.ccsdk.apps.ms.vlantagapi.core;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
|