ec3d9b75a5b7a796a1e8faba3313f4811c94ef52
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
21 package org.openecomp.sdc.ci.tests.execute.product;
22
23 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
24 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT;
25 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
26 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
27 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
28 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
29 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS_DELETE;
30 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_UNSUPPORTED_ERROR;
31 import static org.testng.AssertJUnit.assertEquals;
32 import static org.testng.AssertJUnit.assertTrue;
33
34 import java.util.ArrayList;
35 import java.util.List;
36
37 import org.junit.Rule;
38 import org.junit.rules.TestName;
39 import org.openecomp.sdc.be.dao.api.ActionStatus;
40 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
41 import org.openecomp.sdc.be.model.ComponentInstance;
42 import org.openecomp.sdc.be.model.LifecycleStateEnum;
43 import org.openecomp.sdc.be.model.Product;
44 import org.openecomp.sdc.be.model.User;
45 import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
46 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
47 import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
48 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
49 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
54 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
55 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
56 import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
57 import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
58 import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
61 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
63 import org.testng.AssertJUnit;
64 import org.testng.annotations.BeforeMethod;
65 import org.testng.annotations.Test;
66
67 public class ProductComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
68
69         protected ArtifactReqDetails heatArtifactDetails;
70         @Rule
71         public static TestName name = new TestName();
72
73         public ProductComponentInstanceCRUDTest() {
74                 super(name, ProductComponentInstanceCRUDTest.class.getName());
75         }
76
77         @BeforeMethod
78         public void before() throws Exception {
79                 init();
80                 createComponents();
81         }
82
83         private void createComponents() throws Exception {
84
85                 heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
86                 createAtomicResource(resourceDetailsVFC_01);
87                 changeResourceStateToCertified(resourceDetailsVFC_01);
88                 createAtomicResource(resourceDetailsCP_01);
89                 changeResourceStateToCertified(resourceDetailsCP_01);
90                 createAtomicResource(resourceDetailsVL_01);
91                 changeResourceStateToCertified(resourceDetailsVL_01);
92                 createAtomicResource(resourceDetailsVFC_02);
93                 changeResourceStateToCertified(resourceDetailsVFC_02);
94                 createAtomicResource(resourceDetailsCP_02);
95                 changeResourceStateToCertified(resourceDetailsCP_02);
96                 createAtomicResource(resourceDetailsVL_02);
97                 changeResourceStateToCertified(resourceDetailsVL_02);
98                 createVF(resourceDetailsVF_02);
99                 createVF(resourceDetailsVF_01);
100                 // create check-In services
101                 createService(serviceDetails_01);
102                 createService(serviceDetails_02);
103                 createService(serviceDetails_03);
104                 createProduct(productDetails_01);
105                 createProduct(productDetails_02);
106
107                 // addresourceDetailsCP_02 ,resourceDetailsVFC_02 and
108                 // resourceDetailsVL_02 to resourceDetailsVF_02 check-in VF
109                 RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02,
110                                 resourceDetailsVFC_02, sdncDesignerDetails);
111                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
112                 createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsCP_02,
113                                 sdncDesignerDetails);
114                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
115                 createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVL_02,
116                                 sdncDesignerDetails);
117                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
118                 RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
119                                 LifeCycleStatesEnum.CHECKIN);
120                 resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
121                 // addresourceDetailsCP_01 ,resourceDetailsVFC_01 and
122                 // resourceDetailsVL_01 to resourceDetailsVF_01 and certify
123                 // resourceDetailsVF_01
124                 certifyVf(resourceDetailsVF_01);
125                 createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // serviceDetails_01
126                                                                                                                                                                                                         // has
127                                                                                                                                                                                                         // certified
128                                                                                                                                                                                                         // VF
129                 createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02, sdncDesignerDetails); // serviceDetails_02
130                                                                                                                                                                                                         // has
131                                                                                                                                                                                                         // check-in
132                                                                                                                                                                                                         // VF
133                 restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
134                                 LifeCycleStatesEnum.CHECKIN);
135                 ResourceRestUtils.checkSuccess(restResponse);
136                 restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
137                                 LifeCycleStatesEnum.CHECKIN);
138                 ResourceRestUtils.checkSuccess(restResponse);
139         }
140
141         // pass
142         @Test
143         public void createServiceInstanceTest() throws Exception {
144                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
145                                 sdncPmDetails1);
146                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
147                 getComponentAndValidateRIs(productDetails_01, 1, 0);
148         }
149
150         // DE189427
151         @Test(enabled = false)
152         public void createServiceInstanceFromCheckedOutState() throws Exception {
153                 // can't create instance of checked-out component
154                 RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
155                                 LifeCycleStatesEnum.CHECKOUT);
156                 ResourceRestUtils.checkSuccess(restResponse);
157                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
158                                 sdncPmDetails1);
159                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
160                 getComponentAndValidateRIs(productDetails_01, 1, 0);
161         }
162
163         @Test
164         public void createServiceInstanceInToAnotherServiceInstance() throws Exception {
165                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02,
166                                 sdncPmDetails1);
167                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
168                 String uniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
169                 getComponentAndValidateRIs(productDetails_01, 1, 0);
170                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
171                                 .getComponentResourceInstance(serviceDetails_01);
172                 createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails,
173                                 sdncPmDetails1, uniqueIdFromResponse, ComponentTypeEnum.PRODUCT);
174                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_NOT_FOUND);
175         }
176
177         @Test
178         public void createSeveralServiceInstanceFromSameServices() throws Exception {
179                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
180                                 sdncPmDetails1);
181                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
182                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
183                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
184                 getComponentAndValidateRIs(productDetails_01, 2, 0);
185         }
186
187         @Test
188         public void createSeveralServiceInstanceFromDifferentServices() throws Exception {
189                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
190                                 sdncPmDetails1);
191                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
192                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
193                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
194                 getComponentAndValidateRIs(productDetails_01, 2, 0);
195         }
196
197         @Test
198         public void createCertifiedServiceInstance() throws Exception {
199                 changeServiceStateToCertified(serviceDetails_01);
200                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
201                                 sdncPmDetails1);
202                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
203                 getComponentAndValidateRIs(productDetails_01, 1, 0);
204         }
205
206         @Test
207         public void createServiceInstanceByPm() throws Exception {
208                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
209                                 LifeCycleStatesEnum.CHECKIN);
210                 ResourceRestUtils.checkSuccess(restResponse);
211                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
212                                 LifeCycleStatesEnum.CHECKOUT);
213                 ResourceRestUtils.checkSuccess(restResponse);
214                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
215                                 sdncPmDetails1);
216                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
217                 getComponentAndValidateRIs(productDetails_01, 1, 0);
218         }
219
220         @Test
221         public void createServiceInstanceWithoutVf() throws Exception {
222                 LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncAdminDetails, "0.1", LifeCycleStatesEnum.CHECKIN);
223                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_02, serviceDetails_03,
224                                 sdncPmDetails1);
225                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
226                 getComponentAndValidateRIs(productDetails_02, 1, 0);
227         }
228
229         @Test
230         public void createServiceInstanceByNonProductOwner() throws Exception {
231                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
232                                 sdncPmDetails1);
233                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
234                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails2);
235                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
236                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
237                                 createServiceInstanceResp.getResponse());
238                 getComponentAndValidateRIs(productDetails_01, 1, 0);
239         }
240
241         @Test
242         public void createServiceInstanceByNonAsdcUser() throws Exception {
243                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
244                                 sdncPmDetails1);
245                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
246                 User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
247                 ;
248                 nonExistingSdncUser.setUserId("bt1234");
249                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonExistingSdncUser);
250                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
251                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
252                                 createServiceInstanceResp.getResponse());
253                 getComponentAndValidateRIs(productDetails_01, 1, 0);
254         }
255
256         @Test
257         public void createServiceInstanceToNotCheckOutProduct() throws Exception {
258                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
259                                 sdncPmDetails1);
260                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
261                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
262                                 LifeCycleStatesEnum.CHECKIN);
263                 ResourceRestUtils.checkSuccess(restResponse);
264                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
265                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
266                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
267                                 createServiceInstanceResp.getResponse());
268                 getComponentAndValidateRIs(productDetails_01, 1, 0);
269         }
270
271         // pass
272         @Test
273         public void createServiceInstanceNameIsEmpty() throws Exception {
274                 String expectedServiceInstanceName = serviceDetails_01.getName() + " 1";
275                 String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1";
276                 serviceDetails_01.setName("");
277                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
278                                 sdncPmDetails1);
279                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
280                 String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(),
281                                 "normalizedName");
282                 String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
283                 assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(),
284                                 instanceNormalizedName);
285                 assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
286                 getComponentAndValidateRIs(productDetails_01, 1, 0);
287                 // get product and verify that service instanceName is correct
288                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
289                                 sdncPmDetails1.getUserId());
290                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
291                                 Product.class);
292                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
293                 assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
294                 assertEquals((expectedServiceInstancenormalizedName).toLowerCase(),
295                                 actualComponentInstance.getNormalizedName());
296         }
297
298         // pass
299         @Test
300         public void createServiceInstanceNameIsNull() throws Exception {
301                 String expectedServiceInstanceName = serviceDetails_01.getName() + " 1";
302                 String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1";
303                 serviceDetails_01.setName(null);
304                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
305                                 sdncPmDetails1);
306                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
307                 String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(),
308                                 "normalizedName");
309                 String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
310                 assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(),
311                                 instanceNormalizedName);
312                 assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
313                 getComponentAndValidateRIs(productDetails_01, 1, 0);
314                 // get product and verify that service instanceName is correct
315                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
316                                 sdncPmDetails1.getUserId());
317                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
318                                 Product.class);
319                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
320                 assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
321                 assertEquals((expectedServiceInstancenormalizedName).toLowerCase(),
322                                 actualComponentInstance.getNormalizedName());
323         }
324
325         @Test(enabled = false)
326         public void createServiceInstanceToNonExistingProduct() throws Exception {
327                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
328                                 sdncPmDetails1);
329                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
330                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
331                                 .getComponentResourceInstance(serviceDetails_01);
332                 createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails,
333                                 sdncPmDetails1, "blabla", ComponentTypeEnum.PRODUCT);
334                 AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
335                                 createServiceInstanceResp.getErrorCode().intValue());
336                 ArrayList<String> varibales = new ArrayList<String>();
337                 varibales.add("blabla");
338                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales,
339                                 createServiceInstanceResp.getResponse());
340                 getComponentAndValidateRIs(productDetails_01, 1, 0);
341         }
342
343         @Test
344         public void createServiceInstanceToNonSupportedComponentType() throws Exception {
345                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
346                                 sdncPmDetails1);
347                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
348                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
349                                 .getComponentResourceInstance(serviceDetails_01);
350                 createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails,
351                                 sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE);
352                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
353                 ArrayList<String> varibales = new ArrayList<String>();
354                 varibales.add("null");
355                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales,
356                                 createServiceInstanceResp.getResponse());
357                 getComponentAndValidateRIs(productDetails_01, 1, 0);
358         }
359
360         // pass
361         @Test
362         public void createServiceInstancePositionIsEmpty() throws Exception {
363                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
364                                 .getComponentResourceInstance(serviceDetails_01);
365                 serviceInstanceReqDetails.setPosX("");
366                 serviceInstanceReqDetails.setPosY("");
367                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
368                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
369                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
370                 ComponentInstance componentInstance = ResponseParser
371                                 .parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
372                 addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
373                 getComponentAndValidateRIs(productDetails_01, 1, 0);
374         }
375
376         @Test
377         public void createServiceInstancePositionIsNull() throws Exception {
378                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
379                                 .getComponentResourceInstance(serviceDetails_01);
380                 serviceInstanceReqDetails.setPosX(null);
381                 serviceInstanceReqDetails.setPosY(null);
382                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
383                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
384                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
385                 ComponentInstance componentInstance = ResponseParser
386                                 .parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
387                 addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
388                 getComponentAndValidateRIs(productDetails_01, 1, 0);
389         }
390
391         @Test
392         public void createServiceInstanceByDesigner() throws Exception {
393                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
394                                 sdncPmDetails1);
395                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
396                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncDesignerDetails);
397                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
398                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
399                                 createServiceInstanceResp.getResponse());
400                 getComponentAndValidateRIs(productDetails_01, 1, 0);
401         }
402
403         @Test
404         public void createServiceInstanceUserIdIsEmpty() throws Exception {
405                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
406                                 sdncPmDetails1);
407                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
408                 User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
409                 nonSdncDetails.setUserId("");
410                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonSdncDetails);
411                 assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
412                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
413                                 createServiceInstanceResp.getResponse());
414                 getComponentAndValidateRIs(productDetails_01, 1, 0);
415         }
416
417         //// Update Service instance
418
419         @Test
420         public void updateServiceInstanceNameByPm() throws Exception {
421                 // Check-in Product by PM and Check-out by PM
422                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
423                                 LifeCycleStatesEnum.CHECKIN);
424                 ResourceRestUtils.checkSuccess(restResponse);
425                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
426                                 LifeCycleStatesEnum.CHECKOUT);
427                 ResourceRestUtils.checkSuccess(restResponse);
428                 // Create service instance by PM
429                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
430                                 .getComponentResourceInstance(serviceDetails_01);
431                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
432                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
433                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
434                 String newName = "abcD";
435                 serviceInstanceReqDetails.setName(newName);
436                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
437                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
438                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
439                 String instanceNormalizedName = ResponseParser
440                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
441                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
442                                 "name");
443                 assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
444                 assertEquals("check Resource Instance Name ", newName, instanceName);
445                 // get product and verify that service instanceName is correct
446                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
447                                 sdncPmDetails1.getUserId());
448                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
449                                 Product.class);
450                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
451                 assertEquals(newName, actualComponentInstance.getName());
452                 assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
453         }
454
455         @Test
456         public void updateServiceInstanceNewNameAndLocation() throws Exception {
457                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
458                                 .getComponentResourceInstance(serviceDetails_01);
459                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
460                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
461                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
462                 String newName = "updaatedName100";
463                 serviceInstanceReqDetails.setPosX("100");
464                 serviceInstanceReqDetails.setPosY("100");
465                 serviceInstanceReqDetails.setName(newName);
466                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
467                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
468                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
469                 // get product and verify that service instanceName is correct
470                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
471                                 sdncPmDetails1.getUserId());
472                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
473                                 Product.class);
474                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
475                 assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
476                 assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
477                 assertEquals(newName, actualComponentInstance.getName());
478                 assertEquals(newName.toLowerCase(), actualComponentInstance.getNormalizedName());
479         }
480
481         @Test(enabled = false)
482         public void updateServiceInstanceNameRemoveSpacesFromBiginningAndEnd() throws Exception {
483                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
484                                 .getComponentResourceInstance(serviceDetails_01);
485                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
486                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
487                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
488                 String newName = "  Abcd   ";
489                 String expectedNewName = "  Abcd   ";
490                 serviceInstanceReqDetails.setName(newName);
491                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
492                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
493                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
494                 String instanceNormalizedName = ResponseParser
495                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
496                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
497                                 "name");
498                 assertEquals("check Resource Instance normalizedName ", (expectedNewName).toLowerCase(),
499                                 instanceNormalizedName);
500                 assertEquals("check Resource Instance Name ", expectedNewName, instanceName);
501                 // get product and verify that service instanceName is correct
502                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
503                                 sdncPmDetails1.getUserId());
504                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
505                                 Product.class);
506                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
507                 assertEquals(expectedNewName, actualComponentInstance.getName());
508                 assertEquals((expectedNewName).toLowerCase(), actualComponentInstance.getNormalizedName());
509         }
510
511         // pass
512         @Test
513         public void updateServiceInstanceNameAllowedCharacters() throws Exception {
514                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
515                                 .getComponentResourceInstance(serviceDetails_01);
516                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
517                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
518                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
519                 String newName = "qwer-TYUIOP_asd_0987654321.Abcd";
520                 String ExpectedNormalizName = "qwertyuiopasd0987654321abcd";
521                 serviceInstanceReqDetails.setName(newName);
522                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
523                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
524                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
525                 String instanceNormalizedName = ResponseParser
526                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
527                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
528                                 "name");
529                 assertEquals("check Resource Instance normalizedName ", ExpectedNormalizName, instanceNormalizedName);
530                 assertEquals("check Resource Instance Name ", newName, instanceName);
531                 // get product and verify that service instanceName is correct
532                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
533                                 sdncPmDetails1.getUserId());
534                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
535                                 Product.class);
536                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
537                 assertEquals(newName, actualComponentInstance.getName());
538                 assertEquals(ExpectedNormalizName, actualComponentInstance.getNormalizedName());
539
540         }
541
542         @Test
543         public void updateInstanceNameInvalidCharacters() throws Exception {
544                 char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
545                                 '|', '\\', ',' };
546                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
547                                 .getComponentResourceInstance(serviceDetails_01);
548                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
549                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
550                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
551                 String newName = "Abcd1";
552                 String updateName;
553                 for (int i = 0; i < invalidChars.length; i++) {
554                         updateName = newName + invalidChars[i];
555                         serviceInstanceReqDetails.setName(updateName);
556                         RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
557                                         serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(),
558                                         ComponentTypeEnum.PRODUCT);
559                         assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT,
560                                         updateServiceInstanceResponse.getErrorCode().intValue());
561                         ArrayList<String> varibales = new ArrayList<String>();
562                         varibales.add("Service Instance");
563                         ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), varibales,
564                                         updateServiceInstanceResponse.getResponse());
565                 }
566         }
567
568         // pass
569         @Test
570         public void updateInstanceNameMaxLength() throws Exception {
571                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
572                                 .getComponentResourceInstance(serviceDetails_01);
573                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
574                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
575                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
576                 String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl12345";
577                 serviceInstanceReqDetails.setName(newName);
578                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
579                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
580                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
581                 String instanceNormalizedName = ResponseParser
582                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
583                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
584                                 "name");
585                 assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
586                 assertEquals("check Resource Instance Name ", newName, instanceName);
587                 // get product and verify that service instanceName is correct
588                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
589                                 sdncPmDetails1.getUserId());
590                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
591                                 Product.class);
592                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
593                 assertEquals(newName, actualComponentInstance.getName());
594                 assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
595         }
596
597         @Test
598         public void updateInstanceNameExceedMaxLength() throws Exception {
599                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
600                                 .getComponentResourceInstance(serviceDetails_01);
601                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
602                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
603                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
604                 String expectedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
605                 String expectedNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(),
606                                 "normalizedName");
607                 String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456";
608                 serviceInstanceReqDetails.setName(newName);
609                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
610                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
611                 assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT,
612                                 updateServiceInstanceResponse.getErrorCode().intValue());
613                 ArrayList<String> varibales = new ArrayList<String>();
614                 varibales.add("Service Instance");
615                 varibales.add("50");
616                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), varibales,
617                                 updateServiceInstanceResponse.getResponse());
618                 // get product and verify that service instanceName is correct
619                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
620                                 sdncPmDetails1.getUserId());
621                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
622                                 Product.class);
623                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
624                 assertEquals(expectedName, actualComponentInstance.getName());
625                 assertEquals(expectedNormalizedName, actualComponentInstance.getNormalizedName());
626         }
627
628         @Test
629         public void updateServiceInstanceNameEmpty() throws Exception {
630                 // see US534663 In case a PS/PM removes the current service instance
631                 // name then BE has to generate again the "default" service instance
632                 // name
633                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
634                                 .getComponentResourceInstance(serviceDetails_01);
635                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
636                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
637                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
638                 String newName = "";
639                 serviceInstanceReqDetails.setName(newName);
640                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
641                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
642                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
643                 String instanceNormalizedName = ResponseParser
644                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
645                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
646                                 "name");
647                 assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(),
648                                 instanceNormalizedName);
649                 assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName);
650                 // get product and verify that service instanceName is correct
651                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
652                                 sdncPmDetails1.getUserId());
653                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
654                                 Product.class);
655                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
656                 assertEquals(instanceName, actualComponentInstance.getName());
657                 assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
658         }
659
660         // pass
661         @Test
662         public void updateServiceInstanceNameNull() throws Exception {
663                 // see US534663 In case a PS/PM removes the current service instance
664                 // name then BE has to generate again the "default" service instance
665                 // name
666                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
667                                 .getComponentResourceInstance(serviceDetails_01);
668                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
669                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
670                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
671                 String newName = null;
672                 serviceInstanceReqDetails.setName(newName);
673                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
674                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
675                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
676                 String instanceNormalizedName = ResponseParser
677                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
678                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
679                                 "name");
680                 assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(),
681                                 instanceNormalizedName);
682                 assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName);
683                 // get product and verify that service instanceName is correct
684                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
685                                 sdncPmDetails1.getUserId());
686                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
687                                 Product.class);
688                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
689                 assertEquals(instanceName, actualComponentInstance.getName());
690                 assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
691         }
692
693         @Test
694         public void updateServiceInstanceCheckedByOtherUser() throws Exception {
695                 // see US534663 In case a PS/PM removes the current service instance
696                 // name then BE has to generate again the "default" service instance
697                 // name
698                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
699                                 .getComponentResourceInstance(serviceDetails_01);
700                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
701                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
702                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
703                 String newName = "blabla";
704                 serviceInstanceReqDetails.setName(newName);
705                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
706                                 serviceInstanceReqDetails, sdncPmDetails2, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
707                 assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
708                                 updateServiceInstanceResponse.getErrorCode().intValue());
709                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
710                                 updateServiceInstanceResponse.getResponse());
711         }
712
713         @Test
714         public void updateServiceInstance_UserIdIsNonAsdcUser() throws Exception {
715                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
716                                 .getComponentResourceInstance(serviceDetails_01);
717                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
718                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
719                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
720                 String newName = "blabla";
721                 serviceInstanceReqDetails.setName(newName);
722                 User nonSdncUserDetails = new User();
723                 nonSdncUserDetails.setUserId("bt4567");
724                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
725                                 serviceInstanceReqDetails, nonSdncUserDetails, productDetails_01.getUniqueId(),
726                                 ComponentTypeEnum.PRODUCT);
727                 assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
728                                 updateServiceInstanceResponse.getErrorCode().intValue());
729                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
730                                 updateServiceInstanceResponse.getResponse());
731         }
732
733         @Test
734         public void updateServiceInstanceNameToAlreadyExisting() throws Exception {
735                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
736                                 .getComponentResourceInstance(serviceDetails_01);
737                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
738                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
739                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
740                 String ServiceName1 = ResponseParser.getNameFromResponse(createServiceInstanceResp);
741                 createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails,
742                                 sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
743                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
744                 // Update service instance2 name to service instance1
745                 serviceInstanceReqDetails.setName(ServiceName1);
746                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
747                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
748                 assertEquals("Check response code ", STATUS_CODE_ALREADY_EXISTS,
749                                 updateServiceInstanceResponse.getErrorCode().intValue());
750                 ArrayList<String> varibales = new ArrayList<String>();
751                 varibales.add("Service Instance");
752                 varibales.add(ServiceName1);
753                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales,
754                                 updateServiceInstanceResponse.getResponse());
755         }
756
757         @Test
758         public void updateServiceInstanceForNonExistingProduct() throws Exception {
759                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
760                                 .getComponentResourceInstance(serviceDetails_01);
761                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
762                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
763                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
764                 String newName = "blabla";
765                 serviceInstanceReqDetails.setName(newName);
766                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
767                                 serviceInstanceReqDetails, sdncPmDetails1, "blablabla", ComponentTypeEnum.PRODUCT);
768                 AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
769                                 updateServiceInstanceResponse.getErrorCode().intValue());
770                 ArrayList<String> varibales = new ArrayList<String>();
771                 varibales.add("");
772                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales,
773                                 updateServiceInstanceResponse.getResponse());
774
775         }
776
777         @Test
778         public void updateNonExistingServiceInstance() throws Exception {
779                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
780                                 .getComponentResourceInstance(serviceDetails_01);
781                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
782                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
783                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
784                 String newName = "blabla";
785                 serviceInstanceReqDetails.setName(newName);
786                 serviceInstanceReqDetails.setUniqueId("11111111");
787                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
788                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
789                 ArrayList<String> varibales = new ArrayList<String>();
790                 varibales.add(newName);
791                 varibales.add("service instance");
792                 AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
793                                 updateServiceInstanceResponse.getErrorCode().intValue());
794                 // need to change ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name() to
795                 // ActionStatus.SERVICE_INSTANCE_NOT_FOUND.name()
796                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND.name(), varibales,
797                                 updateServiceInstanceResponse.getResponse());
798         }
799
800         @Test
801         public void updateServiceInstanceLocation() throws Exception {
802                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
803                                 .getComponentResourceInstance(serviceDetails_01);
804                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
805                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
806                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
807                 serviceInstanceReqDetails.setPosX("50");
808                 serviceInstanceReqDetails.setPosY("100");
809                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
810                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
811                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
812                 // get product and verify that service instanceName is correct
813                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
814                                 sdncPmDetails1.getUserId());
815                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
816                                 Product.class);
817                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
818                 assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
819                 assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
820         }
821
822         @Test
823         public void updateServiceInstanceToNonExistingLocation() throws Exception {
824                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
825                                 .getComponentResourceInstance(serviceDetails_01);
826                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
827                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
828                 String nameFromResponse = ResponseParser.getNameFromResponse(createServiceInstanceResp);
829                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
830                 serviceInstanceReqDetails.setPosX("-50");
831                 serviceInstanceReqDetails.setPosY("-100");
832                 serviceInstanceReqDetails.setName(nameFromResponse);
833                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
834                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
835                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
836                 // get product and verify that service instanceName is correct
837                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
838                                 sdncPmDetails1.getUserId());
839                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
840                                 Product.class);
841                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
842                 assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
843                 assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
844                 assertEquals(nameFromResponse, actualComponentInstance.getName());
845         }
846
847         @Test
848         public void updateServiceInstanceLocationNameIsEmpty() throws Exception {
849                 String expectedServiceInstanceName = serviceDetails_01.getName() + " 2";
850                 String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "2";
851                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
852                                 .getComponentResourceInstance(serviceDetails_01);
853                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
854                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
855                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
856                 serviceInstanceReqDetails.setPosX("100");
857                 serviceInstanceReqDetails.setPosY("200");
858                 serviceInstanceReqDetails.setName("");
859                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
860                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
861                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
862                 String nameFromResponse = ResponseParser.getNameFromResponse(updateServiceInstanceResponse);
863                 String postX = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posX");
864                 String postY = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posY");
865                 assertEquals(nameFromResponse, expectedServiceInstanceName);
866                 assertEquals(postX, "100");
867                 assertEquals(postY, "200");
868                 // get product and verify that service instanceName is correct
869                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
870                                 sdncPmDetails1.getUserId());
871                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
872                                 Product.class);
873                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
874                 assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
875                 assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
876                 assertEquals(nameFromResponse, actualComponentInstance.getName());
877                 assertEquals(expectedServiceInstancenormalizedName.toLowerCase(), actualComponentInstance.getNormalizedName());
878         }
879
880         // pass
881         @Test
882         public void updateServiceInstanceNameToProductName() throws Exception {
883                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
884                                 .getComponentResourceInstance(serviceDetails_01);
885                 RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(
886                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
887                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
888                 // ComponentInstance componentInstance =
889                 // ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(),
890                 // ComponentInstance.class);
891                 // addCompInstReqCapToExpected(componentInstance,
892                 // ComponentTypeEnum.PRODUCT);
893                 serviceInstanceReqDetails.setName(productDetails_01.getName());
894                 RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
895                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
896                 ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
897                 String instanceNormalizedName = ResponseParser
898                                 .getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
899                 String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(),
900                                 "name");
901                 assertEquals("check Resource Instance normalizedName ", (serviceInstanceReqDetails.getName()).toLowerCase(),
902                                 instanceNormalizedName);
903                 assertEquals("check Resource Instance Name ", serviceInstanceReqDetails.getName(), instanceName);
904                 // get product and verify that service instanceName is correct
905                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
906                                 sdncPmDetails1.getUserId());
907                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
908                                 Product.class);
909                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
910                 assertEquals(serviceInstanceReqDetails.getName(), actualComponentInstance.getName());
911                 assertEquals((serviceInstanceReqDetails.getName()).toLowerCase(), actualComponentInstance.getNormalizedName());
912         }
913
914         //// Delete Service Instance
915
916         @Test
917         public void deleteAllServiceInstanceFromProduct() throws Exception {
918                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
919                                 sdncPmDetails1);
920                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
921                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
922                 getComponentAndValidateRIs(productDetails_01, 1, 0);
923                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
924                                 sdncPmDetails1);
925                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
926                 getComponentAndValidateRIs(productDetails_01, 0, 0);
927         }
928
929         @Test
930         public void deleteServiceWhileServiceInstanceExistInProduct() throws Exception {
931                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
932                                 sdncPmDetails1);
933                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
934                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
935                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
936                 String serviceInstanceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
937                 getComponentAndValidateRIs(productDetails_01, 2, 0);
938                 // Delete service while service instance of it exist in product
939                 RestResponse deleteServiceResponse = ServiceRestUtils.deleteServiceById(serviceDetails_01.getUniqueId(),
940                                 sdncDesignerDetails.getUserId());
941                 assertTrue(deleteServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
942                 // Get product and verify that service instance still exists
943                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
944                                 sdncPmDetails1.getUserId());
945                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
946                                 Product.class);
947                 // ComponentInstance actualComponentInstance =
948                 // actualProduct.getComponentInstances().get(0);
949                 // assertTrue(serviceInstanceUniqueIdFromResponse ==
950                 // actualComponentInstance.getUniqueId());
951                 getComponentAndValidateRIs(productDetails_01, 2, 0);
952         }
953
954         // pass
955         @Test
956         public void deleteServiceInstanceByPm() throws Exception {
957                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
958                                 sdncPmDetails1);
959                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
960                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
961                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
962                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
963                 getComponentAndValidateRIs(productDetails_01, 2, 0);
964                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
965                                 sdncPmDetails1);
966                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
967                 getComponentAndValidateRIs(productDetails_01, 1, 0);
968         }
969
970         @Test
971         public void deleteServiceInstanceByPmCreatedByPm() throws Exception {
972                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
973                                 LifeCycleStatesEnum.CHECKIN);
974                 ResourceRestUtils.checkSuccess(restResponse);
975                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
976                                 LifeCycleStatesEnum.CHECKOUT);
977                 ResourceRestUtils.checkSuccess(restResponse);
978                 productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
979                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
980                                 sdncPmDetails1);
981                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
982                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
983                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
984                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
985                 getComponentAndValidateRIs(productDetails_01, 2, 0);
986                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
987                                 sdncPmDetails1);
988                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
989                 getComponentAndValidateRIs(productDetails_01, 1, 0);
990         }
991
992         @Test
993         public void deleteServiceInstanceByPmWhichIsCheckedOutByAnotherPm() throws Exception {
994                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
995                                 LifeCycleStatesEnum.CHECKIN);
996                 ResourceRestUtils.checkSuccess(restResponse);
997                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
998                                 LifeCycleStatesEnum.CHECKOUT);
999                 ResourceRestUtils.checkSuccess(restResponse);
1000                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1001                                 sdncPmDetails1);
1002                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1003                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1004                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1005                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1006                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1007                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1008                                 sdncPmDetails2);
1009                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1010                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1011                                 deleteServiceInstanceResp.getResponse());
1012                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1013         }
1014
1015         // DE190189
1016         @Test
1017         public void deleteServiceInstanceByPmCreatedByPs() throws Exception {
1018                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1019                                 sdncPmDetails1);
1020                 String productOldUniqueId = productDetails_01.getUniqueId();
1021                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1022                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1023                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
1024                                 LifeCycleStatesEnum.CHECKIN);
1025                 ResourceRestUtils.checkSuccess(restResponse);
1026                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
1027                                 LifeCycleStatesEnum.CHECKOUT);
1028                 ResourceRestUtils.checkSuccess(restResponse);
1029                 String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
1030                 updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
1031                 // get product and get service instance new uniquId
1032                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
1033                                 sdncPmDetails1.getUserId());
1034                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
1035                                 Product.class);
1036                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
1037                 String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
1038                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1039                                 sdncPmDetails1);
1040                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
1041                 getComponentAndValidateRIs(productDetails_01, 0, 0);
1042         }
1043
1044         // DE190189
1045         @Test
1046         public void deleteServiceInstanceByAdminCreatedByPs() throws Exception {
1047                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1048                                 sdncPmDetails1);
1049                 String productOldUniqueId = productDetails_01.getUniqueId();
1050                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1051                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1052                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
1053                                 LifeCycleStatesEnum.CHECKIN);
1054                 ResourceRestUtils.checkSuccess(restResponse);
1055                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
1056                                 LifeCycleStatesEnum.CHECKOUT);
1057                 ResourceRestUtils.checkSuccess(restResponse);
1058                 String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
1059                 updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
1060                 // get product and get service instance new uniquId
1061                 RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
1062                                 sdncAdminDetails.getUserId());
1063                 Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(),
1064                                 Product.class);
1065                 ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
1066                 String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
1067                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1068                                 sdncAdminDetails);
1069                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
1070                 getComponentAndValidateRIs(productDetails_01, 0, 0);
1071         }
1072
1073         @Test
1074         public void createAndDeleteServiceInstanceByAdmin() throws Exception {
1075                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
1076                                 LifeCycleStatesEnum.CHECKIN);
1077                 ResourceRestUtils.checkSuccess(restResponse);
1078                 restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
1079                                 LifeCycleStatesEnum.CHECKOUT);
1080                 ResourceRestUtils.checkSuccess(restResponse);
1081                 // productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
1082                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1083                                 sdncAdminDetails);
1084                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1085                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1086                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails);
1087                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1088                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1089                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1090                                 sdncAdminDetails);
1091                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
1092                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1093         }
1094
1095         @Test
1096         public void deleteServiceInstanceFromNonCheckOutProduct() throws Exception {
1097                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1098                                 sdncPmDetails1);
1099                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1100                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1101                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1102                 RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
1103                                 LifeCycleStatesEnum.CHECKIN);
1104                 ResourceRestUtils.checkSuccess(restResponse);
1105                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1106                                 sdncPmDetails1);
1107                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1108                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1109                                 deleteServiceInstanceResp.getResponse());
1110                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1111         }
1112
1113         @Test
1114         public void deleteServiceInstanceByDesigner() throws Exception {
1115                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1116                                 sdncPmDetails1);
1117                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1118                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1119                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1120                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1121                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1122                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1123                                 sdncDesignerDetails);
1124                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1125                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1126                                 deleteServiceInstanceResp.getResponse());
1127                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1128         }
1129
1130         @Test
1131         public void deleteServiceInstanceByTester() throws Exception {
1132                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1133                                 sdncPmDetails1);
1134                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1135                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1136                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1137                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1138                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1139                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1140                                 sdncTesterDetails);
1141                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1142                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1143                                 deleteServiceInstanceResp.getResponse());
1144                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1145         }
1146
1147         @Test
1148         public void deleteServiceInstanceByPsWhichIsCheckedOutByAnotherPs() throws Exception {
1149                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1150                                 sdncPmDetails1);
1151                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1152                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1153                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1154                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1155                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1156                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1157                                 sdncPsDetails2);
1158                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1159                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1160                                 deleteServiceInstanceResp.getResponse());
1161                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1162         }
1163
1164         // pass
1165         @Test
1166         public void deleteServiceInstanceByNonAsdcUser() throws Exception {
1167                 User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
1168                 ;
1169                 nonExistingSdncUser.setUserId("bt1234");
1170                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1171                                 sdncPmDetails1);
1172                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1173                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1174                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1175                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1176                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1177                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1178                                 nonExistingSdncUser);
1179                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
1180                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
1181                                 deleteServiceInstanceResp.getResponse());
1182                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1183         }
1184
1185         @Test
1186         public void deleteServiceInstanceFromNonExistingProduct() throws Exception {
1187                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1188                                 sdncPmDetails1);
1189                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1190                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1191                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1192                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1193                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1194                 RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1,
1195                                 "1234567890", serviceInstanceUniqueId, ComponentTypeEnum.PRODUCT);
1196                 assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
1197                 ArrayList<String> varibales = new ArrayList<String>();
1198                 varibales.add("");
1199                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales,
1200                                 deleteResourceInstanceResponse.getResponse());
1201                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1202         }
1203
1204         @Test
1205         public void deleteNonExistingServiceInstanceFromProduct() throws Exception {
1206                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1207                                 sdncPmDetails1);
1208                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1209                 // String serviceInstanceUniqueId =
1210                 // ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1211                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1212                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1213                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1214                 RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1,
1215                                 productDetails_01.getUniqueId(), "1234567890123456unExistingServiceInstance",
1216                                 ComponentTypeEnum.PRODUCT);
1217                 assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
1218                 ArrayList<String> varibales = new ArrayList<String>();
1219                 varibales.add("1234567890123456unExistingServiceInstance");
1220                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales,
1221                                 deleteResourceInstanceResponse.getResponse());
1222                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1223         }
1224
1225         @Test
1226         public void deleteServiceInstanceFromNonSupportedComponentType() throws Exception {
1227                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1228                                 sdncPmDetails1);
1229                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1230                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1231                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1232                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1233                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1234                 RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1,
1235                                 productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.RESOURCE_INSTANCE);
1236                 assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
1237                 ArrayList<String> varibales = new ArrayList<String>();
1238                 varibales.add("null");
1239                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales,
1240                                 deleteResourceInstanceResponse.getResponse());
1241                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1242         }
1243
1244         @Test
1245         public void deleteServiceInstanceComponentTypeIsNotProduct() throws Exception {
1246                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1247                                 sdncPmDetails1);
1248                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1249                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1250                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
1251                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1252                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1253                 RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1,
1254                                 productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.SERVICE);
1255                 assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
1256                 ArrayList<String> varibales = new ArrayList<String>();
1257                 varibales.add("");
1258                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
1259                                 deleteResourceInstanceResponse.getResponse());
1260                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1261         }
1262
1263         @Test
1264         public void deleteServiceInstanceUserIdIsEmpty() throws Exception {
1265                 User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
1266                 nonSdncDetails.setUserId("");
1267                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1268                                 sdncPmDetails1);
1269                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1270                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1271                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1272                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1273                                 nonSdncDetails);
1274                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
1275                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
1276                                 deleteServiceInstanceResp.getResponse());
1277                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1278         }
1279
1280         @Test
1281         public void deleteCertifiedServiceInstance() throws Exception {
1282                 changeServiceStateToCertified(serviceDetails_01);
1283                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1284                                 sdncPmDetails1);
1285                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1286                 String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1287                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
1288                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1289                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1290                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01,
1291                                 sdncPmDetails1);
1292                 assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
1293                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1294         }
1295
1296         ////////////////////////////////////
1297
1298         private void certifyVf(ResourceReqDetails resource) throws Exception {
1299                 RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01,
1300                                 sdncDesignerDetails);
1301                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
1302                 String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
1303
1304                 createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_02,
1305                                 sdncDesignerDetails);
1306                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
1307                 String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
1308
1309                 createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01,
1310                                 sdncDesignerDetails);
1311                 ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
1312                 String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
1313
1314                 // Fixing Vl/Cp req/cap
1315                 ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
1316                 User user = sdncDesignerDetails;
1317                 fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType);
1318                 consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType);
1319
1320                 RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
1321                                 sdncDesignerDetails, resource.getUniqueId());
1322                 ResourceRestUtils.checkSuccess(response);
1323                 RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
1324                 ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
1325         }
1326
1327         private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
1328                 RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
1329                                 LifeCycleStatesEnum.CHECKIN);
1330                 ResourceRestUtils.checkSuccess(restResponse);
1331                 restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
1332                                 LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1333                 if (restResponse.getErrorCode() == 200) {
1334                         restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
1335                                         LifeCycleStatesEnum.STARTCERTIFICATION);
1336                 } else
1337                         return restResponse;
1338                 if (restResponse.getErrorCode() == 200) {
1339                         restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
1340                                         LifeCycleStatesEnum.CERTIFY);
1341                         if (restResponse.getErrorCode() == 200) {
1342                                 String newVersion = ResponseParser.getVersionFromResponse(restResponse);
1343                                 resourceDetails.setVersion(newVersion);
1344                                 resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
1345                                 resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
1346                                 resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
1347                                 String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
1348                                                 "uniqueId");
1349                                 resourceDetails.setUniqueId(uniqueIdFromRresponse);
1350                         }
1351                 }
1352                 return restResponse;
1353         }
1354
1355         private RestResponse changeServiceStateToCertified(ServiceReqDetails serviceDetails) throws Exception {
1356                 /*
1357                  * RestResponse restResponse =
1358                  * LifecycleRestUtils.changeServiceState(serviceDetails,
1359                  * sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
1360                  * ResourceRestUtils.checkSuccess(restResponse);
1361                  */
1362                 RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
1363                                 LifeCycleStatesEnum.CERTIFICATIONREQUEST);
1364                 if (restResponse.getErrorCode() == 200) {
1365                         restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
1366                                         LifeCycleStatesEnum.STARTCERTIFICATION);
1367                 } else
1368                         return restResponse;
1369                 if (restResponse.getErrorCode() == 200) {
1370                         restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
1371                                         LifeCycleStatesEnum.CERTIFY);
1372                         if (restResponse.getErrorCode() == 200) {
1373                                 serviceDetails.setVersion("1.0");
1374                                 serviceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
1375                                 serviceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
1376                                 serviceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
1377                                 String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
1378                                                 "uniqueId");
1379                                 serviceDetails.setUniqueId(uniqueIdFromRresponse);
1380                         }
1381                 }
1382                 return restResponse;
1383         }
1384
1385         @Test
1386         public void deleteServiceInstanceTest() throws Exception {
1387                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1388                                 sdncPmDetails1);
1389                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1390                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1391                 String compInstId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1392
1393                 createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
1394                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1395                 getComponentAndValidateRIs(productDetails_01, 2, 0);
1396                 String compInstId2 = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1397
1398                 RestResponse deleteServiceInstanceResp = deleteServiceInstance(compInstId, productDetails_01, sdncPmDetails1);
1399                 ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
1400                 getComponentAndValidateRIs(productDetails_01, 1, 0);
1401
1402                 deleteServiceInstanceResp = deleteServiceInstance(compInstId2, productDetails_01, sdncPmDetails1);
1403                 ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
1404                 getComponentAndValidateRIs(productDetails_01, 0, 0);
1405         }
1406
1407         @Test
1408         public void returnedServiceInstanceTypeAttributeTest() throws Exception {
1409                 String expectedServiceType = ComponentTypeEnum.SERVICE.getValue().toUpperCase();
1410
1411                 RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
1412                                 sdncPmDetails1);
1413                 ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
1414                 String serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
1415                 ComponentInstanceRestUtils.checkComponentInstanceType(createServiceInstanceResp, expectedServiceType);
1416
1417                 RestResponse getProductResp = ProductRestUtils.getProduct(productDetails_01.getUniqueId(),
1418                                 sdncPsDetails1.getUserId());
1419                 ProductRestUtils.checkSuccess(getProductResp);
1420                 Product productObject = ResponseParser.parseToObjectUsingMapper(getProductResp.getResponse(), Product.class);
1421                 List<ComponentInstance> productComponentInstances = productObject.getComponentInstances();
1422                 for (ComponentInstance comp : productComponentInstances) {
1423                         String actualOriginType = comp.getOriginType().getValue().toUpperCase();
1424                         assertTrue(expectedServiceType.equals(actualOriginType));
1425                 }
1426
1427                 ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory
1428                                 .getComponentResourceInstance(serviceDetails_02);
1429                 serviceInstanceReqDetails.setUniqueId(serviceUniqueIdFromResponse);
1430                 serviceInstanceReqDetails.setComponentUid(serviceDetails_01.getUniqueId());
1431                 RestResponse updateResourceInstance = ComponentInstanceRestUtils.updateComponentInstance(
1432                                 serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
1433                 ComponentInstanceRestUtils.checkSuccess(updateResourceInstance);
1434                 ComponentInstanceRestUtils.checkComponentInstanceType(updateResourceInstance, expectedServiceType);
1435
1436         }
1437 }