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