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