Merge "Reorder modifiers"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / openecomp / mso / apihandlerinfra / MsoRequestTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.mso.apihandlerinfra;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26
27 import java.io.IOException;
28 import java.io.PrintStream;
29 import java.util.Arrays;
30 import java.util.Collection;
31 import java.util.HashMap;
32
33 import mockit.Expectations;
34 import mockit.Mocked;
35 import org.apache.commons.io.IOUtils;
36 import org.apache.commons.lang.CharEncoding;
37 import org.hibernate.Session;
38 import org.junit.Before;
39 import org.junit.Rule;
40 import org.junit.Test;
41 import org.junit.rules.ExpectedException;
42 import org.junit.runner.RunWith;
43 import org.openecomp.mso.apihandler.common.ValidationException;
44 import org.openecomp.mso.db.AbstractSessionFactoryManager;
45 import org.openecomp.mso.properties.MsoJavaProperties;
46 import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
47
48 import com.fasterxml.jackson.core.JsonParseException;
49 import com.fasterxml.jackson.databind.JsonMappingException;
50 import com.fasterxml.jackson.databind.ObjectMapper;
51
52 import junitparams.JUnitParamsRunner;
53 import junitparams.Parameters;
54
55 @RunWith(JUnitParamsRunner.class)
56 public class MsoRequestTest {
57         private ObjectMapper mapper = new ObjectMapper();
58         private HashMap<String, String> instanceIdMapTest = new HashMap<>();
59         private ServiceInstancesRequest sir;
60         private MsoRequest msoRequest;
61         private Action action;
62         private String version;
63         private String originalRequestJSON;
64         private String requestJSON;
65         private boolean expected;
66         private String expectedException;
67         
68         @Rule
69         public ExpectedException thrown = ExpectedException.none();
70         
71         
72         @Before
73         public void validate(){
74                 msoRequest = new MsoRequest();
75         }
76         public String inputStream(String JsonInput)throws IOException{
77                 String input = IOUtils.toString(ClassLoader.class.getResourceAsStream (JsonInput), CharEncoding.UTF_8);
78                 return input;
79         }
80         @Test
81         public void nullInstanceIdMapTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
82                 this.sir = mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class);
83                 this.instanceIdMapTest = null;
84                 thrown.expect(NullPointerException.class);
85                 this.msoRequest = new MsoRequest("nullINstanceIdMap");
86                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
87         }
88         @Test
89         @Parameters(method = "successParameters")
90         public void successTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException{
91                 this.sir = sir;
92                 this.instanceIdMapTest = instanceIdMapTest;
93                 this.action = action;
94                 this.version = version;
95                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
96                 this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
97                 this.msoRequest = new MsoRequest("successTest");
98                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
99         }
100         @Parameters
101         private Collection<Object[]> successParameters() throws JsonParseException, JsonMappingException, IOException{
102                 return Arrays.asList(new Object[][]{
103                         {mapper.readValue(inputStream("/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
104                         {mapper.readValue(inputStream("/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
105                         {mapper.readValue(inputStream("/EmptyCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
106                         {mapper.readValue(inputStream("/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v5"},
107                         {mapper.readValue(inputStream("/PlatformTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
108                         {mapper.readValue(inputStream("/v5EnablePortMirrorService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
109                         {mapper.readValue(inputStream("/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
110                         {mapper.readValue(inputStream("/ValidModelCustomizationIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
111                         {mapper.readValue(inputStream("/ServiceProductFamilyIdUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
112                         {mapper.readValue(inputStream("/ServiceProductFamilyIdFlag.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},             
113                         {mapper.readValue(inputStream("/VnfModelCustomizationIdEmpty.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v5"},
114                         {mapper.readValue(inputStream("/RelatedInstancesVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
115                         {mapper.readValue(inputStream("/RelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
116                         {mapper.readValue(inputStream("/VnfModelCustomizationNameNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
117                         {mapper.readValue(inputStream("/VnfModelCustomizationTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
118                         {mapper.readValue(inputStream("/ServiceModelNameEmptyOnDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v2"},
119                         {mapper.readValue(inputStream("/ServiceModelNameEmptyOnActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v2"},
120                         {mapper.readValue(inputStream("/ModelVersionNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
121                         {mapper.readValue(inputStream("/ModelInvariantIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
122                         {mapper.readValue(inputStream("/ModelInvariantIdConfigurationDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
123                         {mapper.readValue(inputStream("/ModelCustomizationIdUsingPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
124                         {mapper.readValue(inputStream("/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
125                         {mapper.readValue(inputStream("/EmptyOwningEntityName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
126                         {mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v6"},
127                         {mapper.readValue(inputStream("/VnfActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v6"},
128                         {mapper.readValue(inputStream("/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
129                         {mapper.readValue(inputStream("/ProjectAndOwningEntity2.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
130                         {mapper.readValue(inputStream("/PlatformAndLineOfBusiness2.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
131                         {mapper.readValue(inputStream("/UserParams.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"}
132                 });
133         }
134         @Test
135         @Parameters(method = "aLaCarteParameters")
136         public void aLaCarteFlagTest(boolean expected, ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws JsonParseException, IOException, ValidationException{
137                 this.expected = expected;
138                 this.sir = sir;
139                 this.instanceIdMapTest = instanceIdMapTest;
140                 this.action = action;
141                 this.version = version;
142                 this.msoRequest = new MsoRequest("aLaCarteCheck");
143                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
144                 assertEquals(expected, msoRequest.getALaCarteFlag());
145         }
146         @Parameters
147         private Collection<Object[]> aLaCarteParameters() throws IOException{
148                 return Arrays.asList(new Object[][] {
149                         {false, mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
150                         {true, mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
151                         {true, mapper.readValue(inputStream("/v2requestParametersALaCarteFalse.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
152                 });
153         }
154         @Test
155         @Parameters(method = "validationParameters")
156         public void validationFailureTest(String expectedException, ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws JsonParseException, JsonMappingException, IOException, ValidationException{
157                 this.expectedException = expectedException;
158                 this.sir = sir;
159                 this.instanceIdMapTest = instanceIdMapTest;
160                 this.action = action;
161                 this.version = version;
162                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
163                 this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
164                 thrown.expect(ValidationException.class);
165                 thrown.expectMessage(expectedException);
166                 this.msoRequest = new MsoRequest("validationFailure");
167                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
168         }
169         @Parameters
170         private Collection<Object[]> validationParameters() throws IOException{
171                 return Arrays.asList(new Object[][] {
172                         {"No valid aLaCarte in requestParameters", mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v4"},
173                         {"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
174                         {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
175                         {"No valid modelType is specified", mapper.readValue(inputStream("/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
176                         {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
177                         {"No valid tenantId is specified", mapper.readValue(inputStream("/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
178                         {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
179                         {"No valid subscriptionServiceType is specified", mapper.readValue(inputStream("/EmptySubscriptionServiceType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
180                         {"No valid instanceName format is specified", mapper.readValue(inputStream("/InvalidInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
181                         {"No valid requestorId is specified", mapper.readValue(inputStream("/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
182                         {"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
183                         {"No valid subscriberInfo is specified", mapper.readValue(inputStream("/EmptySubscriberInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
184                         {"No valid globalSubscriberId is specified", mapper.readValue(inputStream("/EmptyGlobalSubscriberId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
185                         {"No valid platformName is specified", mapper.readValue(inputStream("/EmptyPlatform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
186                         {"No valid platform is specified", mapper.readValue(inputStream("/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
187                         {"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
188                         {"No valid projectName is specified", mapper.readValue(inputStream("/EmptyProject.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
189                         {"No valid owningEntity is specified", mapper.readValue(inputStream("/OwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
190                         {"No valid owningEntityId is specified", mapper.readValue(inputStream("/EmptyOwningEntityId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
191                         {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
192                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
193                         {"No valid modelName is specified", mapper.readValue(inputStream("/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v4"},
194                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
195                         {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
196                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
197                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
198                         {"No valid productFamilyId is specified", mapper.readValue(inputStream("/VnfProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
199                         {"No valid productFamilyId is specified", mapper.readValue(inputStream("/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
200                         {"No valid productFamilyId is specified", mapper.readValue(inputStream("/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
201                         {"No valid productFamilyId is specified", mapper.readValue(inputStream("/ServiceProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
202                         {"No valid modelVersionId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
203                         {"No valid modelType in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
204                         {"No valid modelInfo in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
205                         {"No valid instanceName format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesNameFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
206                         {"No valid instanceId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
207                         {"No valid instanceId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
208                         {"No valid modelInvariantId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
209                         {"No valid modelName in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
210                         {"No valid modelVersion in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
211                         {"No valid modelInvariantId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInvariantIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
212                         {"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified", mapper.readValue(inputStream("/RelatedInstancesModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
213                         {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstancesInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
214                         {"No valid vnfInstanceId matching the vnfInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstancesVnfInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
215                         {"No valid related vnf instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstancesVnfInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
216                         {"No valid related service instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstancesServiceInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
217                         {"No valid related vnf instance for vfModule request is specified", mapper.readValue(inputStream("/VfModuleRelatedInstancesVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
218                         {"No valid related service instance for vfModule request is specified", mapper.readValue(inputStream("/VfModuleRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
219                         {"No valid related service instance for vnf request is specified", mapper.readValue(inputStream("/VnfRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
220                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationIdPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
221                         {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
222                         {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
223                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
224                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5ModelInvariantIdNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
225                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5ModelInvariantIdDisablePort.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
226                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantIdVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
227                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantIdConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v3"},
228                         {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInvariantIdServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
229                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v4"},
230                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
231                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
232                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
233                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
234                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelVersionIdTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
235                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
236                         {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
237                         {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
238                         {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
239                         {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
240                         {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
241                         {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
242                         {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
243                         {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
244                         {"No valid tenantId is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
245                         {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/v6VnfDeleteInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v6"},
246                         {"No valid related instances is specified", mapper.readValue(inputStream("/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v2"},
247                         {"No valid related instances is specified", mapper.readValue(inputStream("/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, "v2"},
248                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v6"},
249                         {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v6"},
250                         {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/v6AddRelationshipsBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, "v6"},
251                         {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/v6AddRelationshipsBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v6"},
252                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5DeactivatePortMirrorBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v5"},
253                         {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v5ActivatePortMirrorBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
254                         {"No valid related instances is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v2"},
255                         {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
256                         {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
257                         {"No valid related instances is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
258                         {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/v5PortMirrorCreateConfigurationBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
259                         {"No valid source vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoSourceRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
260                         {"No valid destination vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoDestinationRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
261                         {"No valid related instances is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
262                         {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/v4CreateVfModuleMissingModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
263                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v3DeleteServiceInstanceALaCarte.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
264                         {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v4"},
265                         {"No valid related instances is specified", mapper.readValue(inputStream("/v3VolumeGroupBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v4"}
266                 });
267         }
268         @Test
269         public void setInstancedIdHashMapTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
270                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
271                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
272                 this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff001");
273                 this.instanceIdMapTest.put("vfModuleInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff002");
274                 this.instanceIdMapTest.put("volumeGroupInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff003");
275                 this.instanceIdMapTest.put("networkInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff004");
276                 this.instanceIdMapTest.put("configurationInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff005");
277                 this.action = Action.createInstance;
278                 this.version = "v5";
279                 this.msoRequest = new MsoRequest("setInstanceIdHashMap");
280                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
281                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff000", msoRequest.getServiceInstancesRequest().getServiceInstanceId());
282                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff001", msoRequest.getServiceInstancesRequest().getVnfInstanceId());
283                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff002", msoRequest.getServiceInstancesRequest().getVfModuleInstanceId());
284                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff003", msoRequest.getServiceInstancesRequest().getVolumeGroupInstanceId());
285                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff004", msoRequest.getServiceInstancesRequest().getNetworkInstanceId());
286                 assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff005", msoRequest.getServiceInstancesRequest().getConfigurationId());
287         }
288         @Test
289         public void serviceInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
290                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
291                 this.instanceIdMapTest.put("serviceInstanceId", "test");
292                 this.action = Action.createInstance;
293                 this.version = "v5";
294                 thrown.expect(ValidationException.class);
295                 thrown.expectMessage("No valid serviceInstanceId is specified");
296                 this.msoRequest = new MsoRequest("serviceInstanceIdFailure");
297                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
298         }
299         @Test
300         public void vnfInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
301                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
302                 this.instanceIdMapTest.put("vnfInstanceId", "test");
303                 this.action = Action.createInstance;
304                 this.version = "v5";
305                 thrown.expect(ValidationException.class);
306                 thrown.expectMessage("No valid vnfInstanceId is specified");
307                 this.msoRequest = new MsoRequest("vnfInstanceIdFailure");
308                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
309         }
310         @Test
311         public void vfModuleInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
312                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
313                 this.instanceIdMapTest.put("vfModuleInstanceId", "test");
314                 this.action = Action.createInstance;
315                 this.version = "v5";
316                 thrown.expect(ValidationException.class);
317                 thrown.expectMessage("No valid vfModuleInstanceId is specified");
318                 this.msoRequest = new MsoRequest("vfModuleInstanceIdFailure");
319                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
320         }
321         @Test
322         public void volumeGroupInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
323                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
324                 this.instanceIdMapTest.put("volumeGroupInstanceId", "test");
325                 this.action = Action.createInstance;
326                 this.version = "v5";
327                 thrown.expect(ValidationException.class);
328                 thrown.expectMessage("No valid volumeGroupInstanceId is specified");
329                 this.msoRequest = new MsoRequest("volumeGroupInstanceIdFailure");
330                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
331         }
332         @Test
333         public void networkInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
334                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
335                 this.instanceIdMapTest.put("networkInstanceId", "test");
336                 this.action = Action.createInstance;
337                 this.version = "v5";
338                 thrown.expect(ValidationException.class);
339                 thrown.expectMessage("No valid networkInstanceId is specified");
340                 this.msoRequest = new MsoRequest("networkInstanceIdFailure");
341                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
342         }
343         @Test
344         public void configurationInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
345                 this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
346                 this.instanceIdMapTest.put("configurationInstanceId", "test");
347                 this.action = Action.createInstance;
348                 this.version = "v5";
349                 thrown.expect(ValidationException.class);
350                 thrown.expectMessage("No valid configurationInstanceId is specified");
351                 this.msoRequest = new MsoRequest("configurationInstanceIdFailure");
352                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
353         }
354         @Test
355         public void setVolumeGroupRelatedInstancesTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
356                 this.sir = mapper.readValue(inputStream("/VolumeGroupRelatedInstances.json"), ServiceInstancesRequest.class);
357                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
358                 this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff001");
359                 this.action = Action.createInstance;
360                 this.version = "v5";
361                 this.msoRequest = new MsoRequest("setVolumeGroupRelatedInstances");
362                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
363                 assertEquals("vSAMP12", msoRequest.getServiceInstanceType());
364                 assertEquals("vSAMP12" + "/" + "test", msoRequest.getVnfType());
365                 assertEquals("1.0", msoRequest.getAsdcServiceModelVersion());
366         }
367         @Test
368         @Parameters(method = "projectParameters")
369         public void setProjectAndOwningEntityTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException, JsonParseException, JsonMappingException, IOException{
370                 this.sir = sir;
371                 this.action = action;
372                 this.version = version;
373                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
374                 this.msoRequest = new MsoRequest("setProjectAndOwningEntity");
375                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
376                 assertEquals("projectName", msoRequest.getProject().getProjectName());
377                 assertEquals("oeId", msoRequest.getOwningEntity().getOwningEntityId());
378                 assertEquals("oeName", msoRequest.getOwningEntity().getOwningEntityName());
379         }
380         @Parameters
381         private Collection<Object[]> projectParameters() throws IOException{
382                 return Arrays.asList(new Object[][] {
383                         {mapper.readValue(inputStream("/ProjectAndOwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
384                         {mapper.readValue(inputStream("/ProjectAndOwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
385                 });
386         }
387         
388         @Test
389         public void setModelInfoTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
390                 this.sir = mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class);
391                 this.action = Action.createInstance;
392                 this.version = "v5";
393                 this.msoRequest = new MsoRequest("setModelInfo");
394                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
395                 assertEquals("test", msoRequest.getServiceInstancesRequest().getRequestDetails().getModelInfo().getModelVersionId());
396         }
397         @Test
398         public void setServiceInstanceTypeTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
399                 this.sir = mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class);
400                 this.action = Action.createInstance;
401                 this.version = "v5";
402                 this.msoRequest = new MsoRequest("setServiceInstanceType");
403                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
404                 assertEquals("SDNW Service 1710", msoRequest.getServiceInstanceType());
405         }
406         @Test
407         @Parameters(method = "platformParameters")
408         public void setPlatformAndLineOfBusinessTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException, JsonParseException, JsonMappingException, IOException{
409                 this.sir = sir;
410                 this.action = action;
411                 this.instanceIdMapTest = instanceIdMapTest;
412                 this.version = version;
413                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
414                 this.msoRequest = new MsoRequest("setPlatformAndLineOfBusiness");
415                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
416                 assertEquals("platformName", msoRequest.getPlatform().getPlatformName());
417                 assertEquals("lobName", msoRequest.getLineOfBusiness().getLineOfBusinessName());
418         }
419         @Parameters
420         private Collection<Object[]> platformParameters() throws IOException{
421                 return Arrays.asList(new Object[][] {
422                         {mapper.readValue(inputStream("/PlatformAndLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
423                         {mapper.readValue(inputStream("/PlatformAndLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
424                 });
425         }
426         
427         @Test
428         public void setNetworkTypeTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
429                 this.sir = mapper.readValue(inputStream("/NetworkType.json"), ServiceInstancesRequest.class);
430                 this.action = Action.createInstance;
431                 this.version = "v2";
432                 this.msoRequest = new MsoRequest("setNetworkType");
433                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
434                 assertEquals("TestNetworkType", msoRequest.getNetworkType());
435         }
436         @Test
437         public void setModelNameVersionIdTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
438                 this.sir = mapper.readValue(inputStream("/ModelNameVersionId.json"), ServiceInstancesRequest.class);
439                 this.action = Action.createInstance;
440                 this.version = "v5";
441                 this.msoRequest = new MsoRequest("setModelNameVersionId");
442                 this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
443                 assertEquals("test", msoRequest.getModelInfo().getModelNameVersionId());
444         }
445         @Test
446         public void testParseOrchestration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
447                 this.requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
448                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
449                 this.msoRequest = new MsoRequest ("ParseOrchestration");
450                 msoRequest.parseOrchestration(sir);
451                 assertEquals(msoRequest.getRequestInfo().getSource(),"VID");
452                 assertEquals(msoRequest.getRequestInfo().getRequestorId(),"zz9999");
453
454         }
455         @Test
456         public void testParseOrchestrationFailure() throws JsonParseException, JsonMappingException, IOException, ValidationException{
457                 this.requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\"}}}";
458                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
459                 thrown.expect(ValidationException.class);
460                 thrown.expectMessage("No valid requestorId is specified");
461                 this. msoRequest = new MsoRequest ("ParseOrchestration");
462                 msoRequest.parseOrchestration(sir);
463         }
464         @Test
465         public void testParseV3VnfCreate() throws JsonParseException, JsonMappingException, IOException, ValidationException{
466                 this.requestJSON = inputStream("/v3VnfCreate.json");
467                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
468                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
469                 this.msoRequest = new MsoRequest ("1234");
470                 msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v3", originalRequestJSON);
471                 assertEquals(msoRequest.getRequestInfo().getSource(),"VID");
472                 assertEquals(msoRequest.getReqVersion(),3);
473         }
474         @Test
475         public void testParseV3UpdateNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{
476                 this.requestJSON = inputStream("/v3UpdateNetwork.json");
477                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
478                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
479                 this.msoRequest = new MsoRequest ("1234");
480                 msoRequest.parse(sir, instanceIdMapTest, Action.updateInstance, "v3", originalRequestJSON);
481         }
482         @Test
483         public void testParseV3DeleteNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{
484                 this.requestJSON = inputStream("/v3DeleteNetwork.json");
485                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
486                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
487                 this.msoRequest = new MsoRequest ("1234");
488                 msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
489         }
490         @Test
491         public void testParseV3ServiceInstanceDelete() throws JsonParseException, JsonMappingException, IOException, ValidationException{
492                 String requestJSON2;
493                 this.requestJSON = inputStream("/v3DeleteServiceInstance.json");
494                 requestJSON2 = inputStream("/v3DeleteServiceInstanceALaCarte.json");
495                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
496                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
497                 this.msoRequest = new MsoRequest ("1234");
498                 msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
499                 boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isaLaCarte();
500                 assertFalse(testIsALaCarteSet);
501                 this.sir  = mapper.readValue(requestJSON2, ServiceInstancesRequest.class);
502                 this.msoRequest = new MsoRequest ("12345");
503                 msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
504                 testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isaLaCarte();
505                 assertTrue(testIsALaCarteSet);
506                 assertTrue(msoRequest.getALaCarteFlag());
507         }
508         @Test
509         public void testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
510                 this.requestJSON = inputStream("/v4CreateVfModule.json");
511                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
512                 this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
513                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
514                 this.msoRequest = new MsoRequest ("1234");
515                 msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v4", originalRequestJSON);
516                 
517                 this.requestJSON = inputStream("/v4CreateVfModuleNoCustomizationId.json");
518                 this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
519                 this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
520                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
521                 msoRequest = new MsoRequest ("1234");
522                 msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v4", originalRequestJSON);
523         }
524         @Test
525         public void testV5PortMirrorCreateConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
526                 this.requestJSON = inputStream("/v5PortMirrorCreateConfiguration.json");
527                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
528                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
529                 this.msoRequest = new MsoRequest ("1234");
530                 msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v5", originalRequestJSON);
531         }
532         @Test
533         public void testV6PortMirrorCreateConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
534                 this.requestJSON = inputStream("/v6PortMirrorCreateConfiguration.json");
535                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
536                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
537                 this.msoRequest = new MsoRequest ("1234");
538                 msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v6", originalRequestJSON);
539         }
540         @Test
541         public void testV5EnablePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
542                 this.requestJSON = inputStream("/v5EnablePortMirrorConfiguration.json");
543                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
544                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
545                 this.msoRequest = new MsoRequest ("1234");
546                 msoRequest.parse(sir, instanceIdMapTest, Action.enablePort, "v5", originalRequestJSON);
547         }
548         @Test
549         public void testV5DisablePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
550                 this.requestJSON = inputStream("/v5EnablePortMirrorConfiguration.json");
551                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
552                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
553                 this.msoRequest = new MsoRequest ("1234");
554                 msoRequest.parse(sir, instanceIdMapTest, Action.disablePort, "v5", originalRequestJSON);
555         }
556         @Test
557         public void testV5ActivatePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
558                 this.requestJSON = inputStream("/v5ActivatePortMirrorConfiguration.json");
559                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
560                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
561                 this.msoRequest = new MsoRequest ("1234");
562                 msoRequest.parse(sir, instanceIdMapTest, Action.activateInstance, "v5", originalRequestJSON);
563         }
564         @Test
565         public void testV5ActivatePortMirrorNoRelatedInstance() throws JsonParseException, JsonMappingException, IOException, ValidationException{
566                 this.requestJSON = inputStream("/v5ActivatePortMirrorNoRelatedInstance.json");
567                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
568                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
569                 this.msoRequest = new MsoRequest ("1234");
570                 msoRequest.parse(sir, instanceIdMapTest, Action.activateInstance, "v5", originalRequestJSON);
571         }
572         @Test
573         public void testV5DeactivatePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
574                 this.requestJSON = inputStream("/v5DeactivatePortMirrorConfiguration.json");
575                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
576                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
577                 this.msoRequest = new MsoRequest ("1234");
578                 msoRequest.parse(sir, instanceIdMapTest, Action.deactivateInstance, "v5", originalRequestJSON);
579         }
580         @Test
581         public void testV5DeactivatePortMirrorNoRelatedInstance() throws JsonParseException, JsonMappingException, IOException, ValidationException{
582                 this.requestJSON = inputStream("/v5DeactivatePortMirrorNoRelatedInstance.json");
583                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
584                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
585                 this.msoRequest = new MsoRequest ("1234");
586                 msoRequest.parse(sir, instanceIdMapTest, Action.deactivateInstance, "v5", originalRequestJSON);
587         }
588         @Test
589         public void testV6AddRelationships() throws JsonParseException, JsonMappingException, IOException, ValidationException{
590                 this.requestJSON = inputStream("/v6AddRelationships.json");
591                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
592                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
593                 this.msoRequest = new MsoRequest ("V6AddRelationships");
594                 msoRequest.parse(sir, instanceIdMapTest, Action.addRelationships, "v6", originalRequestJSON);
595         }
596         @Test
597         public void testV6RemoveRelationships() throws JsonParseException, JsonMappingException, IOException, ValidationException{
598                 this.requestJSON = inputStream("/v6AddRelationships.json");
599                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
600                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
601                 this.msoRequest = new MsoRequest ("V6RemoveRelationships");
602                 msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON);
603                 assertNotNull(msoRequest.getRequestId());
604                 assertEquals(msoRequest.getReqVersion(), 6);
605         }
606
607         @Test
608         public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
609                                                                         @Mocked Session session) throws ValidationException, IOException {
610
611                 new Expectations() {{
612                         sessionFactoryManager.getSessionFactory().openSession(); result = session;
613                 }};
614
615                 this.requestJSON = inputStream("/v6AddRelationships.json");
616                 this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
617                 this.sir  = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
618                 this.msoRequest = new MsoRequest ("V6RemoveRelationships");
619                 msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON);
620                 msoRequest.createRequestRecord(Status.COMPLETE, Action.createInstance);
621
622         }
623
624 }