aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy
blob: 7c0d519f1c301adae521527ba22bc88ccc147e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package org.openecomp.mso.bpmn.infrastructure.scripts

import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.camunda.bpm.engine.runtime.Execution
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mockito.MockitoAnnotations
import org.openecomp.mso.bpmn.common.scripts.MsoUtils
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.bpmn.core.json.JsonUtils
import org.openecomp.mso.bpmn.common.scripts.VidUtils

import static org.junit.Assert.*;
import static org.mockito.Mockito.*

import com.github.tomakehurst.wiremock.junit.WireMockRule

class CreateGenericAlaCarteServiceInstanceTest  {
	
	@Rule
	public WireMockRule wireMockRule = new WireMockRule(8090);
	
		String Prefix="CRENI_"
		def utils = new MsoUtils()
		JsonUtils jsonUtil = new JsonUtils()
		VidUtils vidUtils = new VidUtils()
		
	String createDBRequestError =
"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
						<soapenv:Header/>
						<soapenv:Body>
							<ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
								<requestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</requestId>
								<lastModifiedBy>BPMN</lastModifiedBy>
								<statusMessage>Received error from SDN-C: No availability zone available</statusMessage>
								<responseBody></responseBody>
								<requestStatus>FAILED</requestStatus>
								<vnfOutputs>&lt;network-id&gt;&lt;/network-id&gt;&lt;network-name&gt;&lt;/network-names&gt;</vnfOutputs>
							</ns:updateInfraRequest>
					   	</soapenv:Body>
					   </soapenv:Envelope>"""

	  String falloutHandlerRequest =
					   """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
					                             xmlns:ns="http://org.openecomp/mso/request/types/v1"
					                             xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
					   <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
					      <request-id>b69c9054-da09-4a2c-adf5-51042b62bfac</request-id>
					      <action>CREATE</action>
					      <source>VID</source>
					   </request-info>
						<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
							<aetgt:ErrorMessage>Received error from SDN-C: No availability zone available.</aetgt:ErrorMessage>
							<aetgt:ErrorCode>5300</aetgt:ErrorCode>
						</aetgt:WorkflowException>
					</aetgt:FalloutHandlerRequest>"""

String jsonIncomingRequest =
"""{
  "service": {
    "name": "so_test4",
    "description": "so_test2",
    "serviceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561519",
    "templateId": "592f9437-a9c0-4303-b9f6-c445bb7e9814",
    "parameters": {
      "globalSubscriberId": "123457",
      "subscriberName": "Customer1",
      "serviceType": "voLTE",
      "templateName": "voLTE Service:1.0",
      "resources": [
        {
          "resourceName": "vIMS",
          "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561516",
          "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561512",
          "nsParameters": {
            "locationConstraints": [
              {
                "vnfProfileId": "zte-vBAS-1.0",
                "locationConstraints": {
                  "vimId": "4050083f-465f-4838-af1e-47a545222ad0"
                }
              },
              {
                "vnfProfileId": "zte-vMME-1.0",
                "locationConstraints": {
                  "vimId": "4050083f-465f-4838-af1e-47a545222ad0"
                }
              }
            ],
            "additionalParamForNs": {}
          }
        },
        {
          "resourceName": "vEPC",
          "resourceDefId": "61c3e96e-0970-4871-b6e0-3b6de7561516",
          "resourceId": "62c3e96e-0970-4871-b6e0-3b6de7561512",
          "nsParameters": {
            "locationConstraints": [
              {
                "vnfProfileId": "zte-CSCF-1.0",
                "locationConstraints": {
                  "vimId": "4050083f-465f-4838-af1e-47a545222ad1"
                }
              }
            ],
            "additionalParamForNs": {}
          }
        },
        {
          "resourceName": "underlayvpn",
          "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561513",
          "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561514",
          "nsParameters": {
            "locationConstraints": [],
            "additionalParamForNs": {
              "externalDataNetworkName": "Flow_out_net",
              "m6000_mng_ip": "181.18.20.2",
              "externalCompanyFtpDataNetworkName": "Flow_out_net",
              "externalPluginManageNetworkName": "plugin_net_2014",
              "externalManageNetworkName": "mng_net_2017",
              "sfc_data_network": "sfc_data_net_2016",
              "NatIpRange": "210.1.1.10-210.1.1.20",
              "location": "4050083f-465f-4838-af1e-47a545222ad0",
              "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"
            }
          }
        },
        {
          "resourceName": "overlayvpn",
          "resourceDefId": "60c3e96e-0970-4871-b6e0-3b6de7561517",
          "resourceId": "60c3e96e-0970-4871-b6e0-3b6de7561518",
          "nsParameters": {
            "locationConstraints": [],
            "additionalParamForNs": {
              "externalDataNetworkName": "Flow_out_net",
              "m6000_mng_ip": "181.18.20.2",
              "externalCompanyFtpDataNetworkName": "Flow_out_net",
              "externalPluginManageNetworkName": "plugin_net_2014",
              "externalManageNetworkName": "mng_net_2017",
              "sfc_data_network": "sfc_data_net_2016",
              "NatIpRange": "210.1.1.10-210.1.1.20",
              "location": "4050083f-465f-4838-af1e-47a545222ad0",
              "sdncontroller": "9b9f02c0-298b-458a-bc9c-be3692e4f35e"
            }
          }
        }
      ]
    }
  }
}"""

	    @Before
		public void init()
		{
			MockitoAnnotations.initMocks(this)
			
		}

		public void initializeVariables(Execution mockExecution) {
			
			verify(mockExecution).setVariable(Prefix + "Success", false)
			
			verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "")
			verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "")
			verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false)
				
		}
				
		@Test
		//@Ignore  
		public void preProcessRequest() {
			
			println "************ preProcessRequest() ************* " 
			ExecutionEntity mockExecution = mock(ExecutionEntity.class)
			// Initialize prerequisite variables
			when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
			when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest)
			try{
									
				// preProcessRequest(Execution execution)						
				CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()
				createGenericALaCarteServiceInstance.preProcessRequest(mockExecution)

				verify(mockExecution).getVariable("isDebugLogEnabled")
				verify(mockExecution).setVariable("prefix", Prefix)
			
				initializeVariables(mockExecution)
				//verify(mockExecution).setVariable(Prefix + "Success", false)
			}catch(Exception e){
				//ignore
			}			
		}
		}