summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /bpmn/MSOCoreBPMN
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCoreBPMN')
-rw-r--r--bpmn/MSOCoreBPMN/pom.xml249
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BPMNLogger.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java)14
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BadInjectedFieldException.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java)2
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java)4
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/MissingInjectedFieldException.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java)2
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java)2
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java)2
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java89
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java)21
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/AllottedResource.java)249
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CloudFlavor.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CompareModelsResult.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResult.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ConfigResource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ConfigResource.java)23
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Configuration.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Configuration.java)140
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Customer.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Customer.java)68
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/HomingSolution.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/InventoryType.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/InventoryType.java)72
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java)273
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/License.java)202
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModelInfo.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModelInfo.java)192
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModuleResource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModuleResource.java)186
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/NetworkResource.java)154
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/OwningEntity.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/OwningEntity.java)8
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Project.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Project.java)8
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Request.java)129
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Resource.java)266
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceDecomposition.java)172
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceInstance.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceInstance.java)128
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceModelInfo.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceModelInfo.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceType.java)50
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/RollbackData.java47
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java)1068
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceInstance.java)223
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Subscriber.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Subscriber.java)136
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Vnf.java139
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java)341
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/internal/VariableNameExtractor.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/DecomposeJsonUtil.java)279
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonDecomposingException.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonDecomposingException.java)6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java)2114
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/xml/XmlTool.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java)140
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java285
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java443
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java320
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/TunnelConnect.java77
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java131
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java102
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java122
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java454
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java170
-rw-r--r--bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml32
-rw-r--r--bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java46
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java247
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java91
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java39
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java110
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java)39
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java63
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java47
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java)111
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java)166
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java39
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java)94
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java38
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java56
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java)116
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java)178
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java)94
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java)96
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java42
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java)41
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java36
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java50
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java)136
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java125
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java)122
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java41
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java)110
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java)23
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java170
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java38
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java)95
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java233
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java (renamed from bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java)53
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java82
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java106
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java271
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java39
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java38
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java42
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java39
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java36
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java50
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java83
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java41
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java65
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn156
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/application-dev.yaml5
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml47
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/AllottedResource.json6
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/ConfigResource.json6
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/NetworkResource.json6
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/SNIROExample.json2
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecomposition.json22
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json51
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/VnfResource.json12
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml4
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties22
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties21
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/request.json2
114 files changed, 6268 insertions, 7511 deletions
diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml
index 2f9d574ae1..fc686e503c 100644
--- a/bpmn/MSOCoreBPMN/pom.xml
+++ b/bpmn/MSOCoreBPMN/pom.xml
@@ -1,134 +1,111 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
<groupId>org.onap.so</groupId>
- <artifactId>bpmn</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>MSOCoreBPMN</artifactId>
- <packaging>jar</packaging>
+ <artifactId>bpmn</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>MSOCoreBPMN</artifactId>
+ <packaging>jar</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>test-compile</id>
- <phase>compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.0.2</version>
- <executions>
- <execution>
- <id>tests-jar</id>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>test-compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- </build>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.2</version>
+ <executions>
+ <execution>
+ <id>tests-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <dependencies>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-rest</artifactId>
- <classifier>classes</classifier>
- <!-- exclusion to use latest commons-fileupload -->
- <exclusions>
- <exclusion>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- latest commons-fileupload -->
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
+ <dependencies>
+ <!-- latest commons-fileupload -->
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
- <scope>provided</scope>
- </dependency>
- <!-- Connectors, in compile scope to include it in the war file -->
- <dependency>
- <groupId>org.camunda.connect</groupId>
- <artifactId>camunda-connect-connectors-all</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.camunda.template-engines</groupId>
- <artifactId>camunda-template-engines-freemarker</artifactId>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-spin</artifactId>
- </dependency>
- <!-- OPTIONAL: spin dataformats -->
- <!-- ...but required to support JsonProvider -->
- <dependency>
- <groupId>org.camunda.spin</groupId>
- <artifactId>camunda-spin-dataformat-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-connect</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>net.sf.saxon</groupId>
- <artifactId>Saxon-HE</artifactId>
- </dependency>
- <dependency>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.connect</groupId>
+ <artifactId>camunda-connect-connectors-all</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine-plugin-connect</artifactId>
+ <version>7.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine</artifactId>
+ <version>7.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>Saxon-HE</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.so</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20160212</version>
- </dependency>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20160212</version>
+ </dependency>
+ <dependency>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-core</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
@@ -139,27 +116,13 @@
<artifactId>json-schema-core</artifactId>
<version>1.2.4</version>
</dependency>
- <dependency>
- <groupId>org.xmlunit</groupId>
- <artifactId>xmlunit-core</artifactId>
- <version>2.5.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>status-control</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>mso-api-handler-common</artifactId>
- <version>${project.version}</version>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>3.8.0</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BPMNLogger.java
index 042cac454d..286526445c 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BPMNLogger.java
@@ -18,16 +18,18 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
-import org.openecomp.mso.logger.MsoLogger;
+import org.onap.so.logger.MsoLogger;
+import org.jboss.logging.MDC;
public class BPMNLogger {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, BPMNLogger.class);
- public static void debug (String isDebugLogEnabled, String LogText) {
- if (("true").equalsIgnoreCase(isDebugLogEnabled))
+ public static void debug (String isDebugLogEnabled, String LogText) {
msoLogger.debug(LogText);
- }
+ }
+
+
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BadInjectedFieldException.java
index 09015f0808..3002d0e70a 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BadInjectedFieldException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
public class BadInjectedFieldException extends RuntimeException {
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java
index 77e418d4c3..99157410d5 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.Expression;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.openecomp.mso.bpmn.core.internal.VariableNameExtractor;
+import org.onap.so.bpmn.core.internal.VariableNameExtractor;
/**
* Base class for service tasks.
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/MissingInjectedFieldException.java
index 7d019c5841..17a78d37b8 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/MissingInjectedFieldException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
/**
* A BadInjectedFieldException that indicates a required field is missing.
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java
index 58e85bf78d..6166071437 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
import org.camunda.bpm.engine.delegate.DelegateExecution;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
index f49712ee8b..9c80548490 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
import java.io.Serializable;
import java.util.HashMap;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java
new file mode 100644
index 0000000000..968c8c1590
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core;
+
+import java.util.Optional;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * Read the URN property value from the execution object or from the spring environment object
+ */
+@Component
+@Configuration
+public class UrnPropertiesReader {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,UrnPropertiesReader.class);
+ private static Environment environment;
+
+ @Autowired
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+ /**
+ * Return the URN property value
+ * if property is present in the execution object, return the same
+ * else search in the environment object. If found, add it to the execution object and return the value
+ * otherwise return null
+ *
+ * @param variableName URN property name
+ * @param execution The flow's execution instance.
+ * @return URN property value
+ */
+ public static String getVariable(String variableName, DelegateExecution execution) {
+ Object value = execution.getVariable(variableName);
+ if (value != null) {
+ LOGGER.trace("Retrieved value for the URN variable, " + variableName + ", from the execution object: " + String.valueOf(value));
+ return String.valueOf(value);
+ }
+ String variableValue = null;
+ if (environment != null && environment.getProperty(variableName) != null) {
+ variableValue = environment.getProperty(variableName);
+ LOGGER.trace("Retrieved value for the URN variable, " + variableName + ", from the environment variable: " + variableValue);
+ execution.setVariable(variableName, variableValue);
+ return variableValue;
+ }
+ return variableValue;
+ }
+
+ /**
+ * Return the URN property value from the environment object
+ * @param variableName URN property name
+ * @return URN property value
+ */
+
+ public static String getVariable(String variableName){
+ if (environment != null) {
+ return environment.getProperty(variableName);
+ } else {
+ return null;
+ }
+ }
+
+ public static String getVariable(String variableName, String defaultValue) {
+ return Optional.ofNullable(getVariable(variableName)).orElse(defaultValue);
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java
index b555563936..8551007795 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
import java.io.Serializable;
@@ -31,6 +31,7 @@ public class WorkflowException implements Serializable {
private final String processKey;
private final int errorCode;
private final String errorMessage;
+ private final String workStep;
/**
* Constructor
@@ -43,6 +44,15 @@ public class WorkflowException implements Serializable {
this.processKey = processKey;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
+ workStep = "*";
+ }
+
+ public WorkflowException(String processKey, int errorCode,
+ String errorMessage, String workStep) {
+ this.processKey = processKey;
+ this.errorCode = errorCode;
+ this.errorMessage = errorMessage;
+ this.workStep = workStep;
}
/**
@@ -65,6 +75,13 @@ public class WorkflowException implements Serializable {
public String getErrorMessage() {
return errorMessage;
}
+
+ /**
+ * Returns the error message.
+ */
+ public String getWorkStep() {
+ return workStep;
+ }
/**
* Returns a string representation of this object.
@@ -72,6 +89,6 @@ public class WorkflowException implements Serializable {
@Override
public String toString() {
return getClass().getSimpleName() + "[processKey=" + getProcessKey() + ",errorCode=" + getErrorCode()
- + ",errorMessage=" + getErrorMessage() + "]";
+ + ",errorMessage=" + getErrorMessage() + ",workStep=" + getWorkStep() + "]";
}
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/AllottedResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java
index 21943c047f..f143346cae 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/AllottedResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java
@@ -1,129 +1,122 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.util.UUID;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * Stores allotted-resource information
- *
- */
-@JsonRootName("allottedResource")
-public class AllottedResource extends Resource {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * set resourceType for this object
- */
- public AllottedResource(){
- resourceType = ResourceType.ALLOTTED_RESOURCE;
- setResourceId(UUID.randomUUID().toString());
- }
-
- /*
- * fields specific to Allotted Resource resource type
- */
- private String allottedResourceType;
- private String allottedResourceRole;
- private String providingServiceModelName;
- private String providingServiceModelInvariantUuid;
- private String providingServiceModelUuid;
- private String nfFunction;
- private String nfType;
- private String nfRole;
- private String nfNamingCode;
- private String orchestrationStatus;
- private TunnelConnect tunnelConnect;
-
- /*
- * GET and SET
- */
- public String getAllottedResourceType() {
- return allottedResourceType;
- }
- public void setAllottedResourceType(String allottedResourceType) {
- this.allottedResourceType = allottedResourceType;
- }
- public String getAllottedResourceRole() {
- return allottedResourceRole;
- }
- public void setAllottedResourceRole(String allottedResourceRole) {
- this.allottedResourceRole = allottedResourceRole;
- }
- public String getProvidingServiceModelName() {
- return providingServiceModelName;
- }
- public void setProvidingServiceModelName(String providingServiceModelName) {
- this.providingServiceModelName = providingServiceModelName;
- }
- public String getProvidingServiceModelInvariantUuid() {
- return providingServiceModelInvariantUuid;
- }
- public void setProvidingServiceModelInvariantUuid(
- String providingServiceModelInvariantUuid) {
- this.providingServiceModelInvariantUuid = providingServiceModelInvariantUuid;
- }
- public String getProvidingServiceModelUuid() {
- return providingServiceModelUuid;
- }
- public void setProvidingServiceModelUuid(String providingServiceModelUuid) {
- this.providingServiceModelUuid = providingServiceModelUuid;
- }
- public String getNfFunction() {
- return nfFunction;
- }
- public void setNfFunction(String nfFunction) {
- this.nfFunction = nfFunction;
- }
- public String getNfType() {
- return nfType;
- }
- public void setNfType(String nfType) {
- this.nfType = nfType;
- }
- public String getNfRole() {
- return nfRole;
- }
- public void setNfRole(String nfRole) {
- this.nfRole = nfRole;
- }
- public String getNfNamingCode() {
- return nfNamingCode;
- }
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
- public String getOrchestrationStatus() {
- return orchestrationStatus;
- }
- public void setOrchestrationStatus(String orchestrationStatus) {
- this.orchestrationStatus = orchestrationStatus;
- }
- public TunnelConnect getTunnelConnect() {
- return tunnelConnect;
- }
- public void setTunnelConnect(TunnelConnect tunnelConnect) {
- this.tunnelConnect = tunnelConnect;
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * Stores allotted-resource information
+ *
+ */
+@JsonRootName("allottedResource")
+public class AllottedResource extends Resource {
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * set resourceType for this object
+ */
+ public AllottedResource(){
+ resourceType = ResourceType.ALLOTTED_RESOURCE;
+ setResourceId(UUID.randomUUID().toString());
+ }
+
+ /*
+ * fields specific to Allotted Resource resource type
+ */
+ private String allottedResourceType;
+ private String allottedResourceRole;
+ private String providingServiceModelName;
+ private String providingServiceModelInvariantUuid;
+ private String providingServiceModelUuid;
+ private String nfFunction;
+ private String nfType;
+ private String nfRole;
+ private String nfNamingCode;
+ private String orchestrationStatus;
+
+ /*
+ * GET and SET
+ */
+ public String getAllottedResourceType() {
+ return allottedResourceType;
+ }
+ public void setAllottedResourceType(String allottedResourceType) {
+ this.allottedResourceType = allottedResourceType;
+ }
+ public String getAllottedResourceRole() {
+ return allottedResourceRole;
+ }
+ public void setAllottedResourceRole(String allottedResourceRole) {
+ this.allottedResourceRole = allottedResourceRole;
+ }
+ public String getProvidingServiceModelName() {
+ return providingServiceModelName;
+ }
+ public void setProvidingServiceModelName(String providingServiceModelName) {
+ this.providingServiceModelName = providingServiceModelName;
+ }
+ public String getProvidingServiceModelInvariantUuid() {
+ return providingServiceModelInvariantUuid;
+ }
+ public void setProvidingServiceModelInvariantUuid(
+ String providingServiceModelInvariantUuid) {
+ this.providingServiceModelInvariantUuid = providingServiceModelInvariantUuid;
+ }
+ public String getProvidingServiceModelUuid() {
+ return providingServiceModelUuid;
+ }
+ public void setProvidingServiceModelUuid(String providingServiceModelUuid) {
+ this.providingServiceModelUuid = providingServiceModelUuid;
+ }
+ public String getNfFunction() {
+ return nfFunction;
+ }
+ public void setNfFunction(String nfFunction) {
+ this.nfFunction = nfFunction;
+ }
+ public String getNfType() {
+ return nfType;
+ }
+ public void setNfType(String nfType) {
+ this.nfType = nfType;
+ }
+ public String getNfRole() {
+ return nfRole;
+ }
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+ public String getNfNamingCode() {
+ return nfNamingCode;
+ }
+ public void setNfNamingCode(String nfNamingCode) {
+ this.nfNamingCode = nfNamingCode;
+ }
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CloudFlavor.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java
index 100d70e1b2..7160a2f333 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CloudFlavor.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
@@ -28,7 +28,9 @@ import java.io.Serializable;
*
*/
public class CloudFlavor extends JsonWrapper implements Serializable {
- private String flavorLabel;
+
+ private static final long serialVersionUID = 8423934332773299577L;
+ private String flavorLabel;
private String flavor;
public CloudFlavor (String flavorLabel, String flavor){
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResult.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CompareModelsResult.java
index 740e89b9d7..bb50597c31 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResult.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CompareModelsResult.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
import java.util.List;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ConfigResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ConfigResource.java
index cd45309f28..1a8a1d83d9 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ConfigResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ConfigResource.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.util.UUID;
@@ -41,20 +41,5 @@ public class ConfigResource extends Resource {
/*
* fields specific to Config Resource resource type
*/
-
- /*
- * GET and SET
- */
-
- private String toscaNodeType;
-
- public String getToscaNodeType() {
- return toscaNodeType;
- }
-
- public void setToscaNodeType(String toscaNodeType) {
- this.toscaNodeType = toscaNodeType;
- }
-
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Configuration.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Configuration.java
index c80a1fddb4..815d85692e 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Configuration.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Configuration.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,71 +18,71 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * Stores configuration information and modeled off
- * of the AAI configuration object
- *
- */
-@JsonRootName("configuration")
-public class Configuration extends JsonWrapper implements Serializable{
-
- private static final long serialVersionUID = 1L;
-
- private String id;
- private String name;
- private String type;
- private String orchestrationStatus;
- private String tunnelBandwidth;
- private String vendorAllowedMaxBandwidth;
- private String resourceVersion;
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public String getOrchestrationStatus() {
- return orchestrationStatus;
- }
- public void setOrchestrationStatus(String orchestrationStatus) {
- this.orchestrationStatus = orchestrationStatus;
- }
- public String getTunnelBandwidth() {
- return tunnelBandwidth;
- }
- public void setTunnelBandwidth(String tunnelBandwidth) {
- this.tunnelBandwidth = tunnelBandwidth;
- }
- public String getVendorAllowedMaxBandwidth() {
- return vendorAllowedMaxBandwidth;
- }
- public void setVendorAllowedMaxBandwidth(String vendorAllowedMaxBandwidth) {
- this.vendorAllowedMaxBandwidth = vendorAllowedMaxBandwidth;
- }
- public String getResourceVersion() {
- return resourceVersion;
- }
- public void setResourceVersion(String resourceVersion) {
- this.resourceVersion = resourceVersion;
- }
-
-
-}
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * Stores configuration information and modeled off
+ * of the AAI configuration object
+ *
+ */
+@JsonRootName("configuration")
+public class Configuration extends JsonWrapper implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ private String id;
+ private String name;
+ private String type;
+ private String orchestrationStatus;
+ private String tunnelBandwidth;
+ private String vendorAllowedMaxBandwidth;
+ private String resourceVersion;
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+ public String getTunnelBandwidth() {
+ return tunnelBandwidth;
+ }
+ public void setTunnelBandwidth(String tunnelBandwidth) {
+ this.tunnelBandwidth = tunnelBandwidth;
+ }
+ public String getVendorAllowedMaxBandwidth() {
+ return vendorAllowedMaxBandwidth;
+ }
+ public void setVendorAllowedMaxBandwidth(String vendorAllowedMaxBandwidth) {
+ this.vendorAllowedMaxBandwidth = vendorAllowedMaxBandwidth;
+ }
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Customer.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Customer.java
index 623ab0df20..ca6d35cf46 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Customer.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Customer.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,35 +18,35 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-/**
- * This class is used to store customer
- * data of services aka ServiceDecomposition
- *
- * @author bb3476
- *
- */
-
-public class Customer extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String subscriptionServiceType;
- private String globalSubscriberId;
-
-
- public String getSubscriptionServiceType() {
- return subscriptionServiceType;
- }
- public void setSubscriptionServiceType(String subscriptionServiceType) {
- this.subscriptionServiceType = subscriptionServiceType;
- }
- public String getGlobalSubscriberId() {
- return globalSubscriberId;
- }
- public void setGlobalSubscriberId(String globalSubscriberId) {
- this.globalSubscriberId = globalSubscriberId;
- }
-
-} \ No newline at end of file
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+/**
+ * This class is used to store customer
+ * data of services aka ServiceDecomposition
+ *
+ * @author bb3476
+ *
+ */
+
+public class Customer extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String subscriptionServiceType;
+ private String globalSubscriberId;
+
+
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+ public void setGlobalSubscriberId(String globalSubscriberId) {
+ this.globalSubscriberId = globalSubscriberId;
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index f0193bc1c3..57e6864943 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
import java.util.List;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/InventoryType.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/InventoryType.java
index fbc312e750..e56ca76b2b 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/InventoryType.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/InventoryType.java
@@ -1,37 +1,37 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-public enum InventoryType{
-
- cloud("CLOUD"),
- service("SERVICE");
-
- private String type;
-
- InventoryType(String type){
- this.type = type;
- }
-
- public String type(){
- return type;
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+public enum InventoryType{
+
+ cloud("CLOUD"),
+ service("SERVICE");
+
+ private String type;
+
+ InventoryType(String type){
+ this.type = type;
+ }
+
+ public String type(){
+ return type;
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
index 5cd078d69c..a725933024 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
@@ -1,139 +1,134 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.List;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import org.openecomp.mso.logger.MsoLogger;
-//import com.fasterxml.jackson.map.SerializationFeature;
-
-
-/**
- * Wrapper encapsulates needed JSON functionality
- * to be extended by MSO service decomposition objects
- * providing ways to convert to and from JSON
- *
- */
-@JsonInclude(Include.NON_NULL)
-public abstract class JsonWrapper implements Serializable {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- @JsonInclude(Include.NON_NULL)
- public String toJsonString(){
-
- String jsonString = "";
- //convert with Jackson
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-
- mapper.setSerializationInclusion(Include.NON_NULL);
-
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try {
- jsonString = ow.writeValueAsString(this);
-// } catch (JsonGenerationException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (JsonMappingException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
- } catch (Exception e){
-
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- @JsonInclude(Include.NON_NULL)
- public JSONObject toJsonObject(){
-
- ObjectMapper mapper = new ObjectMapper();
- // mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- //mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
-
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- // mapper.enable(com.fasterxml.jackson.map.DeserializationFeature.UNWRAP_ROOT_VALUE);
- JSONObject json = new JSONObject();
- try {
- json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JSONException | IOException e) {
- LOGGER.debug("Exception :",e);
- }
- return json;
- }
-
- public String listToJson(List list) {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-
- String jsonString = "";
- try {
- jsonString = mapper.writeValueAsString(list);
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- @JsonInclude(Include.NON_NULL)
- public String toJsonStringNoRootName(){
-
- String jsonString = "";
- //convert with Jackson
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
-
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try {
- jsonString = ow.writeValueAsString(this);
- } catch (Exception e){
-
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- /**
- * Returns a string representation of this object.
- */
- @Override
- public String toString() {
- return this.toJsonString();
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.List;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import org.onap.so.logger.MsoLogger;
+//import com.fasterxml.jackson.map.SerializationFeature;
+
+
+/**
+ * Wrapper encapsulates needed JSON functionality
+ * to be extended by MSO service decomposition objects
+ * providing ways to convert to and from JSON
+ *
+ */
+@JsonInclude(Include.NON_NULL)
+public abstract class JsonWrapper implements Serializable {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, JsonWrapper.class);
+ @JsonInclude(Include.NON_NULL)
+ public String toJsonString(){
+
+ String jsonString = "";
+ //convert with Jackson
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+
+ mapper.setSerializationInclusion(Include.NON_NULL);
+
+ ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
+ try {
+ jsonString = ow.writeValueAsString(this);
+ } catch (Exception e){
+
+ LOGGER.debug("Exception :",e);
+ }
+ return jsonString;
+ }
+
+ @JsonInclude(Include.NON_NULL)
+ public JSONObject toJsonObject(){
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+ JSONObject json = new JSONObject();
+ try {
+ json = new JSONObject(mapper.writeValueAsString(this));
+ } catch (JsonGenerationException e) {
+ LOGGER.debug("Exception :",e);
+ } catch (JsonMappingException e) {
+ LOGGER.debug("Exception :",e);
+ } catch (JSONException e) {
+ LOGGER.debug("Exception :",e);
+ } catch (IOException e) {
+ LOGGER.debug("Exception :",e);
+ }
+ return json;
+ }
+
+ public String listToJson(List list) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+
+ String jsonString = "";
+ try {
+ jsonString = mapper.writeValueAsString(list);
+ } catch (JsonGenerationException e) {
+ LOGGER.debug("Exception :",e);
+ } catch (JsonMappingException e) {
+ LOGGER.debug("Exception :",e);
+ } catch (IOException e) {
+ LOGGER.debug("Exception :",e);
+ }
+ return jsonString;
+ }
+
+ @JsonInclude(Include.NON_NULL)
+ public String toJsonStringNoRootName(){
+
+ String jsonString = "";
+ //convert with Jackson
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+
+ ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
+ try {
+ jsonString = ow.writeValueAsString(this);
+ } catch (Exception e){
+
+ LOGGER.debug("Exception :",e);
+ }
+ return jsonString;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toString() {
+ return this.toJsonString();
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/License.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java
index eeb533c7f2..93dfd4f1f1 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/License.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,103 +18,101 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.json.JSONArray;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * Stores licensing information and is an attribute
- * of a <class>HomingSolution</class>
- *
- */
-@JsonRootName("license")
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class License extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- StringBuilder sb = new StringBuilder();
-
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List<String> entitlementPoolList = new ArrayList<String>();
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List<String> licenseKeyGroupList = new ArrayList<String>();
-
-
- public List<String> getEntitlementPoolList() {
- return entitlementPoolList;
- }
-
- public void setEntitlementPoolList(List<String> entitlementPoolList) {
- this.entitlementPoolList = entitlementPoolList;
- }
-
- public List<String> getLicenseKeyGroupList() {
- return licenseKeyGroupList;
- }
-
- public void setLicenseKeyGroupList(List<String> licenseKeyGroupList) {
- this.licenseKeyGroupList = licenseKeyGroupList;
- }
-
- /**
- * This method adds a Entitlement Pool Uuid
- * to the EntitlementPoolList
- *
- * @param the EntitlementPoolUuid
- */
- public void addEntitlementPool(String entitlementPoolUuid) {
- entitlementPoolList.add(entitlementPoolUuid);
- }
-
- /**
- * This method adds a License Key Group Uuid
- * to the LicenseKeyGroupList
- *
- * @param the licenseKeyGroupUuid
- */
- public void addLicenseKeyGroup(String licenseKeyGroupUuid) {
- licenseKeyGroupList.add(licenseKeyGroupUuid);
- }
-
- /**
- * This method returns the licenseKeyGroupList
- * as a json array
- *
- * @return the strList
- */
- @JsonIgnore
- public JSONArray getLicenseKeyGroupListAsString() {
- JSONArray array = new JSONArray(licenseKeyGroupList);
- return array;
- }
-
- /**
- * This method returns the entitlementPoolList
- * as a json array
- *
- * @return the strList
- */
- @JsonIgnore
- public JSONArray getEntitlementPoolListAsString() {
- JSONArray array = new JSONArray(entitlementPoolList);
- return array;
- }
-
- /**
- * @return the serialversionuid
- */
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
-
-}
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.json.JSONArray;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * Stores licensing information and is an attribute
+ * of a <class>HomingSolution</class>
+ *
+ */
+@JsonRootName("license")
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class License extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List<String> entitlementPoolList = new ArrayList<String>();
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List<String> licenseKeyGroupList = new ArrayList<String>();
+
+
+ public List<String> getEntitlementPoolList() {
+ return entitlementPoolList;
+ }
+
+ public void setEntitlementPoolList(List<String> entitlementPoolList) {
+ this.entitlementPoolList = entitlementPoolList;
+ }
+
+ public List<String> getLicenseKeyGroupList() {
+ return licenseKeyGroupList;
+ }
+
+ public void setLicenseKeyGroupList(List<String> licenseKeyGroupList) {
+ this.licenseKeyGroupList = licenseKeyGroupList;
+ }
+
+ /**
+ * This method adds a Entitlement Pool Uuid
+ * to the EntitlementPoolList
+ *
+ * @param the EntitlementPoolUuid
+ */
+ public void addEntitlementPool(String entitlementPoolUuid) {
+ entitlementPoolList.add(entitlementPoolUuid);
+ }
+
+ /**
+ * This method adds a License Key Group Uuid
+ * to the LicenseKeyGroupList
+ *
+ * @param the licenseKeyGroupUuid
+ */
+ public void addLicenseKeyGroup(String licenseKeyGroupUuid) {
+ licenseKeyGroupList.add(licenseKeyGroupUuid);
+ }
+
+ /**
+ * This method returns the licenseKeyGroupList
+ * as a json array
+ *
+ * @return the strList
+ */
+ @JsonIgnore
+ public JSONArray getLicenseKeyGroupListAsString() {
+ JSONArray array = new JSONArray(licenseKeyGroupList);
+ return array;
+ }
+
+ /**
+ * This method returns the entitlementPoolList
+ * as a json array
+ *
+ * @return the strList
+ */
+ @JsonIgnore
+ public JSONArray getEntitlementPoolListAsString() {
+ JSONArray array = new JSONArray(entitlementPoolList);
+ return array;
+ }
+
+ /**
+ * @return the serialversionuid
+ */
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModelInfo.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModelInfo.java
index a5bb2bc159..983fe50d88 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModelInfo.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModelInfo.java
@@ -1,97 +1,97 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName("modelInfo")
-public class ModelInfo extends JsonWrapper implements Serializable {
-
- /**
- * This is domain object defining structure for MODEL INFO
- * It will be valid for each Resource type object
- */
- private static final long serialVersionUID = 1L;
-
- private String modelName = "";
- private String modelUuid = "";
- private String modelInvariantUuid = "";
- private String modelVersion = "";
- //additionally on resource level
- private String modelCustomizationUuid = "";
- private String modelCustomizationName = "";
- private String modelInstanceName = "";
- private String modelType = "";
-
- //GET and SET methods
-
- public String getModelName() {
- return modelName;
- }
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
- public String getModelUuid() {
- return modelUuid;
- }
- public void setModelUuid(String modelUuid) {
- this.modelUuid = modelUuid;
- }
- public String getModelInvariantUuid() {
- return modelInvariantUuid;
- }
- public void setModelInvariantUuid(String modelInvariantUuid) {
- this.modelInvariantUuid = modelInvariantUuid;
- }
- public String getModelVersion() {
- return modelVersion;
- }
- public void setModelVersion(String modelVersion) {
- this.modelVersion = modelVersion;
- }
- public String getModelCustomizationUuid() {
- return modelCustomizationUuid;
- }
- public void setModelCustomizationUuid(String modelCustomizationUuid) {
- this.modelCustomizationUuid = modelCustomizationUuid;
- }
- public String getModelCustomizationName() {
- return modelCustomizationName;
- }
- public void setModelCustomizationName(String modelCustomizationName) {
- this.modelCustomizationName = modelCustomizationName;
- }
- public String getModelInstanceName() {
- return modelInstanceName;
- }
- public void setModelInstanceName(String modelInstanceName) {
- this.modelInstanceName = modelInstanceName;
- }
- public String getModelType() {
- return modelType;
- }
- public void setModelType(String modelType) {
- this.modelType = modelType;
- }
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName("modelInfo")
+public class ModelInfo extends JsonWrapper implements Serializable {
+
+ /**
+ * This is domain object defining structure for MODEL INFO
+ * It will be valid for each Resource type object
+ */
+ private static final long serialVersionUID = 1L;
+
+ private String modelName = "";
+ private String modelUuid = "";
+ private String modelInvariantUuid = "";
+ private String modelVersion = "";
+ //additionally on resource level
+ private String modelCustomizationUuid = "";
+ private String modelCustomizationName = "";
+ private String modelInstanceName = "";
+ private String modelType = "";
+
+ //GET and SET methods
+
+ public String getModelName() {
+ return modelName;
+ }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+ public String getModelUuid() {
+ return modelUuid;
+ }
+ public void setModelUuid(String modelUuid) {
+ this.modelUuid = modelUuid;
+ }
+ public String getModelInvariantUuid() {
+ return modelInvariantUuid;
+ }
+ public void setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ }
+ public String getModelVersion() {
+ return modelVersion;
+ }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+ public String getModelCustomizationUuid() {
+ return modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+ public String getModelInstanceName() {
+ return modelInstanceName;
+ }
+ public void setModelInstanceName(String modelInstanceName) {
+ this.modelInstanceName = modelInstanceName;
+ }
+ public String getModelType() {
+ return modelType;
+ }
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModuleResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModuleResource.java
index cbc9196289..459d203325 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ModuleResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ModuleResource.java
@@ -1,94 +1,94 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName("vfModule")
-public class ModuleResource extends Resource {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * set resourceType for this object
- */
- public ModuleResource(){
- resourceType = ResourceType.MODULE;
- }
-
- /*
- * fields specific to VF Module resource type
- */
- private String vfModuleName;
- private String vfModuleType;
- private String heatStackId;
- private boolean hasVolumeGroup;
- private boolean isBase;
- private String vfModuleLabel;
- private int initialCount;
-
- /*
- * GET && SET
- */
- public String getVfModuleName() {
- return vfModuleName;
- }
- public void setVfModuleName(String vfModuleName) {
- this.vfModuleName = vfModuleName;
- }
- public String getHeatStackId() {
- return heatStackId;
- }
- public void setHeatStackId(String heatStackId) {
- this.heatStackId = heatStackId;
- }
- public boolean getIsBase() {
- return isBase;
- }
- public void setIsBase(boolean isBase) {
- this.isBase = isBase;
- }
- public String getVfModuleLabel() {
- return vfModuleLabel;
- }
- public void setVfModuleLabel(String vfModuleLabel) {
- this.vfModuleLabel = vfModuleLabel;
- }
- public int getInitialCount() {
- return initialCount;
- }
- public void setInitialCount(int initialCount) {
- this.initialCount = initialCount;
- }
- public String getVfModuleType() {
- return vfModuleType;
- }
- public void setVfModuleType(String vfModuleType) {
- this.vfModuleType = vfModuleType;
- }
- public boolean isHasVolumeGroup() {
- return hasVolumeGroup;
- }
- public void setHasVolumeGroup(boolean hasVolumeGroup) {
- this.hasVolumeGroup = hasVolumeGroup;
- }
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName("vfModule")
+public class ModuleResource extends Resource {
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * set resourceType for this object
+ */
+ public ModuleResource(){
+ resourceType = ResourceType.MODULE;
+ }
+
+ /*
+ * fields specific to VF Module resource type
+ */
+ private String vfModuleName;
+ private String vfModuleType;
+ private String heatStackId;
+ private boolean hasVolumeGroup;
+ private boolean isBase;
+ private String vfModuleLabel;
+ private int initialCount;
+
+ /*
+ * GET && SET
+ */
+ public String getVfModuleName() {
+ return vfModuleName;
+ }
+ public void setVfModuleName(String vfModuleName) {
+ this.vfModuleName = vfModuleName;
+ }
+ public String getHeatStackId() {
+ return heatStackId;
+ }
+ public void setHeatStackId(String heatStackId) {
+ this.heatStackId = heatStackId;
+ }
+ public boolean getIsBase() {
+ return isBase;
+ }
+ public void setIsBase(boolean isBase) {
+ this.isBase = isBase;
+ }
+ public String getVfModuleLabel() {
+ return vfModuleLabel;
+ }
+ public void setVfModuleLabel(String vfModuleLabel) {
+ this.vfModuleLabel = vfModuleLabel;
+ }
+ public int getInitialCount() {
+ return initialCount;
+ }
+ public void setInitialCount(int initialCount) {
+ this.initialCount = initialCount;
+ }
+ public String getVfModuleType() {
+ return vfModuleType;
+ }
+ public void setVfModuleType(String vfModuleType) {
+ this.vfModuleType = vfModuleType;
+ }
+ public boolean isHasVolumeGroup() {
+ return hasVolumeGroup;
+ }
+ public void setHasVolumeGroup(boolean hasVolumeGroup) {
+ this.hasVolumeGroup = hasVolumeGroup;
+ }
+
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/NetworkResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java
index 827885929e..20ab3ecc84 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/NetworkResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java
@@ -1,78 +1,78 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.util.UUID;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-
-/**
- * Encapsulates Network resource data set
- *
- */
-@JsonRootName("networkResource")
-public class NetworkResource extends Resource {
-
- private static final long serialVersionUID = 1L;
- /*
- * set resourceType for this object
- */
- public NetworkResource(){
- resourceType = ResourceType.NETWORK;
- setResourceId(UUID.randomUUID().toString());
- }
- /*
- * fields specific to Network resource type
- */
- private String networkType;
- private String networkRole;
- private String networkTechnology;
- private String networkScope;
-
- /*
- * GET and SET
- */
- public String getNetworkType() {
- return networkType;
- }
- public void setNetworkType(String networkType) {
- this.networkType = networkType;
- }
- public String getNetworkRole() {
- return networkRole;
- }
- public void setNetworkRole(String networkRole) {
- this.networkRole = networkRole;
- }
- public String getNetworkTechnology() {
- return networkTechnology;
- }
- public void setNetworkTechnology(String networkTechnology) {
- this.networkTechnology = networkTechnology;
- }
- public String getNetworkScope() {
- return networkScope;
- }
- public void setNetworkScope(String networkScope) {
- this.networkScope = networkScope;
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+
+/**
+ * Encapsulates Network resource data set
+ *
+ */
+@JsonRootName("networkResource")
+public class NetworkResource extends Resource {
+
+ private static final long serialVersionUID = 1L;
+ /*
+ * set resourceType for this object
+ */
+ public NetworkResource(){
+ resourceType = ResourceType.NETWORK;
+ setResourceId(UUID.randomUUID().toString());
+ }
+ /*
+ * fields specific to Network resource type
+ */
+ private String networkType;
+ private String networkRole;
+ private String networkTechnology;
+ private String networkScope;
+
+ /*
+ * GET and SET
+ */
+ public String getNetworkType() {
+ return networkType;
+ }
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+ public String getNetworkRole() {
+ return networkRole;
+ }
+ public void setNetworkRole(String networkRole) {
+ this.networkRole = networkRole;
+ }
+ public String getNetworkTechnology() {
+ return networkTechnology;
+ }
+ public void setNetworkTechnology(String networkTechnology) {
+ this.networkTechnology = networkTechnology;
+ }
+ public String getNetworkScope() {
+ return networkScope;
+ }
+ public void setNetworkScope(String networkScope) {
+ this.networkScope = networkScope;
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/OwningEntity.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/OwningEntity.java
index 8fcbbd5d3f..903b84ac8a 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/OwningEntity.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/OwningEntity.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
@@ -50,4 +50,4 @@ public class OwningEntity extends JsonWrapper implements Serializable {
this.owningEntityName = owningEntityName;
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Project.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Project.java
index 8088585d23..337626ec61 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Project.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Project.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
@@ -44,4 +44,4 @@ public class Project extends JsonWrapper implements Serializable {
this.projectName = projectName;
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Request.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java
index 394528f897..dac7336013 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Request.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,52 +18,79 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * This class is used to store instance
- * data of services aka ServiceDecomposition
- *
- * @author bb3476
- *
- */
-
-public class Request extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String sdncRequestId;
- private String requestId;
- private ModelInfo modelInfo;
- private String productFamilyId;
-
- public String getSdncRequestId() {
- return sdncRequestId;
- }
- public void setSdncRequestId(String sdncRequestId) {
- this.sdncRequestId = sdncRequestId;
- }
- public String getRequestId() {
- return requestId;
- }
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
- public void setModelInfo(ModelInfo modelInfo) {
- this.modelInfo = modelInfo;
- }
- public String getProductFamilyId() {
- return productFamilyId;
- }
- public void setProductFamilyId(String productFamilyId) {
- this.productFamilyId = productFamilyId;
- }
-
-
-} \ No newline at end of file
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * This class is used to store instance
+ * data of services aka ServiceDecomposition
+ *
+ * @author bb3476
+ *
+ */
+
+public class Request extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String sdncRequestId;
+ private String requestId;
+ private ModelInfo modelInfo;
+ private String productFamilyId;
+ private String callbackUrl;
+ private String serviceId;
+ private String tenantId;
+ private String cloudRegion;
+
+ public String getSdncRequestId() {
+ return sdncRequestId;
+ }
+ public void setSdncRequestId(String sdncRequestId) {
+ this.sdncRequestId = sdncRequestId;
+ }
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+ public String getProductFamilyId() {
+ return productFamilyId;
+ }
+ public void setProductFamilyId(String productFamilyId) {
+ this.productFamilyId = productFamilyId;
+ }
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+ public String getServiceId() {
+ return serviceId;
+ }
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+ public String getCloudRegion() {
+ return cloudRegion;
+ }
+ public void setCloudRegion(String cloudRegion) {
+ this.cloudRegion = cloudRegion;
+ }
+ public String getTenantId() {
+ return tenantId;
+ }
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Resource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java
index ce5ad47a15..00fdbec305 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Resource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java
@@ -1,134 +1,134 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-
-
-public abstract class Resource extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String resourceId; // TODO name this field just id instead, should be the id of the object as it is in aai
- protected ResourceType resourceType; // Enum of vnf or network or allotted resource
- protected ModelInfo modelInfo;
- private long concurrencyCounter = 1L;
-
- //private List modules;
- private ResourceInstance resourceInstance = new ResourceInstance(); // TODO possibly remove
- private HomingSolution homingSolution = new HomingSolution();
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private HomingSolution currentHomingSolution;
-
- //common parameters for all Resources
- private String toscaNodeType;
-
- // GET and SET
- public String getResourceId() {
- return resourceId;
- }
- public void setResourceId(String resourceId) {
- this.resourceId = resourceId;
- }
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
- public void setModelInfo(ModelInfo modelInfo) {
- this.modelInfo = modelInfo;
- }
-
- public ResourceInstance getResourceInstance() {
- return resourceInstance;
- }
- public void setResourceInstance(ResourceInstance resourceInstance) {
- this.resourceInstance = resourceInstance;
- }
- public HomingSolution getHomingSolution(){
- return homingSolution;
- }
-
- public void setHomingSolution(HomingSolution homingSolution){
- this.homingSolution = homingSolution;
- }
- public HomingSolution getCurrentHomingSolution() {
- return currentHomingSolution;
- }
- public void setCurrentHomingSolution(HomingSolution currentHomingSolution) {
- this.currentHomingSolution = currentHomingSolution;
- }
- public void setResourceType(ResourceType resourceType) {
- this.resourceType = resourceType;
- }
-
- public ResourceType getResourceType(){
- return resourceType;
- }
-
- public String getToscaNodeType() {
- return toscaNodeType;
- }
- public void setToscaNodeType(String toscaNodeType) {
- this.toscaNodeType = toscaNodeType;
- }
-
- //Utility methods
-
- public String getResourceInstanceId() {
- return this.getResourceInstance().getInstanceId();
- }
- public String getResourceInstanceName() {
- return this.getResourceInstance().getInstanceName();
- }
- //TODO
-// @JsonIgnore
-// public String getResourceHomingSolution() {
-// }
-
- public void setResourceInstanceId(String newInstanceId){
- this.getResourceInstance().setInstanceId(newInstanceId);
- }
- public void setResourceInstanceName(String newInstanceName){
- this.getResourceInstance().setInstanceName(newInstanceName);
- }
-
- //TODO
-// @JsonIgnore
-// public String setResourceHomingSolution() {
-// }
- /**
- * To be used by macro flow to increment concurrency counter after update to it's structure was completed
- */
- public void incrementConcurrencyCounter(){
- this.concurrencyCounter ++;
- }
- /**
- * Method to get concurrency counter data
- * @return long value for the counter
- */
- @JsonIgnore
- public long getConcurrencyCounter(){
- return concurrencyCounter;
- }
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+
+public abstract class Resource extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String resourceId; // TODO name this field just id instead, should be the id of the object as it is in aai
+ protected ResourceType resourceType; // Enum of vnf or network or allotted resource
+ protected ModelInfo modelInfo;
+ private long concurrencyCounter = 1L;
+
+ //private List modules;
+ private ResourceInstance resourceInstance = new ResourceInstance(); // TODO possibly remove
+ private HomingSolution homingSolution = new HomingSolution();
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private HomingSolution currentHomingSolution;
+
+ //common parameters for all Resources
+ private String toscaNodeType;
+
+ // GET and SET
+ public String getResourceId() {
+ return resourceId;
+ }
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ public ResourceInstance getResourceInstance() {
+ return resourceInstance;
+ }
+ public void setResourceInstance(ResourceInstance resourceInstance) {
+ this.resourceInstance = resourceInstance;
+ }
+ public HomingSolution getHomingSolution(){
+ return homingSolution;
+ }
+
+ public void setHomingSolution(HomingSolution homingSolution){
+ this.homingSolution = homingSolution;
+ }
+ public HomingSolution getCurrentHomingSolution() {
+ return currentHomingSolution;
+ }
+ public void setCurrentHomingSolution(HomingSolution currentHomingSolution) {
+ this.currentHomingSolution = currentHomingSolution;
+ }
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public ResourceType getResourceType(){
+ return resourceType;
+ }
+
+ public String getToscaNodeType() {
+ return toscaNodeType;
+ }
+ public void setToscaNodeType(String toscaNodeType) {
+ this.toscaNodeType = toscaNodeType;
+ }
+
+ //Utility methods
+
+ public String getResourceInstanceId() {
+ return this.getResourceInstance().getInstanceId();
+ }
+ public String getResourceInstanceName() {
+ return this.getResourceInstance().getInstanceName();
+ }
+ //TODO
+// @JsonIgnore
+// public String getResourceHomingSolution() {
+// }
+
+ public void setResourceInstanceId(String newInstanceId){
+ this.getResourceInstance().setInstanceId(newInstanceId);
+ }
+ public void setResourceInstanceName(String newInstanceName){
+ this.getResourceInstance().setInstanceName(newInstanceName);
+ }
+
+ //TODO
+// @JsonIgnore
+// public String setResourceHomingSolution() {
+// }
+ /**
+ * To be used by macro flow to increment concurrency counter after update to it's structure was completed
+ */
+ public void incrementConcurrencyCounter(){
+ this.concurrencyCounter ++;
+ }
+ /**
+ * Method to get concurrency counter data
+ * @return long value for the counter
+ */
+ @JsonIgnore
+ public long getConcurrencyCounter(){
+ return concurrencyCounter;
+ }
+
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java
index 226ed0e01a..7cbd565c77 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceDecomposition.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java
@@ -1,86 +1,86 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/**
- * Abstract superclass for all individual decomposition resources
- *
- */
-//@JsonIgnoreProperties
-public abstract class ResourceDecomposition extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected String resourceType; // Enum of vnf or network or allotted resource
- private ModelInfo modelInfo;
-
- //private List modules;
- private ResourceInstance instanceData = new ResourceInstance();
-
- // GET and SET
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
- public void setModelInfo(ModelInfo modelInfo) {
- this.modelInfo = modelInfo;
- }
-
- public ResourceInstance getInstanceData() {
- return instanceData;
- }
- public void setInstanceData(ResourceInstance instanceData) {
- this.instanceData = instanceData;
- }
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- //Utility methods
- @JsonIgnore
- public ModelInfo getResourceModel() {
- return modelInfo;
- }
- @JsonIgnore
- public String getResourceInstanceId() {
- return this.getInstanceData().getInstanceId();
- }
- @JsonIgnore
- public String getResourceInstanceName() {
- return this.getInstanceData().getInstanceName();
- }
-// @JsonIgnore
-// public String getResourceHomingSolution() {
-// }
-
- public void setResourceInstanceId(String newInstanceId){
- this.getInstanceData().setInstanceId(newInstanceId);
- }
- public void setResourceInstanceName(String newInstanceName){
- this.getInstanceData().setInstanceName(newInstanceName);
- }
-// @JsonIgnore
-// public String setResourceHomingSolution() {
-// }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * Abstract superclass for all individual decomposition resources
+ *
+ */
+//@JsonIgnoreProperties
+public abstract class ResourceDecomposition extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String resourceType; // Enum of vnf or network or allotted resource
+ private ModelInfo modelInfo;
+
+ //private List modules;
+ private ResourceInstance instanceData = new ResourceInstance();
+
+ // GET and SET
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ public ResourceInstance getInstanceData() {
+ return instanceData;
+ }
+ public void setInstanceData(ResourceInstance instanceData) {
+ this.instanceData = instanceData;
+ }
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ //Utility methods
+ @JsonIgnore
+ public ModelInfo getResourceModel() {
+ return modelInfo;
+ }
+ @JsonIgnore
+ public String getResourceInstanceId() {
+ return this.getInstanceData().getInstanceId();
+ }
+ @JsonIgnore
+ public String getResourceInstanceName() {
+ return this.getInstanceData().getInstanceName();
+ }
+// @JsonIgnore
+// public String getResourceHomingSolution() {
+// }
+
+ public void setResourceInstanceId(String newInstanceId){
+ this.getInstanceData().setInstanceId(newInstanceId);
+ }
+ public void setResourceInstanceName(String newInstanceName){
+ this.getInstanceData().setInstanceName(newInstanceName);
+ }
+// @JsonIgnore
+// public String setResourceHomingSolution() {
+// }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceInstance.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceInstance.java
index 70977e1d86..085e278e11 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceInstance.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceInstance.java
@@ -1,65 +1,65 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-/**
- * Use resourceId in resource class instead
- *
- * @author cb645j
- *
- */
-//@JsonIgnoreProperties
-//TODO update any existing references then remove this pointless class
-@Deprecated
-public class ResourceInstance extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String instanceId;
- private String instanceName;
-
-
- public String getInstanceId() {
- return instanceId;
- }
-
- /**
- * This class and method is deprecated so use
- * resourceId field in resource class instead
- *
- * @author cb645j
- *
- */
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
- public String getInstanceName() {
- return instanceName;
- }
- public void setInstanceName(String instanceName) {
- this.instanceName = instanceName;
- }
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * Use resourceId in resource class instead
+ *
+ * @author cb645j
+ *
+ */
+//@JsonIgnoreProperties
+//TODO update any existing references then remove this pointless class
+@Deprecated
+public class ResourceInstance extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String instanceId;
+ private String instanceName;
+
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ /**
+ * This class and method is deprecated so use
+ * resourceId field in resource class instead
+ *
+ * @author cb645j
+ *
+ */
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+ public String getInstanceName() {
+ return instanceName;
+ }
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceModelInfo.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceModelInfo.java
index 724fe16bdc..af36fa01df 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceModelInfo.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceModelInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.domain;
+package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceType.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java
index 65cf03cd15..6147822d31 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ResourceType.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java
@@ -1,26 +1,26 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-public enum ResourceType {
-
- VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION // etc.
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+public enum ResourceType {
+
+ VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION // etc.
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/RollbackData.java
new file mode 100644
index 0000000000..5be0fb4f59
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/RollbackData.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class RollbackData implements Serializable{
+
+ private static final long serialVersionUID = -4811571658272937718L;
+
+ private String requestId;
+ private Map<String, String> additionalData = new HashMap<String, String>();
+
+
+ public String getRequestId(){
+ return requestId;
+ }
+
+ public void setRequestId(String requestId){
+ this.requestId = requestId;
+ }
+
+ public Map<String, String> getAdditionalData(){
+ return additionalData;
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java
index 077e5726d7..099f084637 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java
@@ -1,524 +1,544 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import org.json.JSONObject;
-import org.openecomp.mso.bpmn.core.json.DecomposeJsonUtil;
-import org.openecomp.mso.bpmn.core.json.JsonDecomposingException;
-
-
-
-
-/**
- * Service Decomposition Structure
- * This Java object contains service information:
- * - Service model info
- * - Service type and role
- * - list of VNF resource's decompositon
- * - list of network resource's decompositon
- * - list of allotted resource's decompositon
- */
-@JsonRootName(value = "serviceResources")
-//@JsonTypeInfo(include=As.WRAPPER_OBJECT, use=Id.NAME)
-public class ServiceDecomposition extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @JsonProperty("modelInfo")
- private ModelInfo modelInfo;
- @JsonProperty("serviceType")
- private String serviceType;
- @JsonProperty("serviceRole")
- private String serviceRole;
- private ServiceInstance serviceInstance;
- private Request request;
- private Customer customer;
- private String callbackURN;
- private String sdncVersion;
- @JsonProperty("project")
- private Project project;
- @JsonProperty("owningEntity")
- private OwningEntity owningEntity;
- @JsonProperty("vnfResource")
- private List <VnfResource> vnfResources;
- @JsonProperty("networkResource")
- private List <NetworkResource> networkResources;
- @JsonProperty("allottedResource")
- private List <AllottedResource> allottedResources;
- @JsonProperty("configResource")
- private List <ConfigResource> configResources;
-
- public ServiceDecomposition () {
- super();
- }
-
- public ServiceDecomposition (String catalogRestOutput) throws JsonDecomposingException {
- ServiceDecomposition serviceDecomposition = DecomposeJsonUtil.jsonToServiceDecomposition(catalogRestOutput);
- this.modelInfo = serviceDecomposition.getModelInfo();
- this.vnfResources = serviceDecomposition.getServiceVnfs();
- this.allottedResources = serviceDecomposition.getServiceAllottedResources();
- this.networkResources = serviceDecomposition.getServiceNetworks();
- this.serviceRole = serviceDecomposition.getServiceRole();
- this.serviceType = serviceDecomposition.getServiceType();
- this.configResources = serviceDecomposition.getServiceConfigResources();
- }
-
- /**
- * Constructor taking Catalog DB Adapter REST output (serviceResources model) + service Instance ID
- * @param catalogRestOutput
- * @param serviceInstanceId
- */
- public ServiceDecomposition (String catalogRestOutput, String serviceInstanceId) throws JsonDecomposingException {
- ServiceDecomposition serviceDecomposition = DecomposeJsonUtil.jsonToServiceDecomposition(catalogRestOutput);
- this.modelInfo = serviceDecomposition.getModelInfo();
- this.vnfResources = serviceDecomposition.getServiceVnfs();
- this.allottedResources = serviceDecomposition.getServiceAllottedResources();
- this.configResources = serviceDecomposition.getServiceConfigResources();
- this.networkResources = serviceDecomposition.getServiceNetworks();
-
- this.serviceRole = serviceDecomposition.getServiceRole();
- this.serviceType = serviceDecomposition.getServiceType();
-
- this.serviceInstance = new ServiceInstance();
- this.serviceInstance.setInstanceId(serviceInstanceId);
-
- this.project = serviceDecomposition.getProject();
- this.owningEntity = serviceDecomposition.getOwningEntity();
- }
-
- /**
- * Constructor taking a Service Decomposition JSON serialization
- * @param catalogRestOutput
- * @param serviceInstanceId
- */
- public ServiceDecomposition (JSONObject jsonServiceDecomposition, String serviceInstanceId) {
- //TODO provide constructor implementation
-
- }
-
- //*****
- //GET and SET section
- /**
- * Return just the service model portion of the Service Decomposition as a Java object.
- * The service model object should support retrieval as JSON string that is formatted correctly for sending serviceModelInfo to Building Blocks.
- * @return
- */
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
- public void setModelInfo(ModelInfo modelInfo) {
- this.modelInfo = modelInfo;
- }
- public ServiceInstance getServiceInstance() {
- return serviceInstance;
- }
- public void setServiceInstance(ServiceInstance serviceInstance) {
- this.serviceInstance = serviceInstance;
- }
- public Project getProject() {
- return project;
- }
- public OwningEntity getOwningEntity() {
- return owningEntity;
- }
- public void setProject(Project project) {
- this.project = project;
- }
- public void setOwningEntity(OwningEntity owningEntity) {
- this.owningEntity = owningEntity;
- }
- public List<VnfResource> getServiceVnfs() {
- return vnfResources;
- }
- public void setServiceVnfs(List<VnfResource> vnfResources) {
- this.vnfResources = vnfResources;
- }
- public List<NetworkResource> getServiceNetworks() {
- return networkResources;
- }
- public void setServiceConfigs(List<ConfigResource> configResources) {
- this.configResources = configResources;
- }
- public List<ConfigResource> getServiceConfigs() {
- return configResources;
- }
- public void setServiceNetworks(List<NetworkResource> networkResources) {
- this.networkResources = networkResources;
- }
- public List<AllottedResource> getServiceAllottedResources() {
- return allottedResources;
- }
- public void setServiceAllottedResources(List<AllottedResource> allottedResources) {
- this.allottedResources = allottedResources;
- }
- public List<ConfigResource> getServiceConfigResources() {
- return configResources;
- }
- public void setServiceConfigResources(List<ConfigResource> configResources) {
- this.configResources = configResources;
- }
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getServiceRole() {
- return serviceRole;
- }
-
- public void setServiceRole(String serviceRole) {
- this.serviceRole = serviceRole;
- }
- public Request getRequest() {
- return request;
- }
-
- public void setRequest(Request request) {
- this.request = request;
- }
- public Customer getCustomer() {
- return customer;
- }
- public void setCustomer(Customer customer) {
- this.customer = customer;
- }
- public String getCallbackURN() {
- return callbackURN;
- }
-
- public void setCallbackURN(String callbackURN) {
- this.callbackURN = callbackURN;
- }
-
- public String getSdncVersion() {
- return sdncVersion;
- }
-
- public void setSdncVersion(String sdncVersion) {
- this.sdncVersion = sdncVersion;
- }
-
- //*****
-
- //*****
- //Access methods
-
-
- /**
- * This method returns one combined list of Resources of All Types
- * @return
- */
- @JsonIgnore
- public List<Resource> getServiceResources(){
- ArrayList serviceResources = new ArrayList();
- if(this.getServiceAllottedResources() != null){
- serviceResources.addAll(this.getServiceAllottedResources());
- }
- if(this.getServiceNetworks() != null){
- serviceResources.addAll(this.getServiceNetworks());
- }
- if(this.getServiceVnfs() != null){
- serviceResources.addAll(this.getServiceVnfs());
- }
- if(this.getServiceConfigResources() != null){
- serviceResources.addAll(this.getServiceConfigResources());
- }
- return serviceResources;
- }
-
- /**
- * This method returns String representation of one combined list of Resources of All Types
- */
- @JsonIgnore
- public String getServiceResourcesJsonString() {
- return listToJson((this.getServiceNetworks())) +
- listToJson((this.getServiceVnfs())) +
- listToJson((this.getServiceAllottedResources())) +
- listToJson((this.getServiceConfigResources()));
- }
-
- /**
- * Returns a JSON list of all Network Resource structures (i.e. the serialized NetworkDecomposition objects).
- * @return
- */
- @JsonIgnore
- public String getServiceNetworksJson(){
- return listToJson(this.getServiceNetworks());
- }
- /**
- * Returns a JSON list of all VnfResource structures (i.e. the serialized VnfResource objects).
- * @return
- */
- @JsonIgnore
- public String getServiceVnfsJson(){
- return listToJson(this.getServiceVnfs());
- }
- /**
- * Returns a JSON list of all Allotted Resource structures (i.e. the serialized AllottedResource objects).
- * @return
- */
- @JsonIgnore
- public String getServiceAllottedResourcesJson(){
- return listToJson(this.getServiceAllottedResources());
- }
- /**
- * Returns a JSON list of all Config Resource structures (i.e. the serialized ConfigResource objects).
- * @return
- */
- @JsonIgnore
- public String getServiceConfigResourcesJson(){
- return listToJson(this.getServiceConfigResources());
- }
-
- //TODO - define Resource Object ID
- @JsonIgnore
- public String getVnfResource(String resourceObjectId) {
-
- for (Resource resource : getServiceResources()) {
- //resource.getModelInfo().getModelInvariantId();
-
- if ("extracted information".equals(resourceObjectId)) {
- return resource.toJsonString();
- }
- }
- return "";
- }
-
- //Methods to add Resource to the list
- /**
- * Add VNF resource to the list
- * @param vnfResource
- */
- public void addVnfResource(Resource vnfResource) {
- if (vnfResources == null){
- vnfResources = new ArrayList<>();
- }
- this.vnfResources.add((VnfResource)vnfResource);
- }
- /**
- * Add Network resource to the list
- * @param networkResource
- */
- public void addNetworkResource(Resource networkResource) {
- if (networkResources == null){
- networkResources = new ArrayList<>();
- }
- this.networkResources.add((NetworkResource)networkResource);
- }
- /**
- * Add Allotted resource to the list
- * @param allottedResource
- */
- public void addAllottedResource(Resource allottedResource) {
- if (allottedResources == null){
- allottedResources = new ArrayList<>();
- }
- this.allottedResources.add((AllottedResource)allottedResource);
- }
- /**
- * Add Config resource to the list
- * @param allottedResource
- */
- public void addConfigResource(Resource configResource) {
- if (configResources == null){
- configResources = new ArrayList<>();
- }
- this.configResources.add((ConfigResource)configResource);
- }
- /**
- * Add resource to the list
- * Given a ResourceDecomposition (subclass) object, add it to the Service Decomposition (in the appropriate category, e.g. as a VNF, Network, or Allotted Resource).
- * As dependencies are not currently supported, add it to the end of any ordered lists.
- * @param resource
- */
- public void addResource(Resource resource) {
- //create resource based upon type
- switch (resource.resourceType) {
- case VNF:
- this.addVnfResource(resource);
- break;
- case NETWORK:
- this.addNetworkResource(resource);
- break;
- case ALLOTTED_RESOURCE:
- this.addAllottedResource(resource);
- break;
- case CONFIGURATION:
- this.addConfigResource(resource);
- break;
- default:
- throw new IllegalArgumentException("Invalid resource type: " + resource.resourceType);
- }
- }
-
- /**
- * Add resource to the list
- * @param jsonResource
- */
- public void addVnfResource(String jsonResource) throws JsonDecomposingException {
- VnfResource vnfResource = null;
- vnfResource = DecomposeJsonUtil.jsonToVnfResource(jsonResource);
- this.addVnfResource(vnfResource);
- }
- /**
- * Add resource to the list
- * @param jsonResource
- */
- public void addNetworkResource(String jsonResource) throws JsonDecomposingException {
- NetworkResource networkResource = null;
- networkResource = DecomposeJsonUtil.jsonToNetworkResource(jsonResource);
- this.addVnfResource(networkResource);
- }
- /**
- * Add resource to the list
- * @param Resource
- */
- public void addAllottedResource(String jsonResource) throws JsonDecomposingException {
- AllottedResource allottedResource = null;
- allottedResource = DecomposeJsonUtil.jsonToAllottedResource(jsonResource);
- this.addVnfResource(allottedResource);
- }
- /**
- * Add resource to the list
- * @param Resource
- */
- public void addConfigResource(String jsonResource) throws JsonDecomposingException {
- ConfigResource configResource = null;
- configResource = DecomposeJsonUtil.jsonToConfigResource(jsonResource);
- this.addVnfResource(configResource);
- }
- /**
- * Given a ResourceDecomposition (subclass) object, locate it in the Service Decomposition by its unique ID, and replace the current version with the new one.
- * This method should support concurrency control via an auto-incrementing field in the ResourceDecomposition class.
- * @param newResource
- * @return TRUE if replacement was a success
- */
- public boolean replaceResource(Resource newResource){
- boolean result = false;
- List serviceResources = getServiceResources();
- for (Resource resource : (Iterable<Resource>) serviceResources) {
- System.out.println("resource found");
- if (resource.resourceType == newResource.resourceType) {
- System.out.println("resource type matches");
- if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())) {
- System.out.println("resource id matches");
- //returns TRUE if replacement is a success
- result = Collections.replaceAll(serviceResources, resource, newResource);
- }
- }
- }
- //set updated list into ServiceDecomposition
- this.setResourceList(serviceResources);
- return result;
- }
-
- /**
- * Given a ResourceDecomposition as a JSON string, locate it in the Service Decomposition by its unique ID,
- * and replace the current version with the new one.
- * @param jsonString
- * @return
- */
- public boolean replaceResource(String jsonString){
- //TODO: define unique ID for the Resource!
- return false;
- }
-
- /**
- * Given a resource object ID, locate it in the Service Decomposition by its unique ID, and delete it.
- * @param resource
- * @return TRUE if delete was a success
- */
- public boolean deleteResource(Resource resource){
- List serviceResources = getServiceResources();
- for (Resource item : (Iterable<Resource>) serviceResources) {
- if (item.resourceType == resource.resourceType) {
- if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())) {
- //returns TRUE if replacement is a success
- return serviceResources.remove(resource);
- }
- }
- }
-
- return false;
- }
-
- /**
- * Generic method to set List of ResourceDecomposition objects
- * @param resources
- * @return
- */
- public boolean setResourceList(List<Resource> resources){
- //create resource based upon type
- switch (resources.get(0).resourceType) {
- case VNF:
- this.setServiceVnfs((List<VnfResource>)(List<?>)resources);
- break;
- case NETWORK:
- this.setServiceNetworks((List<NetworkResource>)(List<?>)resources);
- break;
- case ALLOTTED_RESOURCE:
- this.setServiceAllottedResources((List<AllottedResource>)(List<?>)resources);
- break;
- case CONFIGURATION:
- this.setServiceConfigResources((List<ConfigResource>)(List<?>)resources);
- break;
- default:
- throw new IllegalArgumentException("Invalid resource type: " + resources.get(0).resourceType);
- }
-
- return false;
- }
-
- /**
- *
- * This method locates and returns a resource in a given
- * Service Decomposition object by its unique resource id.
- * Returns null if resource doesn't exist.
- *
- * @param resourceId - id of the resource
- * @return resource
- */
- @JsonIgnore
- public Resource getServiceResource(String resourceId){
- List<Resource> resources = getServiceResources();
- for (Resource resource : resources) {
- if (resource.getResourceId().equalsIgnoreCase(resourceId)) {
- //match
- return resource;
- }
- }
- return null;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.json.JSONObject;
+import org.onap.so.bpmn.core.json.DecomposeJsonUtil;
+import org.onap.so.bpmn.core.json.JsonDecomposingException;
+
+
+
+
+/**
+ * Service Decomposition Structure
+ * This Java object contains service information:
+ * - Service model info
+ * - Service type and role
+ * - list of VNF resource's decompositon
+ * - list of network resource's decompositon
+ * - list of allotted resource's decompositon
+ */
+@JsonRootName(value = "serviceResources")
+//@JsonTypeInfo(include=As.WRAPPER_OBJECT, use=Id.NAME)
+public class ServiceDecomposition extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
+ @JsonProperty("serviceType")
+ private String serviceType;
+ @JsonProperty("serviceRole")
+ private String serviceRole;
+ private ServiceInstance serviceInstance;
+ private Request request;
+ private Customer customer;
+ private String callbackURN;
+ private String sdncVersion;
+ @JsonProperty("project")
+ private Project project;
+ @JsonProperty("owningEntity")
+ private OwningEntity owningEntity;
+ @JsonProperty("serviceVnfs")
+ private List <VnfResource> vnfResources;
+ @JsonProperty("networkResource")
+ private List <NetworkResource> networkResources;
+ @JsonProperty("serviceAllottedResources")
+ private List <AllottedResource> allottedResources;
+ @JsonProperty("configResource")
+ private List <ConfigResource> configResources;
+
+ public ServiceDecomposition () {
+ super();
+ }
+
+ public ServiceDecomposition (String catalogRestOutput) throws JsonDecomposingException {
+ ServiceDecomposition serviceDecomposition = DecomposeJsonUtil.jsonToServiceDecomposition(catalogRestOutput);
+ this.modelInfo = serviceDecomposition.getModelInfo();
+ this.vnfResources = serviceDecomposition.getVnfResources();
+ this.allottedResources = serviceDecomposition.getAllottedResources();
+ this.networkResources = serviceDecomposition.getNetworkResources();
+ this.serviceRole = serviceDecomposition.getServiceRole();
+ this.serviceType = serviceDecomposition.getServiceType();
+ this.configResources = serviceDecomposition.getConfigResources();
+ }
+
+ /**
+ * Constructor taking Catalog DB Adapter REST output (serviceResources model) + service Instance ID
+ *
+ * @param catalogRestOutput
+ * @param serviceInstanceId
+ */
+ public ServiceDecomposition (String catalogRestOutput, String serviceInstanceId) throws JsonDecomposingException {
+ ServiceDecomposition serviceDecomposition = DecomposeJsonUtil.jsonToServiceDecomposition(catalogRestOutput);
+ this.modelInfo = serviceDecomposition.getModelInfo();
+ this.vnfResources = serviceDecomposition.getVnfResources();
+ this.allottedResources = serviceDecomposition.getAllottedResources();
+ this.configResources = serviceDecomposition.getConfigResources();
+ this.networkResources = serviceDecomposition.getNetworkResources();
+
+ this.serviceRole = serviceDecomposition.getServiceRole();
+ this.serviceType = serviceDecomposition.getServiceType();
+
+ this.serviceInstance = new ServiceInstance();
+ this.serviceInstance.setInstanceId(serviceInstanceId);
+
+ this.project = serviceDecomposition.getProject();
+ this.owningEntity = serviceDecomposition.getOwningEntity();
+ }
+
+ /**
+ * Constructor taking a Service Decomposition JSON serialization
+ * @param catalogRestOutput
+ * @param serviceInstanceId
+ */
+ public ServiceDecomposition (JSONObject jsonServiceDecomposition, String serviceInstanceId) {
+ //TODO provide constructor implementation
+
+ }
+
+ //*****
+ //GET and SET section
+ /**
+ * Return just the service model portion of the Service Decomposition as a Java object.
+ * The service model object should support retrieval as JSON string that is formatted correctly for sending serviceModelInfo to Building Blocks.
+ * @return
+ */
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+ public ServiceInstance getServiceInstance() {
+ return serviceInstance;
+ }
+ public void setServiceInstance(ServiceInstance serviceInstance) {
+ this.serviceInstance = serviceInstance;
+ }
+ public Project getProject() {
+ return project;
+ }
+ public OwningEntity getOwningEntity() {
+ return owningEntity;
+ }
+ public void setProject(Project project) {
+ this.project = project;
+ }
+ public void setOwningEntity(OwningEntity owningEntity) {
+ this.owningEntity = owningEntity;
+ }
+ public List<VnfResource> getVnfResources() {
+ return vnfResources;
+ }
+ public void setVnfResources(List<VnfResource> vnfResources) {
+ this.vnfResources = vnfResources;
+ }
+ public void setConfigResources(List<ConfigResource> configResources) {
+ this.configResources = configResources;
+ }
+ public List<ConfigResource> getConfigResources() {
+ return configResources;
+ }
+ public void setNetworkResources(List<NetworkResource> networkResources) {
+ this.networkResources = networkResources;
+ }
+ public List<NetworkResource> getNetworkResources() {
+ return networkResources;
+ }
+ public List<AllottedResource> getAllottedResources() {
+ return allottedResources;
+ }
+ public void setAllottedResources(List<AllottedResource> allottedResources) {
+ this.allottedResources = allottedResources;
+ }
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+ public Request getRequest() {
+ return request;
+ }
+
+ public void setRequest(Request request) {
+ this.request = request;
+ }
+ public Customer getCustomer() {
+ return customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ public String getCallbackURN() {
+ return callbackURN;
+ }
+
+ public void setCallbackURN(String callbackURN) {
+ this.callbackURN = callbackURN;
+ }
+ public String getSdncVersion() {
+ return sdncVersion;
+ }
+
+ public void setSdncVersion(String sdncVersion) {
+ this.sdncVersion = sdncVersion;
+ }
+
+ //*****
+
+ //*****
+ //Access methods
+
+
+ /**
+ * This method returns one combined list of Resources of All Types
+ * @return
+ */
+ @JsonIgnore
+ public List<Resource> getServiceResources(){
+ ArrayList serviceResources = new ArrayList();
+ if(this.getAllottedResources() != null){
+ serviceResources.addAll(this.getAllottedResources());
+ }
+ if(this.getNetworkResources() != null){
+ serviceResources.addAll(this.getNetworkResources());
+ }
+ if(this.getVnfResources() != null){
+ serviceResources.addAll(this.getVnfResources());
+ }
+ if(this.getConfigResources() != null){
+ serviceResources.addAll(this.getConfigResources());
+ }
+ return serviceResources;
+ }
+
+ /**
+ * This method returns String representation of one combined list of Resources of All Types
+ */
+ @JsonIgnore
+ public String getServiceResourcesJsonString() {
+ return getServiceNetworksJson() +
+ getServiceVnfsJson() +
+ getServiceAllottedResourcesJson() +
+ getServiceConfigResourcesJson();
+ }
+
+ /**
+ * Returns a JSON list of all Network Resource structures (i.e. the serialized NetworkDecomposition objects).
+ * @return
+ */
+ @JsonIgnore
+ public String getServiceNetworksJson(){
+ return listToJson(this.getNetworkResources());
+ }
+ /**
+ * Returns a JSON list of all VnfResource structures (i.e. the serialized VnfResource objects).
+ * @return
+ */
+ @JsonIgnore
+ public String getServiceVnfsJson(){
+ return listToJson(this.getVnfResources());
+ }
+ /**
+ * Returns a JSON list of all Allotted Resource structures (i.e. the serialized AllottedResource objects).
+ * @return
+ */
+ @JsonIgnore
+ public String getServiceAllottedResourcesJson(){
+ return listToJson(this.getAllottedResources());
+ }
+ /**
+ * Returns a JSON list of all Config Resource structures (i.e. the serialized ConfigResource objects).
+ * @return
+ */
+ @JsonIgnore
+ public String getServiceConfigResourcesJson(){
+ return listToJson(this.getConfigResources());
+ }
+
+ //TODO - define Resource Object ID
+ @JsonIgnore
+ public String getVnfResource(String resourceObjectId) {
+
+ for (Resource resource : getServiceResources()) {
+ //resource.getModelInfo().getModelInvariantId();
+
+ if ("extracted information".equals(resourceObjectId)) {
+ return resource.toJsonString();
+ }
+ }
+ return "";
+ }
+
+ //Methods to add Resource to the list
+ /**
+ * Add VNF resource to the list
+ * @param vnfResource
+ */
+ public void addVnfResource(Resource vnfResource) {
+ if (vnfResources == null){
+ vnfResources = new ArrayList<>();
+ }
+ this.vnfResources.add((VnfResource)vnfResource);
+ }
+ /**
+ * Add Network resource to the list
+ * @param networkResource
+ */
+ public void addNetworkResource(Resource networkResource) {
+ if (networkResources == null){
+ networkResources = new ArrayList<>();
+ }
+ this.networkResources.add((NetworkResource)networkResource);
+ }
+ /**
+ * Add Allotted resource to the list
+ * @param allottedResource
+ */
+ public void addAllottedResource(Resource allottedResource) {
+ if (allottedResources == null){
+ allottedResources = new ArrayList<>();
+ }
+ this.allottedResources.add((AllottedResource)allottedResource);
+ }
+ /**
+ * Add Config resource to the list
+ * @param allottedResource
+ */
+ public void addConfigResource(Resource configResource) {
+ if (configResources == null){
+ configResources = new ArrayList<>();
+ }
+ this.configResources.add((ConfigResource)configResource);
+ }
+ /**
+ * Add resource to the list
+ * Given a ResourceDecomposition (subclass) object, add it to the Service Decomposition (in the appropriate category, e.g. as a VNF, Network, or Allotted Resource).
+ * As dependencies are not currently supported, add it to the end of any ordered lists.
+ * @param resource
+ */
+ public void addResource(Resource resource) {
+ //create resource based upon type
+ switch (resource.resourceType) {
+ case VNF:
+ this.addVnfResource(resource);
+ break;
+ case NETWORK:
+ this.addNetworkResource(resource);
+ break;
+ case ALLOTTED_RESOURCE:
+ this.addAllottedResource(resource);
+ break;
+ case CONFIGURATION:
+ this.addConfigResource(resource);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid resource type: " + resource.resourceType);
+ }
+ }
+
+ /**
+ * Add resource to the list
+ * @param jsonResource
+ */
+ public void addVnfResource(String jsonResource) throws JsonDecomposingException {
+ VnfResource vnfResource = null;
+ vnfResource = DecomposeJsonUtil.jsonToVnfResource(jsonResource);
+ this.addVnfResource(vnfResource);
+ }
+ /**
+ * Add resource to the list
+ * @param jsonResource
+ */
+ public void addNetworkResource(String jsonResource) throws JsonDecomposingException {
+ NetworkResource networkResource = null;
+ networkResource = DecomposeJsonUtil.jsonToNetworkResource(jsonResource);
+ this.addNetworkResource(networkResource);
+ }
+ /**
+ * Add resource to the list
+ * @param Resource
+ */
+ public void addAllottedResource(String jsonResource) throws JsonDecomposingException {
+ AllottedResource allottedResource = null;
+ allottedResource = DecomposeJsonUtil.jsonToAllottedResource(jsonResource);
+ this.addAllottedResource(allottedResource);
+ }
+ /**
+ * Add resource to the list
+ * @param Resource
+ */
+ public void addConfigResource(String jsonResource) throws JsonDecomposingException {
+ ConfigResource configResource = null;
+ configResource = DecomposeJsonUtil.jsonToConfigResource(jsonResource);
+ this.addConfigResource(configResource);
+ }
+ /**
+ * Given a ResourceDecomposition (subclass) object, locate it in the Service Decomposition by its unique ID, and replace the current version with the new one.
+ * This method should support concurrency control via an auto-incrementing field in the ResourceDecomposition class.
+ * @param newResource
+ * @return TRUE if replacement was a success
+ */
+ public boolean replaceResource(Resource newResource){
+ List resources = getResourceList(newResource);
+
+ boolean result = false;
+ for (Resource resource : (Iterable<Resource>) resources) {
+ System.out.println("resource found");
+ if (resource.resourceType == newResource.resourceType) {
+ System.out.println("resource type matches");
+ if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())) {
+ System.out.println("resource id matches");
+ //returns TRUE if replacement is a success
+ result = Collections.replaceAll(resources, resource, newResource);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Given a ResourceDecomposition as a JSON string, locate it in the Service Decomposition by its unique ID,
+ * and replace the current version with the new one.
+ * @param jsonString
+ * @return
+ */
+ public boolean replaceResource(String jsonString){
+ //TODO: define unique ID for the Resource!
+ return false;
+ }
+
+ /**
+ * Given a resource object ID, locate it in the Service Decomposition by its unique ID, and delete it.
+ * @param resource
+ * @return TRUE if delete was a success
+ */
+ public boolean deleteResource(Resource resource){
+ List serviceResourceList = getResourceList(resource);
+ for (Resource item : (Iterable<Resource>) serviceResourceList) {
+ if (item.resourceType == resource.resourceType) {
+ if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())) {
+ //returns TRUE if replacement is a success
+ return serviceResourceList.remove(resource);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Generic method to get List of Resource objects based on input resource's resourceType
+ * @param resource
+ * @return List matching the resourceType of resource
+ */
+ public List getResourceList(Resource resource) {
+ List resourceList;
+ switch(resource.getResourceType()) {
+ case VNF:
+ resourceList = getVnfResources();
+ break;
+ case NETWORK:
+ resourceList = getNetworkResources();
+ break;
+ case ALLOTTED_RESOURCE:
+ resourceList = getAllottedResources();
+ break;
+ case CONFIGURATION:
+ resourceList = getConfigResources();
+ break;
+ default:
+ resourceList = new ArrayList<>();
+ }
+ return resourceList;
+ }
+
+ /**
+ * Generic method to set List of ResourceDecomposition objects
+ * @param resources
+ * @return
+ */
+ public boolean setResourceList(List<Resource> resources){
+ if(resources != null && !resources.isEmpty()) {
+ //create resource based upon type
+ switch (resources.get(0).resourceType) {
+ case VNF:
+ this.setVnfResources((List<VnfResource>)(List<?>)resources);
+ break;
+ case NETWORK:
+ this.setNetworkResources((List<NetworkResource>)(List<?>)resources);
+ break;
+ case ALLOTTED_RESOURCE:
+ this.setAllottedResources((List<AllottedResource>)(List<?>)resources);
+ break;
+ case CONFIGURATION:
+ this.setConfigResources((List<ConfigResource>)(List<?>)resources);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid resource type: " + resources.get(0).resourceType);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ * This method locates and returns a resource in a given
+ * Service Decomposition object by its unique resource id.
+ * Returns null if resource doesn't exist.
+ *
+ * @param resourceId - id of the resource
+ * @return resource
+ */
+ @JsonIgnore
+ public Resource getServiceResource(String resourceId){
+ List<Resource> resources = getServiceResources();
+ for (Resource resource : resources) {
+ if (resource.getResourceId().equalsIgnoreCase(resourceId)) {
+ //match
+ return resource;
+ }
+ }
+ return null;
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceInstance.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java
index aa5e9a035d..6d2db0ca33 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceInstance.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java
@@ -1,109 +1,116 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * This class is used to store instance
- * data of services aka ServiceDecomposition
- *
- * @author cb645j
- *
- */
-public class ServiceInstance extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String instanceId;
- private String instanceName;
- private String orchestrationStatus;
- private Configuration configuration;
- private String serviceType;
- private String serviceId;
- private ModelInfo modelInfo;
- private String environmentContext;
- private String workloadContext;
- private Map serviceParams;
-
- public String getServiceType() {
- return serviceType;
- }
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
- public String getServiceId() {
- return serviceId;
- }
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
- public Map getServiceParams() {
- return serviceParams;
- }
- public void setServiceParams(Map serviceParams) {
- this.serviceParams = serviceParams;
- }
- public String getInstanceId() {
- return instanceId;
- }
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
- public String getInstanceName() {
- return instanceName;
- }
- public void setInstanceName(String instanceName) {
- this.instanceName = instanceName;
- }
- public String getOrchestrationStatus() {
- return orchestrationStatus;
- }
- public void setOrchestrationStatus(String orchestrationStatus) {
- this.orchestrationStatus = orchestrationStatus;
- }
- public Configuration getConfiguration() {
- return configuration;
- }
- public void setConfiguration(Configuration configuration) {
- this.configuration = configuration;
- }
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
- public void setModelInfo(ModelInfo modelInfo) {
- this.modelInfo = modelInfo;
- }
- public String getEnvironmentContext() {
- return environmentContext;
- }
- public void setEnvironmentContext(String environmentContext) {
- this.environmentContext = environmentContext;
- }
- public String getWorkloadContext() {
- return workloadContext;
- }
- public void setWorkloadContext(String workloadContext) {
- this.workloadContext = workloadContext;
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * This class is used to store instance
+ * data of services aka ServiceDecomposition
+ *
+ * @author cb645j
+ *
+ */
+public class ServiceInstance extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String instanceId;
+ private String instanceName;
+ private String orchestrationStatus;
+ private Configuration configuration;
+ private String serviceType;
+ private String serviceRole;
+ private String serviceId;
+ private ModelInfo modelInfo;
+ private String environmentContext;
+ private String workloadContext;
+ private Map serviceParams;
+
+ public String getServiceType() {
+ return serviceType;
+ }
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+ public String getServiceId() {
+ return serviceId;
+ }
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+ public Map getServiceParams() {
+ return serviceParams;
+ }
+ public void setServiceParams(Map serviceParams) {
+ this.serviceParams = serviceParams;
+ }
+ public String getInstanceId() {
+ return instanceId;
+ }
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+ public String getInstanceName() {
+ return instanceName;
+ }
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+ public String getEnvironmentContext() {
+ return environmentContext;
+ }
+ public void setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ }
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+ public String getServiceRole() {
+ return serviceRole;
+ }
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Subscriber.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Subscriber.java
index 5eba487d05..e9028ded17 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/Subscriber.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Subscriber.java
@@ -1,69 +1,69 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-public class Subscriber implements Serializable {
-
- private static final long serialVersionUID = -2416018315129127022L;
- private String globalId;
- private String name;
- private String commonSiteId;
-
- public Subscriber(String globalId, String name, String commonSiteId){
- super();
- this.globalId = globalId;
- this.name = name;
- this.commonSiteId = commonSiteId;
- }
-
-
- public String getGlobalId(){
- return globalId;
- }
-
-
- public void setGlobalId(String globalId){
- this.globalId = globalId;
- }
-
-
- public String getName(){
- return name;
- }
-
-
- public void setName(String name){
- this.name = name;
- }
-
-
- public String getCommonSiteId(){
- return commonSiteId;
- }
-
- public void setCommonSiteId(String commonSiteId){
- this.commonSiteId = commonSiteId;
- }
-
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+public class Subscriber implements Serializable {
+
+ private static final long serialVersionUID = -2416018315129127022L;
+ private String globalId;
+ private String name;
+ private String commonSiteId;
+
+ public Subscriber(String globalId, String name, String commonSiteId){
+ super();
+ this.globalId = globalId;
+ this.name = name;
+ this.commonSiteId = commonSiteId;
+ }
+
+
+ public String getGlobalId(){
+ return globalId;
+ }
+
+
+ public void setGlobalId(String globalId){
+ this.globalId = globalId;
+ }
+
+
+ public String getName(){
+ return name;
+ }
+
+
+ public void setName(String name){
+ this.name = name;
+ }
+
+
+ public String getCommonSiteId(){
+ return commonSiteId;
+ }
+
+ public void setCommonSiteId(String commonSiteId){
+ this.commonSiteId = commonSiteId;
+ }
+
+
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Vnf.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Vnf.java
new file mode 100644
index 0000000000..83043b3ec5
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Vnf.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * This class is used to store instance
+ * data of Vnf for ServiceDecomposition
+ *
+ * @author bb3476
+ *
+ */
+@JsonRootName("vnf")
+public class Vnf extends JsonWrapper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String vnfId;
+ private String vnfName;
+ private String serviceId;
+ private String vnfType;
+ private String orchStatus;
+ private String modelInvariantId;
+ private String modelVersionId;
+ private String modelCustomizationId;
+ private String nfType;
+ private String nfRole;
+ private String nfFunction;
+ private String nfNamingCode;
+ private String tenantId;
+ private String cloudSiteId;
+
+
+ public String getVnfName() {
+ return vnfName;
+ }
+ public void setVnfName(String vnfName) {
+ this.vnfName = vnfName;
+ }
+ public String getServiceId() {
+ return serviceId;
+ }
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+ public String getOrchStatus() {
+ return orchStatus;
+ }
+ public void setOrchStatus(String orchStatus) {
+ this.orchStatus = orchStatus;
+ }
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+ public String getNfType() {
+ return nfType;
+ }
+ public void setNfType(String nfType) {
+ this.nfType = nfType;
+ }
+ public String getNfRole() {
+ return nfRole;
+ }
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+ public String getNfFunction() {
+ return nfFunction;
+ }
+ public void setNfFunction(String nfFunction) {
+ this.nfFunction = nfFunction;
+ }
+ public String getNfNamingCode() {
+ return nfNamingCode;
+ }
+ public void setNfNamingCode(String nfNamingCode) {
+ this.nfNamingCode = nfNamingCode;
+ }
+ public String getVnfId() {
+ return vnfId;
+ }
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+ public String getTenantId() {
+ return tenantId;
+ }
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+ public String getCloudSiteId() {
+ return cloudSiteId;
+ }
+ public void setCloudSiteId(String cloudSiteId) {
+ this.cloudSiteId = cloudSiteId;
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
index a328ddf719..dc76ab0bc7 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
@@ -1,167 +1,176 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * Encapsulates VNF resource data set
- *
- */
-@JsonRootName("vnfResource")
-public class VnfResource extends Resource {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * set resourceType for this object
- */
- public VnfResource(){
- resourceType = ResourceType.VNF;
- setResourceId(UUID.randomUUID().toString());
- }
-
- /*
- * fields specific to VNF resource type
- */
- @JsonProperty("vfModules")
- private List <ModuleResource> vfModules;
- private String vnfHostname;
- private String vnfType;
- private String nfFunction;
- private String nfType;
- private String nfRole;
- private String nfNamingCode;
- private String multiStageDesign;
-
- /*
- * GET and SET
- */
- public List<ModuleResource> getVfModules() {
- return vfModules;
- }
- public void setModules(List<ModuleResource> moduleResources) {
- this.vfModules = moduleResources;
- }
- public String getVnfHostname() {
- return vnfHostname;
- }
- public void setVnfHostname(String vnfHostname) {
- this.vnfHostname = vnfHostname;
- }
- @Deprecated
- public void setVnfType(String vnfType) {
- this.vnfType = vnfType;
- }
- public String getVnfType() {
- return vnfType;
- }
- public String getNfFunction() {
- return nfFunction;
- }
- public void setNfFunction(String nfFunction) {
- this.nfFunction = nfFunction;
- }
- public String getNfType() {
- return nfType;
- }
- public void setNfType(String nfType) {
- this.nfType = nfType;
- }
- public String getNfRole() {
- return nfRole;
- }
- public void setNfRole(String nfRole) {
- this.nfRole = nfRole;
- }
- public String getNfNamingCode() {
- return nfNamingCode;
- }
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
- public String getMultiStageDesign() {
- return multiStageDesign;
- }
- public void setMultiStageDesign(String multiStageDesign) {
- this.multiStageDesign = multiStageDesign;
- }
- /*
- * GET accessors per design requirements
- */
-
- /**
- * Returns a list of all VfModule objects.
- * Base module is first entry in the list
- * @return ordered list of ModuleResources objects
- */
- @JsonIgnore
- public List<ModuleResource> getAllVfModuleObjects(){
- if (vfModules == null) {
- return null;
- }
-
- for (int i = 0; i < vfModules.size(); i++) {
- ModuleResource moduleResource = vfModules.get(i);
- if (moduleResource.getIsBase()){
- vfModules.remove(moduleResource);
- vfModules.add(0,moduleResource);
- }
- }
- return vfModules;
- }
-
- /**
- *
- * @return Returns JSON list of all VfModule structures.
- */
- @JsonIgnore
- public String getAllVfModulesJson(){
-
- return listToJson(vfModules);
- }
-
- // methods to add to the list
- public void addVfModule(ModuleResource moduleResource) {
- if (vfModules == null){
- vfModules = new ArrayList<>();
- }
- this.vfModules.add(moduleResource);
- }
-
-
- /**
- * Utility method to allow construction of the filed in the form of
- * <serviceResources.modelInfo.modelName>/<serviceVnfs.modelInfo.modelInstanceName>
- *
- * default setter for this field deprecated
- * @param modelName << serviceResources.modelInfo.modelName
- */
- public void constructVnfType(String modelName) {
- this.vnfType = modelName.concat("/").concat(this.modelInfo.getModelInstanceName());
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * Encapsulates VNF resource data set
+ *
+ */
+@JsonRootName("vnfResource")
+public class VnfResource extends Resource {
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * set resourceType for this object
+ */
+ public VnfResource(){
+ resourceType = ResourceType.VNF;
+ setResourceId(UUID.randomUUID().toString());
+ }
+
+ /*
+ * fields specific to VNF resource type
+ */
+ @JsonProperty("vfModules")
+ private List <ModuleResource> vfModules;
+ private String vnfHostname;
+ private String vnfType;
+ private String nfFunction;
+ private String nfType;
+ private String nfRole;
+ private String nfNamingCode;
+ private String multiStageDesign;
+ private String orchestrationStatus;
+
+ /*
+ * GET and SET
+ */
+ public List<ModuleResource> getVfModules() {
+ return vfModules;
+ }
+ public void setModules(List<ModuleResource> moduleResources) {
+ this.vfModules = moduleResources;
+ }
+ public String getVnfHostname() {
+ return vnfHostname;
+ }
+ public void setVnfHostname(String vnfHostname) {
+ this.vnfHostname = vnfHostname;
+ }
+ @Deprecated
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+ public String getVnfType() {
+ return vnfType;
+ }
+ public String getNfFunction() {
+ return nfFunction;
+ }
+ public void setNfFunction(String nfFunction) {
+ this.nfFunction = nfFunction;
+ }
+ public String getNfType() {
+ return nfType;
+ }
+ public void setNfType(String nfType) {
+ this.nfType = nfType;
+ }
+ public String getNfRole() {
+ return nfRole;
+ }
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+ public String getNfNamingCode() {
+ return nfNamingCode;
+ }
+ public void setNfNamingCode(String nfNamingCode) {
+ this.nfNamingCode = nfNamingCode;
+ }
+ public String getMultiStageDesign() {
+ return multiStageDesign;
+ }
+ public void setMultiStageDesign(String multiStageDesign) {
+ this.multiStageDesign = multiStageDesign;
+ }
+ /*
+ * GET accessors per design requirements
+ */
+
+
+ public String getOrchestrationStatus(){
+ return orchestrationStatus;
+ }
+
+ public void setOrchestrationStatus(String orchestrationStatus){
+ this.orchestrationStatus = orchestrationStatus;
+ }
+ /**
+ * Returns a list of all VfModule objects.
+ * Base module is first entry in the list
+ * @return ordered list of ModuleResources objects
+ */
+ @JsonIgnore
+ public List<ModuleResource> getAllVfModuleObjects(){
+ if (vfModules == null) {
+ return null;
+ }
+
+ for (int i = 0; i < vfModules.size(); i++) {
+ ModuleResource moduleResource = vfModules.get(i);
+ if (moduleResource.getIsBase()){
+ vfModules.remove(moduleResource);
+ vfModules.add(0,moduleResource);
+ }
+ }
+ return vfModules;
+ }
+
+ /**
+ *
+ * @return Returns JSON list of all VfModule structures.
+ */
+ @JsonIgnore
+ public String getAllVfModulesJson(){
+
+ return listToJson(vfModules);
+ }
+
+ // methods to add to the list
+ public void addVfModule(ModuleResource moduleResource) {
+ if (vfModules == null){
+ vfModules = new ArrayList<>();
+ }
+ this.vfModules.add(moduleResource);
+ }
+
+
+ /**
+ * Utility method to allow construction of the filed in the form of
+ * <serviceResources.modelInfo.modelName>/<serviceVnfs.modelInfo.modelInstanceName>
+ *
+ * default setter for this field deprecated
+ * @param modelName << serviceResources.modelInfo.modelName
+ */
+ public void constructVnfType(String modelName) {
+ this.vnfType = modelName.concat("/").concat(this.modelInfo.getModelInstanceName());
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/internal/VariableNameExtractor.java
index e1aaba74da..f63ab31496 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/internal/VariableNameExtractor.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.internal;
+package org.onap.so.bpmn.core.internal;
import java.util.Optional;
import java.util.regex.Matcher;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/DecomposeJsonUtil.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java
index 8ab93f2842..be7851362c 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/DecomposeJsonUtil.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java
@@ -1,138 +1,143 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.json;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.openecomp.mso.bpmn.core.domain.AllottedResource;
-import org.openecomp.mso.bpmn.core.domain.ConfigResource;
-import org.openecomp.mso.bpmn.core.domain.NetworkResource;
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
-import org.openecomp.mso.bpmn.core.domain.ServiceInstance;
-import org.openecomp.mso.bpmn.core.domain.VnfResource;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class DecomposeJsonUtil implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
-
- private DecomposeJsonUtil() {
- }
-
- private static ObjectMapper createObjectMapper() {
- ObjectMapper om = new ObjectMapper();
- om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- return om;
- }
-
- /**
- * Method to construct Service Decomposition object converting JSON structure
- *
- * @param jsonString input in JSON format confirming ServiceDecomposition
- * @return decoded object
- * @throws JsonDecomposingException thrown when decoding json fails
- */
- public static ServiceDecomposition jsonToServiceDecomposition(String jsonString) throws JsonDecomposingException {
- try {
- ObjectMapper om = new ObjectMapper();
- om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- return om.readValue(jsonString, ServiceDecomposition.class);
- } catch (IOException e) {
- throw new JsonDecomposingException("Exception while converting json to service decomposition", e);
- }
- }
-
- /**
- * Method to construct Service Decomposition object converting JSON structure
- *
- * @param jsonString input in JSON format confirming ServiceDecomposition
- * @param serviceInstanceId service instance id to be put in decoded ServiceDecomposition
- * @return decoded object
- * @throws JsonDecomposingException thrown when decoding json fails
- */
- public static ServiceDecomposition jsonToServiceDecomposition(String jsonString, String serviceInstanceId)
- throws JsonDecomposingException {
- ServiceDecomposition serviceDecomposition = jsonToServiceDecomposition(jsonString);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setInstanceId(serviceInstanceId);
- serviceDecomposition.setServiceInstance(serviceInstance);
- return serviceDecomposition;
- }
-
- /**
- * Method to construct Resource Decomposition object converting JSON structure
- *
- * @param jsonString input in JSON format confirming ResourceDecomposition
- * @return decoded object
- * @throws JsonDecomposingException thrown when decoding json fails
- */
- public static VnfResource jsonToVnfResource(String jsonString) throws JsonDecomposingException {
- try {
- return OBJECT_MAPPER.readValue(jsonString, VnfResource.class);
- } catch (IOException e) {
- throw new JsonDecomposingException("Exception while converting json to vnf resource", e);
- }
- }
-
- /**
- * Method to construct Resource Decomposition object converting JSON structure
- *
- * @param jsonString input in JSON format confirming ResourceDecomposition
- * @return decoded object
- * @throws JsonDecomposingException thrown when decoding json fails
- */
- public static NetworkResource jsonToNetworkResource(String jsonString) throws JsonDecomposingException {
- try {
- return OBJECT_MAPPER.readValue(jsonString, NetworkResource.class);
- } catch (IOException e) {
- throw new JsonDecomposingException("Exception while converting json to network resource", e);
- }
- }
-
- /**
- * Method to construct Resource Decomposition object converting JSON structure
- *
- * @param jsonString - input in JSON format confirming ResourceDecomposition
- * @return decoded object
- * @throws JsonDecomposingException thrown when decoding json fails
- */
- public static AllottedResource jsonToAllottedResource(String jsonString) throws JsonDecomposingException {
- try {
- return OBJECT_MAPPER.readValue(jsonString, AllottedResource.class);
- } catch (IOException e) {
- throw new JsonDecomposingException("Exception while converting json to allotted resource", e);
- }
- }
-
- public static ConfigResource jsonToConfigResource(String jsonString) throws JsonDecomposingException {
- try {
- return OBJECT_MAPPER.readValue(jsonString, ConfigResource.class);
- } catch (IOException e) {
- throw new JsonDecomposingException("Exception while converting json to allotted resource", e);
- }
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.json;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.onap.so.bpmn.core.domain.AllottedResource;
+import org.onap.so.bpmn.core.domain.ConfigResource;
+import org.onap.so.bpmn.core.domain.NetworkResource;
+import org.onap.so.bpmn.core.domain.ServiceDecomposition;
+import org.onap.so.bpmn.core.domain.ServiceInstance;
+import org.onap.so.bpmn.core.domain.VnfResource;
+import org.onap.so.logger.MsoLogger;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class DecomposeJsonUtil implements Serializable {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DecomposeJsonUtil.class);
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
+
+ private DecomposeJsonUtil() {
+ }
+
+ private static ObjectMapper createObjectMapper() {
+ ObjectMapper om = new ObjectMapper();
+ om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ return om;
+ }
+
+ /**
+ * Method to construct Service Decomposition object converting JSON structure
+ *
+ * @param jsonString input in JSON format confirming ServiceDecomposition
+ * @return decoded object
+ * @throws JsonDecomposingException thrown when decoding json fails
+ */
+ public static ServiceDecomposition jsonToServiceDecomposition(String jsonString) throws JsonDecomposingException {
+ try {
+ ObjectMapper om = new ObjectMapper();
+ om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ return om.readValue(jsonString, ServiceDecomposition.class);
+ } catch (IOException e) {
+ throw new JsonDecomposingException("Exception while converting json to service decomposition", e);
+ }
+ }
+
+ /**
+ * Method to construct Service Decomposition object converting JSON structure
+ *
+ * @param jsonString input in JSON format confirming ServiceDecomposition
+ * @param serviceInstanceId service instance id to be put in decoded ServiceDecomposition
+ * @return decoded object
+ * @throws JsonDecomposingException thrown when decoding json fails
+ */
+ public static ServiceDecomposition jsonToServiceDecomposition(String jsonString, String serviceInstanceId)
+ throws JsonDecomposingException {
+ ServiceDecomposition serviceDecomposition = jsonToServiceDecomposition(jsonString);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstanceId(serviceInstanceId);
+ serviceDecomposition.setServiceInstance(serviceInstance);
+ return serviceDecomposition;
+ }
+
+ /**
+ * Method to construct Resource Decomposition object converting JSON structure
+ *
+ * @param jsonString input in JSON format confirming ResourceDecomposition
+ * @return decoded object
+ * @throws JsonDecomposingException thrown when decoding json fails
+ */
+ public static VnfResource jsonToVnfResource(String jsonString) throws JsonDecomposingException {
+ try {
+ return OBJECT_MAPPER.readValue(jsonString, VnfResource.class);
+ } catch (IOException e) {
+ throw new JsonDecomposingException("Exception while converting json to vnf resource", e);
+ }
+ }
+
+ /**
+ * Method to construct Resource Decomposition object converting JSON structure
+ *
+ * @param jsonString input in JSON format confirming ResourceDecomposition
+ * @return decoded object
+ * @throws JsonDecomposingException thrown when decoding json fails
+ */
+ public static NetworkResource jsonToNetworkResource(String jsonString) throws JsonDecomposingException {
+ try {
+ return OBJECT_MAPPER.readValue(jsonString, NetworkResource.class);
+ } catch (IOException e) {
+ throw new JsonDecomposingException("Exception while converting json to network resource", e);
+ }
+ }
+
+ /**
+ * Method to construct Resource Decomposition object converting JSON structure
+ *
+ * @param jsonString - input in JSON format confirming ResourceDecomposition
+ * @return decoded object
+ * @throws JsonDecomposingException thrown when decoding json fails
+ */
+ public static AllottedResource jsonToAllottedResource(String jsonString) throws JsonDecomposingException {
+ try {
+ return OBJECT_MAPPER.readValue(jsonString, AllottedResource.class);
+ } catch (IOException e) {
+ throw new JsonDecomposingException("Exception while converting json to allotted resource", e);
+ }
+ }
+
+ public static ConfigResource jsonToConfigResource(String jsonString) throws JsonDecomposingException {
+ try {
+ return OBJECT_MAPPER.readValue(jsonString, ConfigResource.class);
+ } catch (IOException e) {
+ throw new JsonDecomposingException("Exception while converting json to allotted resource", e);
+ }
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonDecomposingException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonDecomposingException.java
index 352979e7dd..c9d46b9122 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonDecomposingException.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonDecomposingException.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.json;
+package org.onap.so.bpmn.core.json;
import java.io.IOException;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
index 01388352de..ee53148e44 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
@@ -1,1027 +1,1087 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.json;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.runtime.Execution;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.XML;
-import org.openecomp.mso.apihandler.common.ValidationException;
-
-import org.openecomp.mso.bpmn.core.xml.XmlTool;
-import org.openecomp.mso.logger.MsoLogger;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.main.JsonValidator;
-
-/**
- * Utility class for JSON processing
- *
- * @version 1.0
- *
- * Note: It was observed, that depending on the JSON implementation, an org.json.JSONException or a
- * java.util.NoSuchElementException will be thrown in the event of the key value being "not found"
- * in a JSON document. A general check has been added to the applicable catch blocks for this
- * this type of behavior to reduce the amount of logging. As a key value not being found is
- * expect behavior, it makes no sense to log the stack trace associated with this type of failure.
- */
-
-public class JsonUtils {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- private static int MSOJsonIndentFactor = 3;
-
- /**
- * Uses the JSONObject static method to convert a XML doc to JSON.
- *
- * @param xml String containing the XML doc
- * @param pretty flag to determine if the output should be formatted
- * @return String containing the JSON translation
- */
- public static String xml2json(String xml, Boolean pretty) {
-
- try {
- // name spaces cause problems, so just remove them
- JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml));
- if (!pretty) {
- return jsonObj.toString();
- } else {
- // add an indent to make it 'pretty'
- return jsonObj.toString(MSOJsonIndentFactor);
- }
- } catch (Exception e){
- msoLogger.debug("xml2json(): unable to parse xml and convert to json. Exception was: " + e.toString(), e);
- return null;
- }
- }
-
- /**
- * Invokes xml2json(String, Boolean) defaulting to 'pretty' output.
- *
- * @param xml String containing the XML doc
- * @return String containing the JSON translation
- */
- public static String xml2json(String xml) {
- return xml2json(xml, true);
- }
-
- /**
- * Uses the JSONObject static method to convert a JSON doc to XML.
- * Note: this method may not generate valid XML if the JSONObject
- * contains JSONArrays which are used to represent XML attributes
- * in the JSON doc.
- *
- * @param jsonStr String containing the JSON doc
- * @param pretty flag to determine if the output should be formatted
- * @return String containing the XML translation
- */
- public static String json2xml(String jsonStr, Boolean pretty) {
-
- try {
- JSONObject jsonObj = new JSONObject(jsonStr);
- if (pretty) {
-// return XmlTool.normalize(XML.toString(jsonObj));
-// use the local class method which properly handles certain JSONArray content
- return XmlTool.normalize(toXMLString(jsonObj, null));
- } else {
-// return XML.toString(jsonObj);
-// use the local class method which properly handles certain JSONArray content
- return toXMLString(jsonObj, null);
- }
- } catch (Exception e){
- msoLogger.debug("json2xml(): unable to parse json and convert to xml. Exception was: " + e.toString(), e);
- return null;
- }
- }
-
- /**
- * Uses a modified version of the org.json.XML toString() algorithm
- * to convert a JSONObject to an XML Doc. The intent of this is to
- * correctly generate XML from JSON including TAGs for JSONArrays
- *
- * @param obj org.json.JSON object to be converted to XML
- * @param tagName optional XML tagname supplied primarily during recursive calls
- * @return String containing the XML translation
- */
- public static String toXMLString(Object obj, String tagName) throws JSONException {
- StringBuilder strBuf = new StringBuilder();
- int i;
- JSONArray jsonArr;
- JSONObject jsonObj;
- String key;
- Iterator<String> keys;
- int len;
- String str;
- Object curObj;
- if (obj instanceof JSONObject) {
- // msoLogger.debug("toXMLString(): is a JSONObject");
- // append "<tagName>" to the XML output
- if (tagName != null) {
-// msoLogger.debug("toXMLString(): adding opening tagName: " + tagName);
- strBuf.append("<");
- strBuf.append(tagName);
- strBuf.append(">");
- }
- // iterate thru the keys.
- jsonObj = (JSONObject) obj;
- keys = jsonObj.keys();
- while (keys.hasNext()) {
- key = keys.next();
- // msoLogger.debug("toXMLString(): key is " + k);
- curObj = jsonObj.opt(key);
- if (curObj == null) {
- curObj = "";
- }
- if (curObj instanceof String) {
- str = (String) curObj;
- } else {
- str = null;
- }
- // append the content to the XML output
- if ("content".equals(key)) {
- if (curObj instanceof JSONArray) {
- jsonArr = (JSONArray) curObj;
- len = jsonArr.length();
- for (i = 0; i < len; i += 1) {
- if (i > 0) {
- strBuf.append('\n');
- }
- strBuf.append(XML.escape(jsonArr.get(i).toString()));
- }
- } else {
- strBuf.append(XML.escape(curObj.toString()));
- }
- // append an array of similar keys to the XML output
- } else if (curObj instanceof JSONArray) {
- jsonArr = (JSONArray) curObj;
- len = jsonArr.length();
-// msoLogger.debug("toXMLString(): found JSONArray: " + key + ", size: " + len);
- for (i = 0; i < len; i += 1) {
- curObj = jsonArr.get(i);
- if (curObj instanceof JSONArray) {
-// The XML tags for the nested array should be generated below when this method
-// is called recursively and the JSONArray object is passed
-// strBuf.append("<");
-// strBuf.append(key);
-// strBuf.append(">");
- strBuf.append(toXMLString(curObj, null));
-// strBuf.append("</");
-// strBuf.append(key);
-// strBuf.append(">");
- } else {
-// msoLogger.debug("toXMLString(): recursive call toXML() with tagName null");
- // append the opening tag for the array (before 1st element)
- if (i == 0) {
- strBuf.append("<");
- strBuf.append(key);
- strBuf.append(">");
- }
- // append the opening tag for the array
- strBuf.append(toXMLString(curObj, null));
- // append the closing tag for the array (after last element)
- if (i == (len - 1)) {
- strBuf.append("</");
- strBuf.append(key);
- strBuf.append(">");
- }
- }
- }
- } else if (curObj.equals("")) {
- // append a closing tag "<key>" to the XML output
- strBuf.append("<");
- strBuf.append(key);
- strBuf.append("/>");
- } else {
-// msoLogger.debug("toXMLString(): recursive call toXMLString() with tagName: " + key);
- strBuf.append(toXMLString(curObj, key));
- }
- // msoLogger.debug("toXML(): partial XML: " + strBuf.toString());
- }
- if (tagName != null) {
- // append the closing tag "</tagName>" to the XML output
-// msoLogger.debug("toXMLString(): adding closing tagName: " + tagName);
- strBuf.append("</");
- strBuf.append(tagName);
- strBuf.append(">");
- }
- return strBuf.toString();
- // XML does not have good support for arrays. If an array appears in a place
- // where XML is lacking, synthesize an < array > element.
- } else if (obj instanceof JSONArray) {
- jsonArr = (JSONArray) obj;
- len = jsonArr.length();
- for (i = 0; i < len; ++i) {
- curObj = jsonArr.opt(i);
- strBuf.append(toXMLString(curObj, (tagName == null) ? "array"
- : tagName));
- }
- return strBuf.toString();
- } else {
-// msoLogger.debug("toXML(): in else block with tagName: " + tagName);
- str = (obj == null) ? "null" : XML.escape(obj.toString());
- return (tagName == null) ? "\"" + str + "\""
- : (str.length() == 0) ? "<" + tagName + "/>" : "<"
- + tagName + ">" + str + "</" + tagName + ">";
- }
- }
-
- /**
- * Invokes json2xml(String, Boolean) defaulting to 'pretty' output.
- *
- * @param jsonStr String containing the XML doc
- * @return String containing the JSON translation
- */
- public static String json2xml(String jsonStr) {
- return json2xml(jsonStr, true);
- }
-
- /**
- * Formats the JSON String using the value of MSOJsonIndentFactor.
- *
- * @param jsonStr String containing the JSON doc
- * @return String containing the formatted JSON doc
- */
- public static String prettyJson(String jsonStr) {
-// String isDebugLogEnabled = "true";
- try {
- JSONObject jsonObj = new JSONObject(jsonStr);
- return jsonObj.toString(MSOJsonIndentFactor);
- } catch (Exception e){
- msoLogger.debug("prettyJson(): unable to parse/format json input. Exception was: " + e.toString(), e);
- return null;
- }
- }
-
- /**
- * Returns an Iterator over the JSON keys in the specified JSON doc.
- *
- * @param jsonStr String containing the JSON doc
- * @return Iterator over the JSON keys
- * @throws JSONException if the doc cannot be parsed
- */
- public static Iterator <String> getJsonIterator(String jsonStr) throws JSONException {
- return new JSONObject(jsonStr).keys();
- }
-
- /**
- * Returns the name of the "root" property in the specified JSON doc. The
- * "root" property is the single top-level property in the JSON doc. An
- * exception is thrown if the doc is empty or if it contains more than one
- * top-level property.
- *
- * @param jsonStr String containing the JSON doc
- * @return the name of the "root" property
- * @throws JSONException if the doc cannot be parsed, or if it is empty, or if
- * it contains more than one top-level property
- */
- public static String getJsonRootProperty(String jsonStr) throws JSONException {
- Iterator<String> iter = getJsonIterator(jsonStr);
-
- if (!iter.hasNext()) {
- throw new JSONException("Empty JSON object");
- }
-
- String rootPropertyName = iter.next();
-
- if (iter.hasNext()) {
- throw new JSONException("JSON object has more than one root property");
- }
-
- return rootPropertyName;
- }
-
- /**
- * Invokes the getJsonRawValue() method and returns the String equivalent of
- * the object returned.
- *
- * TBD: May need separate methods for boolean, float, and integer fields if the
- * String representation is not sufficient to meet client needs.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return String field value associated with keys
- */
- public static String getJsonValue(String jsonStr, String keys) {
-
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys);
- if (rawValue == null) {
- return null;
- } else {
- if (rawValue instanceof String) {
- msoLogger.debug("getJsonValue(): the raw value is a String Object=" + rawValue);
- return (String) rawValue;
- } else {
- msoLogger.debug("getJsonValue(): the raw value is NOT a String Object=" + rawValue.toString());
- return rawValue.toString();
- }
- }
- } catch (Exception e) {
- msoLogger.debug("getJsonValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
- }
- return null;
- }
-
- /**
- * Invokes the getJsonRawValue() method with the wrap flag set to true
- * and returns the String equivalent of the json node object returned.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return String field value associated with keys
- */
- public static String getJsonNodeValue(String jsonStr, String keys) {
-// String isDebugLogEnabled = "true";
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys, true);
- if (rawValue == null) {
- return null;
- } else {
- if (rawValue instanceof String) {
- msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + rawValue);
- return (String) rawValue;
- } else {
- msoLogger.debug("getJsonNodeValue(): the raw value is NOT a String Object=" + rawValue.toString());
- return rawValue.toString();
- }
- }
- } catch (Exception e) {
- msoLogger.debug("getJsonNodeValue(): unable to parse json to retrieve node for field=" + keys + ". Exception was: " + e.toString(), e);
- }
- return null;
- }
-
- /**
- * Invokes the getJsonRawValue() method and returns the String equivalent of
- * the object returned.
- *
- * TBD: May need separate methods for boolean, float, and integer fields if the
- * String representation is not sufficient to meet client needs.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return String field value associated with keys
- */
- public static int getJsonIntValue(String jsonStr, String keys) {
-// String isDebugLogEnabled = "true";
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys);
- if (rawValue == null) {
- return 0;
- } else {
- if (rawValue instanceof Integer) {
- msoLogger.debug("getJsonValue(): the raw value is an Integer Object=" + rawValue);
- return (Integer) rawValue;
- } else {
- msoLogger.debug("getJsonIntValue(): the raw value is NOT an Integer Object=" + rawValue.toString());
- return 0;
- }
- }
- } catch (Exception e) {
- msoLogger.debug("getJsonIntValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(), e);
- }
- return 0;
- }
-
- /**
- * Invokes the getJsonRawValue() method and returns the boolean equivalent of
- * the object returned.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return boolean field value associated with keys - default is false
- */
- public static boolean getJsonBooleanValue(String jsonStr, String keys) {
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys);
- if (rawValue == null) {
- return false;
- } else {
- if (rawValue instanceof Boolean) {
- msoLogger.debug("getJsonBooleanValue(): the raw value is a Boolean Object=" + rawValue);
- return (Boolean) rawValue;
- } else {
- msoLogger.debug("getJsonBooleanValue(): the raw value is NOT an Boolean Object=" + rawValue.toString());
- return false;
- }
- }
- } catch (Exception e) {
- msoLogger.debug("getJsonBooleanValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
- }
- return false;
- }
-
- /**
- * Invokes the getJsonParamValue() method to obtain the JSONArray associated with
- * the specified keys. The JSONArray is then walked to retrieve the first array
- * value associated with the specified field name (index=0).
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @param name field name for the param to be retrieved
- * @return String param value associated with field name
- */
- public static String getJsonParamValue(String jsonStr, String keys, String name) {
- return getJsonParamValue(jsonStr, keys, name, 0);
- }
-
- /**
- * Invokes the getJsonRawValue() method to obtain the JSONArray associated with
- * the specified keys. The JSONArray is then walked to retrieve the nth array
- * value associated with the specified field name and index.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @param name field name for the param to be retrieved
- * @param index the nth param associated with name starting at 0
- * @return String param value associated with field name
- */
- public static String getJsonParamValue(String jsonStr, String keys, String name, int index) {
-
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys);
- if (rawValue == null) {
- return null;
- } else {
- if (rawValue instanceof JSONArray) {
- msoLogger.debug("getJsonParamValue(): keys=" + keys + " points to JSONArray: " + rawValue.toString());
- int arrayLen = ((JSONArray) rawValue).length();
- if (index < 0 || arrayLen < index+1) {
- msoLogger.debug("getJsonParamValue(): index: " + index + " is out of bounds for array size of " + arrayLen);
- return null;
- }
- int foundCnt = 0;
- for (int i = 0; i < arrayLen; i++) {
- msoLogger.debug("getJsonParamValue(): index: " + i + ", value: " + ((JSONArray) rawValue).get(i).toString());
- if (((JSONArray) rawValue).get(i) instanceof JSONObject) {
-// msoLogger.debug("getJsonParamValue(): index: " + i + " is a JSONObject");
- JSONObject jsonObj = (JSONObject)((JSONArray) rawValue).get(i);
- String parmValue = jsonObj.get(name).toString();
- if (parmValue != null) {
- msoLogger.debug("getJsonParamValue(): found value: " + parmValue + " for name: " + name + " and index: " + i);
- if (foundCnt == index) {
- return parmValue;
- } else {
- foundCnt++;
- continue;
- }
- } else {
- continue;
- }
- } else {
- msoLogger.debug("getJsonParamValue(): the JSONArray element is NOT a JSONObject=" + rawValue.toString());
- return null;
- }
- }
- msoLogger.debug("getJsonParamValue(): content value NOT found for name: " + name);
- return null;
- } else {
- msoLogger.debug("getJsonParamValue(): the raw value is NOT a JSONArray Object=" + rawValue.toString());
- return null;
- }
- }
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("getJsonParamValue(): failed to retrieve param value for keys:" + keys + ", name=" + name + ": " + e.getMessage());
- } else {
- msoLogger.debug("getJsonParamValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(), e);
- }
- }
- return null;
- }
-
- /**
- * Wrapper to generate the JSONObject to pass to the getJsonValueForKey(JSONObject, String)
- * method so that recursion over the subobjects can be supported there
- *
- * @param jsonStr String containing the JSON doc
- * @param key key to the target value
- * @return String field value associated with key
- */
- public static String getJsonValueForKey(String jsonStr, String key) {
-
- try {
- JSONObject jsonObj = new JSONObject(jsonStr);
- return getJsonValueForKey(jsonObj, key);
- } catch (Exception e) {
- msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(), e);
- }
- return null;
- }
-
- /**
- * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
- * single key/field name specified. Returns the associated value if found or null if the key is not found
- *
- * @param jsonObj JSONObject representation of the the JSON doc
- * @param key key to the target value
- * @return String field value associated with key
- */
- public static String getJsonValueForKey(JSONObject jsonObj, String key) {
-
- String keyValue = null;
- try {
- if (jsonObj.has(key)) {
- Object value = jsonObj.get(key);
- msoLogger.debug("getJsonValueForKey(): found value=" + (String) value + ", for key=" + key);
- if (value == null) {
- return null;
- } else {
- return ((String) value);
- }
- } else {
-// msoLogger.debug("getJsonValueForKey(): iterating over the keys");
- Iterator <String> itr = jsonObj.keys();
- while (itr.hasNext()) {
- String nextKey = itr.next();
- Object obj = jsonObj.get(nextKey);
- if (obj instanceof JSONObject) {
-// msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call on: " +
-// ((JSONObject) obj).toString(MSOJsonIndentFactor));
- keyValue = getJsonValueForKey((JSONObject) obj, key);
- if (keyValue != null) {
-// msoLogger.debug("getJsonValueForKey(): found value=" + keyValue + ", for key=" + key);
- break;
- }
- } else {
- msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
- }
- }
- }
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("getJsonValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
- } else {
- msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(), e);
- }
- keyValue = null;
- }
- return keyValue;
- }
-
- /**
- * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
- * single key/field name specified. Returns the associated value if found or null if the key is not found
- *
- * @param jsonObj JSONObject representation of the the JSON doc
- * @param key key to the target value
- * @return String field value associated with key
- */
- public static Integer getJsonIntValueForKey(JSONObject jsonObj, String key) {
-// String isDebugLogEnabled = "true";
- Integer keyValue = null;
- try {
- if (jsonObj.has(key)) {
- Integer value = (Integer) jsonObj.get(key);
- msoLogger.debug("getJsonIntValueForKey(): found value=" + value + ", for key=" + key);
- return value;
- } else {
-// msoLogger.debug("getJsonIntValueForKey(): iterating over the keys");
- Iterator <String> itr = jsonObj.keys();
- while (itr.hasNext()) {
- String nextKey = itr.next();
- Object obj = jsonObj.get(nextKey);
- if (obj instanceof JSONObject) {
-// msoLogger.debug("getJsonIntValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call");
- keyValue = getJsonIntValueForKey((JSONObject) obj, key);
- if (keyValue != null) {
-// msoLogger.debug("getJsonIntValueForKey(): found value=" + keyValue + ", for key=" + key);
- break;
- }
- } else {
- msoLogger.debug("getJsonIntValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
- }
- }
- }
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("getJsonIntValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
- } else {
- msoLogger.debug("getJsonIntValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(),e);
- }
- keyValue = null;
- }
- return keyValue;
- }
-
- /**
- * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
- * single key/field name specified. Returns the associated value if found or null if the key is not found
- *
- * @param jsonObj JSONObject representation of the the JSON doc
- * @param key key to the target value
- * @return String field value associated with key
- */
- public static Boolean getJsonBooleanValueForKey(JSONObject jsonObj, String key) {
- Boolean keyValue = null;
- try {
- if (jsonObj.has(key)) {
- Boolean value = (Boolean) jsonObj.get(key);
- msoLogger.debug("getJsonBooleanValueForKey(): found value=" + value + ", for key=" + key);
- return value;
- } else {
-// msoLogger.debug("getJsonBooleanValueForKey(): iterating over the keys");
- Iterator <String> itr = jsonObj.keys();
- while (itr.hasNext()) {
- String nextKey = itr.next();
- Object obj = jsonObj.get(nextKey);
- if (obj instanceof JSONObject) {
-// msoLogger.debug("getJsonBooleanValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call");
- keyValue = getJsonBooleanValueForKey((JSONObject) obj, key);
- if (keyValue != null) {
-// msoLogger.debug("getJsonBooleanValueForKey(): found value=" + keyValue + ", for key=" + key);
- break;
- }
- } else {
- msoLogger.debug("getJsonBooleanValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
- }
- }
- }
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("getJsonBooleanValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
- } else {
- msoLogger.debug("getJsonBooleanValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(),e);
- }
- keyValue = null;
- }
- return keyValue;
- }
-
- /**
- * Boolean method to determine if a key path is valid for the JSON doc. Invokes
- * getJsonValue().
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return Boolean true if keys points to value in the JSON doc
- */
- public static Boolean jsonValueExists(String jsonStr, String keys) {
- if (getJsonRawValue(jsonStr, keys) == null) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Inserts the new key/value pair at the appropriate location in the JSON
- * document after first determining if keyed field already exists. If
- * it does exist, return the JSON unmodified, otherwise return the new JSON
- * Note: this method currently only supports String value inserts.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the value to be added in the format of "key1.key2.key3..."
- * @return String containing the updated JSON doc
- */
- public static String addJsonValue(String jsonStr, String keys, String value) {
-
- // only attempt to insert the key/value pair if it does not exist
- if (!jsonValueExists(jsonStr, keys)) {
- return putJsonValue(jsonStr, keys, value);
- } else {
- msoLogger.debug("addJsonValue(): JSON add failed, key=" + keys + "/value=" + value + " already exists");
- return jsonStr;
- }
- }
-
- /**
- * Updates the value for the specified key in the JSON document
- * after first determining if keyed field exists. If it does
- * not exist, return the JSON unmodified, otherwise return the updated JSON.
- * Note: this method currently only supports String value updates.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the value to be updated in the format of "key1.key2.key3..."
- * @return String containing the updated JSON doc
- */
- public static String updJsonValue(String jsonStr, String keys, String newValue) {
-
- // only attempt to modify the key/value pair if it exists
- if (jsonValueExists(jsonStr, keys)) {
- return putJsonValue(jsonStr, keys, newValue);
- } else {
- msoLogger.debug("updJsonValue(): JSON update failed, no value exists for key=" + keys);
- return jsonStr;
- }
- }
-
- /**
- * Deletes the value for the specified key in the JSON document
- * after first determining if keyed field exists. If it does
- * not exist, return the JSON unmodified, otherwise return the updated JSON
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..."
- * @return String containing the updated JSON doc
- */
- public static String delJsonValue(String jsonStr, String keys) {
-
- // only attempt to remove the key/value pair if it exists
- if (jsonValueExists(jsonStr, keys)) {
- // passing a null value results in a delete
- return putJsonValue(jsonStr, keys, null);
- } else {
- msoLogger.debug("delJsonValue(): JSON delete failed, no value exists for key=" + keys);
- return jsonStr;
- }
- }
-
- /**
- * Walks the JSON doc using the full key path to retrieve the associated
- * value. All but the last key points to the 'parent' object name(s) in order
- * in the JSON hierarchy with the last key pointing to the target value.
- * The value returned is a Java object.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return Object field value associated with keys
- */
- private static Object getJsonRawValue(String jsonStr, String keys) {
- return getJsonRawValue(jsonStr, keys, false);
- }
-
- /**
- * Walks the JSON doc using the full key path to retrieve the associated
- * value. All but the last key points to the 'parent' object name(s) in order
- * in the JSON hierarchy with the last key pointing to the target value.
- * The value returned is a Java object.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @param wrap Boolean which determines if returned JSONObjects sould be "wrapped"
- * Note: wrap does not apply to returned scalar values
- * @return Object field value associated with keys
- */
- private static Object getJsonRawValue(String jsonStr, String keys, Boolean wrap) {
-
- String keyStr = "";
- try {
- JSONObject jsonObj = new JSONObject(jsonStr);
- StringTokenizer keyTokens = new StringTokenizer(keys, ".");
- while (keyTokens.hasMoreElements()) {
- keyStr = keyTokens.nextToken();
- Object keyValue = jsonObj.get(keyStr);
- if (keyValue instanceof JSONObject) {
-// msoLogger.debug("getJsonRawValue(): key=" + keyStr + " points to json object");
- jsonObj = (JSONObject) keyValue;
- } else {
- if (keyTokens.hasMoreElements()) {
- msoLogger.debug("getJsonRawValue(): value found prior to last key for key=" + keyStr);
- }
- return keyValue;
- }
- }
- // return the json 'node' that the key points to
- // note: since this is a json object and not a scalar value,
- // use the wrap flag to determine if the object should
- // be wrapped with a root node value
- // (the last key in the keys String)
- if (wrap) {
- JSONObject wrappedJsonObj = new JSONObject();
- wrappedJsonObj.put(keyStr, jsonObj);
- return wrappedJsonObj.toString();
- } else {
- return jsonObj.toString();
- }
-
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("getJsonRawValue(): failed to retrieve param value for key=" + keyStr + ": " + e.getMessage());
- } else {
- msoLogger.debug("getJsonRawValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
- }
- }
- return null;
- }
-
- /**
- * Private method invoked by the public add, update, and delete methods.
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..."
- * @return String containing the updated JSON doc
- */
- private static String putJsonValue(String jsonStr, String keys, String value) {
-
- String keyStr = "";
- try {
- JSONObject jsonObj = new JSONObject(jsonStr);
- JSONObject jsonObjOut = jsonObj;
- StringTokenizer keyTokens = new StringTokenizer(keys, ".");
- while (keyTokens.hasMoreElements()) {
- keyStr = keyTokens.nextToken();
- if (keyTokens.hasMoreElements()) {
- Object keyValue = jsonObj.get(keyStr);
- if (keyValue instanceof JSONObject) {
-// msoLogger.debug("putJsonValue(): key=" + keyStr + " points to json object");
- jsonObj = (JSONObject) keyValue;
- } else {
- msoLogger.debug("putJsonValue(): key=" + keyStr + " not the last key but points to non-json object: " + keyValue);
- return null;
- }
- } else { // at the last/new key value
- jsonObj.put(keyStr, value);
- return jsonObjOut.toString(3);
- }
- }
- // should not hit this point if the key points to a valid key value
- return null;
-
- } catch (Exception e) {
- // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
- if (e.getMessage().contains("not found")) {
- msoLogger.debug("putJsonValue(): failed to put param value for key=" + keyStr + ": " + e.getMessage());
- } else {
- msoLogger.debug("putJsonValue(): unable to parse json to put value for key=" + keys + ". Exception was: " + e.toString(),e);
- }
- }
- return null;
- }
-
- /**
- * This json util method converts a json array of Key Value
- * pair objects into a Java Map.
- *
- * @param execution
- * @param entryArray - the getJsonValue of a json Array of key/value pairs
- *
- * @return Map - a Map containing the entries
- */
- public Map<String, String> jsonStringToMap(DelegateExecution execution, String entry) {
- msoLogger.debug("Started Json String To Map Method");
-
- Map<String, String> map = new HashMap<>();
-
- //Populate Map
- JSONObject obj = new JSONObject(entry);
-
- /* Wildfly is pushing a version of org.json which does not
- * auto cast to string. Leaving it as an object prevents
- * a method not found exception at runtime.
- */
- final Iterator<String> keys = obj.keys();
- while (keys.hasNext()) {
- final String key = keys.next();
- map.put(key, obj.getString(key));
- }
- msoLogger.debug("Outgoing Map is: " + map);
- msoLogger.debug("Completed Json String To Map Method");
- return map;
- }
-
- /**
- * This json util method converts a json array of Key Value
- * pair objects into a Java Map.
- *
- * @param execution
- * @param entryArray - the getJsonValue of a json Array of key/value pairs
- * @param keyNode - the name of the node that represents the key
- * @param valueNode - the name of the node that represents the value
- *
- * @return Map - a Map containing the entries
- *
- */
- public Map<String, String> entryArrayToMap(DelegateExecution execution, String entryArray, String keyNode, String valueNode) {
- msoLogger.debug("Started Entry Array To Map Util Method");
-
- Map<String, String> map = new HashMap<>();
- //Populate Map
- String entryListJson = "{ \"wrapper\":" + entryArray + "}";
- JSONObject obj = new JSONObject(entryListJson);
- JSONArray arr = obj.getJSONArray("wrapper");
- for (int i = 0; i < arr.length(); i++){
- JSONObject jo = arr.getJSONObject(i);
- String key = jo.getString(keyNode);
- String value = jo.getString(valueNode);
- map.put(key, value);
- }
- msoLogger.debug("Outgoing Map is: " + map);
- msoLogger.debug("Completed Entry Array To Map Util Method");
- return map;
- }
-
- /**
- * This json util method converts a json Array of Strings
- * to a Java List. It takes each String in the json Array
- * and puts it in a Java List<String>.
- *
- * @param execution
- * @param jsonArrayOfStrings - the getJsonValue of a json array of strings
- *
- * @return List - a java list containing the strings
- *
- *
- */
- public List<String> StringArrayToList(Execution execution, String jsonArrayOfStrings) {
- msoLogger.debug("Started String Array To List Util Method");
-
- List<String> list = new ArrayList<>();
- //Populate List
- String stringListJson = "{ \"strings\":" + jsonArrayOfStrings + "}";
- JSONObject obj = new JSONObject(stringListJson);
- JSONArray arr = obj.getJSONArray("strings");
- for (int i = 0; i < arr.length(); i++){
- String s = arr.get(i).toString();
- list.add(s);
- }
- msoLogger.debug("Outgoing List is: " + list);
- msoLogger.debug("Completed String Array To List Util Method");
- return list;
- }
-
- /**
- *
- * Invokes the getJsonRawValue() method to determine if the
- * json element/variable exist. Returns true if the
- * json element exist
- *
- * @param jsonStr String containing the JSON doc
- * @param keys full key path to the target value in the format of "key1.key2.key3..."
- * @return boolean field value associated with keys
- *
- *
- */
- public static boolean jsonElementExist(String jsonStr, String keys) {
-
- try {
- Object rawValue = getJsonRawValue(jsonStr, keys);
-
- return !(rawValue == null);
-
- } catch (Exception e) {
- msoLogger.debug("jsonElementExist(): unable to determine if json element exist. Exception is: " + e.toString(),e);
- }
- return true;
- }
-
- /**
- *
- * Validates the JSON document against a schema file.
- *
- * @param jsonStr String containing the JSON doc
- * @param jsonSchemaPath full path to a valid JSON schema file
- * @return String the validation results/report
- *
- *
- */
- public static String jsonSchemaValidation(String jsonStr, String jsonSchemaPath) throws ValidationException {
- try {
- msoLogger.debug("JSON document to be validated: " + jsonStr);
- JsonNode document = JsonLoader.fromString(jsonStr);
-// JsonNode document = JsonLoader.fromFile(jsonDoc);
- JsonNode schema = JsonLoader.fromPath(jsonSchemaPath);
-
- JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
- JsonValidator validator = factory.getValidator();
-
- ProcessingReport report = validator.validate(schema, document);
- msoLogger.debug("JSON schema validation report: " + report.toString());
- return report.toString();
- } catch (IOException e) {
- msoLogger.debug("IOException performing JSON schema validation on document: " + e.toString());
- throw new ValidationException(e.getMessage());
- } catch (ProcessingException e) {
- msoLogger.debug("ProcessingException performing JSON schema validation on document: " + e.toString());
- throw new ValidationException(e.getMessage());
- }
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.bpmn.core.json;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.Execution;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.XML;
+import org.onap.so.bpmn.core.xml.XmlTool;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MsoLogger;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jackson.JsonLoader;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.main.JsonSchemaFactory;
+import com.github.fge.jsonschema.main.JsonValidator;
+
+/**
+ * Utility class for JSON processing
+ *
+ * @version 1.0
+ *
+ * Note: It was observed, that depending on the JSON implementation, an org.json.JSONException or a
+ * java.util.NoSuchElementException will be thrown in the event of the key value being "not found"
+ * in a JSON document. A general check has been added to the applicable catch blocks for this
+ * this type of behavior to reduce the amount of logging. As a key value not being found is
+ * expect behavior, it makes no sense to log the stack trace associated with this type of failure.
+ */
+public class JsonUtils {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, JsonUtils.class);
+ private static int MSOJsonIndentFactor = 3;
+
+ /**
+ * Uses the JSONObject static method to convert a XML doc to JSON.
+ *
+ * @param xml String containing the XML doc
+ * @param pretty flag to determine if the output should be formatted
+ * @return String containing the JSON translation
+ */
+ public static String xml2json(String xml, Boolean pretty) {
+ try {
+ // name spaces cause problems, so just remove them
+ JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml));
+ if (!pretty) {
+ return jsonObj.toString();
+ } else {
+ // add an indent to make it 'pretty'
+ return jsonObj.toString(MSOJsonIndentFactor);
+ }
+ } catch (Exception e){
+ msoLogger.debug("xml2json(): unable to parse xml and convert to json. Exception was: " + e.toString(), e);
+ return null;
+ }
+ }
+
+ /**
+ * Invokes xml2json(String, Boolean) defaulting to 'pretty' output.
+ *
+ * @param xml String containing the XML doc
+ * @return String containing the JSON translation
+ */
+ public static String xml2json(String xml) {
+ return xml2json(xml, true);
+ }
+
+ /**
+ * Uses the JSONObject static method to convert a JSON doc to XML.
+ * Note: this method may not generate valid XML if the JSONObject
+ * contains JSONArrays which are used to represent XML attributes
+ * in the JSON doc.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param pretty flag to determine if the output should be formatted
+ * @return String containing the XML translation
+ */
+ public static String json2xml(String jsonStr, Boolean pretty) {
+
+ try {
+ JSONObject jsonObj = new JSONObject(jsonStr);
+ if (pretty) {
+// return XmlTool.normalize(XML.toString(jsonObj));
+// use the local class method which properly handles certain JSONArray content
+ return XmlTool.normalize(toXMLString(jsonObj, null));
+ } else {
+// return XML.toString(jsonObj);
+// use the local class method which properly handles certain JSONArray content
+ return toXMLString(jsonObj, null);
+ }
+ } catch (Exception e){
+ msoLogger.debug("json2xml(): unable to parse json and convert to xml. Exception was: " + e.toString(), e);
+ return null;
+ }
+ }
+
+ /**
+ * Uses a modified version of the org.json.XML toString() algorithm
+ * to convert a JSONObject to an XML Doc. The intent of this is to
+ * correctly generate XML from JSON including TAGs for JSONArrays
+ *
+ * @param obj org.json.JSON object to be converted to XML
+ * @param tagName optional XML tagname supplied primarily during recursive calls
+ * @return String containing the XML translation
+ */
+ public static String toXMLString(Object obj, String tagName) throws JSONException {
+ StringBuilder strBuf = new StringBuilder();
+ int i;
+ JSONArray jsonArr;
+ JSONObject jsonObj;
+ String key;
+ Iterator<String> keys;
+ int len;
+ String str;
+ Object curObj;
+ if (obj instanceof JSONObject) {
+ // msoLogger.debug("toXMLString(): is a JSONObject");
+ // append "<tagName>" to the XML output
+ if (tagName != null) {
+// msoLogger.debug("toXMLString(): adding opening tagName: " + tagName);
+ strBuf.append("<");
+ strBuf.append(tagName);
+ strBuf.append(">");
+ }
+ // iterate thru the keys.
+ jsonObj = (JSONObject) obj;
+ keys = jsonObj.keys();
+ while (keys.hasNext()) {
+ key = keys.next();
+ // msoLogger.debug("toXMLString(): key is " + k);
+ curObj = jsonObj.opt(key);
+ if (curObj == null) {
+ curObj = "";
+ }
+ if (curObj instanceof String) {
+ str = (String) curObj;
+ } else {
+ str = null;
+ }
+ // append the content to the XML output
+ if ("content".equals(key)) {
+ if (curObj instanceof JSONArray) {
+ jsonArr = (JSONArray) curObj;
+ len = jsonArr.length();
+ for (i = 0; i < len; i += 1) {
+ if (i > 0) {
+ strBuf.append('\n');
+ }
+ strBuf.append(XML.escape(jsonArr.get(i).toString()));
+ }
+ } else {
+ strBuf.append(XML.escape(curObj.toString()));
+ }
+ // append an array of similar keys to the XML output
+ } else if (curObj instanceof JSONArray) {
+ jsonArr = (JSONArray) curObj;
+ len = jsonArr.length();
+// msoLogger.debug("toXMLString(): found JSONArray: " + key + ", size: " + len);
+ for (i = 0; i < len; i += 1) {
+ curObj = jsonArr.get(i);
+ if (curObj instanceof JSONArray) {
+// The XML tags for the nested array should be generated below when this method
+// is called recursively and the JSONArray object is passed
+// strBuf.append("<");
+// strBuf.append(key);
+// strBuf.append(">");
+ strBuf.append(toXMLString(curObj, null));
+// strBuf.append("</");
+// strBuf.append(key);
+// strBuf.append(">");
+ } else {
+// msoLogger.debug("toXMLString(): recursive call toXML() with tagName null");
+ // append the opening tag for the array (before 1st element)
+ if (i == 0) {
+ strBuf.append("<");
+ strBuf.append(key);
+ strBuf.append(">");
+ }
+ // append the opening tag for the array
+ strBuf.append(toXMLString(curObj, null));
+ // append the closing tag for the array (after last element)
+ if (i == (len - 1)) {
+ strBuf.append("</");
+ strBuf.append(key);
+ strBuf.append(">");
+ }
+ }
+ }
+ } else if (curObj.equals("")) {
+ // append a closing tag "<key>" to the XML output
+ strBuf.append("<");
+ strBuf.append(key);
+ strBuf.append("/>");
+ } else {
+// msoLogger.debug("toXMLString(): recursive call toXMLString() with tagName: " + key);
+ strBuf.append(toXMLString(curObj, key));
+ }
+ // msoLogger.debug("toXML(): partial XML: " + strBuf.toString());
+ }
+ if (tagName != null) {
+ // append the closing tag "</tagName>" to the XML output
+// msoLogger.debug("toXMLString(): adding closing tagName: " + tagName);
+ strBuf.append("</");
+ strBuf.append(tagName);
+ strBuf.append(">");
+ }
+ return strBuf.toString();
+ // XML does not have good support for arrays. If an array appears in a place
+ // where XML is lacking, synthesize an < array > element.
+ } else if (obj instanceof JSONArray) {
+ jsonArr = (JSONArray) obj;
+ len = jsonArr.length();
+ for (i = 0; i < len; ++i) {
+ curObj = jsonArr.opt(i);
+ strBuf.append(toXMLString(curObj, (tagName == null) ? "array"
+ : tagName));
+ }
+ return strBuf.toString();
+ } else {
+// msoLogger.debug("toXML(): in else block with tagName: " + tagName);
+ str = (obj == null) ? "null" : XML.escape(obj.toString());
+ return (tagName == null) ? "\"" + str + "\""
+ : (str.length() == 0) ? "<" + tagName + "/>" : "<"
+ + tagName + ">" + str + "</" + tagName + ">";
+ }
+ }
+
+ /**
+ * Invokes json2xml(String, Boolean) defaulting to 'pretty' output.
+ *
+ * @param jsonStr String containing the XML doc
+ * @return String containing the JSON translation
+ */
+ public static String json2xml(String jsonStr) {
+ return json2xml(jsonStr, true);
+ }
+
+ /**
+ * Formats the JSON String using the value of MSOJsonIndentFactor.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @return String containing the formatted JSON doc
+ */
+ public static String prettyJson(String jsonStr) {
+// String isDebugLogEnabled = "true";
+ try {
+ JSONObject jsonObj = new JSONObject(jsonStr);
+ return jsonObj.toString(MSOJsonIndentFactor);
+ } catch (Exception e){
+ msoLogger.debug("prettyJson(): unable to parse/format json input. Exception was: " + e.toString(), e);
+ return null;
+ }
+ }
+
+ /**
+ * Returns an Iterator over the JSON keys in the specified JSON doc.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @return Iterator over the JSON keys
+ * @throws JSONException if the doc cannot be parsed
+ */
+ public static Iterator <String> getJsonIterator(String jsonStr) throws JSONException {
+ return new JSONObject(jsonStr).keys();
+ }
+
+ /**
+ * Returns the name of the "root" property in the specified JSON doc. The
+ * "root" property is the single top-level property in the JSON doc. An
+ * exception is thrown if the doc is empty or if it contains more than one
+ * top-level property.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @return the name of the "root" property
+ * @throws JSONException if the doc cannot be parsed, or if it is empty, or if
+ * it contains more than one top-level property
+ */
+ public static String getJsonRootProperty(String jsonStr) throws JSONException {
+ Iterator<String> iter = getJsonIterator(jsonStr);
+
+ if (!iter.hasNext()) {
+ throw new JSONException("Empty JSON object");
+ }
+
+ String rootPropertyName = iter.next();
+
+ if (iter.hasNext()) {
+ throw new JSONException("JSON object has more than one root property");
+ }
+
+ return rootPropertyName;
+ }
+
+ /**
+ * Invokes the getJsonRawValue() method and returns the String equivalent of
+ * the object returned.
+ *
+ * TBD: May need separate methods for boolean, float, and integer fields if the
+ * String representation is not sufficient to meet client needs.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return String field value associated with keys
+ */
+ public static String getJsonValue(String jsonStr, String keys) {
+// String isDebugLogEnabled = "true";
+ try {
+ Object rawValue = getJsonRawValue(jsonStr, keys);
+ if (rawValue == null) {
+ return null;
+ } else {
+ if (rawValue instanceof String) {
+ msoLogger.debug("getJsonValue(): the raw value is a String Object=" + rawValue);
+ return (String) rawValue;
+ } else {
+ msoLogger.debug("getJsonValue(): the raw value is NOT a String Object=" + rawValue.toString());
+ return rawValue.toString();
+ }
+ }
+ } catch (Exception e) {
+ msoLogger.debug("getJsonValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
+ }
+ return null;
+ }
+
+ /**
+ * Invokes the getJsonRawValue() method with the wrap flag set to true
+ * and returns the String equivalent of the json node object returned.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return String field value associated with keys
+ */
+ public static String getJsonNodeValue(String jsonStr, String keys) {
+// String isDebugLogEnabled = "true";
+ try {
+ Object rawValue = getJsonRawValue(jsonStr, keys, true);
+ if (rawValue == null) {
+ return null;
+ } else {
+ if (rawValue instanceof String) {
+ msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + rawValue);
+ return (String) rawValue;
+ } else {
+ msoLogger.debug("getJsonNodeValue(): the raw value is NOT a String Object=" + rawValue.toString());
+ return rawValue.toString();
+ }
+ }
+ } catch (Exception e) {
+ msoLogger.debug("getJsonNodeValue(): unable to parse json to retrieve node for field=" + keys + ". Exception was: " + e.toString(), e);
+ }
+ return null;
+ }
+
+ /**
+ * Invokes the getJsonRawValue() method and returns the String equivalent of
+ * the object returned.
+ *
+ * TBD: May need separate methods for boolean, float, and integer fields if the
+ * String representation is not sufficient to meet client needs.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return String field value associated with keys
+ */
+ public static int getJsonIntValue(String jsonStr, String keys) {
+// String isDebugLogEnabled = "true";
+ try {
+ Object rawValue = getJsonRawValue(jsonStr, keys);
+ if (rawValue == null) {
+ return 0;
+ } else {
+ if (rawValue instanceof Integer) {
+ msoLogger.debug("getJsonIntValue(): the raw value is an Integer Object=" + ((String) rawValue).toString());
+ return (Integer) rawValue;
+ } else {
+ msoLogger.debug("getJsonIntValue(): the raw value is NOT an Integer Object=" + rawValue.toString());
+ return 0;
+ }
+ }
+ } catch (Exception e) {
+ msoLogger.debug("getJsonIntValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(), e);
+ }
+ return 0;
+ }
+
+ /**
+ * Invokes the getJsonRawValue() method and returns the boolean equivalent of
+ * the object returned.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return boolean field value associated with keys - default is false
+ */
+ public static boolean getJsonBooleanValue(String jsonStr, String keys) {
+ try {
+ Object rawValue = getJsonRawValue(jsonStr, keys);
+ if (rawValue == null) {
+ return false;
+ } else {
+ if (rawValue instanceof Boolean) {
+ msoLogger.debug("getJsonBooleanValue(): the raw value is a Boolean Object=" + rawValue);
+ return (Boolean) rawValue;
+ } else {
+ msoLogger.debug("getJsonBooleanValue(): the raw value is NOT an Boolean Object=" + rawValue.toString());
+ return false;
+ }
+ }
+ } catch (Exception e) {
+ msoLogger.debug("getJsonBooleanValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
+ }
+ return false;
+ }
+
+ /**
+ * Invokes the getJsonParamValue() method to obtain the JSONArray associated with
+ * the specified keys. The JSONArray is then walked to retrieve the first array
+ * value associated with the specified field name (index=0).
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @param name field name for the param to be retrieved
+ * @return String param value associated with field name
+ */
+ public static String getJsonParamValue(String jsonStr, String keys, String name) {
+ return getJsonParamValue(jsonStr, keys, name, 0);
+ }
+
+ /**
+ * Invokes the getJsonRawValue() method to obtain the JSONArray associated with
+ * the specified keys. The JSONArray is then walked to retrieve the nth array
+ * value associated with the specified field name and index.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @param name field name for the param to be retrieved
+ * @param index the nth param associated with name starting at 0
+ * @return String param value associated with field name
+ */
+ public static String getJsonParamValue(String jsonStr, String keys, String name, int index) {
+// String isDebugLogEnabled = "true";
+ try {
+ Object rawValue = getJsonRawValue(jsonStr, keys);
+ if (rawValue == null) {
+ return null;
+ } else {
+ if (rawValue instanceof JSONArray) {
+ msoLogger.debug("getJsonParamValue(): keys=" + keys + " points to JSONArray: " + rawValue.toString());
+ int arrayLen = ((JSONArray) rawValue).length();
+ if (index < 0 || arrayLen < index+1) {
+ msoLogger.debug("getJsonParamValue(): index: " + index + " is out of bounds for array size of " + arrayLen);
+ return null;
+ }
+ int foundCnt = 0;
+ for (int i = 0; i < arrayLen; i++) {
+ msoLogger.debug("getJsonParamValue(): index: " + i + ", value: " + ((JSONArray) rawValue).get(i).toString());
+ if (((JSONArray) rawValue).get(i) instanceof JSONObject) {
+// msoLogger.debug("getJsonParamValue(): index: " + i + " is a JSONObject");
+ JSONObject jsonObj = (JSONObject)((JSONArray) rawValue).get(i);
+ String parmValue = jsonObj.get(name).toString();
+ if (parmValue != null) {
+ msoLogger.debug("getJsonParamValue(): found value: " + parmValue + " for name: " + name + " and index: " + i);
+ if (foundCnt == index) {
+ return parmValue;
+ } else {
+ foundCnt++;
+ continue;
+ }
+ } else {
+ continue;
+ }
+ } else {
+ msoLogger.debug("getJsonParamValue(): the JSONArray element is NOT a JSONObject=" + rawValue.toString());
+ return null;
+ }
+ }
+ msoLogger.debug("getJsonParamValue(): content value NOT found for name: " + name);
+ return null;
+ } else {
+ msoLogger.debug("getJsonParamValue(): the raw value is NOT a JSONArray Object=" + rawValue.toString());
+ return null;
+ }
+ }
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("getJsonParamValue(): failed to retrieve param value for keys:" + keys + ", name=" + name + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("getJsonParamValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(), e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Wrapper to generate the JSONObject to pass to the getJsonValueForKey(JSONObject, String)
+ * method so that recursion over the subobjects can be supported there
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param key key to the target value
+ * @return String field value associated with key
+ */
+ public static String getJsonValueForKey(String jsonStr, String key) {
+
+ try {
+ JSONObject jsonObj = new JSONObject(jsonStr);
+ return getJsonValueForKey(jsonObj, key);
+ } catch (Exception e) {
+ msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(), e);
+ }
+ return null;
+ }
+
+ /**
+ * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
+ * single key/field name specified. Returns the associated value if found or null if the key is not found
+ *
+ * @param jsonObj JSONObject representation of the the JSON doc
+ * @param key key to the target value
+ * @return String field value associated with key
+ */
+ public static String getJsonValueForKey(JSONObject jsonObj, String key) {
+
+ String keyValue = null;
+ try {
+ if (jsonObj.has(key)) {
+ Object value = jsonObj.get(key);
+ msoLogger.debug("getJsonValueForKey(): found value=" + (String) value + ", for key=" + key);
+ if (value == null) {
+ return null;
+ } else {
+ return ((String) value);
+ }
+ } else {
+// msoLogger.debug("getJsonValueForKey(): iterating over the keys");
+ Iterator <String> itr = jsonObj.keys();
+ while (itr.hasNext()) {
+ String nextKey = itr.next();
+ Object obj = jsonObj.get(nextKey);
+ if (obj instanceof JSONObject) {
+// msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call on: " +
+// ((JSONObject) obj).toString(MSOJsonIndentFactor));
+ keyValue = getJsonValueForKey((JSONObject) obj, key);
+ if (keyValue != null) {
+// msoLogger.debug("getJsonValueForKey(): found value=" + keyValue + ", for key=" + key);
+ break;
+ }
+ } else {
+ msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
+ }
+ }
+ }
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("getJsonValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(), e);
+ }
+ keyValue = null;
+ }
+ return keyValue;
+ }
+
+ /**
+ * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
+ * single key/field name specified. Returns the associated value if found or null if the key is not found
+ *
+ * @param jsonObj JSONObject representation of the the JSON doc
+ * @param key key to the target value
+ * @return String field value associated with key
+ */
+ public static Integer getJsonIntValueForKey(JSONObject jsonObj, String key) {
+// String isDebugLogEnabled = "true";
+ Integer keyValue = null;
+ try {
+ if (jsonObj.has(key)) {
+ Integer value = (Integer) jsonObj.get(key);
+ msoLogger.debug("getJsonIntValueForKey(): found value=" + value + ", for key=" + key);
+ return value;
+ } else {
+// msoLogger.debug("getJsonIntValueForKey(): iterating over the keys");
+ Iterator <String> itr = jsonObj.keys();
+ while (itr.hasNext()) {
+ String nextKey = itr.next();
+ Object obj = jsonObj.get(nextKey);
+ if (obj instanceof JSONObject) {
+// msoLogger.debug("getJsonIntValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call");
+ keyValue = getJsonIntValueForKey((JSONObject) obj, key);
+ if (keyValue != null) {
+// msoLogger.debug("getJsonIntValueForKey(): found value=" + keyValue + ", for key=" + key);
+ break;
+ }
+ } else {
+ msoLogger.debug("getJsonIntValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
+ }
+ }
+ }
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("getJsonIntValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("getJsonIntValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(),e);
+ }
+ keyValue = null;
+ }
+ return keyValue;
+ }
+
+ /**
+ * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the
+ * single key/field name specified. Returns the associated value if found or null if the key is not found
+ *
+ * @param jsonObj JSONObject representation of the the JSON doc
+ * @param key key to the target value
+ * @return String field value associated with key
+ */
+ public static Boolean getJsonBooleanValueForKey(JSONObject jsonObj, String key) {
+ Boolean keyValue = null;
+ try {
+ if (jsonObj.has(key)) {
+ Boolean value = (Boolean) jsonObj.get(key);
+ msoLogger.debug("getJsonBooleanValueForKey(): found value=" + value + ", for key=" + key);
+ return value;
+ } else {
+// msoLogger.debug("getJsonBooleanValueForKey(): iterating over the keys");
+ Iterator <String> itr = jsonObj.keys();
+ while (itr.hasNext()) {
+ String nextKey = itr.next();
+ Object obj = jsonObj.get(nextKey);
+ if (obj instanceof JSONObject) {
+// msoLogger.debug("getJsonBooleanValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call");
+ keyValue = getJsonBooleanValueForKey((JSONObject) obj, key);
+ if (keyValue != null) {
+// msoLogger.debug("getJsonBooleanValueForKey(): found value=" + keyValue + ", for key=" + key);
+ break;
+ }
+ } else {
+ msoLogger.debug("getJsonBooleanValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key");
+ }
+ }
+ }
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("getJsonBooleanValueForKey(): failed to retrieve param value for key=" + key + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("getJsonBooleanValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString(),e);
+ }
+ keyValue = null;
+ }
+ return keyValue;
+ }
+
+ /**
+ * Boolean method to determine if a key path is valid for the JSON doc. Invokes
+ * getJsonValue().
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return Boolean true if keys points to value in the JSON doc
+ */
+ public static Boolean jsonValueExists(String jsonStr, String keys) {
+ if (getJsonRawValue(jsonStr, keys) == null) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Inserts the new key/value pair at the appropriate location in the JSON
+ * document after first determining if keyed field already exists. If
+ * it does exist, return the JSON unmodified, otherwise return the new JSON
+ * Note: this method currently only supports String value inserts.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the value to be added in the format of "key1.key2.key3..."
+ * @return String containing the updated JSON doc
+ */
+ public static String addJsonValue(String jsonStr, String keys, String value) {
+
+ // only attempt to insert the key/value pair if it does not exist
+ if (!jsonValueExists(jsonStr, keys)) {
+ return putJsonValue(jsonStr, keys, value);
+ } else {
+ msoLogger.debug("addJsonValue(): JSON add failed, key=" + keys + "/value=" + value + " already exists");
+ return jsonStr;
+ }
+ }
+
+ /**
+ * Updates the value for the specified key in the JSON document
+ * after first determining if keyed field exists. If it does
+ * not exist, return the JSON unmodified, otherwise return the updated JSON.
+ * Note: this method currently only supports String value updates.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the value to be updated in the format of "key1.key2.key3..."
+ * @return String containing the updated JSON doc
+ */
+ public static String updJsonValue(String jsonStr, String keys, String newValue) {
+// String isDebugLogEnabled = "true";
+ // only attempt to modify the key/value pair if it exists
+ if (jsonValueExists(jsonStr, keys)) {
+ return putJsonValue(jsonStr, keys, newValue);
+ } else {
+ msoLogger.debug("updJsonValue(): JSON update failed, no value exists for key=" + keys);
+ return jsonStr;
+ }
+ }
+
+ /**
+ * Deletes the value for the specified key in the JSON document
+ * after first determining if keyed field exists. If it does
+ * not exist, return the JSON unmodified, otherwise return the updated JSON
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..."
+ * @return String containing the updated JSON doc
+ */
+ public static String delJsonValue(String jsonStr, String keys) {
+
+ // only attempt to remove the key/value pair if it exists
+ if (jsonValueExists(jsonStr, keys)) {
+ // passing a null value results in a delete
+ return putJsonValue(jsonStr, keys, null);
+ } else {
+ msoLogger.debug("delJsonValue(): JSON delete failed, no value exists for key=" + keys);
+ return jsonStr;
+ }
+ }
+
+ /**
+ * Walks the JSON doc using the full key path to retrieve the associated
+ * value. All but the last key points to the 'parent' object name(s) in order
+ * in the JSON hierarchy with the last key pointing to the target value.
+ * The value returned is a Java object.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @return Object field value associated with keys
+ */
+ private static Object getJsonRawValue(String jsonStr, String keys) {
+ return getJsonRawValue(jsonStr, keys, false);
+ }
+
+ /**
+ * Walks the JSON doc using the full key path to retrieve the associated
+ * value. All but the last key points to the 'parent' object name(s) in order
+ * in the JSON hierarchy with the last key pointing to the target value.
+ * The value returned is a Java object.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the target value in the format of "key1.key2.key3..."
+ * @param wrap Boolean which determines if returned JSONObjects sould be "wrapped"
+ * Note: wrap does not apply to returned scalar values
+ * @return Object field value associated with keys
+ */
+ private static Object getJsonRawValue(String jsonStr, String keys, Boolean wrap) {
+
+ String keyStr = "";
+ try {
+ JSONObject jsonObj = new JSONObject(jsonStr);
+ StringTokenizer keyTokens = new StringTokenizer(keys, ".");
+ while (keyTokens.hasMoreElements()) {
+ keyStr = keyTokens.nextToken();
+ Object keyValue = jsonObj.get(keyStr);
+ if (keyValue instanceof JSONObject) {
+// msoLogger.debug("getJsonRawValue(): key=" + keyStr + " points to json object");
+ jsonObj = (JSONObject) keyValue;
+ } else {
+ if (keyTokens.hasMoreElements()) {
+ msoLogger.debug("getJsonRawValue(): value found prior to last key for key=" + keyStr);
+ }
+ return keyValue;
+ }
+ }
+ // return the json 'node' that the key points to
+ // note: since this is a json object and not a scalar value,
+ // use the wrap flag to determine if the object should
+ // be wrapped with a root node value
+ // (the last key in the keys String)
+ if (wrap) {
+ JSONObject wrappedJsonObj = new JSONObject();
+ wrappedJsonObj.put(keyStr, jsonObj);
+ return wrappedJsonObj.toString();
+ } else {
+ return jsonObj.toString();
+ }
+
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("getJsonRawValue(): failed to retrieve param value for key=" + keyStr + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("getJsonRawValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString(),e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Private method invoked by the public add, update, and delete methods.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..."
+ * @return String containing the updated JSON doc
+ */
+ private static String putJsonValue(String jsonStr, String keys, String value) {
+
+ String keyStr = "";
+ try {
+ JSONObject jsonObj = new JSONObject(jsonStr);
+ JSONObject jsonObjOut = jsonObj;
+ StringTokenizer keyTokens = new StringTokenizer(keys, ".");
+ while (keyTokens.hasMoreElements()) {
+ keyStr = keyTokens.nextToken();
+ if (keyTokens.hasMoreElements()) {
+ Object keyValue = jsonObj.get(keyStr);
+ if (keyValue instanceof JSONObject) {
+// msoLogger.debug("putJsonValue(): key=" + keyStr + " points to json object");
+ jsonObj = (JSONObject) keyValue;
+ } else {
+ msoLogger.debug("putJsonValue(): key=" + keyStr + " not the last key but points to non-json object: " + keyValue);
+ return null;
+ }
+ } else { // at the last/new key value
+ jsonObj.put(keyStr, value);
+ return jsonObjOut.toString(3);
+ }
+ }
+ // should not hit this point if the key points to a valid key value
+ return null;
+
+ } catch (Exception e) {
+ // JSONObject::get() throws a "not found" exception if one of the specified keys is not found
+ if (e.getMessage().contains("not found")) {
+ msoLogger.debug("putJsonValue(): failed to put param value for key=" + keyStr + ": " + e.getMessage());
+ } else {
+ msoLogger.debug("putJsonValue(): unable to parse json to put value for key=" + keys + ". Exception was: " + e.toString(),e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This json util method converts a json array of Key Value
+ * pair objects into a Java Map.
+ *
+ * @param execution
+ * @param entryArray - the getJsonValue of a json Array of key/value pairs
+ *
+ * @return Map - a Map containing the entries
+ */
+ public Map<String, String> jsonStringToMap(DelegateExecution execution, String entry) {
+ msoLogger.debug("Started Json String To Map Method");
+
+ Map<String, String> map = new HashMap<>();
+
+ //Populate Map
+ JSONObject obj = new JSONObject(entry);
+
+ /* Wildfly is pushing a version of org.json which does not
+ * auto cast to string. Leaving it as an object prevents
+ * a method not found exception at runtime.
+ */
+ final Iterator<String> keys = obj.keys();
+ while (keys.hasNext()) {
+ final String key = keys.next();
+ map.put(key, obj.getString(key));
+ }
+ msoLogger.debug("Outgoing Map is: " + map);
+ msoLogger.debug("Completed Json String To Map Method");
+ return map;
+ }
+
+ /**
+ * This json util method converts a json array of Key Value
+ * pair objects into a Java Map.
+ *
+ * @param execution
+ * @param entryArray - the getJsonValue of a json Array of key/value pairs
+ * @param keyNode - the name of the node that represents the key
+ * @param valueNode - the name of the node that represents the value
+ * @return Map - a Map containing the entries
+ *
+ */
+ public Map<String, String> entryArrayToMap(DelegateExecution execution, String entryArray, String keyNode, String valueNode) {
+ msoLogger.debug("Started Entry Array To Map Util Method");
+
+ Map<String, String> map = new HashMap<>();
+ //Populate Map
+ String entryListJson = "{ \"wrapper\":" + entryArray + "}";
+ JSONObject obj = new JSONObject(entryListJson);
+ JSONArray arr = obj.getJSONArray("wrapper");
+ for (int i = 0; i < arr.length(); i++){
+ JSONObject jo = arr.getJSONObject(i);
+ String key = jo.getString(keyNode);
+ String value = jo.getString(valueNode);
+ map.put(key, value);
+ }
+ msoLogger.debug("Completed Entry Array To Map Util Method");
+ return map;
+ }
+
+ /**
+ * This json util method converts a json array of Key Value pair objects into a Java Map.
+ *
+ * @param entryArray - the json Array of key/value pairs objects
+ * @param keyNode - the name of the node that represents the key
+ * @param valueNode - the name of the node that represents the value
+ * @return Map - a Map containing the entries
+ * @author cb645j
+ *
+ */
+ public Map<String, String> entryArrayToMap(String entryArray, String keyNode, String valueNode){
+ msoLogger.debug("Started Entry Array To Map Util Method");
+
+ Map<String, String> map = new HashMap<>();
+ String entryListJson = "{ \"wrapper\":" + entryArray + "}";
+ JSONObject obj = new JSONObject(entryListJson); // TODO just put in json array
+ JSONArray arr = obj.getJSONArray("wrapper");
+ for(int i = 0; i < arr.length(); i++){
+ JSONObject jo = arr.getJSONObject(i);
+ String key = jo.getString(keyNode);
+ String value = jo.getString(valueNode);
+ map.put(key, value);
+ }
+ msoLogger.debug("Completed Entry Array To Map Util Method");
+ return map;
+ }
+
+ /**
+ * This json util method converts a json Array of Strings to a Java List. It takes each
+ * String in the json Array and puts it in a Java List<String>.
+ *
+ * @param execution
+ * @param jsonArray - string value of a json array
+ * @return List - a java list containing the strings
+ *
+ * @author cb645j
+ */
+ public List<String> StringArrayToList(Execution execution, String jsonArray){
+ msoLogger.debug("Started String Array To List Util Method");
+
+ List<String> list = new ArrayList<>();
+ // Populate List
+ // TODO
+ String stringListJson = "{ \"strings\":" + jsonArray + "}";
+ JSONObject obj = new JSONObject(stringListJson);
+ JSONArray arr = obj.getJSONArray("strings");
+ for(int i = 0; i < arr.length(); i++){
+ String s = arr.get(i).toString();
+ list.add(s);
+ }
+ msoLogger.debug("Outgoing List is: " + list);
+ msoLogger.debug("Completed String Array To List Util Method");
+ return list;
+ }
+
+ /**
+ * This json util method converts a json Array of Strings to a Java List. It takes each
+ * String in the json Array and puts it in a Java List<String>.
+ *
+ * @param jsonArray - string value of a json array
+ * @return List - a java list containing the strings
+ *
+ * @author cb645j
+ */
+ public List<String> StringArrayToList(String jsonArray){
+ msoLogger.debug("Started Json Util String Array To List");
+ List<String> list = new ArrayList<>();
+
+ JSONArray arr = new JSONArray(jsonArray);
+ for(int i = 0; i < arr.length(); i++){
+ String s = arr.get(i).toString();
+ list.add(s);
+ }
+ msoLogger.debug("Completed Json Util String Array To List");
+ return list;
+ }
+
+ /**
+ * This json util method converts a json Array of Strings to a Java List. It takes each
+ * String in the json Array and puts it in a Java List<String>.
+ *
+ * @param jsonArray - json array
+ * @return List - a java list containing the strings
+ *
+ * @author cb645j
+ */
+ public List<String> StringArrayToList(JSONArray jsonArray){
+ msoLogger.debug("Started Json Util String Array To List");
+ List<String> list = new ArrayList<>();
+
+ for(int i = 0; i < jsonArray.length(); i++){
+ String s = jsonArray.get(i).toString();
+ list.add(s);
+ }
+ msoLogger.debug("Completed Json Util String Array To List");
+ return list;
+ }
+
+ /**
+ *
+ * Invokes the getJsonRawValue() method to determine if the json element/variable exist.
+ * Returns true if the json element exist
+ *
+ * @param jsonStr - String containing the JSON doc
+ * @param keys - full key path to the target value in the format of "key1.key2.key3..."
+ * @return boolean field value associated with keys
+ *
+ */
+ public static boolean jsonElementExist(String jsonStr, String keys){
+
+ try{
+ Object rawValue = getJsonRawValue(jsonStr, keys);
+
+ return !(rawValue == null);
+
+ } catch(Exception e){
+ msoLogger.debug("jsonElementExist(): unable to determine if json element exist. Exception is: " + e.toString(), e);
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Validates the JSON document against a schema file.
+ *
+ * @param jsonStr String containing the JSON doc
+ * @param jsonSchemaPath full path to a valid JSON schema file
+ *
+ */
+ public static String jsonSchemaValidation(String jsonStr, String jsonSchemaPath) throws ValidationException {
+ try {
+ msoLogger.debug("JSON document to be validated: " + jsonStr);
+ JsonNode document = JsonLoader.fromString(jsonStr);
+// JsonNode document = JsonLoader.fromFile(jsonDoc);
+ JsonNode schema = JsonLoader.fromPath(jsonSchemaPath);
+
+ JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
+ JsonValidator validator = factory.getValidator();
+
+ ProcessingReport report = validator.validate(schema, document);
+ msoLogger.debug("JSON schema validation report: " + report.toString());
+ return report.toString();
+ } catch (IOException e) {
+ msoLogger.debug("IOException performing JSON schema validation on document: " + e.toString());
+ throw new ValidationException(e.getMessage());
+ } catch (ProcessingException e) {
+ msoLogger.debug("ProcessingException performing JSON schema validation on document: " + e.toString());
+ throw new ValidationException(e.getMessage());
+ }
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/xml/XmlTool.java
index 1fc43baef8..f261b56f00 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/xml/XmlTool.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.xml;
+package org.onap.so.bpmn.core.xml;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -32,6 +32,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -48,7 +49,8 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.openecomp.mso.logger.MsoLogger;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.onap.so.logger.MsoLogger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -62,7 +64,7 @@ import org.xml.sax.SAXException;
public final class XmlTool {
private static final Map<String, Integer> ENTITIES = new HashMap<>();
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL);
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL, XmlTool.class);
static {
ENTITIES.put("amp", 38);
ENTITIES.put("quot", 34);
@@ -99,6 +101,8 @@ public final class XmlTool {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
+ dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
DocumentBuilder db = dbFactory.newDocumentBuilder();
InputSource source = new InputSource(new StringReader(String.valueOf(xml)));
Document doc = db.parse(source);
@@ -137,133 +141,7 @@ public final class XmlTool {
if (value == null) {
return null;
}
-
- String s = String.valueOf(value);
- StringBuilder out = new StringBuilder();
- boolean modified = false;
-
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
-
- if (c == '<') {
- out.append("&lt;");
- modified = true;
- } else if (c == '>') {
- out.append("&gt;");
- modified = true;
- } else if (c == '&') {
- out.append("&amp;");
- modified = true;
- } else if (c < 32 || c > 126) {
- out.append("&#").append((int) c).append(";");
- modified = true;
- } else {
- out.append(c);
- }
- }
-
- if (modified) {
- return out.toString();
- } else {
- return s;
- }
- }
-
- /**
- * Encodes a value so it can be used inside an XML attribute.
- * @param value the string to encode
- * @return the encoded string
- */
- public static String encodeAttr(Object value) {
- if (value == null) {
- return null;
- }
-
- String s = String.valueOf(value);
- StringBuilder out = new StringBuilder();
- boolean modified = false;
-
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
-
- if (c == '<') {
- out.append("&lt;");
- modified = true;
- } else if (c == '>') {
- out.append("&gt;");
- modified = true;
- } else if (c == '"') {
- out.append("&quot;");
- modified = true;
- } else if (c == '&') {
- out.append("&amp;");
- modified = true;
- } else if (c < 32 || c > 126) {
- out.append("&#").append((int) c).append(";");
- modified = true;
- } else {
- out.append(c);
- }
- }
-
- if (modified) {
- return out.toString();
- } else {
- return s;
- }
- }
-
- /**
- * Decodes XML entities in a string value
- * @param value a value with embedded XML entities
- * @return the decoded string
- */
- public static String decode(Object value) {
- if (value == null) {
- return null;
- }
-
- String s = String.valueOf(value);
-
- StringBuilder out = new StringBuilder(s.length());
- int ampIndex = s.indexOf("&");
- int lastEnd = 0;
-
- while (ampIndex >= 0) {
- int nextAmpIndex = s.indexOf("&", ampIndex + 1);
- int nextSemiIndex = s.indexOf(";", ampIndex + 1);
- if (nextSemiIndex != -1 && (nextAmpIndex == -1 || nextSemiIndex < nextAmpIndex)) {
- int code = -1;
- String entity = s.substring(ampIndex + 1, nextSemiIndex);
-
- try {
- if (entity.startsWith("#")) {
- code = Integer.parseInt(entity.substring(1), 10);
- } else {
- if (ENTITIES.containsKey(entity)) {
- code = ENTITIES.get(entity);
- }
- }
- } catch (NumberFormatException x) {
- // Do nothing
- }
-
- out.append(s.substring(lastEnd, ampIndex));
- lastEnd = nextSemiIndex + 1;
- if (code >= 0 && code <= 0xffff) {
- out.append((char) code);
- } else {
- out.append("&");
- out.append(entity);
- out.append(";");
- }
- }
-
- ampIndex = nextAmpIndex;
- }
-
- out.append(s.substring(lastEnd));
- return out.toString();
+ return StringEscapeUtils.escapeXml11(value.toString());
}
/**
@@ -351,6 +229,8 @@ public final class XmlTool {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
+ dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
DocumentBuilder db = dbFactory.newDocumentBuilder();
InputSource source = new InputSource(new StringReader(xml));
Document doc = db.parse(source);
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java
deleted file mode 100644
index 1e55586be3..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.Base64;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.camunda.bpm.engine.ProcessEngines;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.CryptoUtils;
-import org.openecomp.mso.utils.UUIDChecker;
-
-@Path("/")
-public class HealthCheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- private static final String SITENAME = "mso.sitename";
- private static final String ADAPTER_ENDPOINT = "mso.adapters.openecomp.db.endpoint";
- private static final String ADAPTER_NAMESPACE = "mso.adapters.namespace";
- private static final String CONFIG = "mso.bpmn.urn.properties";
- private static final String CREDENTIAL = "mso.adapters.db.auth";
- private static final String MSOKEY = "mso.msoKey";
- private String healthcheckDebugEnabled = "mso.healthcheck.log.debug";
-
- private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- private static final String NOT_FOUND = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Application Not Started</title></head><body>Application not started. Properties file missing or invalid or database Connection failed</body></html>";
- private static final String NOT_HEALTHY = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Application Not Started</title></head><body>Application not available or at least one of the sub-modules is not available.</body></html>";
- public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK)
- .entity (CHECK_HTML)
- .build ();
- public static final Response HEALTH_CHECK_NOK_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE)
- .entity (NOT_HEALTHY)
- . build ();
- public static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE)
- .entity (NOT_FOUND)
- .build ();
-
- @HEAD
- @GET
- @Path("/nodehealthcheck")
- @Produces("text/html")
- public Response nodeHealthcheck () {
- MsoLogger.setServiceName ("NodeHealthcheck");
- // Generate a Request Id
- String requestId = UUIDChecker.generateUUID(msoLogger);
-
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> props = propertyConfiguration.getProperties(CONFIG);
-
- if (props == null) {
-
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.AvailabilityError, "Unable to load " + CONFIG);
-
- return NOT_STARTED_RESPONSE;
- }
-
- String siteName = props.get(SITENAME);
- String endpoint = props.get(ADAPTER_ENDPOINT);
-
- if (null == siteName || siteName.length () == 0 || null == endpoint || endpoint.length () == 0) {
-
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, "Unable to load key attributes (" + SITENAME + " or " + ADAPTER_ENDPOINT + ") from the config file:" + CONFIG);
-
- return NOT_STARTED_RESPONSE;
- }
-
- try {
- if (!this.getSiteStatus (endpoint, siteName, props.get(CREDENTIAL), props.get(MSOKEY), props.get(ADAPTER_NAMESPACE))) {
- msoLogger.debug("This site is currently disabled for maintenance.");
- return HEALTH_CHECK_NOK_RESPONSE;
- }
- } catch (Exception e) {
-
- msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception while getting SiteStatus", e);
-
- msoLogger.debug("Exception while getting SiteStatus");
- return NOT_STARTED_RESPONSE;
- }
-
-
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.BPMN, requestId)) {
- msoLogger.debug("nodeHealthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- } else {
- msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available.");
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
- }
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces("text/html")
- public Response healthcheck (@QueryParam("requestId") String requestId) {
- MsoLogger.setServiceName ("Healthcheck");
- verifyOldUUID(requestId);
-
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> props = propertyConfiguration.getProperties(CONFIG);
-
- if (props == null) {
-
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.AvailabilityError, "Unable to load " + CONFIG);
-
- return NOT_STARTED_RESPONSE;
- }
-
- String siteName = props.get(SITENAME);
- String endpoint = props.get(ADAPTER_ENDPOINT);
-
- if (null == siteName || siteName.length () == 0 || null == endpoint || endpoint.length () == 0) {
-
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, "Unable to load key attributes (" + SITENAME + " or " + ADAPTER_ENDPOINT + ") from the config file:" + CONFIG);
-
- return NOT_STARTED_RESPONSE;
- }
-
- try {
- if (!this.getSiteStatus (endpoint, siteName, props.get(CREDENTIAL), props.get(MSOKEY), props.get(ADAPTER_NAMESPACE))) {
- msoLogger.debug("This site is currently disabled for maintenance.");
- return HEALTH_CHECK_NOK_RESPONSE;
- }
- } catch (Exception e) {
-
- msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception while getting SiteStatus", e);
-
- msoLogger.debug("Exception while getting SiteStatus");
- return NOT_STARTED_RESPONSE;
- }
-
- try {
- // TODO: check the appropriate process engine
- // ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery().list();
- } catch (final Exception e) {
-
- msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception while verifying Camunda engine", e);
-
- msoLogger.debug("Exception while verifying Camunda engine");
- return NOT_STARTED_RESPONSE;
- }
-
- return HEALTH_CHECK_RESPONSE;
- }
-
-
- private String verifyOldUUID (String oldId) {
- if (!isValidUUID(oldId)) {
- String newId = UUID.randomUUID().toString();
- MsoLogger.setLogContext(newId, null);
- return newId;
- }
- MsoLogger.setLogContext(oldId, null);
- return oldId;
- }
-
-
- private boolean isValidUUID (String id) {
- try {
- if (null == id) {
- return false;
- }
- UUID uuid = UUID.fromString(id);
- return uuid.toString().equalsIgnoreCase(id);
- } catch (IllegalArgumentException iae) {
- msoLogger.debug("IllegalArgumentException :",iae);
- return false;
- }
- }
-
- private String decrypt(String encryptedString, String key){
- try {
- if (encryptedString != null && !encryptedString.isEmpty() && key != null && !key.isEmpty()) {
- return CryptoUtils.decrypt(encryptedString, key);
- }
- } catch (Exception e) {
- msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Failed to decrypt credentials", e);
- }
- return null;
- }
-
- private boolean getSiteStatus (String url, String site, String credential, String key, String adapterNamespace) throws Exception {
- // set the connection timeout value to 30 seconds (30000 milliseconds)
- RequestConfig.Builder requestBuilder = RequestConfig.custom();
- requestBuilder = requestBuilder.setConnectTimeout(30000);
- requestBuilder = requestBuilder.setConnectionRequestTimeout(30000);
- HttpClientBuilder builder = HttpClientBuilder.create ();
- builder.setDefaultRequestConfig (requestBuilder.build ());
-
- HttpPost post = new HttpPost(url);
-
- String cred = decrypt(credential, key);
- if (cred != null && !cred.isEmpty()) {
- post.setHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString(cred.getBytes()));
- }
- if(healthcheckDebugEnabled == null){
- healthcheckDebugEnabled = "false";
- }
- BPMNLogger.debug(healthcheckDebugEnabled, "Post url is: " + url);
-
- //now create a soap request message as follows:
- final StringBuilder payload = new StringBuilder();
- payload.append("\n");
- payload.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:req=\"")
- .append(adapterNamespace).append("/requestsdb\">\n");
- payload.append("<soapenv:Header/>\n");
- payload.append("<soapenv:Body>\n");
- payload.append("<req:getSiteStatus>\n");
- payload.append("<siteName>").append(site).append("</siteName>\n");
- payload.append("</req:getSiteStatus>\n");
- payload.append("</soapenv:Body>\n");
- payload.append("</soapenv:Envelope>\n");
-
- BPMNLogger.debug(healthcheckDebugEnabled, "Initialize SOAP request to url:" + url);
- BPMNLogger.debug(healthcheckDebugEnabled, "The payload of the request is:" + payload);
- HttpEntity entity = new StringEntity(payload.toString(),"UTF-8");
- post.setEntity(entity);
-
- CloseableHttpClient client = builder.build ();
- HttpResponse response = client.execute(post);
- BPMNLogger.debug(healthcheckDebugEnabled, "Response received is:" + response);
-
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
-
- msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError,
- "Communication with DB Adapter failed, The response received from DB Adapter is with failed status code:" + statusCode);
-
- Exception e = new Exception("Communication with DB Adapter failed");
- throw e;
- }
- BufferedReader rd = new BufferedReader(
- new InputStreamReader(response.getEntity().getContent()));
-
- StringBuilder result = new StringBuilder();
- String line = "";
- while ((line = rd.readLine()) != null) {
- result.append(line);
- }
- BPMNLogger.debug(healthcheckDebugEnabled, "Content of the response is:" + result);
- String status = result.substring(result.indexOf("<return>") + 8, result.indexOf("</return>"));
-
- client.close (); //shut down the connection
- return Boolean.valueOf(status);
- }
-} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java
deleted file mode 100644
index f75722ecc5..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
-import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.file.ClosedWatchServiceException;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.slf4j.MDC;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * Loads the property configuration from file system and refreshes the
- * properties when the property gets changed.
- *
- * WARNING: automatic refreshes might not work on network filesystems.
- */
-public class PropertyConfiguration {
-
- /**
- * The base name of the MSO BPMN properties file (mso.bpmn.properties).
- */
- public static final String MSO_BPMN_PROPERTIES = "mso.bpmn.properties";
-
- /**
- * The base name of the MSO BPMN URN-Mappings properties file (mso.bpmn.urn.properties).
- */
- public static final String MSO_BPMN_URN_PROPERTIES = "mso.bpmn.urn.properties";
-
- /**
- * The base name of the MSO Topology properties file (topology.properties).
- */
- public static final String MSO_TOPOLOGY_PROPERTIES = "topology.properties";
- /**
- * The name of the meta-property holding the time the properties were loaded
- * from the file.
- */
- public static final String TIMESTAMP_PROPERTY = "mso.properties.timestamp";
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
-
- private static final List<String> SUPPORTED_FILES =
- Arrays.asList(MSO_BPMN_PROPERTIES, MSO_BPMN_URN_PROPERTIES, MSO_TOPOLOGY_PROPERTIES);
-
- private volatile String msoConfigPath = null;
-
- private final ConcurrentHashMap<String, Map<String, String>> propFileCache =
- new ConcurrentHashMap<>();
-
- private final Object CACHELOCK = new Object();
- private FileWatcherThread fileWatcherThread = null;
-
- // The key is the file name
- private Map<String, TimerTask> timerTaskMap = new HashMap<>();
-
- /**
- * Private Constructor.
- */
- private PropertyConfiguration() {
- startUp();
- }
-
- /**
- * Singleton holder pattern eliminates locking when accessing the instance
- * and still provides for lazy initialization.
- */
- private static class PropertyConfigurationInstanceHolder {
- private static PropertyConfiguration instance = new PropertyConfiguration();
- }
-
- /**
- * Gets the one and only instance of this class.
- */
- public static PropertyConfiguration getInstance() {
- return PropertyConfigurationInstanceHolder.instance;
- }
-
- static void resetPropertyConfigurationSingletonInstance(){
- PropertyConfigurationInstanceHolder.instance = new PropertyConfiguration();
- }
-
- /**
- * Returns the list of supported files.
- */
- public static List<String> supportedFiles() {
- return new ArrayList<>(SUPPORTED_FILES);
- }
-
- /**
- * May be called to restart the PropertyConfiguration if it was previously shut down.
- */
- public synchronized void startUp() {
- msoConfigPath = System.getProperty("mso.config.path");
-
- if (msoConfigPath == null) {
- LOGGER.debug("mso.config.path JVM system property is not set");
- return;
- }
-
- try {
- Path directory = FileSystems.getDefault().getPath(msoConfigPath);
- WatchService watchService = FileSystems.getDefault().newWatchService();
- directory.register(watchService, ENTRY_MODIFY);
-
- LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", "Starting FileWatcherThread");
- LOGGER.debug("Starting FileWatcherThread");
- fileWatcherThread = new FileWatcherThread(watchService);
- fileWatcherThread.start();
- } catch (Exception e) {
- LOGGER.debug("Error occurred while starting FileWatcherThread:", e);
- LOGGER.error(
- MessageEnum.BPMN_GENERAL_EXCEPTION,
- "BPMN",
- "Property Configuration",
- MsoLogger.ErrorCode.UnknownError,
- "Error occurred while starting FileWatcherThread:" + e);
- }
- }
-
- /**
- * May be called to shut down the PropertyConfiguration. A shutDown followed
- * by a startUp will reset the PropertyConfiguration to its initial state.
- */
- public synchronized void shutDown() {
- if (fileWatcherThread != null) {
- LOGGER.debug("Shutting down FileWatcherThread " + System.identityHashCode(fileWatcherThread));
- fileWatcherThread.shutdown();
-
- long waitInSeconds = 10;
-
- try {
- fileWatcherThread.join(waitInSeconds * 1000);
- } catch (InterruptedException e) {
- LOGGER.debug("FileWatcherThread " + System.identityHashCode(fileWatcherThread)
- + " shutdown did not occur within " + waitInSeconds + " seconds",e);
- }
-
- LOGGER.debug("Finished shutting down FileWatcherThread " + System.identityHashCode(fileWatcherThread));
- fileWatcherThread = null;
- }
-
- clearCache();
- msoConfigPath = null;
- }
-
- public synchronized boolean isFileWatcherRunning() {
- return fileWatcherThread != null;
- }
-
- public void clearCache() {
- synchronized(CACHELOCK) {
- propFileCache.clear();
- }
- }
-
- public int cacheSize() {
- return propFileCache.size();
- }
-
- // TODO: throw IOException?
- public Map<String, String> getProperties(String fileName) {
- Map<String, String> properties = propFileCache.get(fileName);
-
- if (properties == null) {
- if (!SUPPORTED_FILES.contains(fileName)) {
- throw new IllegalArgumentException("Not a supported property file: " + fileName);
- }
-
- if (msoConfigPath == null) {
- LOGGER.debug("mso.config.path JVM system property must be set to load " + fileName);
-
- LOGGER.error(
- MessageEnum.BPMN_GENERAL_EXCEPTION,
- "BPMN",
- MDC.get(fileName),
- MsoLogger.ErrorCode.UnknownError,
- "mso.config.path JVM system property must be set to load " + fileName);
-
- return null;
- }
-
- try {
- properties = readProperties(new File(msoConfigPath, fileName));
- } catch (Exception e) {
- LOGGER.debug("Error loading " + fileName);
-
- LOGGER.error(
- MessageEnum.BPMN_GENERAL_EXCEPTION,
- "BPMN",
- MDC.get(fileName),
- MsoLogger.ErrorCode.UnknownError,
- "Error loading " + fileName, e);
-
- return null;
- }
- }
-
- return Collections.unmodifiableMap(properties);
- }
-
- /**
- * Reads properties from the specified file, updates the property file cache, and
- * returns the properties in a map.
- * @param file the file to read
- * @return a map of properties
- */
- private Map<String, String> readProperties(File file) throws IOException {
- String fileName = file.getName();
- LOGGER.debug("Reading " + fileName);
-
- Map<String, String> properties = new HashMap<>();
- Properties newProperties = new Properties();
-
- try (FileReader reader = new FileReader(file)) {
- newProperties.load(reader);
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
- }
-
- for (Entry<Object, Object> entry : newProperties.entrySet()) {
- properties.put(entry.getKey().toString(), entry.getValue().toString());
- }
-
- properties.put(TIMESTAMP_PROPERTY, String.valueOf(System.currentTimeMillis()));
-
- synchronized(CACHELOCK) {
- propFileCache.put(fileName, properties);
- }
-
- return properties;
- }
-
- /**
- * File watcher thread which monitors a directory for file modification.
- */
- private class FileWatcherThread extends Thread {
- private final WatchService watchService;
- private final Timer timer = new Timer("FileWatcherTimer");
-
- public FileWatcherThread(WatchService service) {
- this.watchService = service;
- }
-
- public void shutdown() {
- interrupt();
- }
-
- @Override
- public void run() {
- LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN",
- "FileWatcherThread started");
-
- LOGGER.debug("Started FileWatcherThread " + System.identityHashCode(fileWatcherThread));
-
- try {
- WatchKey watchKey = null;
-
- while (!isInterrupted()) {
- try {
- if (watchKey != null) {
- watchKey.reset();
- }
-
- watchKey = watchService.take();
-
- for (WatchEvent<?> event : watchKey.pollEvents()) {
- @SuppressWarnings("unchecked")
- WatchEvent<Path> pathEvent = (WatchEvent<Path>) event;
-
- if ("EVENT_OVERFLOW".equals(pathEvent.kind())) {
- LOGGER.debug("Ignored overflow event for " + msoConfigPath);
- continue;
- }
-
- String fileName = pathEvent.context().getFileName().toString();
-
- if (!SUPPORTED_FILES.contains(fileName)) {
- LOGGER.debug("Ignored modify event for " + fileName);
- continue;
- }
-
- LOGGER.debug("Configuration file has changed: " + fileName);
-
- LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN",
- "Configuation file has changed: " + fileName);
-
- // There's a potential problem here. The MODIFY event is
- // triggered as soon as somebody starts writing the file but
- // there's no obvious way to know when the write is done. If we
- // read the file while the write is still in progress, then the
- // cache can really be messed up. As a workaround, we use a timer
- // to sleep for at least one second, and then we sleep for as long
- // as it takes for the file's lastModified time to stop changing.
- // The timer has another benefit: it consolidates multiple events
- // that we seem to receive when a file is modified.
-
- synchronized(timerTaskMap) {
- TimerTask task = timerTaskMap.get(fileName);
-
- if (task != null) {
- task.cancel();
- }
-
- File file = new File(msoConfigPath, fileName);
- task = new DelayTimerTask(timer, file, 1000);
- timerTaskMap.put(fileName, task);
- }
- }
- } catch (InterruptedException e) {
- LOGGER.debug("InterruptedException :",e);
- break;
- } catch (ClosedWatchServiceException e) {
- LOGGER.info(
- MessageEnum.BPMN_GENERAL_INFO,
- "BPMN",
- "FileWatcherThread shut down because the watch service was closed");
- LOGGER.debug("ClosedWatchServiceException :",e);
- break;
- } catch (Exception e) {
- LOGGER.error(
- MessageEnum.BPMN_GENERAL_EXCEPTION,
- "BPMN",
- "Property Configuration",
- MsoLogger.ErrorCode.UnknownError,
- "FileWatcherThread caught unexpected " + e.getClass().getSimpleName(), e);
- }
-
- }
- } finally {
- timer.cancel();
-
- synchronized(timerTaskMap) {
- timerTaskMap.clear();
- }
-
- try {
- watchService.close();
- } catch (IOException e) {
- LOGGER.debug("FileWatcherThread caught " + e.getClass().getSimpleName()
- + " while closing the watch service",e);
- }
-
- LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN",
- "FileWatcherThread stopped");
- }
- }
- }
-
- private class DelayTimerTask extends TimerTask {
- private final File file;
- private final long lastModifiedTime;
- private final Timer timer;
-
- public DelayTimerTask(Timer timer, File file, long delay) {
- this.timer = timer;
- this.file = file;
- this.lastModifiedTime = file.lastModified();
- timer.schedule(this, delay);
- }
-
- @Override
- public void run() {
- try {
- long newLastModifiedTime = file.lastModified();
-
- if (newLastModifiedTime == lastModifiedTime) {
- try {
- readProperties(file);
- } catch (Exception e) {
- LOGGER.error(
- MessageEnum.BPMN_GENERAL_EXCEPTION,
- "BPMN",
- "Property Configuration",
- MsoLogger.ErrorCode.UnknownError,
- "Unable to reload " + file, e);
- }
- } else {
- LOGGER.debug("Delaying reload of " + file + " by 1 second");
-
- synchronized(timerTaskMap) {
- TimerTask task = timerTaskMap.get(file.getName());
-
- if (task != null && task != this) {
- task.cancel();
- }
-
- task = new DelayTimerTask(timer, file, 1000);
- timerTaskMap.put(file.getName(), task);
- }
- }
- } finally {
- synchronized(timerTaskMap) {
- TimerTask task = timerTaskMap.get(file.getName());
-
- if (task == this) {
- timerTaskMap.remove(file.getName());
- }
- }
- }
- }
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java
deleted file mode 100644
index 98659d2a62..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.openecomp.mso.logger.MsoLogger;
-
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
-
-/**
- * Sets up mso.bpmn.properties and mso.bpmn.urn.properties for unit tests.
- */
-public class PropertyConfigurationSetup {
-
- private static Path msoConfigPath = null;
- private static Path bpmnPropertiesPath = null;
- private static Path bpmnUrnPropertiesPath = null;
- private static boolean modifiedConfiguration = false;
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
-
- /**
- * Ensures that the the PropertyConfiguration is initialized and that the
- * property data is reset to initial values. Any extra properties that are
- * specified will be merged with the initial values. The following example
- * shows how a test can specify a replacement URN mapping property.
- * <pre>
- * Map<String, String> urnProperties =
- * PropertyConfigurationSetup.createBpmnUrnProperties();
- * urnProperties.add("mso.po.timeout", "PT1M");
- * PropertyConfiguration.init(urnProperties);
- * </pre>
- * @param args one or more maps created with createBpmnProperties()
- * and/or createBpmnUrnProperties()
- */
- public static synchronized void init(Object ... args) throws IOException {
-
- Map<String, String> extraBpmnProperties = null;
- Map<String, String> extraBpmnUrnProperties = null;
-
- boolean propertiesSpecified = false;
-
- for (Object arg : args) {
- @SuppressWarnings("unchecked")
- Map<String, String> properties = (Map<String, String>) arg;
-
- String type = properties.get("PROPERTIES-TYPE");
-
- if (PropertyConfiguration.MSO_BPMN_PROPERTIES.equals(type)) {
- if (properties.size() > 1) {
- extraBpmnProperties = properties;
- propertiesSpecified = false;
- }
- } else if (PropertyConfiguration.MSO_BPMN_URN_PROPERTIES.equals(type)) {
- if (properties.size() > 1) {
- extraBpmnUrnProperties = properties;
- propertiesSpecified = false;
- }
- } else {
- throw new IllegalArgumentException("Not a supported PROPERTIES-TYPE map");
- }
- }
-
- // There are three cases in which we need to change the existing configuration:
- // 1) There is no existing configuration, i.e. first time setup
- // 2) The existing configuration was modified, i.e. it has non-default values
- // 3) Non-default values are specified for this initialization
-
- if (msoConfigPath == null || modifiedConfiguration || propertiesSpecified) {
- modifiedConfiguration = propertiesSpecified;
-
- Path bpmnPropertiesSourcePath = Paths.get("src", "test", "resources", "mso.bpmn.properties");
- Path bpmnUrnPropertiesSourcePath = Paths.get("src", "test", "resources", "mso.bpmn.urn.properties");
-
- if (msoConfigPath == null) {
- // Initialize from scratch.
- msoConfigPath = Files.createTempDirectory("mso-config-path-");
- System.setProperty("mso.config.path", msoConfigPath.toString());
- msoConfigPath.toFile().deleteOnExit();
-
- bpmnPropertiesPath = msoConfigPath.resolve("mso.bpmn.properties");
- mergeCopy(bpmnPropertiesSourcePath, extraBpmnProperties, bpmnPropertiesPath);
- bpmnPropertiesPath.toFile().deleteOnExit();
-
- bpmnUrnPropertiesPath = msoConfigPath.resolve("mso.bpmn.urn.properties");
- mergeCopy(bpmnUrnPropertiesSourcePath, extraBpmnUrnProperties, bpmnUrnPropertiesPath);
- bpmnUrnPropertiesPath.toFile().deleteOnExit();
-
- PropertyConfiguration.getInstance();
- } else {
- // Just reset the data.
- PropertyConfiguration.getInstance().clearCache();
- mergeCopy(bpmnPropertiesSourcePath, extraBpmnProperties, bpmnPropertiesPath);
- mergeCopy(bpmnUrnPropertiesSourcePath, extraBpmnUrnProperties, bpmnUrnPropertiesPath);
- }
- }
- }
-
- /**
- * Resets the PropertyConfiguration to its initial state, as if it had never
- * been started. Note that this is a very expensive option and should not
- * be needed by most unit tests.
- * @throws IOException
- */
- public static synchronized void nuke() throws IOException {
- if (msoConfigPath == null) {
- return;
- }
-
- PropertyConfiguration.getInstance().shutDown();
-
- bpmnUrnPropertiesPath.toFile().delete();
- bpmnUrnPropertiesPath = null;
-
- bpmnPropertiesPath.toFile().delete();
- bpmnPropertiesPath = null;
-
- msoConfigPath.toFile().delete();
- msoConfigPath = null;
-
- System.setProperty("mso.config.path", null);
-
- modifiedConfiguration = false;
- }
-
- /**
- * Create a map to hold properties to be added to mso.bpmn.properties.
- */
- public static Map<String, String> createBpmnProperties() {
- Map<String, String> properties = new HashMap<>();
- properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_PROPERTIES);
- return properties;
- }
-
- /**
- * Create a map to hold properties to be added to mso.bpmn.urn.properties.
- */
- public static Map<String, String> createBpmnUrnProperties() {
- Map<String, String> properties = new HashMap<>();
- properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_URN_PROPERTIES);
- return properties;
- }
-
- /**
- * Adds (or replaces) the specified values in the mso.bpmn.urn.properties file.
- * Note that properties added this way may take some time to be loaded by the
- * PropertyConfiguration, just like they do when a property file is updated on
- * a real MSO system. This method will optionally wait for the new properties
- * to be loaded. Timeout results in an IOException.
- * @param properties new properties
- * @param wait maximum amount of time to wait for new properties to be loaded,
- * in milliseconds. A value of zero means, "Do not wait."
- * @throws IOException
- */
- public static synchronized void addProperties(Map<String, String> properties, long wait)
- throws IOException, InterruptedException {
-
- if (msoConfigPath == null) {
- throw new IllegalStateException();
- }
-
- String type = properties.get("PROPERTIES-TYPE");
- Path path;
-
- if (PropertyConfiguration.MSO_BPMN_PROPERTIES.equals(type)) {
- path = bpmnPropertiesPath;
- } else if (PropertyConfiguration.MSO_BPMN_URN_PROPERTIES.equals(type)) {
- path = bpmnUrnPropertiesPath;
- } else {
- throw new IllegalArgumentException("Not a supported PROPERTIES-TYPE map");
- }
-
- String oldTimestamp = PropertyConfiguration.getInstance().getProperties(type)
- .get(PropertyConfiguration.TIMESTAMP_PROPERTY);
-
- modifiedConfiguration = true;
- addProperties(properties, path);
-
- if (wait <= 0) {
- return;
- }
-
- long endTime = System.currentTimeMillis() + wait;
-
- while (true) {
- Thread.sleep(250);
-
- String newTimestamp = PropertyConfiguration.getInstance().getProperties(type)
- .get(PropertyConfiguration.TIMESTAMP_PROPERTY);
-
- if (!newTimestamp.equals(oldTimestamp)) {
- return;
- }
-
- long now = System.currentTimeMillis();
-
- if (now >= endTime) {
- throw new IOException("Timed out after " + wait
- + "ms waiting for PropertyConfiguration change");
- }
- }
- }
-
- /**
- * Helper method that adds properties to the specified file.
- */
- private static void addProperties(Map<String, String> values, Path path)
- throws IOException {
-
- FileReader fileReader = null;
- FileOutputStream outputStream = null;
-
- try {
- fileReader = new FileReader(path.toFile());
- Properties properties = new Properties();
- properties.load(fileReader);
-
- for (String key : values.keySet()) {
- if (!key.equals("PROPERTIES-TYPE")) {
- properties.setProperty(key, values.get(key));
- }
- }
-
- outputStream = new FileOutputStream(path.toFile());
- properties.store(outputStream, "Custom Test Properties");
- } finally {
- if (fileReader != null) {
- try {
- fileReader.close();
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- }
-
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- }
- }
- }
-
- /**
- * Helper method that copies properties from the specified source file, and
- * optionally merges them with the specified extra values, then writes the
- * whole mess to the destination file.
- */
- private static void mergeCopy(Path sourcePath, Map<String, String> extraValues, Path destPath)
- throws IOException {
- if (extraValues == null || extraValues.isEmpty()) {
- Files.copy(sourcePath, destPath, StandardCopyOption.REPLACE_EXISTING);
- return;
- }
-
- FileReader fileReader = null;
- FileOutputStream outputStream = null;
-
- try {
- fileReader = new FileReader(sourcePath.toFile());
- Properties properties = new Properties();
- properties.load(fileReader);
-
- for (String key : extraValues.keySet()) {
- if (!key.equals("PROPERTIES-TYPE")) {
- properties.setProperty(key, extraValues.get(key));
- }
- }
-
- outputStream = new FileOutputStream(destPath.toFile());
- properties.store(outputStream, "Custom Test Properties");
- } finally {
- if (fileReader != null) {
- try {
- fileReader.close();
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- }
-
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/TunnelConnect.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/TunnelConnect.java
deleted file mode 100644
index 01e7245aa7..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/TunnelConnect.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * This class represents the specifics of a tunnel
- * cross connect piece of a resource
- *
- * @author cb645j
- *
- *TODO This may change to house both isp speeds
- */
-@JsonRootName("tunnelConnect")
-public class TunnelConnect extends JsonWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String id;
- private String upBandwidth;
- private String downBandwidth;
- private String upBandwidth2;
- private String downBandwidth2;
-
-
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getUpBandwidth() {
- return upBandwidth;
- }
- public void setUpBandwidth(String upBandwidth) {
- this.upBandwidth = upBandwidth;
- }
- public String getDownBandwidth() {
- return downBandwidth;
- }
- public void setDownBandwidth(String downBandwidth) {
- this.downBandwidth = downBandwidth;
- }
- public String getUpBandwidth2() {
- return upBandwidth2;
- }
- public void setUpBandwidth2(String upBandwidth2) {
- this.upBandwidth2 = upBandwidth2;
- }
- public String getDownBandwidth2() {
- return downBandwidth2;
- }
- public void setDownBandwidth2(String downBandwidth2) {
- this.downBandwidth2 = downBandwidth2;
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java
deleted file mode 100644
index 1efcf5f286..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.json;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.List;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-import org.openecomp.mso.logger.MsoLogger;
-
-@JsonInclude(Include.NON_NULL)
-public abstract class JsonWrapper implements Serializable {
-
-
- private static final long serialVersionUID = 8633550139273639875L;
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- @JsonInclude(Include.NON_NULL)
- public String toJsonString(){
-
- String jsonString = "";
- //convert with Jackson
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- mapper.setSerializationInclusion(Include.NON_NULL);
-
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try {
- jsonString = ow.writeValueAsString(this);
-// } catch (JsonGenerationException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (JsonMappingException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
- } catch (Exception e){
-
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- @JsonInclude(Include.NON_NULL)
- public JSONObject toJsonObject() {
-
- ObjectMapper mapper = new ObjectMapper();
- // mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- //mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
-
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- // mapper.enable(com.fasterxml.jackson.map.DeserializationFeature.UNWRAP_ROOT_VALUE);
- JSONObject json = new JSONObject();
- try {
- json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JSONException | IOException e) {
- LOGGER.debug("Exception :",e);
- }
- return json;
- }
-
- public String listToJson(List list) {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-
- String jsonString = "";
- try {
- jsonString = mapper.writeValueAsString(list);
- } catch (IOException e) {
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- @JsonInclude(Include.NON_NULL)
- public String toJsonStringNoRootName(){
-
- String jsonString = "";
- //convert with Jackson
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
-
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try {
- jsonString = ow.writeValueAsString(this);
- } catch (Exception e){
-
- LOGGER.debug("Exception :",e);
- }
- return jsonString;
- }
-
- /**
- * Returns a string representation of this object.
- */
- public String toString() {
- return this.toJsonString();
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java
deleted file mode 100644
index 4dde5ae595..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.mybatis;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
-import org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration;
-import org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor;
-import org.camunda.bpm.engine.impl.interceptor.CommandInterceptor;
-import org.camunda.bpm.engine.impl.interceptor.LogInterceptor;
-import org.camunda.bpm.engine.impl.util.ReflectUtil;
-
-
-/**
- * A special process engine that provides access to MyBatis mappings.
- * @version 1.0
- */
-public class CustomMyBatisSessionFactory extends
- StandaloneProcessEngineConfiguration {
-
- private String resourceName;
-
- /**
- * Overridden to ensure nobody ever tries to initialize this process engine
- * in the normal way. We are using this process engine only for MyBatis
- * access.
- */
- @Override
- protected void init() {
- throw new UnsupportedOperationException("init");
- }
-
- /**
- * Initialize the ProcessEngineConfiguration from an existing one, just
- * using the database settings to initialize the database / MyBatis stuff.
- */
- public void initFromProcessEngineConfiguration(
- ProcessEngineConfigurationImpl processEngineConfiguration,
- String resourceName) {
- this.resourceName = resourceName;
-
- setDatabaseType(processEngineConfiguration.getDatabaseType());
- setDataSource(processEngineConfiguration.getDataSource());
- setDatabaseTablePrefix(processEngineConfiguration
- .getDatabaseTablePrefix());
-
- initDataSource();
- // initVariableTypes();
- initCommandContextFactory();
- initTransactionFactory();
- initTransactionContextFactory();
- initCommandExecutors();
- initSqlSessionFactory();
- initIncidentHandlers();
- initIdentityProviderSessionFactory();
- initSessionFactories();
- }
-
- /**
- * In order to always open a new command context set the property
- * "alwaysOpenNew" to true inside the CommandContextInterceptor.
- *
- * If you execute the custom queries inside the process engine (for example
- * in a service task), you have to do this.
- */
- @Override
- protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() {
- List<CommandInterceptor> defaultCommandInterceptorsTxRequired =
- new ArrayList<>();
- defaultCommandInterceptorsTxRequired.add(new LogInterceptor());
- defaultCommandInterceptorsTxRequired.add(new CommandContextInterceptor(
- commandContextFactory, this, true));
- return defaultCommandInterceptorsTxRequired;
- }
-
- @Override
- protected InputStream getMyBatisXmlConfigurationSteam() {
- return ReflectUtil.getResourceAsStream(resourceName);
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java
deleted file mode 100644
index c48b671b72..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.mybatis;
-
-/**
- * A bean that represents a single URN mapping.
- */
-public class URNMapping {
- private String name;
- private String value;
- private String rev;
-
- /**
- * Get the name.
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the name.
- * @param name the name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Get the value mapped to the name.
- * @return the value mapped to the name
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Set the value mapped to the name.
- * @param value the value mapped to the name
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Get the revision attribute (currently unused).
- * @return the revision attribute
- */
- public String getRev() {
- return rev;
- }
-
- /**
- * Set the revision attribute (currently unused).
- * @param rev the revision attribute
- */
- public void setRev(String rev) {
- this.rev = rev;
- }
-
- /**
- * Converts a URN to "normal" form so it can used as a java or groovy
- * variable identifier. This is done in a way that makes the identifier
- * as readable as possible, but note that it might result in a loss of
- * uniqueness.
- * <ol>
- * <li> URN_ is prepended </li>
- * <li> All characters that are not letters or digits are converted to
- * underscore characters </li>
- * <li> Sequences of multiple underscores are collapsed to a single
- * underscore character </li>
- * </ol>
- * Examples:
- * <p>
- * aai:endpoint becomes URN_aai_endpoint <br/>
- * ae:internal-reporting becomes URN_ae_internal_reporting <br/>
- *
- * @param urn the URN
- * @return a normalized identifier
- */
- public static String createIdentifierFromURN(String urn) {
- StringBuilder builder = new StringBuilder();
- builder.append("URN_");
- char last = builder.charAt(builder.length() - 1);
-
- int len = urn.length();
-
- for (int i = 0; i < len; i++) {
- char c = urn.charAt(i);
-
- if (!Character.isLetterOrDigit(c) && c != '_') {
- c = '_';
- }
-
- if (!(c == '_' && last == '_')) {
- builder.append(c);
- }
-
- last = c;
- }
-
- return builder.toString();
- }
-} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
deleted file mode 100644
index b66169db92..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.plugins;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.ExecutionListener;
-import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
-import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
-import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
-import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
-import org.camunda.bpm.engine.impl.context.Context;
-import org.camunda.bpm.engine.impl.interceptor.Command;
-import org.camunda.bpm.engine.impl.interceptor.CommandContext;
-import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
-import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
-import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
-import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl;
-import org.camunda.bpm.engine.impl.util.xml.Element;
-import org.camunda.bpm.engine.impl.variable.VariableDeclaration;
-
-import org.openecomp.mso.bpmn.core.BPMNLogger;
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
-import org.openecomp.mso.bpmn.core.mybatis.CustomMyBatisSessionFactory;
-import org.openecomp.mso.bpmn.core.mybatis.URNMapping;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * Plugin for MSO logging and URN mapping.
- */
-public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- private static final String FSPROPKEY = "URNMapping.FileSystemLoading.Enabled";
-
- @Override
- public void preInit(
- ProcessEngineConfigurationImpl processEngineConfiguration) {
- List<BpmnParseListener> preParseListeners = processEngineConfiguration
- .getCustomPreBPMNParseListeners();
- if (preParseListeners == null) {
- preParseListeners = new ArrayList<>();
- processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
- }
- preParseListeners.add(new LoggingParseListener());
- }
-
- /**
- * Called when a process flow is parsed so we can inject listeners.
- */
- public static class LoggingParseListener extends AbstractBpmnParseListener {
- private void injectLogExecutionListener(ActivityImpl activity) {
- activity.addListener(
- ExecutionListener.EVENTNAME_END,
- new LoggingExecutionListener("END"));
-
- activity.addListener(
- ExecutionListener.EVENTNAME_START,
- new LoggingExecutionListener("START"));
-
- activity.addListener(
- ExecutionListener.EVENTNAME_TAKE,
- new LoggingExecutionListener("TAKE"));
- }
-
- @Override
- public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {
- }
-
- @Override
- public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
- // Inject these listeners only on the main start event for the flow, not on any embedded subflow start events
- if (scope instanceof ProcessDefinitionEntity) {
- startEventActivity.addListener(ExecutionListener.EVENTNAME_START, new URNMappingInitializerListener("START"));
- startEventActivity.addListener(ExecutionListener.EVENTNAME_START, new LoggingInitializerListener("START"));
- }
-
- injectLogExecutionListener(startEventActivity);
- }
-
- @Override
- public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) {
- injectLogExecutionListener(timerActivity);
- }
-
- @Override
- public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
- //injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) {
- injectLogExecutionListener(timerActivity);
- }
-
- @Override
- public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) {
- //injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, ActivityImpl signalActivity) {
- injectLogExecutionListener(signalActivity);
- }
-
- @Override
- public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) {
- injectLogExecutionListener(signalActivity);
- }
-
- @Override
- public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) {
- injectLogExecutionListener(compensationActivity);
- }
-
- @Override
- public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
- injectLogExecutionListener(activity);
- }
-
- @Override
- public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) {
- injectLogExecutionListener(nestedActivity);
- }
-
- @Override
- public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, ActivityImpl nestedActivity) {
- injectLogExecutionListener(nestedActivity);
- }
-
- @Override
- public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, ActivityImpl messageActivity) {
- injectLogExecutionListener(messageActivity);
- }
- }
-
- /**
- * Initializes URN mapping variables on process entry.
- */
- public static class URNMappingInitializerListener implements ExecutionListener {
- private String event;
-
- public URNMappingInitializerListener(String eventData) {
- this.event = eventData;
- }
-
- public String getEvent() {
- return event;
- }
-
- @Override
- public void notify(DelegateExecution execution) throws Exception {
- ProcessEngineConfigurationImpl processEngineConfiguration =
- Context.getProcessEngineConfiguration();
- loadURNProperties(execution, processEngineConfiguration);
- }
-
- private void loadURNProperties(DelegateExecution execution,
- ProcessEngineConfigurationImpl processEngineConfiguration) {
- Map<String,String> bpmnProps = PropertyConfiguration.getInstance().getProperties("mso.bpmn.properties");
- if (bpmnProps == null) {
- LOGGER.debug("Unable to load mso.bpmn.properties; loading URN Mapping from DB");
-
- LOGGER.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError,
- "Unable to load mso.bpmn.properties; loading URN Mapping from DB");
-
- loadFromDB(execution, processEngineConfiguration);
- } else {
- String fsEnabled = bpmnProps.get(FSPROPKEY);
- if (fsEnabled != null) {
- if (Boolean.parseBoolean(fsEnabled)) {
- LOGGER.debug("File system loading is enabled; loading URN properties from File system");
- LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", "File system loading is enabled; loading URN properties from File System");
- loadFromFileSystem(execution);
- } else {
- LOGGER.debug("File system loading is disabled; loading URN properties from DB");
- LOGGER.info (MessageEnum.BPMN_GENERAL_INFO, "BPMN", "File system loading is disabled; loading URN properties from DB");
-
- loadFromDB(execution, processEngineConfiguration);
- }
- } else {
-
- LOGGER.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError,
- "Unable to retrieve URNMapping.FileSystemLoading.Enabled from mso.bpmn.properties; loading URN Mapping from DB");
-
- loadFromDB(execution, processEngineConfiguration);
- }
- }
- }
-
- private void loadFromFileSystem(DelegateExecution execution) {
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> props = propertyConfiguration.getProperties("mso.bpmn.urn.properties");
- for (String key : props.keySet()) {
- String varName = URNMapping.createIdentifierFromURN(key);
- String varValue = props.get(key);
- execution.setVariable(varName, varValue);
- }
- }
-
- private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) {
- Command<List<URNMapping>> command = commandContext -> (List<URNMapping>) commandContext.getDbSqlSession()
- .selectList("mso.urnMapping.selectAll", null);
-
- CustomMyBatisSessionFactory sessionFactory = new CustomMyBatisSessionFactory();
- sessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration,
- "customMyBatisConfiguration.xml");
-
- List<URNMapping> mappings = sessionFactory.getCommandExecutorTxRequired().execute(command);
-
- if (mappings != null && !mappings.isEmpty()) {
- for (URNMapping mapping : mappings) {
- String varName = URNMapping.createIdentifierFromURN(mapping.getName());
- String varValue = mapping.getValue();
-
- LOGGER.debug("URN Mapping = '" + mapping.getName()
- + "', setting variable '" + varName + "' to '" + varValue + "'");
-
- execution.setVariable(varName, varValue);
- }
- }
- }
- }
-
- /**
- * Sets the isDebugLogEnabled variable on process entry.
- */
- public static class LoggingInitializerListener implements ExecutionListener {
- private String event;
-
- public LoggingInitializerListener(String eventData) {
- this.event = eventData;
- }
-
- public String getEvent() {
- return event;
- }
-
- @Override
- public void notify(DelegateExecution execution) throws Exception {
- String processKey = execution.getProcessEngineServices().getRepositoryService()
- .getProcessDefinition(execution.getProcessDefinitionId()).getKey();
-
- // If a "true" value is already injected, e.g. from a top-level flow, it SHOULD NOT be
- // overridden by the value in the URN mapping. This allows a top-level flow and all
- // invoked subflows to be debugged by turning on the debug flag for just the top-level
- // flow, assuming the isDebugEnabled flag variable is passed from the top-level flow to
- // its subflows.
-
- // If a "false" value is already injected, e.g. from a top-level flow, it SHOULD be
- // overridden by the value in the URN mapping. This allows a subflow to be debugged
- // without turning on the the debug flag for the top-level flow.
-
- String injectedValue = (String) execution.getVariable("isDebugLogEnabled");
- String urnValue = "true".equals(execution.getVariable("URN_log_debug_" + processKey)) ? "true" : "false";
-
- if ("true".equals(injectedValue)) {
- LOGGER.debug("Setting isDebugLogEnabled to \"" + injectedValue + "\" for process: " + processKey + " (injected value)");
- execution.setVariable("isDebugLogEnabled", injectedValue);
- } else {
- LOGGER.debug("Setting isDebugLogEnabled to \"" + urnValue + "\" for process: " + processKey + " (from URN mapping)");
- execution.setVariable("isDebugLogEnabled", urnValue);
- }
- }
- }
-
- /**
- * Logs details about the current activity.
- */
- public static class LoggingExecutionListener implements ExecutionListener {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- private static ConcurrentHashMap<String, Long> startTimes = new ConcurrentHashMap<>();
-
- private String event;
-
- public LoggingExecutionListener(String event) {
- this.event = event;
- }
-
- public String getEvent() {
- return event;
- }
-
- public void notify(DelegateExecution execution) throws Exception {
- BPMNLogger.debug(
- (String) execution.getVariable("isDebugLogEnabled"),
- "Logging for activity---------------:" + event + ":"
- + execution.getCurrentActivityName()
- + ", processDefinitionId="
- + execution.getProcessDefinitionId() + ", activtyId="
- + execution.getCurrentActivityId() + ", activtyName='"
- + execution.getCurrentActivityName() + "'"
- + ", processInstanceId="
- + execution.getProcessInstanceId() + ", businessKey="
- + execution.getProcessBusinessKey() + ", executionId="
- + execution.getId());
-
- if (!isBlank(execution.getCurrentActivityName())) {
- try {
- String id = execution.getId();
- if ("START".equals(event) && id != null ) {
- startTimes.put(id, System.currentTimeMillis());
- } else if ("END".equals(event) && id != null) {
- String prefix = (String) execution.getVariable("prefix");
-
- if (prefix != null ) {
- MsoLogger.setServiceName("MSO." + prefix.substring(0,prefix.length()-1));
- }
-
- String requestId = (String) execution.getVariable("mso-request-id");
- String svcid = (String) execution.getVariable("mso-service-instance-id");
- MsoLogger.setLogContext(requestId, svcid);
- long startTime = startTimes.remove(id);
-
- if (startTime != 0) {
-
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- event + ": " + execution.getCurrentActivityName(), "BPMN", execution.getCurrentActivityName(), null);
-
- }
- }
- } catch(Exception e) {
- LOGGER.debug("Exception at notify: " + e);
- }
- }
- }
-
- private boolean isBlank(Object object) {
- return object == null || "".equals(object.toString().trim());
- }
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java
deleted file mode 100644
index d25dcb6f3c..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.plugins;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.ExecutionListener;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior;
-import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
-import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
-import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration;
-import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
-import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
-import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
-import org.camunda.bpm.engine.impl.pvm.PvmTransition;
-import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
-import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl;
-import org.camunda.bpm.engine.impl.util.xml.Element;
-
-import org.openecomp.mso.bpmn.core.BPMNLogger;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-
-/**
- * This plugin does the following:
- * <ol>
- * <li>
- * Adds logic at the start of every Call Activity to remove any existing
- * WorkflowException object from the execution (saving a copy of it in a
- * different variable).
- * </li>
- * <li>
- * Adds logic at the end of every Call Activity to generate a MSOWorkflowException
- * event if there is a WorkflowException object in the execution.
- * </li>
- * </ol>
- */
-public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin {
-
- @Override
- public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
- List<BpmnParseListener> preParseListeners =
- processEngineConfiguration.getCustomPreBPMNParseListeners();
-
- if (preParseListeners == null) {
- preParseListeners = new ArrayList<>();
- processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
- }
-
- preParseListeners.add(new WorkflowExceptionParseListener());
- }
-
- public static class WorkflowExceptionParseListener extends AbstractBpmnParseListener {
- @Override
- public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {
- AtomicInteger triggerTaskIndex = new AtomicInteger(1);
- List<ActivityImpl> activities = new ArrayList<>(processDefinition.getActivities());
- recurse(activities, triggerTaskIndex);
- }
-
- /**
- * Helper method that recurses (into subprocesses) over all the listed activities.
- * @param activities a list of workflow activities
- * @param triggerTaskIndex the index of the next trigger task (mutable)
- */
- private void recurse(List<ActivityImpl> activities, AtomicInteger triggerTaskIndex) {
- for (ActivityImpl activity : activities) {
- String type = (String) activity.getProperty("type");
-
- if ("callActivity".equals(type)) {
- // Add a WorkflowExceptionResetListener to clear the WorkflowException
- // variable when each Call Activity starts.
-
- activity.addListener(
- ExecutionListener.EVENTNAME_START,
- new WorkflowExceptionResetListener());
-
- // Add a WorkflowExceptionTriggerTask after the call activity.
- // It must be a task because a listener cannot be used to generate
- // an event. Throwing BpmnError from an execution listener will
- // cause the process to die.
-
- List<PvmTransition> outTransitions =
- new ArrayList<>(activity.getOutgoingTransitions());
-
- for (PvmTransition transition : outTransitions) {
- String triggerTaskId = "WorkflowExceptionTriggerTask_" + triggerTaskIndex;
-
- ActivityImpl triggerTask = activity.getFlowScope().createActivity(triggerTaskId);
-
- ClassDelegateActivityBehavior behavior = new ClassDelegateActivityBehavior(
- WorkflowExceptionTriggerTask.class.getName(),
- new ArrayList<>(0));
-
- triggerTask.setActivityBehavior(behavior);
- triggerTask.setName("Workflow Exception Trigger Task " + triggerTaskIndex);
- triggerTaskIndex.getAndIncrement();
-
- TransitionImpl transitionImpl = (TransitionImpl) transition;
- TransitionImpl triggerTaskOutTransition = triggerTask.createOutgoingTransition();
- triggerTaskOutTransition.setDestination((ActivityImpl)transitionImpl.getDestination());
- transitionImpl.setDestination(triggerTask);
- }
- } else if ("subProcess".equals(type)) {
- recurse(new ArrayList<>(activity.getActivities()), triggerTaskIndex);
- }
- }
- }
- }
-
- /**
- * If there is a WorkflowException object in the execution, this method
- * removes it (saving a copy of it in a different variable).
- */
- public static class WorkflowExceptionResetListener implements ExecutionListener {
- public void notify(DelegateExecution execution) throws Exception {
- Object workflowException = execution.getVariable("WorkflowException");
-
- if (workflowException instanceof WorkflowException) {
- int index = 1;
- String saveName = "SavedWorkflowException" + index;
- while (execution.getVariable(saveName) != null) {
- saveName = "SavedWorkflowException" + (++index);
- }
-
- BPMNLogger.debug((String)execution.getVariable("isDebugLogEnabled"),
- "WorkflowExceptionResetTask is moving WorkflowException to " + saveName);
-
- execution.setVariable(saveName, workflowException);
- execution.setVariable("WorkflowException", null);
- }
- }
- }
-
- /**
- * Generates an MSOWorkflowException event if there is a WorkflowException
- * object in the execution.
- */
- public static class WorkflowExceptionTriggerTask implements JavaDelegate {
- public void execute(DelegateExecution execution) throws Exception {
- if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
- BPMNLogger.debug((String)execution.getVariable("isDebugLogEnabled"),
- "WorkflowExceptionTriggerTask is generating a MSOWorkflowException event");
- throw new BpmnError("MSOWorkflowException");
- }
- }
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml b/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml
deleted file mode 100644
index 2c3d5dad0a..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-
-<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
-
-<configuration>
- <settings>
- <setting name="lazyLoadingEnabled" value="false" />
- </settings>
- <mappers>
- <mapper resource="urnMapping.xml" />
- </mappers>
-</configuration>
diff --git a/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml b/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml
deleted file mode 100644
index 274c859dd9..0000000000
--- a/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="mso.urnMapping">
-
- <resultMap id="urnMapping" type="org.openecomp.mso.bpmn.core.mybatis.URNMapping">
- <result property="name" column="NAME_" jdbcType="VARCHAR"/>
- <result property="value" column="VALUE_" jdbcType="VARCHAR" />
- <result property="rev" column="REV_" jdbcType="INTEGER" />
- </resultMap>
-
- <select id="selectAll" resultMap="urnMapping">
- select NAME_, VALUE_, REV_
- from MSO_URN_MAPPING
- </select>
-
- <select id="selectOne" resultMap="urnMapping">
- select NAME_, VALUE_, REV_
- from MSO_URN_MAPPING
- where name = #{name}
- </select>
-
-</mapper>
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java
new file mode 100644
index 0000000000..b35e65485f
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java
@@ -0,0 +1,46 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class BadInjectedFiledExceptionTest {
+
+ private BadInjectedFieldException badInjectedFieldException;
+
+ @Test
+ public void test() {
+ String fieldName = "anyFieldName";
+ String taskName = "anyTask";
+ Object info = new String("info");
+
+ String expectedMessage1 = taskName+" injected field '"+fieldName+"' is bad: "+(String)info;
+ badInjectedFieldException = new BadInjectedFieldException(fieldName, taskName, info);
+ assertEquals(expectedMessage1, badInjectedFieldException.getMessage());
+
+ String expectedMessage2 = "java.lang.Throwable: anyCause";
+ Throwable cause = new Throwable("anyCause");
+ badInjectedFieldException = new BadInjectedFieldException(fieldName, taskName, info, cause);
+ assertEquals(expectedMessage2, badInjectedFieldException.getCause().toString());
+
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java
new file mode 100644
index 0000000000..40fcb982c1
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java
@@ -0,0 +1,247 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RepositoryService;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.Expression;
+import org.camunda.bpm.engine.repository.ProcessDefinition;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.junit.rules.ExpectedException;
+
+public class BaseTaskTest {
+
+ private String prefix = "PRE_";
+ private String processKey = "AnyProcessKey";
+ private String definitionId = "100";
+ private String anyVariable = "anyVariable";
+ private String anyValueString = "anyValue";
+ private String badValueString = "123abc";
+ private int anyValueInt = 123;
+ private Integer anyValueInteger = new Integer(anyValueInt);
+ private long anyValuelong = 123L;
+ private Long anyValueLong = new Long(anyValuelong);
+
+ private DelegateExecution mockExecution;
+ private Expression mockExpression;
+ private BaseTask baseTask;
+ private Object obj1;
+ private Object obj2;
+ private Object objectString;
+ private Object objectInteger;
+ private Object objectLong;
+ private Object objectBoolean;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ baseTask = new BaseTask();
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class);
+ when(mockProcessDefinition.getKey()).thenReturn(processKey);
+ RepositoryService mockRepositoryService = mock(RepositoryService.class);
+ when(mockRepositoryService.getProcessDefinition(definitionId)).thenReturn(mockProcessDefinition);
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class);
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService);
+ mockExecution = mock(DelegateExecution.class);
+ when(mockExecution.getId()).thenReturn(definitionId);
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices);
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition);
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix);
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true");
+ mockExpression = mock(Expression.class);
+ }
+
+ @Test
+ public void testExecution() throws Exception{
+ baseTask.execute(mockExecution);
+ assertEquals("BaseTask", baseTask.getTaskName());
+ }
+
+ @Test
+ public void testGetFieldAndMissingInjectedException() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+
+ expectedException.expect(MissingInjectedFieldException.class);
+ obj2 = baseTask.getField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ obj1 = baseTask.getField(mockExpression, mockExecution, null);
+ }
+
+ @Test
+ public void testGetOptionalField() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getOptionalField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+ }
+
+ @Test
+ public void testGetStringFieldAndMissingInjectedFieldException() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getStringField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+
+ expectedException.expect(MissingInjectedFieldException.class);
+ Object objectBoolean = new Boolean(true); // bad data
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean);
+ obj2 = baseTask.getStringField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetStringFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ obj1 = baseTask.getStringField(mockExpression, mockExecution, null);
+ }
+
+ @Test
+ public void testGetOptionalStringField() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getOptionalStringField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+ }
+
+ @Test
+ public void testGetIntegerFieldAndMissingInjectedFieldException() throws Exception{
+ objectInteger = new Integer(anyValueInt);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger);
+ obj1 = baseTask.getIntegerField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueInteger, (Integer)obj1);
+
+ expectedException.expect(MissingInjectedFieldException.class);
+ objectString = new String(badValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj2 = baseTask.getIntegerField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetIntegerFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ obj1 = baseTask.getIntegerField(mockExpression, mockExecution, null);
+ }
+
+
+ @Test
+ public void testGetOptionalIntegerField() throws Exception{
+ objectInteger = new Integer(anyValueInt);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger);
+ obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueInteger, (Integer)obj1);
+ }
+
+ @Test
+ public void testGetOptionalIntegerFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ objectBoolean = new Boolean(true);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean);
+ obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetLongFieldAndMissingInjectedFieldException() throws Exception{
+ objectLong = new Long(anyValuelong);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectLong);
+ obj1 = baseTask.getLongField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueLong, (Long)obj1);
+
+ expectedException.expect(MissingInjectedFieldException.class);
+ objectString = new String(badValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj2 = baseTask.getLongField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetLongFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ obj2 = baseTask.getLongField(mockExpression, mockExecution, null);
+ }
+
+ @Test
+ public void testGetOptionalLongField() throws Exception{
+ objectLong = new Long(anyValuelong);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectLong);
+ obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueLong, (Long)obj1);
+ }
+
+ @Test
+ public void testGetOptionalLongFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ objectBoolean = new Boolean(true);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean);
+ obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetOutputAndMissingInjectedFieldException() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getOutputField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+
+ expectedException.expect(MissingInjectedFieldException.class);
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj2 = baseTask.getOutputField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetOutputAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ obj2 = baseTask.getOutputField(null, mockExecution, anyVariable);
+ }
+
+ @Test
+ public void testGetOptionalOutputField() throws Exception{
+ objectString = new String(anyValueString);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectString);
+ obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable);
+ assertEquals(anyValueString, obj1.toString());
+ }
+
+ @Test
+ public void testGetOptionalOutputFieldAndBadInjectedFieldException() throws Exception{
+ expectedException.expect(BadInjectedFieldException.class);
+ objectBoolean = new Boolean(true);
+ when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean);
+ obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable);
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java
new file mode 100644
index 0000000000..2415e619d7
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation;
+import static org.onap.so.openpojo.rules.HasAnnotationPropertyWithValueMatcher.hasAnnotationPropertyWithValue;
+
+import javax.persistence.Column;
+import javax.persistence.Temporal;
+
+import org.junit.Test;
+import org.onap.so.openpojo.rules.CustomSetterMustExistRule;
+import org.onap.so.openpojo.rules.EqualsAndHashCodeTester;
+import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule;
+import org.onap.so.openpojo.rules.HasToStringRule;
+import org.onap.so.openpojo.rules.ToStringTester;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.PojoClassFilter;
+import com.openpojo.reflection.filters.FilterEnum;
+import com.openpojo.reflection.filters.FilterNonConcrete;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.BusinessKeyMustExistRule;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.NoNestedClassRule;
+import com.openpojo.validation.rule.impl.NoPrimitivesRule;
+import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule;
+import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule;
+import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+
+public class BeansTest {
+
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
+
+ private PojoClassFilter enumFilter = new FilterEnum();
+
+
+
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.bpmn.core.domain");
+
+ }
+
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create()
+ .with(new GetterMustExistRule())
+ .with(new NoNestedClassRule())
+ .with(new SerializableMustHaveSerialVersionUIDRule())
+ .with(new NoPublicFieldsExceptStaticFinalRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+
+
+
+ .build();
+
+
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete());
+ }
+ private static class FilterTestClasses implements PojoClassFilter {
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java
new file mode 100644
index 0000000000..b0aa41b05d
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java
@@ -0,0 +1,39 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class MissingInjectedFiledExceptionTest {
+
+ private MissingInjectedFieldException missingInjectedFieldException;
+
+ @Test
+ public void test() {
+ String fieldName = "anyFieldName";
+ String taskName = "anyTask";
+ String info = "missing required field";
+ String expectedMessage1 = taskName+" injected field '"+fieldName+"' is bad: "+info;
+ missingInjectedFieldException = new MissingInjectedFieldException(fieldName, taskName);
+ assertEquals(expectedMessage1, missingInjectedFieldException.getMessage());
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java
new file mode 100644
index 0000000000..b605209739
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java
@@ -0,0 +1,110 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RepositoryService;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.repository.ProcessDefinition;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ResponseBuilderTest {
+
+ private String prefix = "PRE_";
+ private String processKey = "AnyProcessKey";
+ private String definitionId = "100";
+ private int errorCode_200 = 200;
+ private int errorCode_404 = 404;
+ private String errorMessage = "any error message!";
+ private String errorMessageXML = "<ErrorMessage>any error message!</ErrorMessage><ErrorCode>200</ErrorCode>";
+ private String response = "<WorkflowResponse>bad</WorkflowResponse>";
+
+ private DelegateExecution mockExecution;
+ private ResponseBuilder responseBuilder;
+ private WorkflowException workflowException;
+ private Object obj;
+
+ @Before
+ public void before() throws Exception {
+ responseBuilder = new ResponseBuilder();
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class);
+ when(mockProcessDefinition.getKey()).thenReturn(processKey);
+ RepositoryService mockRepositoryService = mock(RepositoryService.class);
+ when(mockRepositoryService.getProcessDefinition(definitionId)).thenReturn(mockProcessDefinition);
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class);
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService);
+ mockExecution = mock(DelegateExecution.class);
+ when(mockExecution.getId()).thenReturn(definitionId);
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices);
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition);
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix);
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true");
+ }
+
+ @Test
+ public void buildWorkflowException_WorkflowException_2000_Test() {
+ when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(errorMessage);
+ when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_200);
+ workflowException = responseBuilder.buildWorkflowException(mockExecution);
+ assertEquals(2000, workflowException.getErrorCode());
+ assertEquals("any error message!", workflowException.getErrorMessage());
+ }
+
+ @Test
+ public void buildWorkflowException_WorkflowException_XML_2000_Test() {
+ when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(errorMessageXML);
+ when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_200);
+ workflowException = responseBuilder.buildWorkflowException(mockExecution);
+ assertEquals(2000, workflowException.getErrorCode());
+ assertEquals("any error message!", workflowException.getErrorMessage());
+ }
+
+ @Test
+ public void buildWorkflowException_WorkflowException_NULL_Test() {
+ when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(null);
+ when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(null);
+ workflowException = responseBuilder.buildWorkflowException(mockExecution);
+ assertEquals(null, workflowException);
+ }
+
+ @Test
+ public void buildWorkflowException_Response_1002_Test() {
+ when(mockExecution.getVariable(processKey+"Response")).thenReturn(response);
+ when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_404);
+ workflowException = responseBuilder.buildWorkflowException(mockExecution);
+ assertEquals(response, workflowException.getErrorMessage());
+ assertEquals(1002, workflowException.getErrorCode());
+ }
+
+ @Test
+ public void buildWorkflowResponse_Object_Test() {
+ String workflowResponse = "<WorkflowResponse>good</WorkflowResponse>";
+ when(mockExecution.getVariable("WorkflowResponse")).thenReturn(workflowResponse);
+ obj = responseBuilder.buildWorkflowResponse(mockExecution);
+ assertEquals(workflowResponse, obj);
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java
index c51af23e30..875df6cf94 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,10 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.onap.so.bpmn.core;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.entry;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.hamcrest.Matchers.isIn;
+import java.util.Arrays;
+import java.util.Collections;
import org.junit.Test;
@@ -41,11 +48,11 @@ public class RollbackDataTest {
data.put(TYPE_A, "key2", "value2");
data.put(TYPE_B, "key3", "value3");
// when, then
- assertThat(data.toString()).isIn(
+ assertThat(data.toString(), isIn(Arrays.asList(
"[typeB{key3=value3},typeA{key1=value1, key2=value2}]",
"[typeB{key3=value3},typeA{key2=value2, key1=value1}]",
"[typeA{key1=value1, key2=value2},typeB{key3=value3}]",
- "[typeA{key2=value2, key1=value1},typeB{key3=value3}]");
+ "[typeA{key2=value2, key1=value1},typeB{key3=value3}]")));
}
@Test
@@ -53,8 +60,8 @@ public class RollbackDataTest {
// given
RollbackData data = new RollbackData();
// then
- assertThat(data.hasType(TYPE_A)).isFalse();
- assertThat(data.get(TYPE_A, KEY_1)).isNull();
+ assertFalse(data.hasType(TYPE_A));
+ assertNull(data.get(TYPE_A, KEY_1));
}
@Test
@@ -64,9 +71,9 @@ public class RollbackDataTest {
// when
data.put(TYPE_A, KEY_1, VALUE_1);
// then
- assertThat(data.hasType(TYPE_A)).isTrue();
- assertThat(data.hasType(TYPE_B)).isFalse();
- assertThat(data.get(TYPE_A, KEY_1)).isEqualTo(VALUE_1);
+ assertTrue(data.hasType(TYPE_A));
+ assertFalse(data.hasType(TYPE_B));
+ assertEquals(VALUE_1, data.get(TYPE_A, KEY_1));
}
@Test
@@ -77,9 +84,9 @@ public class RollbackDataTest {
data.put(TYPE_A, KEY_1, VALUE_1);
data.put(TYPE_B, KEY_1, VALUE_2);
// then
- assertThat(data.get(TYPE_A, KEY_1)).isEqualTo(VALUE_1);
- assertThat(data.get(TYPE_A)).containsExactly(entry(KEY_1, VALUE_1));
- assertThat(data.get(TYPE_B, KEY_1)).isEqualTo(VALUE_2);
- assertThat(data.get(TYPE_B)).containsExactly(entry(KEY_1, VALUE_2));
+ assertEquals(VALUE_1, data.get(TYPE_A, KEY_1));
+ assertThat(data.get(TYPE_A), is(Collections.singletonMap(KEY_1, VALUE_1)));
+ assertEquals(VALUE_2, data.get(TYPE_B, KEY_1));
+ assertThat(data.get(TYPE_B), is(Collections.singletonMap(KEY_1, VALUE_2)));
}
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java
new file mode 100644
index 0000000000..5d9a1d61f2
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core;
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.core.env.Environment;
+
+import static org.mockito.Mockito.*;
+
+public class UrnPropertiesReaderTest {
+
+ @Test
+ public void testGetVariableFromExecution() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class);
+ when(mockExecution.getVariable("testKey")).thenReturn("testValue");
+ String value = UrnPropertiesReader.getVariable("testKey",mockExecution);
+ Assert.assertEquals("testValue", value);
+ verify(mockExecution).getVariable("testKey");
+ verify(mockExecution, never()).setVariable("testKey", value);
+ }
+
+ @Test
+ public void testGetVariableFromEnvironment() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class);
+ Environment mockEnvironment = mock(Environment.class);
+ when(mockEnvironment.getProperty("testKey")).thenReturn("testValue");
+ UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader();
+ urnPropertiesReader.setEnvironment(mockEnvironment);
+ String value = UrnPropertiesReader.getVariable("testKey",mockExecution);
+ Assert.assertEquals("testValue",value);
+ verify(mockExecution).getVariable("testKey");
+ verify(mockExecution).setVariable("testKey", value);
+ }
+
+ @Test
+ public void testGetVariableNotExist() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class);
+ String value = UrnPropertiesReader.getVariable("notExist", mockExecution);
+ Assert.assertEquals(null, value);
+ verify(mockExecution).getVariable("notExist");
+ verify(mockExecution, never()).setVariable("notExist", value);
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java
new file mode 100644
index 0000000000..c1e9b8776b
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java
@@ -0,0 +1,47 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.junit.Test;
+
+public class WorkflowExceptionTest {
+
+ private WorkflowException workflowException;
+
+ @Test
+ public void test() {
+ String processKey = "AnyProcessKey";
+ int errorCode = 200;
+ String errorMessage = "any error message!";
+ workflowException = new WorkflowException(processKey, errorCode, errorMessage);
+ assertEquals(errorCode, workflowException.getErrorCode());
+ assertEquals(errorMessage, workflowException.getErrorMessage());
+ assertEquals(processKey, workflowException.getProcessKey());
+ assertEquals("*", workflowException.getWorkStep());
+ String workStep = "one";
+ workflowException = new WorkflowException(processKey, errorCode, errorMessage, workStep);
+ assertEquals(workStep, workflowException.getWorkStep());
+ assertNotEquals(null, workflowException.toString());
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java
index 09720be9b9..b1dd8659cd 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java
@@ -1,57 +1,54 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class AllottedResourceTest {
- private AllottedResource ar = new AllottedResource();
- TunnelConnect tc = new TunnelConnect();
-
- @Test
- public void testAllottedResource() {
- ar.setAllottedResourceType("allottedResourceType");
- ar.setAllottedResourceRole("allottedResourceRole");
- ar.setProvidingServiceModelName("providingServiceModelName");
- ar.setProvidingServiceModelInvariantUuid("providingServiceModelInvariantUuid");
- ar.setProvidingServiceModelUuid("providingServiceModelUuid");
- ar.setNfFunction("nfFunction");
- ar.setNfType("nfType");
- ar.setNfRole("nfRole");
- ar.setNfNamingCode("nfNamingCode");
- ar.setOrchestrationStatus("orchestrationStatus");
- ar.setTunnelConnect(tc);
- assertEquals(ar.getAllottedResourceType(), "allottedResourceType");
- assertEquals(ar.getAllottedResourceRole(), "allottedResourceRole");
- assertEquals(ar.getProvidingServiceModelName(), "providingServiceModelName");
- assertEquals(ar.getProvidingServiceModelInvariantUuid(), "providingServiceModelInvariantUuid");
- assertEquals(ar.getProvidingServiceModelUuid(), "providingServiceModelUuid");
- assertEquals(ar.getNfFunction(), "nfFunction");
- assertEquals(ar.getNfType(), "nfType");
- assertEquals(ar.getNfRole(), "nfRole");
- assertEquals(ar.getNfNamingCode(), "nfNamingCode");
- assertEquals(ar.getOrchestrationStatus(), "orchestrationStatus");
- assertEquals(ar.getTunnelConnect(), tc);
-
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class AllottedResourceTest {
+ private AllottedResource ar = new AllottedResource();
+
+ @Test
+ public void testAllottedResource() {
+ ar.setAllottedResourceType("allottedResourceType");
+ ar.setAllottedResourceRole("allottedResourceRole");
+ ar.setProvidingServiceModelName("providingServiceModelName");
+ ar.setProvidingServiceModelInvariantUuid("providingServiceModelInvariantUuid");
+ ar.setProvidingServiceModelUuid("providingServiceModelUuid");
+ ar.setNfFunction("nfFunction");
+ ar.setNfType("nfType");
+ ar.setNfRole("nfRole");
+ ar.setNfNamingCode("nfNamingCode");
+ ar.setOrchestrationStatus("orchestrationStatus");
+ assertEquals(ar.getAllottedResourceType(), "allottedResourceType");
+ assertEquals(ar.getAllottedResourceRole(), "allottedResourceRole");
+ assertEquals(ar.getProvidingServiceModelName(), "providingServiceModelName");
+ assertEquals(ar.getProvidingServiceModelInvariantUuid(), "providingServiceModelInvariantUuid");
+ assertEquals(ar.getProvidingServiceModelUuid(), "providingServiceModelUuid");
+ assertEquals(ar.getNfFunction(), "nfFunction");
+ assertEquals(ar.getNfType(), "nfType");
+ assertEquals(ar.getNfRole(), "nfRole");
+ assertEquals(ar.getNfNamingCode(), "nfNamingCode");
+ assertEquals(ar.getOrchestrationStatus(), "orchestrationStatus");
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java
index 90cb7362cf..af9c7a7fa6 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java
@@ -1,83 +1,83 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class CompareModelsResultTest {
-
- private CompareModelsResult modelsResult;
- private List<ResourceModelInfo> addedResourceList;
- private List<ResourceModelInfo> deletedResourceList;
- private ResourceModelInfo resourceModelInfo1;
- private ResourceModelInfo resourceModelInfo2;
- private List<String> requestInputs;
-
- @Before
- public void before() {
- resourceModelInfo1 = new ResourceModelInfo();
- resourceModelInfo1.setResourceCustomizationUuid("f1d563e8-e714-4393-8f99-cc480144a05e");
- resourceModelInfo1.setResourceInvariantUuid("e1d563e8-e714-4393-8f99-cc480144a05f");
- resourceModelInfo1.setResourceName("resourceName1");
- resourceModelInfo1.setResourceUuid("f1d563e8-e714-4393-8f99-cc480144a05g");
- resourceModelInfo2 = new ResourceModelInfo();
- resourceModelInfo2.setResourceCustomizationUuid("a1d563e8-e714-4393-8f99-cc480144a05d");
- resourceModelInfo2.setResourceInvariantUuid("b1d563e8-e714-4393-8f99-cc480144a05e");
- resourceModelInfo2.setResourceName("resourceName2");
- resourceModelInfo2.setResourceUuid("c1d563e8-e714-4393-8f99-cc480144a05f");
- }
-
- @Test
- public void testSetAddedResourceList() {
- addedResourceList = new ArrayList<ResourceModelInfo>();
- addedResourceList.add(resourceModelInfo1);
- addedResourceList.add(resourceModelInfo2);
- modelsResult = new CompareModelsResult();
- modelsResult.setAddedResourceList(addedResourceList);
- assertEquals(addedResourceList, modelsResult.getAddedResourceList());
- }
-
- @Test
- public void testSetDeletedResourceList() {
- deletedResourceList = new ArrayList<ResourceModelInfo>();
- deletedResourceList.add(resourceModelInfo1);
- deletedResourceList.add(resourceModelInfo2);
- modelsResult = new CompareModelsResult();
- modelsResult.setDeletedResourceList(deletedResourceList);
- assertEquals(deletedResourceList, modelsResult.getDeletedResourceList());
- }
-
- @Test
- public void testSetRequestInputs() {
- requestInputs = new ArrayList<String>();
- requestInputs.add("requestInput1");
- requestInputs.add("requestInput2");
- modelsResult = new CompareModelsResult();
- modelsResult.setRequestInputs(requestInputs);
- assertEquals(requestInputs, modelsResult.getRequestInputs());
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+package org.onap.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CompareModelsResultTest {
+
+ private CompareModelsResult modelsResult;
+ private List<ResourceModelInfo> addedResourceList;
+ private List<ResourceModelInfo> deletedResourceList;
+ private ResourceModelInfo resourceModelInfo1;
+ private ResourceModelInfo resourceModelInfo2;
+ private List<String> requestInputs;
+
+ @Before
+ public void before() {
+ resourceModelInfo1 = new ResourceModelInfo();
+ resourceModelInfo1.setResourceCustomizationUuid("f1d563e8-e714-4393-8f99-cc480144a05e");
+ resourceModelInfo1.setResourceInvariantUuid("e1d563e8-e714-4393-8f99-cc480144a05f");
+ resourceModelInfo1.setResourceName("resourceName1");
+ resourceModelInfo1.setResourceUuid("f1d563e8-e714-4393-8f99-cc480144a05g");
+ resourceModelInfo2 = new ResourceModelInfo();
+ resourceModelInfo2.setResourceCustomizationUuid("a1d563e8-e714-4393-8f99-cc480144a05d");
+ resourceModelInfo2.setResourceInvariantUuid("b1d563e8-e714-4393-8f99-cc480144a05e");
+ resourceModelInfo2.setResourceName("resourceName2");
+ resourceModelInfo2.setResourceUuid("c1d563e8-e714-4393-8f99-cc480144a05f");
+ }
+
+ @Test
+ public void testSetAddedResourceList() {
+ addedResourceList = new ArrayList<ResourceModelInfo>();
+ addedResourceList.add(resourceModelInfo1);
+ addedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setAddedResourceList(addedResourceList);
+ assertEquals(addedResourceList, modelsResult.getAddedResourceList());
+ }
+
+ @Test
+ public void testSetDeletedResourceList() {
+ deletedResourceList = new ArrayList<ResourceModelInfo>();
+ deletedResourceList.add(resourceModelInfo1);
+ deletedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setDeletedResourceList(deletedResourceList);
+ assertEquals(deletedResourceList, modelsResult.getDeletedResourceList());
+ }
+
+ @Test
+ public void testSetRequestInputs() {
+ requestInputs = new ArrayList<String>();
+ requestInputs.add("requestInput1");
+ requestInputs.add("requestInput2");
+ modelsResult = new CompareModelsResult();
+ modelsResult.setRequestInputs(requestInputs);
+ assertEquals(requestInputs, modelsResult.getRequestInputs());
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java
new file mode 100644
index 0000000000..13a30d26ee
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java
@@ -0,0 +1,39 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ConfigResourceTest {
+ private ConfigResource configresource = new ConfigResource();{
+ configresource.resourceType = ResourceType.CONFIGURATION;
+ }
+
+ @Test
+ public void testConfigResource() {
+ configresource.setToscaNodeType("toscaNodeType");
+ assertEquals(configresource.getToscaNodeType(), "toscaNodeType");
+
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java
index df8440addf..fe84a1b5a7 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java
@@ -1,47 +1,47 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ConfigurationTest {
- private Configuration configuration = new Configuration();
-
- @Test
- public void testConfigurationTest() {
- configuration.setId("id");
- configuration.setName("name");
- configuration.setType("type");
- configuration.setOrchestrationStatus("orchestrationStatus");
- configuration.setTunnelBandwidth("tunnelBandwidth");
- configuration.setVendorAllowedMaxBandwidth("vendorAllowedMaxBandwidth");
- configuration.setResourceVersion("resourceVersion");
- assertEquals(configuration.getId(), "id");
- assertEquals(configuration.getName(), "name");
- assertEquals(configuration.getType(), "type");
- assertEquals(configuration.getOrchestrationStatus(), "orchestrationStatus");
- assertEquals(configuration.getTunnelBandwidth(), "tunnelBandwidth");
- assertEquals(configuration.getVendorAllowedMaxBandwidth(), "vendorAllowedMaxBandwidth");
- assertEquals(configuration.getResourceVersion(), "resourceVersion");
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ConfigurationTest {
+ private Configuration configuration = new Configuration();
+
+ @Test
+ public void testConfigurationTest() {
+ configuration.setId("id");
+ configuration.setName("name");
+ configuration.setType("type");
+ configuration.setOrchestrationStatus("orchestrationStatus");
+ configuration.setTunnelBandwidth("tunnelBandwidth");
+ configuration.setVendorAllowedMaxBandwidth("vendorAllowedMaxBandwidth");
+ configuration.setResourceVersion("resourceVersion");
+ assertEquals(configuration.getId(), "id");
+ assertEquals(configuration.getName(), "name");
+ assertEquals(configuration.getType(), "type");
+ assertEquals(configuration.getOrchestrationStatus(), "orchestrationStatus");
+ assertEquals(configuration.getTunnelBandwidth(), "tunnelBandwidth");
+ assertEquals(configuration.getVendorAllowedMaxBandwidth(), "vendorAllowedMaxBandwidth");
+ assertEquals(configuration.getResourceVersion(), "resourceVersion");
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java
new file mode 100644
index 0000000000..86eb717664
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java
@@ -0,0 +1,38 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class CustomerTest {
+ private Customer customer = new Customer();
+
+ @Test
+ public void testCustomer() {
+ customer.setSubscriptionServiceType("subscriptionServiceType");
+ customer.setGlobalSubscriberId("globalSubscriberId");
+ assertEquals(customer.getSubscriptionServiceType(), "subscriptionServiceType");
+ assertEquals(customer.getGlobalSubscriberId(), "globalSubscriberId");
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java
new file mode 100644
index 0000000000..b4860c6323
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.domain;
+
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.PojoClassFilter;
+import com.openpojo.reflection.filters.FilterNonConcrete;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+
+public class DomainPojoTest {
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
+
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.bpmn.core.domain");
+ }
+
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create()
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete());
+ }
+
+ private static class FilterTestClasses implements PojoClassFilter {
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java
index e334348b5d..9750e03b4c 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java
@@ -1,58 +1,58 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class HomingSolutionTest {
-
- private HomingSolution homingsolution = new HomingSolution();
- InventoryType inventory = InventoryType.cloud;
- VnfResource vnfresource = new VnfResource();
- License license = new License();
-
- @Test
- public void testHomingSolution() {
- homingsolution.setInventoryType(inventory);
- homingsolution.setRehome(true);
- homingsolution.setServiceInstanceId("serviceInstanceId");
- homingsolution.setCloudOwner("cloudOwner");
- homingsolution.setCloudRegionId("cloudRegionId");
- homingsolution.setAicClli("aicClli");
- homingsolution.setAicVersion("aicVersion");
- homingsolution.setTenant("tenant");
- homingsolution.setVnf(vnfresource);
- homingsolution.setLicense(license);
- assertEquals(homingsolution.getInventoryType(), inventory);
- assertEquals(homingsolution.isRehome(), true);
- assertEquals(homingsolution.getServiceInstanceId(), "serviceInstanceId");
- assertEquals(homingsolution.getCloudOwner(), "cloudOwner");
- assertEquals(homingsolution.getCloudRegionId(), "cloudRegionId");
- assertEquals(homingsolution.getAicClli(), "aicClli");
- assertEquals(homingsolution.getAicVersion(), "aicVersion");
- assertEquals(homingsolution.getTenant(), "tenant");
- assertEquals(homingsolution.getVnf(), vnfresource);
- assertEquals(homingsolution.getLicense(), license);
-
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class HomingSolutionTest {
+
+ private HomingSolution homingsolution = new HomingSolution();
+ InventoryType inventory = InventoryType.cloud;
+ VnfResource vnfresource = new VnfResource();
+ License license = new License();
+
+ @Test
+ public void testHomingSolution() {
+ homingsolution.setInventoryType(inventory);
+ homingsolution.setRehome(true);
+ homingsolution.setServiceInstanceId("serviceInstanceId");
+ homingsolution.setCloudOwner("cloudOwner");
+ homingsolution.setCloudRegionId("cloudRegionId");
+ homingsolution.setAicClli("aicClli");
+ homingsolution.setAicVersion("aicVersion");
+ homingsolution.setTenant("tenant");
+ homingsolution.setVnf(vnfresource);
+ homingsolution.setLicense(license);
+ assertEquals(homingsolution.getInventoryType(), inventory);
+ assertEquals(homingsolution.isRehome(), true);
+ assertEquals(homingsolution.getServiceInstanceId(), "serviceInstanceId");
+ assertEquals(homingsolution.getCloudOwner(), "cloudOwner");
+ assertEquals(homingsolution.getCloudRegionId(), "cloudRegionId");
+ assertEquals(homingsolution.getAicClli(), "aicClli");
+ assertEquals(homingsolution.getAicVersion(), "aicVersion");
+ assertEquals(homingsolution.getTenant(), "tenant");
+ assertEquals(homingsolution.getVnf(), vnfresource);
+ assertEquals(homingsolution.getLicense(), license);
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java
index 9ed194c455..e3133cb1c6 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java
@@ -1,89 +1,89 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.BDDMockito.Then;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-
-//@RunWith(PowerMockRunner.class)
-//@PrepareForTest({License.class})
-public class LicenseTest {
-
- //@Mock
- private License license= new License();
- //@InjectMocks
- //private LicenseTest licenceTest;
- List<String> entitlementPoolList = new ArrayList<String>();
- private List<String> licenseKeyGroupList = new ArrayList<String>();
- //JSONArray array = new JSONArray(entitlementPoolList);
- //JSONArray array1 = new JSONArray(licenseKeyGroupList);
- //@PrepareForTest({License.class})
- Long serialVersionUID = 333L;
-
- @Test
- public void testLicense() {
- license.setEntitlementPoolList(entitlementPoolList);
- license.setLicenseKeyGroupList(licenseKeyGroupList);
- //license.addEntitlementPool("entitlementPoolUuid");
- license.addLicenseKeyGroup("licenseKeyGroupUuid");
- assertEquals(license.getEntitlementPoolList(), entitlementPoolList);
- assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList);
- assert(license.getEntitlementPoolListAsString()!= null);
- assert(license.getLicenseKeyGroupListAsString()!=null);
- license.addEntitlementPool("entitlementPoolUuid");
- //assertEquals(license.getSerialversionuid(), serialVersionUID);
- //assertArrayEquals(license.getSerialversionuid(), serialVersionUID);
- //assert
-
- /*PowerMockito.mockStatic(License.class);
- Mockito.when(License.getSerialversionuid()).thenReturn(getserial());
- assertEquals(License.getSerialversionuid(),"abc");*/
-
- }
- // @Before
- // public void mocksetUp() {
-// Long serialVersionUID = 333L;
-// PowerMockito.mockStatic(License.class);
-// expect (license.getSerialversionuid()).andReturn(serialVersionUID);
-// //PowerMockito.when(license.getSerialversionuid().
-// //PowerMockito.when(MathUtil.addInteger(2, 2)).thenReturn(1);
-// }
-
- /*private Long getserial() {
-
- return abc;
- }*/
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.BDDMockito.Then;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+
+//@RunWith(PowerMockRunner.class)
+//@PrepareForTest({License.class})
+public class LicenseTest {
+
+ //@Mock
+ private License license= new License();
+ //@InjectMocks
+ //private LicenseTest licenceTest;
+ List<String> entitlementPoolList = new ArrayList<String>();
+ private List<String> licenseKeyGroupList = new ArrayList<String>();
+ //JSONArray array = new JSONArray(entitlementPoolList);
+ //JSONArray array1 = new JSONArray(licenseKeyGroupList);
+ //@PrepareForTest({License.class})
+ Long serialVersionUID = 333L;
+
+ @Test
+ public void testLicense() {
+ license.setEntitlementPoolList(entitlementPoolList);
+ license.setLicenseKeyGroupList(licenseKeyGroupList);
+ //license.addEntitlementPool("entitlementPoolUuid");
+ license.addLicenseKeyGroup("licenseKeyGroupUuid");
+ assertEquals(license.getEntitlementPoolList(), entitlementPoolList);
+ assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList);
+ assert(license.getEntitlementPoolListAsString()!= null);
+ assert(license.getLicenseKeyGroupListAsString()!=null);
+ license.addEntitlementPool("entitlementPoolUuid");
+ //assertEquals(license.getSerialversionuid(), serialVersionUID);
+ //assertArrayEquals(license.getSerialversionuid(), serialVersionUID);
+ //assert
+
+ /*PowerMockito.mockStatic(License.class);
+ Mockito.when(License.getSerialversionuid()).thenReturn(getserial());
+ assertEquals(License.getSerialversionuid(),"abc");*/
+
+ }
+ // @Before
+ // public void mocksetUp() {
+// Long serialVersionUID = 333L;
+// PowerMockito.mockStatic(License.class);
+// expect (license.getSerialversionuid()).andReturn(serialVersionUID);
+// //PowerMockito.when(license.getSerialversionuid().
+// //PowerMockito.when(MathUtil.addInteger(2, 2)).thenReturn(1);
+// }
+
+ /*private Long getserial() {
+
+ return abc;
+ }*/
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java
index 90eb230a4c..3d07f85c04 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java
@@ -1,47 +1,47 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ModelInfoTest {
- private ModelInfo modelinfo = new ModelInfo();
-
- @Test
- public void testModelInfo() {
- modelinfo.setModelName("modelName");
- modelinfo.setModelUuid("modelUuid");
- modelinfo.setModelInvariantUuid("modelInvariantUuid");
- modelinfo.setModelVersion("modelVersion");
- modelinfo.setModelCustomizationUuid("modelCustomizationUuid");
- modelinfo.setModelInstanceName("modelInstanceName");
- modelinfo.setModelType("modelType");
- assertEquals(modelinfo.getModelName(), "modelName");
- assertEquals(modelinfo.getModelUuid(), "modelUuid");
- assertEquals(modelinfo.getModelInvariantUuid(), "modelInvariantUuid");
- assertEquals(modelinfo.getModelVersion(), "modelVersion");
- assertEquals(modelinfo.getModelCustomizationUuid(), "modelCustomizationUuid");
- assertEquals(modelinfo.getModelInstanceName(), "modelInstanceName");
- assertEquals(modelinfo.getModelType(), "modelType");
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ModelInfoTest {
+ private ModelInfo modelinfo = new ModelInfo();
+
+ @Test
+ public void testModelInfo() {
+ modelinfo.setModelName("modelName");
+ modelinfo.setModelUuid("modelUuid");
+ modelinfo.setModelInvariantUuid("modelInvariantUuid");
+ modelinfo.setModelVersion("modelVersion");
+ modelinfo.setModelCustomizationUuid("modelCustomizationUuid");
+ modelinfo.setModelInstanceName("modelInstanceName");
+ modelinfo.setModelType("modelType");
+ assertEquals(modelinfo.getModelName(), "modelName");
+ assertEquals(modelinfo.getModelUuid(), "modelUuid");
+ assertEquals(modelinfo.getModelInvariantUuid(), "modelInvariantUuid");
+ assertEquals(modelinfo.getModelVersion(), "modelVersion");
+ assertEquals(modelinfo.getModelCustomizationUuid(), "modelCustomizationUuid");
+ assertEquals(modelinfo.getModelInstanceName(), "modelInstanceName");
+ assertEquals(modelinfo.getModelType(), "modelType");
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java
index 58cd45c3f1..dcb62cfc40 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java
@@ -1,48 +1,48 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ModuleResourceTest {
- private ModuleResource moduleresource = new ModuleResource();
-
- @Test
- public void testModuleResource() {
-
- moduleresource.setVfModuleName("vfModuleName");
- moduleresource.setHeatStackId("heatStackId");
- moduleresource.setIsBase(true);
- moduleresource.setVfModuleLabel("vfModuleLabel");
- moduleresource.setInitialCount(0);
- moduleresource.setVfModuleType("vfModuleType");
- moduleresource.setHasVolumeGroup(true);
- assertEquals(moduleresource.getVfModuleName(), "vfModuleName");
- assertEquals(moduleresource.getHeatStackId(), "heatStackId");
- assertEquals(moduleresource.getIsBase(), true);
- assertEquals(moduleresource.getVfModuleLabel(), "vfModuleLabel");
- assertEquals(moduleresource.getInitialCount(), 0);
- assertEquals(moduleresource.getVfModuleType(), "vfModuleType");
- assertEquals(moduleresource.isHasVolumeGroup(), true);
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ModuleResourceTest {
+ private ModuleResource moduleresource = new ModuleResource();
+
+ @Test
+ public void testModuleResource() {
+
+ moduleresource.setVfModuleName("vfModuleName");
+ moduleresource.setHeatStackId("heatStackId");
+ moduleresource.setIsBase(true);
+ moduleresource.setVfModuleLabel("vfModuleLabel");
+ moduleresource.setInitialCount(0);
+ moduleresource.setVfModuleType("vfModuleType");
+ moduleresource.setHasVolumeGroup(true);
+ assertEquals(moduleresource.getVfModuleName(), "vfModuleName");
+ assertEquals(moduleresource.getHeatStackId(), "heatStackId");
+ assertEquals(moduleresource.getIsBase(), true);
+ assertEquals(moduleresource.getVfModuleLabel(), "vfModuleLabel");
+ assertEquals(moduleresource.getInitialCount(), 0);
+ assertEquals(moduleresource.getVfModuleType(), "vfModuleType");
+ assertEquals(moduleresource.isHasVolumeGroup(), true);
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java
new file mode 100644
index 0000000000..6ca9cef8d2
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java
@@ -0,0 +1,42 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class NetworkResourceTest {
+ private NetworkResource nr = new NetworkResource();
+
+ @Test
+ public void testNetworkResource() {
+ nr.setNetworkType("networkType");
+ nr.setNetworkRole("networkRole");
+ nr.setNetworkTechnology("networkTechnology");
+ nr.setNetworkScope("networkScope");
+ assertEquals(nr.getNetworkType(), "networkType");
+ assertEquals(nr.getNetworkRole(), "networkRole");
+ assertEquals(nr.getNetworkTechnology(), "networkTechnology");
+ assertEquals(nr.getNetworkScope(), "networkScope");
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java
index 1086cc75ef..396d866446 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java
@@ -1,38 +1,39 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
* ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 TechMahindra
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.bpmn.core;
+*/
-import org.junit.Test;
+package org.onap.so.bpmn.core.domain;
-public class HealthCheckHandlerTest {
+import static org.junit.Assert.*;
- HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
+import org.junit.Test;
- @Test
- public void nodeHealthcheck() throws Exception {
- healthCheckHandler.nodeHealthcheck();
- }
+public class OwningEntityTest {
+ private OwningEntity oe = new OwningEntity();
- @Test
- public void healthcheck() throws Exception {
- healthCheckHandler.healthcheck("test-123");
- }
+ @Test
+ public void testOwingEntity() {
+ oe.setOwningEntityId("owningEntityId");
+ oe.setOwningEntityName("owningEntityName");
+ assertEquals(oe.getOwningEntityId(), "owningEntityId");
+ assertEquals(oe.getOwningEntityName(), "owningEntityName");
+
+ }
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java
new file mode 100644
index 0000000000..9081f9dd14
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java
@@ -0,0 +1,36 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ProjectTest {
+
+ private Project project = new Project();
+
+ @Test
+ public void testProject() {
+ project.setProjectName("projectName");
+ assertEquals(project.getProjectName(), "projectName");
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java
new file mode 100644
index 0000000000..0c552ce19e
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java
@@ -0,0 +1,44 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class RequestTest {
+
+ private Request request = new Request();
+ ModelInfo model = new ModelInfo();
+
+ @Test
+ public void testRequest() {
+ request.setSdncRequestId("sdncRequestId");
+ request.setRequestId("requestId");
+ request.setModelInfo(model);
+ request.setProductFamilyId("productFamilyId");
+ assertEquals(request.getSdncRequestId(), "sdncRequestId");
+ assertEquals(request.getRequestId(), "requestId");
+ assertEquals(request.getModelInfo(), model);
+ assertEquals(request.getProductFamilyId(), "productFamilyId");
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java
new file mode 100644
index 0000000000..573ffab4aa
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java
@@ -0,0 +1,50 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ResourceDecompositionTest {
+
+ private ResourceDecomposition rd = new ResourceDecomposition() {
+ private static final long serialVersionUID = 1L;
+ };
+ ModelInfo model = new ModelInfo();
+ ResourceInstance ri = new ResourceInstance();
+
+
+
+ @Test
+ public void testResourceDecomposition() {
+ rd.setModelInfo(model);
+ rd.setInstanceData(ri);
+ rd.setResourceType("resourceType");
+ rd.setResourceInstanceId("newInstanceId");
+ rd.setResourceInstanceName("newInstanceName");
+ assertEquals(rd.getResourceModel(), model);
+ assertEquals(rd.getModelInfo(), model);
+ assertEquals(rd.getInstanceData(), ri);
+ assertEquals(rd.getResourceInstanceId(), "newInstanceId");
+ assertEquals(rd.getResourceInstanceName(), "newInstanceName");
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java
index 8d6b61f4aa..afdbcd9f98 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java
@@ -1,68 +1,68 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ResourceTest {
- private Resource resource = new Resource() {
- private static final long serialVersionUID = 1L;
-
-
- };
- ModelInfo model = new ModelInfo();
- ResourceInstance ri = new ResourceInstance();
- HomingSolution hs = new HomingSolution();
- ResourceType rt = ResourceType.VNF;
- public long concurrencyCounter = 1L;
- long initval = resource.getConcurrencyCounter();
-
- @Test
- public void testResource() {
- resource.setResourceId("resourceId");
- resource.setModelInfo(model);
- resource.setResourceInstance(ri);
- resource.setHomingSolution(hs);
- resource.setCurrentHomingSolution(hs);
- resource.setResourceType(rt);
- resource.setToscaNodeType("toscaNodeType");
- resource.setResourceInstanceId("newInstanceId");
- resource.setResourceInstanceName("newInstanceName");
- resource.incrementConcurrencyCounter();
- assertEquals(resource.getResourceId(), "resourceId");
- assertEquals(resource.getModelInfo(), model);
- assertEquals(resource.getResourceInstance(), ri);
- assertEquals(resource.getHomingSolution(), hs);
- assertEquals(resource.getCurrentHomingSolution(), hs);
- assertEquals(resource.getResourceType(), rt);
- assertEquals(resource.getToscaNodeType(), "toscaNodeType");
- assertEquals(resource.getResourceInstanceId(), "newInstanceId");
- assertEquals(resource.getResourceInstanceName(), "newInstanceName");
- assertEquals(resource.getConcurrencyCounter(), initval+1);
-
-
-
-
-
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ResourceTest {
+ private Resource resource = new Resource() {
+ private static final long serialVersionUID = 1L;
+
+
+ };
+ ModelInfo model = new ModelInfo();
+ ResourceInstance ri = new ResourceInstance();
+ HomingSolution hs = new HomingSolution();
+ ResourceType rt = ResourceType.VNF;
+ public long concurrencyCounter = 1L;
+ long initval = resource.getConcurrencyCounter();
+
+ @Test
+ public void testResource() {
+ resource.setResourceId("resourceId");
+ resource.setModelInfo(model);
+ resource.setResourceInstance(ri);
+ resource.setHomingSolution(hs);
+ resource.setCurrentHomingSolution(hs);
+ resource.setResourceType(rt);
+ resource.setToscaNodeType("toscaNodeType");
+ resource.setResourceInstanceId("newInstanceId");
+ resource.setResourceInstanceName("newInstanceName");
+ resource.incrementConcurrencyCounter();
+ assertEquals(resource.getResourceId(), "resourceId");
+ assertEquals(resource.getModelInfo(), model);
+ assertEquals(resource.getResourceInstance(), ri);
+ assertEquals(resource.getHomingSolution(), hs);
+ assertEquals(resource.getCurrentHomingSolution(), hs);
+ assertEquals(resource.getResourceType(), rt);
+ assertEquals(resource.getToscaNodeType(), "toscaNodeType");
+ assertEquals(resource.getResourceInstanceId(), "newInstanceId");
+ assertEquals(resource.getResourceInstanceName(), "newInstanceName");
+ assertEquals(resource.getConcurrencyCounter(), initval+1);
+
+
+
+
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java
new file mode 100644
index 0000000000..82470f125b
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java
@@ -0,0 +1,125 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+public class ServiceDecompositionTest {
+ private static final String RESOURCE_PATH = "src/test/resources/json-examples/";
+
+ VnfResource vnfResource;
+ NetworkResource networkResource;
+ AllottedResource allottedResource;
+ ConfigResource configResource;
+
+ @Before
+ public void before() {
+ vnfResource = new VnfResource();
+ vnfResource.setResourceId("vnfResourceId");
+ vnfResource.setModules(new ArrayList<>());
+
+ networkResource = new NetworkResource();
+ networkResource.setResourceId("networkResourceId");
+
+ allottedResource = new AllottedResource();
+ allottedResource.setResourceId("allottedResourceId");
+
+ configResource = new ConfigResource();
+ configResource.setResourceId("configResourceId");
+ }
+
+ @Test
+ public void serviceDecompositionTest() throws JsonProcessingException, IOException {
+ // covering methods not covered by openpojo test
+ String catalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecomposition.json")));
+
+ ServiceDecomposition serviceDecomp = new ServiceDecomposition(catalogRestOutput);
+ serviceDecomp.addVnfResource(vnfResource);
+ serviceDecomp.addNetworkResource(networkResource);
+ serviceDecomp.addAllottedResource(allottedResource);
+ serviceDecomp.addConfigResource(configResource);
+
+ assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource));
+ assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource));
+ assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource));
+ assertThat(serviceDecomp.getServiceResource(configResource.getResourceId()), sameBeanAs(configResource));
+
+ VnfResource vnfResourceReplace = new VnfResource();
+ vnfResourceReplace.setResourceId(vnfResource.getResourceId());
+ vnfResourceReplace.setResourceInstanceName("vnfResourceReplaceInstanceName");
+
+ assertTrue(serviceDecomp.replaceResource(vnfResourceReplace));
+ assertTrue(serviceDecomp.getVnfResources().contains(vnfResourceReplace));
+
+ assertTrue(serviceDecomp.deleteResource(vnfResourceReplace));
+ assertFalse(serviceDecomp.deleteResource(vnfResourceReplace));
+ assertFalse(serviceDecomp.deleteResource(new VnfResource()));
+ }
+
+ @Test
+ public void serviceDecompositionJsonTest() throws IOException {
+ String catalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecomposition.json")));
+ String expectedCatalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecompositionExpected.json")));
+ String vnfResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "VnfResource.json")));
+ String networkResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "NetworkResource.json")));
+ String allottedResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "AllottedResource.json")));
+ String configResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ConfigResource.json")));
+
+ ServiceDecomposition serviceDecomp = new ServiceDecomposition(catalogRestOutput, "serviceInstanceId");
+ serviceDecomp.addResource(vnfResource);
+ serviceDecomp.addResource(networkResource);
+ serviceDecomp.addResource(allottedResource);
+ serviceDecomp.addResource(configResource);
+
+ assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource));
+ assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource));
+ assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource));
+ assertThat(serviceDecomp.getServiceResource(configResource.getResourceId()), sameBeanAs(configResource));
+
+ serviceDecomp = new ServiceDecomposition(catalogRestOutput, "serviceInstanceId");
+ serviceDecomp.addVnfResource(vnfResourceJson);
+ serviceDecomp.addNetworkResource(networkResourceJson);
+ serviceDecomp.addAllottedResource(allottedResourceJson);
+ serviceDecomp.addConfigResource(configResourceJson);
+
+ ServiceDecomposition expectedServiceDecomp = new ServiceDecomposition(expectedCatalogRestOutput, "serviceInstanceId");
+
+ assertThat(serviceDecomp, sameBeanAs(expectedServiceDecomp));
+ assertEquals(serviceDecomp.listToJson(Arrays.asList(networkResource)) + serviceDecomp.listToJson(Arrays.asList(vnfResource)) +
+ serviceDecomp.listToJson(Arrays.asList(allottedResource)) + serviceDecomp.listToJson(Arrays.asList(configResource)),
+ serviceDecomp.getServiceResourcesJsonString());
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java
index b600fef3fd..7cacc9da88 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java
@@ -1,61 +1,61 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import java.util.Map;
-
-import org.junit.Test;
-
-public class ServiceInstanceTest {
-
- private ServiceInstance si= new ServiceInstance();
- Map serviceParams;
- Configuration config= new Configuration();
- ModelInfo model= new ModelInfo();
-
- @Test
- public void testServiceInstance() {
- si.setServiceType("serviceType");
- si.setServiceId("serviceId");
- si.setServiceParams(serviceParams);
- si.setInstanceId("instanceId");
- si.setInstanceName("instanceName");
- si.setOrchestrationStatus("orchestrationStatus");
- si.setConfiguration(config);
- si.setModelInfo(model);
- si.setEnvironmentContext("environmentContext");
- si.setWorkloadContext("workloadContext");
- assertEquals(si.getServiceType(), "serviceType");
- assertEquals(si.getServiceId(), "serviceId");
- assertEquals(si.getServiceParams(), serviceParams);
- assertEquals(si.getInstanceId(), "instanceId");
- assertEquals(si.getInstanceName(), "instanceName");
- assertEquals(si.getOrchestrationStatus(), "orchestrationStatus");
- assertEquals(si.getConfiguration(), config);
- assertEquals(si.getModelInfo(), model);
- assertEquals(si.getEnvironmentContext(), "environmentContext");
- assertEquals(si.getWorkloadContext(), "workloadContext");
-
-
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+public class ServiceInstanceTest {
+
+ private ServiceInstance si= new ServiceInstance();
+ Map serviceParams;
+ Configuration config= new Configuration();
+ ModelInfo model= new ModelInfo();
+
+ @Test
+ public void testServiceInstance() {
+ si.setServiceType("serviceType");
+ si.setServiceId("serviceId");
+ si.setServiceParams(serviceParams);
+ si.setInstanceId("instanceId");
+ si.setInstanceName("instanceName");
+ si.setOrchestrationStatus("orchestrationStatus");
+ si.setConfiguration(config);
+ si.setModelInfo(model);
+ si.setEnvironmentContext("environmentContext");
+ si.setWorkloadContext("workloadContext");
+ assertEquals(si.getServiceType(), "serviceType");
+ assertEquals(si.getServiceId(), "serviceId");
+ assertEquals(si.getServiceParams(), serviceParams);
+ assertEquals(si.getInstanceId(), "instanceId");
+ assertEquals(si.getInstanceName(), "instanceName");
+ assertEquals(si.getOrchestrationStatus(), "orchestrationStatus");
+ assertEquals(si.getConfiguration(), config);
+ assertEquals(si.getModelInfo(), model);
+ assertEquals(si.getEnvironmentContext(), "environmentContext");
+ assertEquals(si.getWorkloadContext(), "workloadContext");
+
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java
new file mode 100644
index 0000000000..b862c8704f
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java
@@ -0,0 +1,41 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class SubscriberTest {
+ Subscriber subscriber= new Subscriber("globalId", "name", "commonSiteId");
+
+ @Test
+ public void testSubscriber() {
+ subscriber.setGlobalId("globalId");
+ subscriber.setName("name");
+ subscriber.setCommonSiteId("commonSiteId");
+ assertEquals(subscriber.getGlobalId(), "globalId");
+ assertEquals(subscriber.getName(), "name");
+ assertEquals(subscriber.getCommonSiteId(), "commonSiteId");
+
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
index e476ef9fd5..24947e9a8d 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
@@ -1,55 +1,55 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class VnfResourceTest {
-
- private VnfResource vnf= new VnfResource();
- List<ModuleResource> moduleResources;
-
- @Test
- public void testVnfResource() {
- vnf.setModules(moduleResources);
- vnf.setVnfHostname("vnfHostname");
- vnf.setVnfType("vnfType");
- vnf.setNfFunction("nfFunction");
- vnf.setNfType("nfType");
- vnf.setNfRole("nfRole");
- vnf.setNfNamingCode("nfNamingCode");
- vnf.setMultiStageDesign("multiStageDesign");
- assertEquals(vnf.getVfModules(), moduleResources);
- assertEquals(vnf.getVnfHostname(), "vnfHostname");
- assertEquals(vnf.getVnfType(), "vnfType");
- assertEquals(vnf.getNfFunction(), "nfFunction");
- assertEquals(vnf.getNfType(), "nfType");
- assertEquals(vnf.getNfRole(), "nfRole");
- assertEquals(vnf.getNfNamingCode(), "nfNamingCode");
- assertEquals(vnf.getMultiStageDesign(), "multiStageDesign");
-
-
- }
-
-}
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 TechMahindra
+ * ================================================================================
+ * 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.so.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class VnfResourceTest {
+
+ private VnfResource vnf= new VnfResource();
+ List<ModuleResource> moduleResources;
+
+ @Test
+ public void testVnfResource() {
+ vnf.setModules(moduleResources);
+ vnf.setVnfHostname("vnfHostname");
+ vnf.setVnfType("vnfType");
+ vnf.setNfFunction("nfFunction");
+ vnf.setNfType("nfType");
+ vnf.setNfRole("nfRole");
+ vnf.setNfNamingCode("nfNamingCode");
+ vnf.setMultiStageDesign("multiStageDesign");
+ assertEquals(vnf.getVfModules(), moduleResources);
+ assertEquals(vnf.getVnfHostname(), "vnfHostname");
+ assertEquals(vnf.getVnfType(), "vnfType");
+ assertEquals(vnf.getNfFunction(), "nfFunction");
+ assertEquals(vnf.getNfType(), "nfType");
+ assertEquals(vnf.getNfRole(), "nfRole");
+ assertEquals(vnf.getNfNamingCode(), "nfNamingCode");
+ assertEquals(vnf.getMultiStageDesign(), "multiStageDesign");
+
+
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java
index 57f479f7cb..e32bc88b7c 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,9 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.internal;
-
-import static org.assertj.core.api.Assertions.assertThat;
+package org.onap.so.bpmn.core.internal;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.contains;
import java.util.Optional;
import org.junit.Test;
@@ -36,7 +37,8 @@ public class VariableNameExtractorTest {
// when
Optional<String> extracted = extractor.extract();
// then
- assertThat(extracted).isPresent().contains(name);
+ assertTrue(extracted.isPresent());
+ assertThat(extracted.get(), containsString(name));
}
@Test
@@ -48,7 +50,8 @@ public class VariableNameExtractorTest {
// when
Optional<String> extracted = extractor.extract();
// then
- assertThat(extracted).isPresent().contains(name);
+ assertTrue(extracted.isPresent());
+ assertThat(extracted.get(), containsString(name));
}
@Test
@@ -59,7 +62,7 @@ public class VariableNameExtractorTest {
// when
Optional<String> extracted = extractor.extract();
// then
- assertThat(extracted).isNotPresent();
+ assertFalse(extracted.isPresent());
}
@Test
@@ -70,7 +73,7 @@ public class VariableNameExtractorTest {
// when
Optional<String> extracted = extractor.extract();
// then
- assertThat(extracted).isNotPresent();
+ assertFalse(extracted.isPresent());
}
@Test
@@ -81,6 +84,6 @@ public class VariableNameExtractorTest {
// when
Optional<String> extracted = extractor.extract();
// then
- assertThat(extracted).isNotPresent();
+ assertFalse(extracted.isPresent());
}
} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java
new file mode 100644
index 0000000000..c1f7cce30b
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java
@@ -0,0 +1,170 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core.json;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.bpmn.core.domain.AllottedResource;
+import org.onap.so.bpmn.core.domain.ConfigResource;
+import org.onap.so.bpmn.core.domain.NetworkResource;
+import org.onap.so.bpmn.core.domain.ServiceDecomposition;
+import org.onap.so.bpmn.core.domain.VnfResource;
+
+public class DecomposeJsonUtilTest {
+
+ private VnfResource vnfResource;
+ private NetworkResource networkResource;
+ private AllottedResource allottedResource;
+ private ConfigResource configResource;
+ private ServiceDecomposition serviceDecomposition;
+
+ private String serviceInstanceId = "serviceInstanceId";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+
+ }
+
+ @Test
+ public void testJsonToServiceDecomposition_twoParams() throws JsonDecomposingException {
+ serviceDecomposition = createServiceDecompositionData();
+ ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(serviceDecomposition.toString(), "serviceInstanceId");
+ assertEquals(serviceInstanceId, serviceDecompositionObj.getServiceInstance().getInstanceId());
+ }
+
+ @Test
+ public void testJsonToServiceDecomposition() throws JsonDecomposingException {
+ serviceDecomposition = createServiceDecompositionData();
+ ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(serviceDecomposition.toString());
+ assertEquals(serviceDecomposition.getServiceType(), serviceDecompositionObj.getServiceType());
+ }
+
+ @Test
+ public void testJsonToServiceDecomposition_JsonDecomposingException() throws JsonDecomposingException {
+ expectedException.expect(JsonDecomposingException.class);
+ vnfResource = createVnfResourceData(); // wrong object
+ ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(vnfResource.toString());
+ }
+
+ @Test
+ public void testJsonToVnfResource() throws JsonDecomposingException {
+ vnfResource = createVnfResourceData();
+ VnfResource vnfResourceObj = DecomposeJsonUtil.jsonToVnfResource(vnfResource.toString());
+ assertEquals(vnfResource.getResourceId(), vnfResourceObj.getResourceId());
+ }
+
+ @Test
+ public void testJsonToVnfResource_JsonDecomposingException() throws JsonDecomposingException {
+ expectedException.expect(JsonDecomposingException.class);
+ networkResource = createNetworkResourceData(); // wrong object
+ VnfResource vnfResourceObj = DecomposeJsonUtil.jsonToVnfResource(networkResource.toString());
+ }
+
+ @Test
+ public void testJsonToNetworkResource() throws JsonDecomposingException {
+ networkResource = createNetworkResourceData();
+ NetworkResource networkResourceObj = DecomposeJsonUtil.jsonToNetworkResource(networkResource.toString());
+ assertEquals(networkResource.getResourceId(), networkResourceObj.getResourceId());
+ }
+
+ @Test
+ public void testJsonToNetworkResource_JsonDecomposingException() throws JsonDecomposingException {
+ expectedException.expect(JsonDecomposingException.class);
+ vnfResource = createVnfResourceData(); // wrong object
+ NetworkResource networkResourceObj = DecomposeJsonUtil.jsonToNetworkResource(vnfResource.toString());
+ }
+
+ @Test
+ public void testJsonToAllottedResource() throws JsonDecomposingException {
+ allottedResource = createAllottedResourceData();
+ AllottedResource allottedResourceObj = DecomposeJsonUtil.jsonToAllottedResource(allottedResource.toString());
+ assertEquals(allottedResource.getResourceId(), allottedResourceObj.getResourceId());
+ }
+
+ @Test
+ public void testJsonToAllottedResource_JsonDecomposingException() throws JsonDecomposingException {
+ expectedException.expect(JsonDecomposingException.class);
+ configResource = createConfigResourceData(); // wrong object
+ AllottedResource allottedResourceObj = DecomposeJsonUtil.jsonToAllottedResource(configResource.toString());
+ }
+
+ @Test
+ public void testJsonToConfigResource() throws JsonDecomposingException {
+ configResource = createConfigResourceData();
+ ConfigResource configResourceObj = DecomposeJsonUtil.jsonToConfigResource(configResource.toString());
+ assertEquals(configResource.getResourceId(), configResourceObj.getResourceId());
+ }
+
+ @Test
+ public void testJsonToConfigResource_JsonDecomposingException() throws JsonDecomposingException {
+ expectedException.expect(JsonDecomposingException.class);
+ allottedResource = createAllottedResourceData(); // wrong object
+ ConfigResource configResourceObj = DecomposeJsonUtil.jsonToConfigResource(allottedResource.toString());
+ }
+
+ // data creation section
+ private VnfResource createVnfResourceData() {
+ vnfResource = new VnfResource();
+ vnfResource.setResourceId("resourceId");
+ vnfResource.setNfFunction("nfFunction");
+ vnfResource.setNfNamingCode("nfNamingCode");
+ vnfResource.setNfRole("nfRole");
+ return vnfResource;
+ }
+
+ private NetworkResource createNetworkResourceData() {
+ networkResource = new NetworkResource();
+ networkResource.setNetworkRole("networkRole");
+ networkResource.setResourceId("resourceId");
+ return networkResource;
+ }
+
+ private AllottedResource createAllottedResourceData() {
+ allottedResource = new AllottedResource();
+ allottedResource.setResourceId("resourceId");
+ allottedResource.setNfFunction("nfFunction");
+ allottedResource.setNfNamingCode("nfNamingCode");
+ allottedResource.setNfRole("nfRole");
+ return allottedResource;
+ }
+
+ private ConfigResource createConfigResourceData() {
+ configResource = new ConfigResource();
+ configResource.setResourceId("resourceId");
+ configResource.setToscaNodeType("toscaNodeType");
+ return configResource;
+ }
+
+ private ServiceDecomposition createServiceDecompositionData() {
+ serviceDecomposition = new ServiceDecomposition();
+ serviceDecomposition.setSdncVersion("sdncVersion");
+ serviceDecomposition.setServiceRole("serviceRole");
+ serviceDecomposition.setServiceType("serviceType");
+ return serviceDecomposition;
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java
new file mode 100644
index 0000000000..6c8b7326e2
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java
@@ -0,0 +1,38 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core.json;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class JsonDecomposingExceptionTest {
+
+ private JsonDecomposingException jsonDecomposingException;
+
+ @Test
+ public void test() {
+ String expectedMessage = "java.lang.Throwable: anyCause";
+ String message = "java.lang.Throwable: anyCause";
+ Throwable cause = new Throwable("anyCause");
+ jsonDecomposingException = new JsonDecomposingException(message, cause);
+ assertEquals(expectedMessage, jsonDecomposingException.getMessage());
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java
index 9643db7834..667027f8de 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java
@@ -18,31 +18,10 @@
* ============LICENSE_END=========================================================
*/
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
+package org.onap.so.bpmn.core.json;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
@@ -53,9 +32,9 @@ import org.json.JSONObject;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.bpmn.core.json.JsonUtils;
-import org.openecomp.mso.bpmn.core.xml.XmlTool;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.bpmn.core.xml.XmlTool;
+import org.onap.so.exceptions.ValidationException;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.DefaultNodeMatcher;
import org.xmlunit.diff.Diff;
@@ -64,11 +43,11 @@ import org.xmlunit.diff.ElementSelectors;
/**
* @version 1.0
*/
-public class JsonUtilsTest {
+public class JsonUtils2Test {
private static final String EOL = "\n";
private static final String XML_REQ =
- "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
+ "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
" <request-info>" + EOL +
" <request-id>DEV-VF-0021</request-id>" + EOL +
" <action>CREATE_VF_MODULE</action>" + EOL +
@@ -92,14 +71,14 @@ public class JsonUtilsTest {
" <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
" <asdc-service-model-version>1</asdc-service-model-version>" + EOL +
" </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
+ " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
" <param name=\"network\">network1111</param>" + EOL +
" <param name=\"server\">server1111</param>" + EOL +
" </vnf-params> " + EOL +
"</vnf-request>" + EOL;
private static final String XML_REQ_NO_ATTRS =
- "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
+ "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
" <request-info>" + EOL +
" <action>DELETE_VF_MODULE</action>" + EOL +
" <source>PORTAL</source>" + EOL +
@@ -116,7 +95,7 @@ public class JsonUtilsTest {
" <orchestration-status>pending-delete</orchestration-status>" + EOL +
" <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
" </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://org.openecomp/mso/infra/vnf-request/v1\"/>" + EOL +
+ " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
private static final String XML_ARRAY_REQ =
@@ -184,7 +163,7 @@ public class JsonUtilsTest {
Diff diffXml = DiffBuilder.compare(xmlIn).withTest(xmlOut).ignoreWhitespace()
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
- assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
+ assertFalse(diffXml.hasDifferences());
}
@Test
@@ -192,11 +171,11 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
// when, then
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name")).isEqualTo("STMTN5MMSC21");
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.request-info.action")).isEqualTo("CREATE_VF_MODULE");
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version")).isEqualTo("1");
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version")).isEqualTo("1.5");
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module")).isEqualTo("true");
+ assertEquals("STMTN5MMSC21", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name"));
+ assertEquals("CREATE_VF_MODULE", JsonUtils.getJsonValue(json, "vnf-request.request-info.action"));
+ assertEquals("1", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version"));
+ assertEquals("1.5", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version"));
+ assertEquals("true", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module"));
}
@Test
@@ -204,7 +183,7 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
// when, then
- assertThat(JsonUtils.getJsonValueForKey(json, "source")).isEqualTo("PORTAL");
+ assertEquals("PORTAL", JsonUtils.getJsonValueForKey(json, "source"));
}
@Test
@@ -212,7 +191,7 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
// when, then
- assertThat(JsonUtils.getJsonValueForKey(json, "nonexistent-node")).isNull();
+ assertNull(JsonUtils.getJsonValueForKey(json, "nonexistent-node"));
}
@Test
@@ -220,7 +199,7 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
// when, then
- assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad")).isNull();
+ assertNull(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad"));
}
@Test
@@ -228,16 +207,12 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
// when, then
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name")).isEqualTo("network");
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content"))
- .isEqualTo("network1111");
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1)).isEqualTo("server");
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1))
- .isEqualTo("server1111");
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam"))
- .withFailMessage("Expected null for nonexistent param").isNull();
- assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2))
- .withFailMessage("Expected null for index out of bound").isNull();
+ assertEquals("network", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name"));
+ assertEquals("network1111", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content"));
+ assertEquals("server", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1));
+ assertEquals("server1111", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1));
+ assertNull(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam"));
+ assertNull(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2));
}
@Test
@@ -250,7 +225,7 @@ public class JsonUtilsTest {
String jsonUpd = JsonUtils.addJsonValue(json, key, value);
// then
String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
- assertThat(extractedValue).isEqualTo(value);
+ assertEquals(value, extractedValue);
}
@Test
@@ -259,13 +234,12 @@ public class JsonUtilsTest {
String json = JsonUtils.xml2json(XML_REQ);
String key = "vnf-request.vnf-inputs.vnf-name";
String newValue = "STMTN5MMSC22";
- String oldValue = JsonUtils.getJsonValue(json, key);
// when
String jsonUpd = JsonUtils.addJsonValue(json, key, newValue);
// then
String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
- assertThat(extractedValue).isEqualTo(oldValue).isNotEqualTo(newValue);
- }
+ assertNotEquals(newValue, extractedValue);
+ }
@Test
public void shouldUpdateValueInJson() throws Exception {
@@ -278,7 +252,7 @@ public class JsonUtilsTest {
String jsonUpd = JsonUtils.updJsonValue(json, key, newValue);
// then
String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
- assertThat(extractedValue).isNotEqualTo(oldValue).isEqualTo(newValue);
+ assertEquals(newValue, extractedValue);
}
@Test
@@ -286,12 +260,11 @@ public class JsonUtilsTest {
// given
String json = JsonUtils.xml2json(XML_REQ);
String key = "vnf-request.vnf-inputs.vnf-name";
- String oldValue = JsonUtils.getJsonValue(json, key);
// when
String jsonUpd = JsonUtils.delJsonValue(json, key);
// then
String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
- assertThat(extractedValue).isNotEqualTo(oldValue).isNull();
+ assertNull(extractedValue);
JSONObject jsonObj = new JSONObject(json);
Integer intValue = JsonUtils.getJsonIntValueForKey(jsonObj, "persona-model-version");
Assert.assertTrue(intValue == 1);
@@ -307,7 +280,7 @@ public class JsonUtilsTest {
// when
String jsonUpd = JsonUtils.delJsonValue(json, key);
// then
- assertThat(jsonUpd).isEqualTo(json);
+ assertEquals(json, jsonUpd);
}
@Test
@@ -321,8 +294,8 @@ public class JsonUtilsTest {
// then
Diff diffXml = DiffBuilder.compare(xmlReq).withTest(xmlOut).ignoreWhitespace()
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
- assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
- }
+ assertFalse(diffXml.hasDifferences());
+ }
@Test
public void shouldConvertJsonContainingArrayToXml() throws Exception {
@@ -332,7 +305,7 @@ public class JsonUtilsTest {
// then
Diff diffXml = DiffBuilder.compare(XML_ARRAY_REQ).withTest(xmlOut).ignoreWhitespace()
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
- assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
+ assertFalse(diffXml.hasDifferences());
}
@Test
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java
new file mode 100644
index 0000000000..07523ca931
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java
@@ -0,0 +1,233 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.core.json;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.Execution;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.onap.so.exceptions.ValidationException;
+
+public class JsonUtilsTest {
+
+ @Mock public DelegateExecution execution;
+ @Mock public Execution mockEexecution;
+ private final String fileLocation = "src/test/resources/json-examples/";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void jsonStringToMapTest() throws IOException {
+
+ JsonUtils utils = new JsonUtils();
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ String entry = JsonUtils.getJsonValue(response, "SDNCServiceResponse.params");
+ Map<String, String> map = utils.jsonStringToMap(execution, entry);
+ assertEquals(map.get("e2e-vpn-key"), "my-key");
+ }
+
+ @Test
+ public void entryArrayToMapTest() throws IOException {
+ JsonUtils utils = new JsonUtils();
+ String response = this.getJson("SNIROExample.json");
+ String entry = JsonUtils.getJsonValue(response, "solutionInfo.placementInfo");
+ JSONArray arr = new JSONArray(entry);
+ JSONObject homingDataJson = arr.getJSONObject(0);
+ JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
+ Map<String, String> map = utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue");
+ assertEquals(map.get("cloudOwner"), "att-aic");
+ }
+ @Test
+ public void entryArrayToMapStringTest() throws IOException {
+ JsonUtils utils = new JsonUtils();
+ String response = this.getJson("SNIROExample.json");
+ String entry = JsonUtils.getJsonValue(response, "solutionInfo.placementInfo");
+ JSONArray arr = new JSONArray(entry);
+ JSONObject homingDataJson = arr.getJSONObject(0);
+ JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
+ Map<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue");
+ assertEquals(map.get("cloudOwner"), "att-aic");
+ }
+ @Test
+ public void getJsonRootPropertyTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ assertEquals("SDNCServiceResponse",JsonUtils.getJsonRootProperty(response));
+ }
+ @Test
+ public void getJsonRootProperty_ExceptionTest() throws IOException {
+ expectedException.expect(JSONException.class);
+ String response = this.getJson("SNIROExample.json");
+ String root = JsonUtils.getJsonRootProperty(response);
+ }
+ @Test
+ public void getJsonNodeValueTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ String code = JsonUtils.getJsonNodeValue(response,"SDNCServiceResponse.responseCode");
+ assertEquals("200", code);
+ }
+ @Test
+ public void stringArrayToList_jsonStringTest() throws IOException {
+ String response = this.getJson("SNIROExample.json");
+ String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo");
+ JsonUtils utils = new JsonUtils();
+ List<String> listString = utils.StringArrayToList(licenseInfo);
+ assertNotNull(listString.get(0));
+ }
+ @Test
+ public void stringArrayToList_JSONArrayTest() throws IOException {
+ String response = this.getJson("SNIROExample.json");
+ String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo");
+ JSONArray jsonArray = new JSONArray(licenseInfo);
+ JsonUtils utils = new JsonUtils();
+ List<String> listString = utils.StringArrayToList(jsonArray);
+ assertNotNull(listString.get(0));
+ }
+ @Test
+ public void stringArrayToList_withExecutionTest() throws IOException {
+ String response = this.getJson("SNIROExample.json");
+ String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo");
+ JsonUtils utils = new JsonUtils();
+ List<String> listString = utils.StringArrayToList(mockEexecution, licenseInfo);
+ assertNotNull(listString.get(0));
+ }
+ @Test
+ public void jsonElementExist_trueTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ boolean isExist = JsonUtils.jsonElementExist(response,"SDNCServiceResponse.responseCode");
+ assertEquals(true, isExist);
+ }
+ @Test
+ public void jsonElementExist_falseTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ boolean isExist = JsonUtils.jsonElementExist(response,"SDNCServiceResponse.responseX");
+ assertEquals(false, isExist);
+ }
+ @Test
+ public void jsonElementExist_NullTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ boolean isExist = JsonUtils.jsonElementExist(response, null);
+ assertEquals(true, isExist);
+ }
+ @Test
+ public void jsonSchemaValidation_ExceptionTest() throws IOException, ValidationException {
+ expectedException.expect(ValidationException.class);
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ String isExist = JsonUtils.jsonSchemaValidation(response, fileLocation);
+ }
+ @Test
+ public void getJsonIntValueTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ int intValue = JsonUtils.getJsonIntValue(response,"SDNCServiceResponse.responseCode");
+ assertEquals(0, intValue);
+ }
+ @Test
+ public void getJsonBooleanValueTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ boolean isBoolean = JsonUtils.getJsonBooleanValue(response,"SDNCServiceResponse.responseCode");
+ assertEquals(false, isBoolean);
+ }
+ @Test
+ public void prettyJsonTest() throws IOException {
+ String response = this.getJson("SNIROExample.json");
+ assertNotNull(JsonUtils.prettyJson(response));
+ String malformedJson = "{\"name\" \"myName\"}";
+ assertNull(JsonUtils.prettyJson(malformedJson));
+ }
+ @Test
+ public void xml2jsonTest() throws IOException {
+ String expectedJson = "{\"name\":\"myName\"}";
+ String xml = "<name>myName</name>";
+ assertEquals(expectedJson, JsonUtils.xml2json(xml,false));
+ }
+ @Test
+ public void xml2jsonErrorTest() throws IOException {
+ String malformedXml = "<name>myName<name>";
+ assertNull(JsonUtils.xml2json(malformedXml));
+ }
+ @Test
+ public void json2xmlTest() throws IOException {
+ String expectedXml = "<name>myName</name>";
+ String malformedJson = "{\"name\":\"myName\"}";
+ assertEquals(expectedXml, JsonUtils.json2xml(malformedJson, false));
+ }
+ @Test
+ public void json2xmlErrorTest() throws IOException {
+ String malformedJson = "{\"name\" \"myName\"}";
+ assertNull(JsonUtils.json2xml(malformedJson));
+ }
+ @Test
+ public void getJsonValueErrorTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ assertNull(JsonUtils.getJsonValue(response,null));
+ }
+ @Test
+ public void getJsonNodeValueErrorTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ assertNull(JsonUtils.getJsonNodeValue(response,null));
+ }
+ @Test
+ public void getJsonIntValueErrorTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ assertEquals(0, JsonUtils.getJsonIntValue(response,null));
+ }
+ @Test
+ public void getJsonBooleanValueErrorTest() throws IOException {
+ String response = this.getJson("SDNCServiceResponseExample.json");
+ assertEquals(false, JsonUtils.getJsonBooleanValue(response,null));
+ }
+ @Test
+ public void getJsonValueForKeyErrorTest() throws IOException {
+ String malformedJson = "{\"name\" \"myName\"}";
+ assertNull(JsonUtils.getJsonValueForKey(malformedJson, "name"));
+ }
+ @Test
+ public void updJsonValueTest() throws IOException {
+ String expectedJson = "{\"name\": \"yourName\"}";
+ String json = "{\"name\":\"myName\"}";
+ assertEquals(expectedJson, JsonUtils.updJsonValue(json, "name", "yourName"));
+ }
+ @Test
+ public void updJsonValueErrorTest() throws IOException {
+ String expectedJson = "{\"name\" \"myName\"}";
+ String json = "{\"name\" \"myName\"}";
+ assertEquals(expectedJson, JsonUtils.updJsonValue(json, "name", "yourName"));
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java
index f29ccc75e0..f3cc094873 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,21 +18,21 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core.utils;
+package org.onap.so.bpmn.core.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import org.openecomp.mso.logger.MsoLogger;
+import org.onap.so.logger.MsoLogger;
/**
* Sets up the unit test (H2) database for Camunda.
*/
public class CamundaDBSetup {
private static boolean isDBConfigured = false;
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CamundaDBSetup.class);
private CamundaDBSetup() {
}
@@ -48,51 +48,10 @@ public class CamundaDBSetup {
PreparedStatement stmt = null;
try {
- connection = DriverManager.getConnection(
- "jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1", "sa", "");
- stmt = connection.prepareStatement("delete from ACT_HI_VARINST");
- stmt.executeUpdate();
- stmt.close();
- stmt = null;
-
- stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column TEXT_ clob");
- stmt.executeUpdate();
- stmt.close();
- stmt = null;
-
-// stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column NAME_ clob");
-// stmt.executeUpdate();
-// stmt.close();
-// stmt = null;
-
- stmt = connection.prepareStatement("delete from ACT_HI_DETAIL");
- stmt.executeUpdate();
- stmt.close();
- stmt = null;
-
- stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column TEXT_ clob");
- stmt.executeUpdate();
- stmt.close();
- stmt = null;
-
-// stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column NAME_ clob");
-// stmt.executeUpdate();
-// stmt.close();
-// stmt = null;
-
- stmt = connection.prepareStatement("ALTER TABLE ACT_RU_VARIABLE alter column TEXT_ clob");
- stmt.executeUpdate();
- stmt.close();
- stmt = null;
-
- connection.close();
- connection = null;
isDBConfigured = true;
- } catch (SQLException e) {
- LOGGER.debug ("CamundaDBSetup caught " + e.getClass().getSimpleName());
- LOGGER.debug("SQLException :",e);
+
} finally {
if (stmt != null) {
try {
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java
new file mode 100644
index 0000000000..6bad0c6c29
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java
@@ -0,0 +1,82 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.so.bpmn.core.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Optional;
+
+import org.junit.Test;
+
+public class XmlToolTest {
+
+ private String response = "<Response>good</Response>";
+ private String responseModified = "<Response>veryGood</Response>";
+ private String encodeResponse = "&lt;Response&gt;good&lt;/Response&gt;";
+ private String encodeResponseNamespace = "<Response xmlns:ns2=\"http://ecomp.att.com/mso/request/types/v1\">good</Response>";
+ private String attribute = "<Response>good&\"bad\"</Response>";
+ private String updatedAttribute = "&lt;Response&gt;good&amp;&quot;bad&quot;&lt;/Response&gt;";
+
+ private String content = "<dummy><configuration-event>" +
+ "<event-type>test</event-type>" +
+ "<event-correlator-type>test</event-correlator-type>" +
+ "<event-correlator>123</event-correlator>" +
+ "<event-parameters><event-parameter>" +
+ "<tag-name>test</tag-name>" +
+ "<tag-value>test</tag-value></event-parameter></event-parameters>" +
+ "</configuration-event></dummy>";
+
+ @Test
+ public void test() throws Exception {
+ Object xmlMessage = new String(response);
+ String xmlResponse = XmlTool.normalize(xmlMessage);
+ assertEquals(response, xmlResponse.toString());
+ String xmlEncode = XmlTool.encode(xmlMessage);
+ assertEquals(encodeResponse, xmlEncode.toString());
+ Optional<String> optXml = XmlTool.modifyElement(response, "Response", "veryGood");
+ Object obj1 = new String(optXml.get().toString());
+ String noPreamble = XmlTool.removePreamble(obj1);
+ assertEquals(responseModified, noPreamble.toString());
+ Object obj2 = new String(encodeResponseNamespace);
+ String noNamespace = XmlTool.removeNamespaces(obj2);
+ assertEquals(response, noNamespace.toString());
+ Object obj3 = new String(attribute);
+
+ assertEquals(null, XmlTool.normalize(null));
+ assertEquals(null, XmlTool.encode(null));
+ assertEquals(null, XmlTool.removePreamble(null));
+ assertEquals(null, XmlTool.removeNamespaces(null));
+ assertEquals(Optional.empty(), XmlTool.modifyElement(null, "Response", "veryGood"));
+ }
+
+ @Test
+ public void normalizeTest() throws Exception {
+ String response = XmlTool.normalize(content);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void modifyElementTest() throws Exception {
+ String response = XmlTool.modifyElement(content, "event-type", "uCPE-VMS").get();
+ assertNotNull(response);
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java
deleted file mode 100644
index 57a512891f..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class PropertyConfigurationTest {
- @Before
- public void beforeTest() throws IOException {
- PropertyConfiguration.resetPropertyConfigurationSingletonInstance();
-
- Map<String, String> defaultProperties = PropertyConfigurationSetup.createBpmnProperties();
- defaultProperties.put("testValue", "testKey");
- PropertyConfigurationSetup.init(defaultProperties);
- }
-
- @Test
- public void testPropertyFileWatcher() throws InterruptedException, IOException {
- Assert.assertEquals(true, PropertyConfiguration.getInstance().isFileWatcherRunning());
- }
-
- @Test
- public void testPropertyLoading() throws IOException, InterruptedException {
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES);
- Assert.assertNotNull(props);
- Assert.assertEquals("testValue", props.get("testKey"));
- }
-
- @Test
- public void testPropertyReload() throws IOException, InterruptedException {
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES);
- Assert.assertNotNull(properties);
- Assert.assertEquals("testValue", properties.get("testKey"));
-
- Map<String, String> newProperties = PropertyConfigurationSetup.createBpmnProperties();
- newProperties.put("newKey", "newValue");
- PropertyConfigurationSetup.addProperties(newProperties, 10000);
-
- // Reload and check for the new value
- properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES);
- Assert.assertNotNull(properties);
- Assert.assertEquals("newValue", properties.get("newKey"));
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testPropertyFileDoesNotExists_NotIntheList() throws IOException {
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- propertyConfiguration.getProperties("badfile.properties");
- Assert.fail("Expected IllegalArgumentException");
- }
-
- @Test(expected=java.lang.UnsupportedOperationException.class)
- public void testPropertyModificationException() throws IOException {
- PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance();
- Map<String,String> props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES);
- Assert.assertNotNull(props);
- Assert.assertEquals("testValue", props.get("testKey"));
- props.put("newKey", "newvalue");
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java
deleted file mode 100644
index 1346fde674..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.Expression;
-import org.camunda.bpm.engine.test.Deployment;
-import org.camunda.bpm.engine.test.ProcessEngineRule;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * Unit test for BaseTask class.
- */
-public class TestBaseTask {
-
- @Rule
- public ProcessEngineRule processEngineRule = new ProcessEngineRule();
-
- @BeforeClass
- public static void setUpClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- PropertyConfiguration.resetPropertyConfigurationSingletonInstance();
- }
-
- @Before
- public void beforeTest() throws Exception {
- CamundaDBSetup.configure();
- PropertyConfigurationSetup.init();
- }
-
- @Test
- @Deployment(resources={"BaseTaskTest.bpmn"})
- public void shouldInvokeService() {
- Map<String, Object> variables = new HashMap<>();
- variables.put("firstName", "Jane");
- variables.put("lastName", "Doe");
- variables.put("age", 25);
- variables.put("lastVisit", 1438270117000L);
-
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- assertNotNull(runtimeService);
- processEngineRule.getTaskService();
- runtimeService.startProcessInstanceByKey("BaseTaskTest", variables);
- }
-
- /**
- * Unit test code for BaseTask.
- */
- public static class TestTask extends BaseTask {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
-
- private Expression existingString;
- private Expression nonExistingString;
- private Expression existingStringFromVar;
- private Expression nonExistingStringFromVar;
-
- private Expression existingInteger;
- private Expression nonExistingInteger;
- private Expression existingIntegerFromVar;
- private Expression nonExistingIntegerFromVar;
-
- private Expression existingLong;
- private Expression nonExistingLong;
- private Expression existingLongFromVar;
- private Expression nonExistingLongFromVar;
-
- private Expression existingOutputVar;
- private Expression nonExistingOutputVar;
- private Expression existingBadOutputVar;
-
- public void execute(DelegateExecution execution) throws Exception {
- msoLogger.debug("Started executing " + getClass().getSimpleName());
-
- /*********************************************************************/
- msoLogger.debug("Running String Field Tests");
- /*********************************************************************/
-
- String s = getStringField(existingString, execution, "existingString");
- Assert.assertEquals("Hello World", s);
-
- try {
- s = getStringField(nonExistingString, execution, "nonExistingString");
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- }
- }
-
- s = getOptionalStringField(existingString, execution, "existingString");
- Assert.assertEquals("Hello World", s);
-
- s = getOptionalStringField(nonExistingString, execution, "nonExistingString");
- Assert.assertEquals(null, s);
-
- /*********************************************************************/
- msoLogger.debug("Running String Expression Tests");
- /*********************************************************************/
-
- s = getStringField(existingStringFromVar, execution, "existingStringFromVar");
- Assert.assertEquals("Jane", s);
-
- try {
- s = getStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar");
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingStringFromVar");
- }
- }
-
- s = getOptionalStringField(existingStringFromVar, execution, "existingStringFromVar");
- Assert.assertEquals("Jane", s);
-
- s = getOptionalStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar");
- Assert.assertEquals(null, s);
-
- /*********************************************************************/
- msoLogger.debug("Running Integer Field Tests");
- /*********************************************************************/
-
- Integer i = getIntegerField(existingInteger, execution, "existingInteger");
- Assert.assertEquals((Integer)42, i);
-
- try {
- i = getIntegerField(nonExistingInteger, execution, "nonExistingInteger");
- Assert.fail("Expected BadInjectedFieldException for nonExistingInteger");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingInteger");
- }
- }
-
- i = getOptionalIntegerField(existingInteger, execution, "existingInteger");
- Assert.assertEquals((Integer)42, i);
-
- i = getOptionalIntegerField(nonExistingInteger, execution, "nonExistingInteger");
- Assert.assertEquals(null, i);
-
- /*********************************************************************/
- msoLogger.debug("Running Integer Expression Tests");
- /*********************************************************************/
-
- i = getIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar");
- Assert.assertEquals((Integer)25, i);
-
- try {
- i = getIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar");
- Assert.fail("Expected BadInjectedFieldException for nonExistingInteger");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingIntegerFromVar");
- }
- }
-
- i = getOptionalIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar");
- Assert.assertEquals((Integer)25, i);
-
- i = getOptionalIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar");
- Assert.assertEquals(null, i);
-
- /*********************************************************************/
- msoLogger.debug("Running Long Field Tests");
- /*********************************************************************/
-
- Long l = getLongField(existingLong, execution, "existingLong");
- Assert.assertEquals((Long)123456789L, l);
-
- try {
- l = getLongField(nonExistingLong, execution, "nonExistingLong");
- Assert.fail("Expected BadInjectedFieldException for nonExistingLong");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingLong");
- }
- }
-
- l = getOptionalLongField(existingLong, execution, "existingLong");
- Assert.assertEquals((Long)123456789L, l);
-
- l = getOptionalLongField(nonExistingLong, execution, "nonExistingLong");
- Assert.assertEquals(null, l);
-
- /*********************************************************************/
- msoLogger.debug("Running Long Expression Tests");
- /*********************************************************************/
-
- l = getLongField(existingLongFromVar, execution, "existingLongFromVar");
- Assert.assertEquals((Long)1438270117000L, l);
-
- try {
- l = getLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar");
- Assert.fail("Expected BadInjectedFieldException for nonExistingLong");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingLongFromVar");
- }
- }
-
- l = getOptionalLongField(existingLongFromVar, execution, "existingLongFromVar");
- Assert.assertEquals((Long)1438270117000L, l);
-
- l = getOptionalLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar");
- Assert.assertEquals(null, i);
-
- /*********************************************************************/
- msoLogger.debug("Running Output Variable Field Tests");
- /*********************************************************************/
-
- String var = getOutputField(existingOutputVar, execution, "existingOutputVar");
- Assert.assertEquals("goodVariable", var);
-
- try {
- var = getOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar");
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- }
- }
-
- var = getOptionalOutputField(existingOutputVar, execution, "existingOutputVar");
- Assert.assertEquals("goodVariable", var);
-
- var = getOptionalOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar");
- Assert.assertEquals(null, var);
-
- try {
- var = getOutputField(existingBadOutputVar, execution, "existingBadOutputVar");
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- } catch (Exception e) {
- if (!(e instanceof BadInjectedFieldException)) {
- Assert.fail("Expected BadInjectedFieldException for nonExistingString");
- }
- }
-
- msoLogger.debug("Finished executing " + getClass().getSimpleName());
- }
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java
deleted file mode 100644
index ecaf601c90..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ConfigResourceTest {
- private ConfigResource configresource = new ConfigResource();{
- configresource.resourceType = ResourceType.CONFIGURATION;
- }
-
- @Test
- public void testConfigResource() {
- configresource.setToscaNodeType("toscaNodeType");
- assertEquals(configresource.getToscaNodeType(), "toscaNodeType");
-
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java
deleted file mode 100644
index 1a4e0898ee..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class CustomerTest {
- private Customer customer = new Customer();
-
- @Test
- public void testCustomer() {
- customer.setSubscriptionServiceType("subscriptionServiceType");
- customer.setGlobalSubscriberId("globalSubscriberId");
- assertEquals(customer.getSubscriptionServiceType(), "subscriptionServiceType");
- assertEquals(customer.getGlobalSubscriberId(), "globalSubscriberId");
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java
deleted file mode 100644
index 22e62663c9..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class NetworkResourceTest {
- private NetworkResource nr = new NetworkResource();
-
- @Test
- public void testNetworkResource() {
- nr.setNetworkType("networkType");
- nr.setNetworkRole("networkRole");
- nr.setNetworkTechnology("networkTechnology");
- nr.setNetworkScope("networkScope");
- assertEquals(nr.getNetworkType(), "networkType");
- assertEquals(nr.getNetworkRole(), "networkRole");
- assertEquals(nr.getNetworkTechnology(), "networkTechnology");
- assertEquals(nr.getNetworkScope(), "networkScope");
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java
deleted file mode 100644
index 215fa3cff9..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class OwningEntityTest {
- private OwningEntity oe = new OwningEntity();
-
- @Test
- public void testOwingEntity() {
- oe.setOwningEntityId("owningEntityId");
- oe.setOwningEntityName("owningEntityName");
- assertEquals(oe.getOwningEntityId(), "owningEntityId");
- assertEquals(oe.getOwningEntityName(), "owningEntityName");
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java
deleted file mode 100644
index 3a9a53f743..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ProjectTest {
-
- private Project project = new Project();
-
- @Test
- public void testProject() {
- project.setProjectName("projectName");
- assertEquals(project.getProjectName(), "projectName");
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java
deleted file mode 100644
index 9a9d41567a..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class RequestTest {
-
- private Request request = new Request();
- ModelInfo model = new ModelInfo();
-
- @Test
- public void testRequest() {
- request.setSdncRequestId("sdncRequestId");
- request.setRequestId("requestId");
- request.setModelInfo(model);
- request.setProductFamilyId("productFamilyId");
- assertEquals(request.getSdncRequestId(), "sdncRequestId");
- assertEquals(request.getRequestId(), "requestId");
- assertEquals(request.getModelInfo(), model);
- assertEquals(request.getProductFamilyId(), "productFamilyId");
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java
deleted file mode 100644
index 5eaa60260b..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ResourceDecompositionTest {
-
- private ResourceDecomposition rd = new ResourceDecomposition() {
- private static final long serialVersionUID = 1L;
- };
- ModelInfo model = new ModelInfo();
- ResourceInstance ri = new ResourceInstance();
-
-
-
- @Test
- public void testResourceDecomposition() {
- rd.setModelInfo(model);
- rd.setInstanceData(ri);
- rd.setResourceType("resourceType");
- rd.setResourceInstanceId("newInstanceId");
- rd.setResourceInstanceName("newInstanceName");
- assertEquals(rd.getResourceModel(), model);
- assertEquals(rd.getModelInfo(), model);
- assertEquals(rd.getInstanceData(), ri);
- assertEquals(rd.getResourceInstanceId(), "newInstanceId");
- assertEquals(rd.getResourceInstanceName(), "newInstanceName");
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java
deleted file mode 100644
index 58548db23b..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class ServiceDecompositionTest {
- private ServiceDecomposition sd = new ServiceDecomposition();
- ModelInfo model= new ModelInfo();
- ServiceInstance si= new ServiceInstance();
- Project project= new Project();
- OwningEntity oe= new OwningEntity();
- //VnfResource vnf = new VnfResource();
- List<VnfResource> vnfResources;
- List<NetworkResource> networkResources;
- List<ConfigResource> configResources;
- List<AllottedResource> allottedResources;
- Request request= new Request();
- Customer customer= new Customer();
-
-
- @Test
- public void testServiceDecomposition() {
- sd.setModelInfo(model);
- sd.setServiceInstance(si);
- sd.setProject(project);
- sd.setOwningEntity(oe);
- sd.setServiceVnfs(vnfResources);
- sd.setServiceConfigs(configResources);
- sd.setServiceNetworks(networkResources);
- sd.setServiceAllottedResources(allottedResources);
- sd.setServiceConfigResources(configResources);
- sd.setServiceType("serviceType");
- sd.setServiceRole("serviceRole");
- sd.setRequest(request);
- sd.setCustomer(customer);
- sd.setCallbackURN("callbackURN");
- sd.setSdncVersion("sdncVersion");
- assertEquals(sd.getModelInfo(), model);
- assertEquals(sd.getServiceInstance(), si);
- assertEquals(sd.getProject(), project);
- assertEquals(sd.getOwningEntity(), oe);
- assertEquals(sd.getServiceVnfs(), vnfResources);
- assertEquals(sd.getServiceConfigs(), configResources);
- assertEquals(sd.getServiceNetworks(), networkResources);
- assertEquals(sd.getServiceAllottedResources(), allottedResources);
- assertEquals(sd.getServiceConfigResources(), configResources);
- assertEquals(sd.getRequest(), request);
- assertEquals(sd.getCustomer(), customer);
- assertEquals(sd.getCallbackURN(), "callbackURN");
- assertEquals(sd.getSdncVersion(), "sdncVersion");
-
-
-
-
-
-
-
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java
deleted file mode 100644
index 7e9aef29a6..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class SubscriberTest {
- Subscriber subscriber= new Subscriber("globalId", "name", "commonSiteId");
-
- @Test
- public void testSubscriber() {
- subscriber.setGlobalId("globalId");
- subscriber.setName("name");
- subscriber.setCommonSiteId("commonSiteId");
- assertEquals(subscriber.getGlobalId(), "globalId");
- assertEquals(subscriber.getName(), "name");
- assertEquals(subscriber.getCommonSiteId(), "commonSiteId");
-
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java
deleted file mode 100644
index 2a5639f0ff..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.bpmn.core.domain;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TunnelConnectTest {
- private TunnelConnect tc= new TunnelConnect();
-
- @Test
- public void testTunnelConnect() {
- tc.setId("id");
- tc.setUpBandwidth("upBandwidth");
- tc.setDownBandwidth("downBandwidth");
- tc.setUpBandwidth2("upBandwidth2");
- tc.setDownBandwidth2("downBandwidth2");
- assertEquals(tc.getId(), "id");
- assertEquals(tc.getUpBandwidth(), "upBandwidth");
- assertEquals(tc.getDownBandwidth(), "downBandwidth");
- assertEquals(tc.getUpBandwidth2(), "upBandwidth2");
- assertEquals(tc.getDownBandwidth2(), "downBandwidth2");
-
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java
deleted file mode 100644
index 644f98349c..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.core.json;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Map;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.junit.Test;
-import org.mockito.Mock;
-
-public class JsonUtilsTest {
-
- @Mock public DelegateExecution execution;
- private final String fileLocation = "src/test/resources/json-examples/";
-
- @Test
- public void jsonStringToMapTest() throws IOException {
-
- JsonUtils utils = new JsonUtils();
- String response = this.getJson("SDNCServiceResponseExample.json");
- String entry = utils.getJsonValue(response, "SDNCServiceResponse.params");
- Map<String, String> map = utils.jsonStringToMap(execution, entry);
- assertEquals(map.get("e2e-vpn-key"), "my-key");
- }
-
- @Test
- public void entryArrayToMapTest() throws IOException {
- JsonUtils utils = new JsonUtils();
- String response = this.getJson("SNIROExample.json");
- String entry = utils.getJsonValue(response, "solutionInfo.placement");
- JSONArray arr = new JSONArray(entry);
- JSONObject homingDataJson = arr.getJSONObject(0);
- JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
- Map<String, String> map = utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue");
- assertEquals(map.get("cloudOwner"), "att-aic");
- }
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
- }
-}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn b/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn
index bb15ce2e5e..4d531d23e2 100644
--- a/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn
+++ b/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn
@@ -1,79 +1,79 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_IS440DbGEeWouodEI7MXGQ" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn">
- <bpmn2:process id="BaseTaskTest" name="BaseTaskTest" isExecutable="true">
- <bpmn2:startEvent id="StartEvent_1">
- <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
- </bpmn2:startEvent>
- <bpmn2:serviceTask id="ServiceTask_1" camunda:class="org.openecomp.mso.bpmn.core.TestBaseTask$TestTask" name="TestTask">
- <bpmn2:extensionElements>
- <camunda:field name="existingString">
- <camunda:string>Hello World</camunda:string>
- </camunda:field>
- <camunda:field name="existingStringFromVar">
- <camunda:expression>${firstName}</camunda:expression>
- </camunda:field>
- <camunda:field name="nonExistingStringFromVar">
- <camunda:expression>${undefinedVariable}</camunda:expression>
- </camunda:field>
- <camunda:field name="existingInteger">
- <camunda:string>42</camunda:string>
- </camunda:field>
- <camunda:field name="existingIntegerFromVar">
- <camunda:expression>${age}</camunda:expression>
- </camunda:field>
- <camunda:field name="nonExistingIntegerFromVar">
- <camunda:expression>${undefinedVariable}</camunda:expression>
- </camunda:field>
- <camunda:field name="existingLong">
- <camunda:string>123456789</camunda:string>
- </camunda:field>
- <camunda:field name="existingLongFromVar">
- <camunda:expression>${lastVisit}</camunda:expression>
- </camunda:field>
- <camunda:field name="nonExistingLongFromVar">
- <camunda:expression>${undefinedVariable}</camunda:expression>
- </camunda:field>
- <camunda:field name="existingOutputVar">
- <camunda:string>goodVariable</camunda:string>
- </camunda:field>
- <camunda:field name="existingBadOutputVar">
- <camunda:string>bad Variable</camunda:string>
- </camunda:field>
- </bpmn2:extensionElements>
- <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
- </bpmn2:serviceTask>
- <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ServiceTask_1"/>
- <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ServiceTask_1" targetRef="EndEvent_1"/>
- <bpmn2:endEvent id="EndEvent_1">
- <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
- </bpmn2:endEvent>
- </bpmn2:process>
- <bpmndi:BPMNDiagram id="BPMNDiagram_1">
- <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BaseTaskTest">
- <bpmndi:BPMNShape id="_BPMNShape_StartEvent_36" bpmnElement="StartEvent_1">
- <dc:Bounds height="36.0" width="36.0" x="55.0" y="38.0"/>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_68" bpmnElement="ServiceTask_1">
- <dc:Bounds height="80.0" width="100.0" x="180.0" y="16.0"/>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_36" targetElement="_BPMNShape_ServiceTask_68">
- <di:waypoint xsi:type="dc:Point" x="91.0" y="56.0"/>
- <di:waypoint xsi:type="dc:Point" x="180.0" y="56.0"/>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="_BPMNShape_EndEvent_83" bpmnElement="EndEvent_1">
- <dc:Bounds height="36.0" width="36.0" x="369.0" y="38.0"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds height="0.0" width="0.0" x="387.0" y="79.0"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ServiceTask_68" targetElement="_BPMNShape_EndEvent_83">
- <di:waypoint xsi:type="dc:Point" x="280.0" y="56.0"/>
- <di:waypoint xsi:type="dc:Point" x="369.0" y="56.0"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds height="6.0" width="6.0" x="370.0" y="57.0"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_IS440DbGEeWouodEI7MXGQ" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn">
+ <bpmn2:process id="BaseTaskTest" name="BaseTaskTest" isExecutable="true">
+ <bpmn2:startEvent id="StartEvent_1">
+ <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
+ </bpmn2:startEvent>
+ <bpmn2:serviceTask id="ServiceTask_1" camunda:class="org.onap.so.bpmn.core.TestBaseTask$TestTask" name="TestTask">
+ <bpmn2:extensionElements>
+ <camunda:field name="existingString">
+ <camunda:string>Hello World</camunda:string>
+ </camunda:field>
+ <camunda:field name="existingStringFromVar">
+ <camunda:expression>${firstName}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="nonExistingStringFromVar">
+ <camunda:expression>${undefinedVariable}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="existingInteger">
+ <camunda:string>42</camunda:string>
+ </camunda:field>
+ <camunda:field name="existingIntegerFromVar">
+ <camunda:expression>${age}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="nonExistingIntegerFromVar">
+ <camunda:expression>${undefinedVariable}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="existingLong">
+ <camunda:string>123456789</camunda:string>
+ </camunda:field>
+ <camunda:field name="existingLongFromVar">
+ <camunda:expression>${lastVisit}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="nonExistingLongFromVar">
+ <camunda:expression>${undefinedVariable}</camunda:expression>
+ </camunda:field>
+ <camunda:field name="existingOutputVar">
+ <camunda:string>goodVariable</camunda:string>
+ </camunda:field>
+ <camunda:field name="existingBadOutputVar">
+ <camunda:string>bad Variable</camunda:string>
+ </camunda:field>
+ </bpmn2:extensionElements>
+ <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
+ <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
+ </bpmn2:serviceTask>
+ <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ServiceTask_1"/>
+ <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ServiceTask_1" targetRef="EndEvent_1"/>
+ <bpmn2:endEvent id="EndEvent_1">
+ <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
+ </bpmn2:endEvent>
+ </bpmn2:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BaseTaskTest">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_36" bpmnElement="StartEvent_1">
+ <dc:Bounds height="36.0" width="36.0" x="55.0" y="38.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_68" bpmnElement="ServiceTask_1">
+ <dc:Bounds height="80.0" width="100.0" x="180.0" y="16.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_36" targetElement="_BPMNShape_ServiceTask_68">
+ <di:waypoint xsi:type="dc:Point" x="91.0" y="56.0"/>
+ <di:waypoint xsi:type="dc:Point" x="180.0" y="56.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_EndEvent_83" bpmnElement="EndEvent_1">
+ <dc:Bounds height="36.0" width="36.0" x="369.0" y="38.0"/>
+ <bpmndi:BPMNLabel>
+ <dc:Bounds height="0.0" width="0.0" x="387.0" y="79.0"/>
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ServiceTask_68" targetElement="_BPMNShape_EndEvent_83">
+ <di:waypoint xsi:type="dc:Point" x="280.0" y="56.0"/>
+ <di:waypoint xsi:type="dc:Point" x="369.0" y="56.0"/>
+ <bpmndi:BPMNLabel>
+ <dc:Bounds height="6.0" width="6.0" x="370.0" y="57.0"/>
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
</bpmn2:definitions> \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/application-dev.yaml b/bpmn/MSOCoreBPMN/src/test/resources/application-dev.yaml
new file mode 100644
index 0000000000..7aa9a26e63
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/application-dev.yaml
@@ -0,0 +1,5 @@
+log:
+ debug:
+ TestTask: 'true'
+
+testKey: 'testValue' \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml b/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml
deleted file mode 100644
index bc218f0125..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
-
- <property name="jdbcUrl" value="jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000" />
- <property name="jdbcDriver" value="org.h2.Driver" />
- <property name="jdbcUsername" value="sa" />
- <property name="jdbcPassword" value="" />
-
- <!-- Database configurations -->
- <property name="databaseSchemaUpdate" value="true" />
-
- <!-- job executor configurations -->
- <property name="jobExecutorActivate" value="false" />
-
- <property name="history" value="full" />
-
- <!--<property name="idGenerator" ref="uuidGenerator" />-->
-
- <!-- engine plugins -->
- <property name="processEnginePlugins">
- <list>
- <ref bean="connectProcessEnginePlugin" />
- <ref bean="spinProcessEnginePlugin" />
- <ref bean="loggingPlugin" />
- <ref bean="workflowExceptionPlugin" />
- </list>
- </property>
-
- </bean>
-
- <bean id="loggingPlugin" class="org.openecomp.mso.bpmn.core.plugins.LoggingAndURNMappingPlugin" />
-
- <!-- Needed until all subflows generate MSOWorkflowException events -->
- <bean id="workflowExceptionPlugin" class="org.openecomp.mso.bpmn.core.plugins.WorkflowExceptionPlugin" />
-
- <!--<bean id="uuidGenerator" class="org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator" />-->
-
- <!-- engine plugin beans -->
- <bean id="connectProcessEnginePlugin" class="org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin" />
- <bean id="spinProcessEnginePlugin" class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" />
-
-</beans>
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/AllottedResource.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/AllottedResource.json
new file mode 100644
index 0000000000..9731e70dde
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/AllottedResource.json
@@ -0,0 +1,6 @@
+{
+ "allottedResource" : {
+ "resourceId" : "allottedResourceId",
+ "resourceType" : "ALLOTTED_RESOURCE"
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ConfigResource.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ConfigResource.json
new file mode 100644
index 0000000000..412d13bcb6
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ConfigResource.json
@@ -0,0 +1,6 @@
+{
+ "configResource" : {
+ "resourceId" : "configResourceId",
+ "resourceType" : "CONFIGURATION"
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/NetworkResource.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/NetworkResource.json
new file mode 100644
index 0000000000..57d3c5d70d
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/NetworkResource.json
@@ -0,0 +1,6 @@
+{
+ "networkResource" : {
+ "resourceId" : "networkResourceId",
+ "resourceType" : "NETWORK"
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/SNIROExample.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/SNIROExample.json
index 7e56b1a59d..838bcd85a7 100644
--- a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/SNIROExample.json
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/SNIROExample.json
@@ -11,7 +11,7 @@
]
}
],
- "placement": [
+ "placementInfo": [
{
"assignmentInfo": [
{
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecomposition.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecomposition.json
new file mode 100644
index 0000000000..9acaabe2d1
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecomposition.json
@@ -0,0 +1,22 @@
+{
+ "serviceResources" : {
+ "modelInfo" : {
+ "modelName" : "modelName",
+ "modelUuid" : "modelUuid",
+ "modelInvariantUuid" : "modelInvariantUuid",
+ "modelVersion" : "modelVersion",
+ "modelCustomizationUuid" : "modelCustomizationUuid",
+ "modelCustomizationName" : "modelCustomizationName",
+ "modelInstanceName" : "modelInstanceName",
+ "modelType" : "modelType"
+ },
+ "serviceType" : "serviceType",
+ "serviceRole" : "serviceRole",
+ "project" : {},
+ "owningEntity" : {},
+ "vnfResource" : [],
+ "networkResource" : [],
+ "allottedResource" : [],
+ "configResource" : []
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json
new file mode 100644
index 0000000000..c424293ca2
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json
@@ -0,0 +1,51 @@
+{
+ "serviceResources" : {
+ "modelInfo" : {
+ "modelName" : "modelName",
+ "modelUuid" : "modelUuid",
+ "modelInvariantUuid" : "modelInvariantUuid",
+ "modelVersion" : "modelVersion",
+ "modelCustomizationUuid" : "modelCustomizationUuid",
+ "modelCustomizationName" : "modelCustomizationName",
+ "modelInstanceName" : "modelInstanceName",
+ "modelType" : "modelType"
+ },
+ "serviceType" : "serviceType",
+ "serviceRole" : "serviceRole",
+ "project" : {},
+ "owningEntity" : {},
+ "serviceInstance" : {
+ "serviceInstanceId" : "serviceInstanceId"
+ },
+ "serviceVnfs" : [
+ {
+ "resourceId" : "vnfResourceId",
+ "resourceType" : "VNF",
+ "resourceInstance" : {},
+ "homingSolution" : {
+ "license" : {},
+ "rehome" : false
+ },
+ "vfModules" : []
+ }
+ ],
+ "networkResource" : [
+ {
+ "resourceId" : "networkResourceId",
+ "resourceType" : "NETWORK"
+ }
+ ],
+ "serviceAllottedResources" : [
+ {
+ "resourceId" : "allottedResourceId",
+ "resourceType" : "ALLOTTED_RESOURCE"
+ }
+ ],
+ "configResource" : [
+ {
+ "resourceId" : "configResourceId",
+ "resourceType" : "CONFIGURATION"
+ }
+ ]
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/VnfResource.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/VnfResource.json
new file mode 100644
index 0000000000..cd8c59d248
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/VnfResource.json
@@ -0,0 +1,12 @@
+{
+ "vnfResource" : {
+ "resourceId" : "vnfResourceId",
+ "resourceType" : "VNF",
+ "resourceInstance" : {},
+ "homingSolution" : {
+ "license" : {},
+ "rehome" : false
+ },
+ "vfModules" : []
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml b/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml
index 92876fcb19..02ac437db6 100644
--- a/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml
+++ b/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml
@@ -39,7 +39,9 @@
<logger name="com.att.eelf.error" level="trace" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
-
+ <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties
deleted file mode 100644
index d329dbb207..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ECOMP MSO
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-URNMapping.FileSystemLoading.Enabled=true
-testKey=testValue
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties
deleted file mode 100644
index 7fa587311a..0000000000
--- a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ECOMP MSO
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-log.debug.TestTask=true
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/request.json b/bpmn/MSOCoreBPMN/src/test/resources/request.json
index 8fa195b839..9513e81d6a 100644
--- a/bpmn/MSOCoreBPMN/src/test/resources/request.json
+++ b/bpmn/MSOCoreBPMN/src/test/resources/request.json
@@ -1,7 +1,7 @@
{
"variables": {
"bpmnRequest": {
- "value": "<aetgt:service-request xmlns:aetgt=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"\n xmlns=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"\n xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"\n xmlns:msolayer3=\"http://org.openecomp/mso/request/layer3/schema/v1\"\n xmlns:rest=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">\n <msoservtypes:request-information>\n <msoservtypes:request-id>d00eb185-b1d7-429e-aca3-42a61b459535</msoservtypes:request-id>\n <msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action>\n <msoservtypes:source>OMX</msoservtypes:source>\n <msoservtypes:notification-url>http://localhost:28080/simulada/CSI/SendManagedNetworkStatusNotification</msoservtypes:notification-url>\n <msoservtypes:order-number>19630501</msoservtypes:order-number>\n <msoservtypes:order-version>1</msoservtypes:order-version>\n </msoservtypes:request-information>\n <msoservtypes:service-information>\n <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type>\n <msoservtypes:service-instance-id>AA01|VLXM|003717||SW_INTERNET</msoservtypes:service-instance-id>\n <msoservtypes:subscriber-name>TEST_4306301</msoservtypes:subscriber-name>\n </msoservtypes:service-information>\n <service-parameters>\n <msolayer3:l2-homing-information>\n <msolayer3:evc-name>01|VLXM|121601/PT</msolayer3:evc-name>\n <msolayer3:topology>PointToPoint</msolayer3:topology>\n <msolayer3:preferred-aic-clli>MTSNJA4LX01</msolayer3:preferred-aic-clli>\n </msolayer3:l2-homing-information>\n <msolayer3:internet-service-information>\n <msolayer3:internet-evc-access-information>\n <msolayer3:internet-evc-speed-value>10</msolayer3:internet-evc-speed-value>\n <msolayer3:internet-evc-speed-units>Mbps</msolayer3:internet-evc-speed-units>\n <msolayer3:ip-version>ds</msolayer3:ip-version>\n </msolayer3:internet-evc-access-information>\n <msolayer3:vr-lan>\n <msolayer3:routing-protocol>none</msolayer3:routing-protocol>\n <msolayer3:vr-lan-interface>\n <msolayer3:vr-designation>primary</msolayer3:vr-designation>\n <msolayer3:v4-public-lan-prefixes>\n <msolayer3:t-provided-v4-lan-public-prefixes>\n <msolayer3:request-index>1</msolayer3:request-index>\n <msolayer3:v4-next-hop-address>32.10.30.116</msolayer3:v4-next-hop-address>\n <msolayer3:v4-lan-public-prefix-length>32</msolayer3:v4-lan-public-prefix-length>\n </msolayer3:t-provided-v4-lan-public-prefixes>\n </msolayer3:v4-public-lan-prefixes>\n <msolayer3:v6-public-lan-prefixes>\n <msolayer3:t-provided-v6-lan-public-prefixes>\n <msolayer3:request-index>1</msolayer3:request-index>\n <msolayer3:v6-next-hop-address>2507:0CB4:85A5:0030:0000:0000:0000:0010</msolayer3:v6-next-hop-address>\n <msolayer3:v6-lan-public-prefix-length>48</msolayer3:v6-lan-public-prefix-length>\n </msolayer3:t-provided-v6-lan-public-prefixes>\n </msolayer3:v6-public-lan-prefixes>\n <msolayer3:dhcp>\n <msolayer3:v4-dhcp-server-enabled>Y</msolayer3:v4-dhcp-server-enabled>\n <msolayer3:v6-dhcp-server-enabled>Y</msolayer3:v6-dhcp-server-enabled>\n <msolayer3:use-v4-default-pool>Y</msolayer3:use-v4-default-pool>\n <msolayer3:use-v6-default-pool>Y</msolayer3:use-v6-default-pool>\n </msolayer3:dhcp>\n <msolayer3:pat>\n <msolayer3:v4-pat-enabled>Y</msolayer3:v4-pat-enabled>\n <msolayer3:use-v4-default-pool>N</msolayer3:use-v4-default-pool>\n </msolayer3:pat>\n <msolayer3:firewall-lite>\n <msolayer3:stateful-firewall-lite-v4-enabled>Y</msolayer3:stateful-firewall-lite-v4-enabled>\n <msolayer3:stateful-firewall-lite-v6-enabled>Y</msolayer3:stateful-firewall-lite-v6-enabled>\n </msolayer3:firewall-lite>\n </msolayer3:vr-lan-interface>\n </msolayer3:vr-lan>\n </msolayer3:internet-service-information>\n </service-parameters>\n</aetgt:service-request>\n",
+ "value": "<aetgt:service-request xmlns:aetgt=\"http://org.onap/so/request/layer3serviceactivate/schema/v1\"\n xmlns=\"http://org.onap/so/request/layer3serviceactivate/schema/v1\"\n xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"\n xmlns:msolayer3=\"http://org.onap/so/request/layer3/schema/v1\"\n xmlns:rest=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">\n <msoservtypes:request-information>\n <msoservtypes:request-id>d00eb185-b1d7-429e-aca3-42a61b459535</msoservtypes:request-id>\n <msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action>\n <msoservtypes:source>OMX</msoservtypes:source>\n <msoservtypes:notification-url>http://localhost:28080/simulada/CSI/SendManagedNetworkStatusNotification</msoservtypes:notification-url>\n <msoservtypes:order-number>19630501</msoservtypes:order-number>\n <msoservtypes:order-version>1</msoservtypes:order-version>\n </msoservtypes:request-information>\n <msoservtypes:service-information>\n <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type>\n <msoservtypes:service-instance-id>AA01|VLXM|003717||SW_INTERNET</msoservtypes:service-instance-id>\n <msoservtypes:subscriber-name>TEST_4306301</msoservtypes:subscriber-name>\n </msoservtypes:service-information>\n <service-parameters>\n <msolayer3:l2-homing-information>\n <msolayer3:evc-name>01|VLXM|121601/PT</msolayer3:evc-name>\n <msolayer3:topology>PointToPoint</msolayer3:topology>\n <msolayer3:preferred-aic-clli>MTSNJA4LX01</msolayer3:preferred-aic-clli>\n </msolayer3:l2-homing-information>\n <msolayer3:internet-service-information>\n <msolayer3:internet-evc-access-information>\n <msolayer3:internet-evc-speed-value>10</msolayer3:internet-evc-speed-value>\n <msolayer3:internet-evc-speed-units>Mbps</msolayer3:internet-evc-speed-units>\n <msolayer3:ip-version>ds</msolayer3:ip-version>\n </msolayer3:internet-evc-access-information>\n <msolayer3:vr-lan>\n <msolayer3:routing-protocol>none</msolayer3:routing-protocol>\n <msolayer3:vr-lan-interface>\n <msolayer3:vr-designation>primary</msolayer3:vr-designation>\n <msolayer3:v4-public-lan-prefixes>\n <msolayer3:t-provided-v4-lan-public-prefixes>\n <msolayer3:request-index>1</msolayer3:request-index>\n <msolayer3:v4-next-hop-address>32.10.30.116</msolayer3:v4-next-hop-address>\n <msolayer3:v4-lan-public-prefix-length>32</msolayer3:v4-lan-public-prefix-length>\n </msolayer3:t-provided-v4-lan-public-prefixes>\n </msolayer3:v4-public-lan-prefixes>\n <msolayer3:v6-public-lan-prefixes>\n <msolayer3:t-provided-v6-lan-public-prefixes>\n <msolayer3:request-index>1</msolayer3:request-index>\n <msolayer3:v6-next-hop-address>2507:0CB4:85A5:0030:0000:0000:0000:0010</msolayer3:v6-next-hop-address>\n <msolayer3:v6-lan-public-prefix-length>48</msolayer3:v6-lan-public-prefix-length>\n </msolayer3:t-provided-v6-lan-public-prefixes>\n </msolayer3:v6-public-lan-prefixes>\n <msolayer3:dhcp>\n <msolayer3:v4-dhcp-server-enabled>Y</msolayer3:v4-dhcp-server-enabled>\n <msolayer3:v6-dhcp-server-enabled>Y</msolayer3:v6-dhcp-server-enabled>\n <msolayer3:use-v4-default-pool>Y</msolayer3:use-v4-default-pool>\n <msolayer3:use-v6-default-pool>Y</msolayer3:use-v6-default-pool>\n </msolayer3:dhcp>\n <msolayer3:pat>\n <msolayer3:v4-pat-enabled>Y</msolayer3:v4-pat-enabled>\n <msolayer3:use-v4-default-pool>N</msolayer3:use-v4-default-pool>\n </msolayer3:pat>\n <msolayer3:firewall-lite>\n <msolayer3:stateful-firewall-lite-v4-enabled>Y</msolayer3:stateful-firewall-lite-v4-enabled>\n <msolayer3:stateful-firewall-lite-v6-enabled>Y</msolayer3:stateful-firewall-lite-v6-enabled>\n </msolayer3:firewall-lite>\n </msolayer3:vr-lan-interface>\n </msolayer3:vr-lan>\n </msolayer3:internet-service-information>\n </service-parameters>\n</aetgt:service-request>\n",
"type": "String"
},
"host": {