[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / property / ComponentInstancePropertyTest.java
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.property;
22
23 import static org.testng.AssertJUnit.assertTrue;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import org.junit.Rule;
29 import org.junit.rules.TestName;
30 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
31 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
32 import org.openecomp.sdc.be.model.ComponentInstance;
33 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
34 import org.openecomp.sdc.be.model.Resource;
35 import org.openecomp.sdc.be.model.Service;
36 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
37 import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
42 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
43 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
44 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
45 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
46 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
47 import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
48 import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
49 import org.testng.annotations.BeforeMethod;
50 import org.testng.annotations.Test;
51
52 import fj.data.Either;
53
54 // open bug for this class: DE199108 - closed, DE199741
55 public class ComponentInstancePropertyTest extends ComponentBaseTest {
56
57         protected Resource basicVFC;
58         protected Resource vfc1FromBasicVFC;
59         protected Resource vfc2FromVfc1;
60         protected Resource vfResource;
61
62         private List<ComponentInstanceProperty> expectedPropertyList;
63         private List<ComponentInstanceProperty> actualPropertyList;
64         // protected String updatedStringValue = "{Not Default String Value}";
65         protected String updatedStringValue = "Not Default String Value";
66         protected String updatedIntegerValue = "666";
67         protected String updatedBooleanValue = "false";
68         protected String newStringPropName = "stringProp2";
69         protected String newIntegerPropName = "integerProp2";
70         protected String newBooleanPropName = "booleanProp2";
71         // bug DE199741 protected String newStringPropValue = "<second string
72         // value>";
73         protected String newStringPropValue = "second string value";
74         protected String newIntegerPropValue = "888";
75         protected String newBooleanPropValue = "false";
76
77         @BeforeMethod
78         public void init() {
79                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
80                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
81         }
82
83         @Rule
84         public static TestName name = new TestName();
85
86         public ComponentInstancePropertyTest() {
87                 super(name, ComponentInstancePropertyTest.class.getName());
88         }
89
90         // --------------Regular
91         // resource-------------------------------------------------------------------------------
92
93         @Test
94         public void nestedResourceProperty3Levels() throws Exception {
95
96                 // first res
97                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
98                 // second resource
99                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
100                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
101                 // third resource
102                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
103                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
104                 // verify property
105                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
106                 actualPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, actualPropertyList);
107                 assertTrue("check list size failed, expected 3", actualPropertyList.size() == 3);
108
109         }
110
111         // --------------VF
112         // resource-----------------------------------------------------------
113
114         @Test
115         public void nestedVfResourceProperty3Levels() throws Exception {
116
117                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
118                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
119                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
120                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
121                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
122
123                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
124                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
125
126                 // create VF + add RI
127                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
128                                 .value();
129                 ComponentInstance componentInstDetails = AtomicOperationUtils
130                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
131                                 .value();
132                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
133                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
134                                 vfResource);
135                 // verify property
136                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
137                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
138                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
139         }
140
141         @Test
142         public void nestedVfResourceProperty3LevelsAndCpWithProp() throws Exception {
143
144                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
145                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
146                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
147                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
148                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
149
150                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
151                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
152
153                 // four resource
154                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP,
155                                 NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
156                                 .value();
157                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
158                 cpStringProperty.setName("Different Name");
159                 cpStringProperty.setPropertyDefaultValue("Different value from default");
160                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
161                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
162                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
163                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
164                 // create VF + add RI
165                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
166                                 .value();
167                 ComponentInstance componentInstDetails = AtomicOperationUtils
168                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
169                                 .value();
170                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
171                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
172                                 vfResource);
173                 componentInstDetails = AtomicOperationUtils
174                                 .addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
175                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
176                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, cp, expectedPropertyList,
177                                 vfResource);
178                 // verify property
179                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
180                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
181                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
182         }
183
184         @Test
185         public void nestedCertifiedVfResourceProperty3Levels() throws Exception {
186                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
187                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
188                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
189                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
190                                 LifeCycleStatesEnum.CERTIFY, vfc1FromBasicVFC);
191
192                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
193                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
194                 // create VF + add RI
195                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
196                                 .value();
197                 ComponentInstance componentInstDetails = AtomicOperationUtils
198                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
199                                 .value();
200                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
201                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
202                                 vfResource);
203                 // verify property
204                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
205                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
206                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
207                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
208                                 vfResource);
209                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
210                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
211         }
212
213         @Test
214         public void nestedVfResourceProperty3Levels2SameResInstances() throws Exception {
215
216                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
217                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
218                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
219                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
220                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
221
222                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
223                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
224                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
225                 // create VF + add RI
226                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
227                                 .value();
228                 ComponentInstance componentInstDetails = AtomicOperationUtils
229                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
230                                 .value();
231                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
232                 // verify property
233                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
234                                 vfResource);
235
236                 componentInstDetails = AtomicOperationUtils
237                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
238                                 .value();
239                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
240                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
241                                 vfResource);
242                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
243                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
244                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
245         }
246
247         // ------------------update resource
248         // property-----------------------------------
249
250         @Test
251         public void nestedVfResourceProperty3LevelsUpdateFirstLevelProperty() throws Exception {
252                 // first res
253                 basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
254                                 NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
255                                 .value();
256                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
257                                 .addDefaultPropertyToResource(PropertyTypeEnum.STRING, basicVFC, UserRoleEnum.DESIGNER, true);
258                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
259                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
260                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
261
262                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
263                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
264                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
265                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
266
267                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
268                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
269
270                 // create VF + add RI
271                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
272                                 .value();
273                 ComponentInstance componentInstDetails = AtomicOperationUtils
274                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
275                                 .value();
276                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
277                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
278                                 vfResource);
279
280                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
281                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
282
283                 // verify property
284                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
285
286                 // update property
287                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
288                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
289                 expectedUpdatePropDetails.setValue(updatedStringValue);
290                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
291                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
292                                 .updatePropertyValueOnResourceInstance(vfResource, componentInstDetails,
293                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
294                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
295                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
296
297                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
298
299                 actualPropertyList = new ArrayList<>();
300                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
301
302                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
303                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
304                 assertTrue("property was not updated propely",
305                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
306
307         }
308
309         @Test
310         public void nestedVfResourceProperty3LevelsUpdateSecondLevelProperty() throws Exception {
311                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
312
313                 // second resource
314                 vfc1FromBasicVFC = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC,
315                                 basicVFC, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left().value();
316                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
317                                 .addCustomPropertyToResource(ElementFactory.getDefaultIntegerProperty(), vfc1FromBasicVFC,
318                                                 UserRoleEnum.DESIGNER, true);
319                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
320                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
321                 AtomicOperationUtils.changeComponentState(vfc1FromBasicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY,
322                                 true);
323
324                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
325                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
326
327                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
328                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
329
330                 // create VF + add RI
331                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
332                                 .value();
333                 ComponentInstance componentInstDetails = AtomicOperationUtils
334                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
335                                 .value();
336                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
337                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
338                                 vfResource);
339                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
340                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
341
342                 // verify property
343                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
344
345                 // update property
346                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
347                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
348                 expectedUpdatePropDetails.setValue(updatedIntegerValue);
349                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
350                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
351                                 .updatePropertyValueOnResourceInstance(vfResource, componentInstDetails,
352                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
353                 assertTrue(
354                                 "expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS
355                                                 + " ,but was " + updatePropertyValueOnResourceInstance.getErrorCode(),
356                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
357
358                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
359
360                 actualPropertyList = new ArrayList<>();
361                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
362                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
363                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
364                 assertTrue("property was not updated properly",
365                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
366
367         }
368
369         @Test
370         public void nestedVfResourceProperty3LevelsUpdateThirdLevelProperty() throws Exception {
371
372                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
373                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
374                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
375
376                 // third resource
377                 vfc2FromVfc1 = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC,
378                                 vfc1FromBasicVFC, ResourceCategoryEnum.GENERIC_DATABASE, UserRoleEnum.DESIGNER, true).left().value();
379                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
380                                 .addCustomPropertyToResource(ElementFactory.getDefaultBooleanProperty(), vfc2FromVfc1,
381                                                 UserRoleEnum.DESIGNER, true);
382                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
383                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
384                 AtomicOperationUtils.changeComponentState(vfc2FromVfc1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN,
385                                 true);
386
387                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
388                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
389
390                 // create VF + add RI
391                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
392                                 .value();
393                 ComponentInstance componentInstDetails = AtomicOperationUtils
394                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
395                                 .value();
396                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
397                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
398                                 vfResource);
399                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
400                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
401
402                 // verify property
403                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
404
405                 // update property
406                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
407                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
408                 expectedUpdatePropDetails.setValue(updatedBooleanValue);
409                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
410                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
411                                 .updatePropertyValueOnResourceInstance(vfResource, componentInstDetails,
412                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
413                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
414                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
415
416                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
417
418                 actualPropertyList = new ArrayList<>();
419                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
420                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
421                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
422                 assertTrue("property was not updated propely",
423                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
424
425         }
426
427         // ---------------------Service------------------------------------------------------------------------
428
429         /**
430          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
431          */
432         @Test
433         public void serviceWithNestedResourceProperty3Levels() throws Exception {
434
435                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
436                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
437                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
438                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
439                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
440                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
441                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
442
443                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
444                                 .value();
445                 ComponentInstance componentInstDetails = AtomicOperationUtils
446                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
447                                 .value();
448                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
449                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
450                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
451                                 vfResource);
452                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
453                 componentInstDetails = AtomicOperationUtils
454                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
455                                 .value();
456                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
457                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
458                                 expectedPropertyList);
459                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
460                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
461
462         }
463
464         /**
465          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
466          * (p1)
467          */
468         @Test
469         public void serviceWithNestedResourceProperty3LevelsAndVfProperty() throws Exception {
470
471                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
472                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
473                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
474                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
475                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
476                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
477                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
478
479                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
480                                 .value();
481                 ComponentInstance componentInstDetails = AtomicOperationUtils
482                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
483                                 .value();
484                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
485                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
486                                 vfResource);
487                 PropertyReqDetails propDetails = ElementFactory.getDefaultBooleanProperty();
488                 propDetails.setName(newBooleanPropName);
489                 propDetails.setPropertyDefaultValue(newBooleanPropValue);
490                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
491                 propDetails = ElementFactory.getDefaultStringProperty();
492                 propDetails.setName(newStringPropName);
493                 propDetails.setPropertyDefaultValue(newStringPropValue);
494                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
495                 propDetails = ElementFactory.getDefaultIntegerProperty();
496                 propDetails.setName(newIntegerPropName);
497                 propDetails.setPropertyDefaultValue(newIntegerPropValue);
498                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
499                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
500                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
501                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfResource, expectedPropertyList);
502
503                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
504                 componentInstDetails = AtomicOperationUtils
505                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
506                                 .value();
507                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
508                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
509                                 expectedPropertyList);
510                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
511                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
512
513         }
514
515         /**
516          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
517          * (p1) CP(VF inst) (p5)
518          */
519         @Test
520         public void serviceWithNestedResourceProperty3LevelsAndCp() throws Exception {
521
522                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
523                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
524                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
525                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
526                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
527                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
528                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
529
530                 // four resource
531                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP,
532                                 NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
533                                 .value();
534                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
535                 cpStringProperty.setName("Different Name");
536                 cpStringProperty.setPropertyDefaultValue("Different value from default");
537                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
538                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
539                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
540                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
541                 // create VF + add RI
542                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
543                                 .value();
544                 ComponentInstance componentInstDetails = AtomicOperationUtils
545                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
546                                 .value();
547                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
548                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
549                                 vfResource);
550                 componentInstDetails = AtomicOperationUtils
551                                 .addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
552                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
553                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
554                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, cp, expectedPropertyList,
555                                 vfResource);
556
557                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
558                 componentInstDetails = AtomicOperationUtils
559                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
560                                 .value();
561                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
562                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
563                                 expectedPropertyList);
564                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
565                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
566
567         }
568
569         /**
570          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
571          * (p1) CP(inst) (p5)
572          */
573         @Test
574         public void serviceWithNestedResourceProperty3LevelsAndCpResInst() throws Exception {
575
576                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
577                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
578                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
579                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
580                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
581                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
582                 // expectedPropertyList =
583                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
584                 // expectedPropertyList);
585
586                 // four resource
587                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP,
588                                 NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
589                                 .value();
590                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
591                 cpStringProperty.setName("Different Name");
592                 cpStringProperty.setPropertyDefaultValue("Different value from default");
593                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
594                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
595                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
596                 // create VF + add RI
597                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
598                                 .value();
599                 ComponentInstance componentInstDetails = AtomicOperationUtils
600                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
601                                 .value();
602                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
603                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
604
605                 // Service
606                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
607                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
608                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
609                                 null);
610                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
611
612                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
613                 componentInstDetails = AtomicOperationUtils
614                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
615                                 .value();
616                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
617                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
618                                 expectedPropertyList);
619                 componentInstDetails = AtomicOperationUtils
620                                 .addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
621                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
622                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
623                                 expectedPropertyList);
624                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
625                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
626
627         }
628
629         /**
630          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) | (p3) (p2) (p1)
631          * | (VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
632          * 
633          * VF2(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) | (p3') (p2') (p1') |
634          * (VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
635          */
636         @Test
637         public void serviceNestedVfResourceProperty3Levels2SameResInstances() throws Exception {
638
639                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
640                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
641                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
642                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
643                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
644                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
645
646                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
647                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
648
649                 // create VF + add RI
650                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
651                                 .value();
652                 ComponentInstance componentInstDetails = AtomicOperationUtils
653                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
654                                 .value();
655                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
656                 // verify property
657                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
658                                 vfResource);
659
660                 componentInstDetails = AtomicOperationUtils
661                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
662                                 .value();
663                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
664                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList,
665                                 vfResource);
666                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
667                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
668                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
669                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
670
671                 // Service
672                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
673                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
674                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
675                                 null);
676                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
677                                 null);
678                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
679                 componentInstDetails = AtomicOperationUtils
680                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
681                                 .value();
682                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
683                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
684                                 expectedPropertyList);
685                 componentInstDetails = AtomicOperationUtils
686                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
687                                 .value();
688                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
689                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
690                                 expectedPropertyList);
691                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
692                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
693                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
694
695         }
696
697         // service test template
698         /**
699          * Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
700          * (p1)
701          */
702         @Test
703         public void serviceNestedVfResourceProperty3LevelsAndSelfVfProperty() throws Exception {
704
705                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
706                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
707                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
708                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
709                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
710                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
711
712                 // create VF + add RI
713                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
714                                 .value();
715                 ComponentInstance componentInstDetails = AtomicOperationUtils
716                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
717                                 .value();
718                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
719                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
720                 newProp.setName(newStringPropName);
721                 newProp.setPropertyDefaultValue(newStringPropValue);
722                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
723                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
724                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
725
726                 // Service
727                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
728                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
729                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
730                                 null);
731                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
732                 componentInstDetails = AtomicOperationUtils
733                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
734                                 .value();
735                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
736                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
737                                 expectedPropertyList);
738                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
739                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
740                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
741
742         }
743
744         /**
745          * update property(p4)
746          * 
747          * 
748          * VFC(p1) ^ | VFC(p2) ^ | Service-->VF(inst)-->VF-->(VFC(inst)-->VFC(p3)
749          * (p4)
750          */
751         @Test
752         public void serviceNestedVfResourceProperty3LevelsAndSelfVfProperty_UpdateVfproperty() throws Exception {
753                 // Create VFC(check-in state) derived from another resource
754                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
755                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
756                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
757                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
758                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
759                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
760
761                 // create VF + add RI
762                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
763                                 .value();
764                 ComponentInstance componentInstDetails = AtomicOperationUtils
765                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
766                                 .value();
767
768                 // add property to VF
769                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
770                 newProp.setName(newStringPropName);
771                 newProp.setPropertyDefaultValue(newStringPropValue);
772                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
773                                 .addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
774                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
775                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
776                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
777                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
778
779                 // Service
780                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
781                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
782                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
783                                 null);
784                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
785                 componentInstDetails = AtomicOperationUtils
786                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
787                                 .value();
788                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
789                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
790                                 expectedPropertyList);
791
792                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
793                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
794                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
795
796                 // update VF instance property
797                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
798                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
799                 expectedUpdatePropDetails.setValue(updatedStringValue);
800                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
801                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
802                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
803                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
804                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
805                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
806
807                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
808
809                 actualPropertyList = new ArrayList<>();
810                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
811
812                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
813                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
814                 assertTrue("property was not updated propely",
815                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
816
817         }
818
819         /**
820          * update property(p1)
821          * Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
822          * (p1)
823          */
824         @Test
825         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance1LevelProperty()
826                         throws Exception {
827
828                 basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
829                                 NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
830                                 .value();
831                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
832                                 .addDefaultPropertyToResource(PropertyTypeEnum.STRING, basicVFC, UserRoleEnum.DESIGNER, true);
833                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
834                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
835                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
836                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
837                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
838                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
839                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
840                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
841
842                 // create VF + add RI
843                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
844                                 .value();
845                 ComponentInstance componentInstDetails = AtomicOperationUtils
846                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
847                                 .value();
848                 // verify property
849                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
850                 newProp.setName(newStringPropName);
851                 newProp.setPropertyDefaultValue(newStringPropValue);
852                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
853                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
854                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
855
856                 // Service
857                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
858                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
859                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
860                                 null);
861                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
862                 componentInstDetails = AtomicOperationUtils
863                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
864                                 .value();
865                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
866                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
867                                 expectedPropertyList);
868
869                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
870                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
871                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
872
873                 // update VF property
874                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
875                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
876                 expectedUpdatePropDetails.setValue(updatedStringValue);
877                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
878                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
879                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
880                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
881                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
882                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
883
884                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
885
886                 actualPropertyList = new ArrayList<>();
887                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
888
889                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
890                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
891                 assertTrue("property was not updated propely",
892                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
893
894         }
895
896         /**
897          * update property(p2)
898          * Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
899          * (p1)
900          */
901         @Test
902         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance2LevelProperty()
903                         throws Exception {
904
905                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
906                 vfc1FromBasicVFC = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC,
907                                 basicVFC, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left().value();
908                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
909                                 .addCustomPropertyToResource(ElementFactory.getDefaultIntegerProperty(), vfc1FromBasicVFC,
910                                                 UserRoleEnum.DESIGNER, true);
911                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
912                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
913                 AtomicOperationUtils.changeComponentState(vfc1FromBasicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY,
914                                 true);
915                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
916                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
917                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
918
919                 // create VF + add RI
920                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
921                                 .value();
922                 ComponentInstance componentInstDetails = AtomicOperationUtils
923                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
924                                 .value();
925
926                 // verify property
927                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
928                 newProp.setName(newStringPropName);
929                 newProp.setPropertyDefaultValue(newStringPropValue);
930                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
931                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
932                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
933
934                 // Service
935                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
936                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
937                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
938                                 null);
939                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
940                 componentInstDetails = AtomicOperationUtils
941                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
942                                 .value();
943                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
944                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
945                                 expectedPropertyList);
946
947                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
948                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
949                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
950
951                 // update VF property
952                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
953                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
954                 expectedUpdatePropDetails.setValue(updatedIntegerValue);
955                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
956                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
957                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
958                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
959                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
960                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
961
962                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
963                 actualPropertyList = new ArrayList<>();
964                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
965                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
966                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
967                 assertTrue("property was not updated propely",
968                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
969
970         }
971
972         /**
973          * update property(p3)
974          * Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
975          * (p1)
976          */
977         @Test
978         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance3LevelProperty()
979                         throws Exception {
980
981                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
982                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
983                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
984                 vfc2FromVfc1 = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC,
985                                 vfc1FromBasicVFC, ResourceCategoryEnum.GENERIC_DATABASE, UserRoleEnum.DESIGNER, true).left().value();
986                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils
987                                 .addCustomPropertyToResource(ElementFactory.getDefaultBooleanProperty(), vfc2FromVfc1,
988                                                 UserRoleEnum.DESIGNER, true);
989                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
990                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
991                 AtomicOperationUtils.changeComponentState(vfc2FromVfc1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN,
992                                 true);
993                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
994
995                 // create VF + add RI
996                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
997                                 .value();
998                 ComponentInstance componentInstDetails = AtomicOperationUtils
999                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
1000                                 .value();
1001                 // verify property
1002                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
1003                 newProp.setName(newStringPropName);
1004                 newProp.setPropertyDefaultValue(newStringPropValue);
1005                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
1006                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
1007                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
1008
1009                 // Service
1010                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
1011                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
1012                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
1013                                 null);
1014                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
1015                 componentInstDetails = AtomicOperationUtils
1016                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
1017                                 .value();
1018                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1019                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
1020                                 expectedPropertyList);
1021
1022                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1023                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1024                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
1025
1026                 // update VF property
1027                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils
1028                                 .getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
1029                 expectedUpdatePropDetails.setValue(updatedBooleanValue);
1030                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
1031                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
1032                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
1033                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
1034                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
1035                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1036
1037                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1038
1039                 actualPropertyList = new ArrayList<>();
1040                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1041
1042                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
1043                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
1044                 assertTrue("property was not updated propely",
1045                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
1046
1047         }
1048
1049         /**
1050          * update property p5'
1051          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
1052          * (p1) CP(inst on VF) (p5) CP(inst) (p5')
1053          */
1054         @Test
1055         public void serviceWithNestedResourceProperty3LevelsAndCpOnVfUpdateCpInstanceOfService() throws Exception {
1056                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
1057                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
1058                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
1059                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
1060                                 LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
1061                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
1062                 // expectedPropertyList =
1063                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
1064                 // expectedPropertyList);
1065
1066                 // four resource
1067                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP,
1068                                 NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
1069                                 .value();
1070                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
1071                 cpStringProperty.setName("Different Name");
1072                 cpStringProperty.setPropertyDefaultValue("Different value from default");
1073                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
1074                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1075                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
1076                 // create VF + add RI
1077                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
1078                                 .value();
1079                 ComponentInstance componentInstDetails = AtomicOperationUtils
1080                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
1081                                 .value();
1082                 componentInstDetails = AtomicOperationUtils
1083                                 .addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
1084                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
1085                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
1086
1087                 // Service
1088                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
1089                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
1090                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
1091                                 null);
1092                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
1093
1094                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
1095                 componentInstDetails = AtomicOperationUtils
1096                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
1097                                 .value();
1098                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1099                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
1100                                 expectedPropertyList);
1101
1102                 componentInstDetails = AtomicOperationUtils
1103                                 .addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
1104                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1105                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
1106                                 expectedPropertyList);
1107
1108                 // service = AtomicOperationUtils.getServiceObject(service,
1109                 // UserRoleEnum.DESIGNER);
1110                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1111                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
1112
1113                 String propNameToUpdate = "cidr";
1114                 String propTypeToUpdate = "string";
1115
1116                 // update CP property
1117                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(
1118                                 service, componentInstDetails, propNameToUpdate, propTypeToUpdate);
1119                 expectedUpdatePropDetails.setValue(updatedStringValue);
1120                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
1121                 List<String> path = expectedUpdatePropDetails.getPath();
1122                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
1123                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
1124                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
1125                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
1126                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1127
1128                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1129
1130                 actualPropertyList = new ArrayList<>();
1131                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1132
1133                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
1134                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, path);
1135                 assertTrue("property was not updated propely",
1136                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
1137         }
1138
1139         /**
1140          * update property p5
1141          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2)
1142          * (p1) CP(inst on VF) (p5) CP(inst) (p5')
1143          */
1144         @Test
1145         public void serviceWithNestedResourceProperty3LevelsAndCpOnVfUpdateCpInstanceOfVf() throws Exception {
1146                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
1147                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(
1148                                 ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
1149                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(),
1150                                 LifeCycleStatesEnum.CERTIFY, vfc1FromBasicVFC);
1151                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
1152                 // expectedPropertyList =
1153                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
1154                 // expectedPropertyList);
1155
1156                 // four resource
1157                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP,
1158                                 NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
1159                                 .value();
1160                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
1161                 cpStringProperty.setName("Different Name");
1162                 cpStringProperty.setPropertyDefaultValue("Different value from default");
1163                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
1164                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
1165                 // create VF + add RI
1166                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
1167                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left()
1168                                 .value();
1169                 ComponentInstance componentInstDetails = AtomicOperationUtils
1170                                 .addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left()
1171                                 .value();
1172                 componentInstDetails = AtomicOperationUtils
1173                                 .addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
1174                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
1175                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
1176
1177                 // Service
1178                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
1179                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
1180                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList,
1181                                 null);
1182                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
1183
1184                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
1185                 componentInstDetails = AtomicOperationUtils
1186                                 .addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left()
1187                                 .value();
1188                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1189                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
1190                                 expectedPropertyList);
1191
1192                 componentInstDetails = AtomicOperationUtils
1193                                 .addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
1194                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1195                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service,
1196                                 expectedPropertyList);
1197
1198                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1199                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1200                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
1201
1202                 String propNameToUpdate = "cidr";
1203                 String propTypeToUpdate = "string";
1204
1205                 // update CP property
1206                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(
1207                                 service, componentInstDetails, propNameToUpdate, propTypeToUpdate);
1208                 expectedUpdatePropDetails.setValue(updatedStringValue);
1209                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
1210                 List<String> path = expectedUpdatePropDetails.getPath();
1211                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils
1212                                 .updatePropertyValueOnResourceInstance(service, componentInstDetails,
1213                                                 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
1214                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS,
1215                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
1216
1217                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
1218
1219                 actualPropertyList = new ArrayList<>();
1220                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
1221
1222                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils
1223                                 .getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, path);
1224                 assertTrue("property was not updated propely",
1225                                 PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
1226         }
1227
1228         // -------------------Methods--------------------------
1229         public static PropertyDataDefinition convertToPropertyDataDefinitionObject(PropertyReqDetails prop) {
1230                 PropertyDataDefinition propDataDef = new PropertyDataDefinition();
1231                 propDataDef.setDefaultValue(prop.getPropertyDefaultValue());
1232                 propDataDef.setType(prop.getPropertyType());
1233                 propDataDef.setPassword(prop.getPropertyPassword());
1234                 propDataDef.setDescription(prop.getPropertyDescription());
1235                 return propDataDef;
1236         }
1237
1238         protected Resource createResourceWithPropertyDerivedFromOtherResource(PropertyReqDetails propertyReqDetails,
1239                         LifeCycleStatesEnum state, Resource derivedFromResource) throws Exception {
1240                 Resource resource = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC,
1241                                 derivedFromResource, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left()
1242                                 .value();
1243                 if (propertyReqDetails != null) {
1244                         AtomicOperationUtils.addCustomPropertyToResource(propertyReqDetails, resource, UserRoleEnum.DESIGNER, true);
1245                 }
1246                 AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, state, true);
1247                 return AtomicOperationUtils.getResourceObject(resource, UserRoleEnum.DESIGNER);
1248                 // return resource;
1249         }
1250
1251         protected Resource createResourceWithProperty(PropertyReqDetails propertyReqDetails, LifeCycleStatesEnum state)
1252                         throws Exception {
1253                 Resource resource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
1254                                 NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left()
1255                                 .value();
1256                 if (propertyReqDetails != null) {
1257                         AtomicOperationUtils.addCustomPropertyToResource(propertyReqDetails, resource, UserRoleEnum.DESIGNER, true);
1258                 }
1259                 AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, state, true);
1260                 return AtomicOperationUtils.getResourceObject(resource, UserRoleEnum.DESIGNER);
1261         }
1262
1263 }