Fix for radio buttons
[sdc.git] / asdc-tests / src / main / java / org / openecomp / sdc / ci / tests / execute / property / ComponentInstancePropertyTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.property;
22
23 import static org.testng.AssertJUnit.assertTrue;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import org.apache.http.HttpStatus;
29 import org.junit.Rule;
30 import org.junit.rules.TestName;
31 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
32 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
33 import org.openecomp.sdc.be.model.ComponentInstance;
34 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
35 import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames;
36 import org.openecomp.sdc.be.model.Resource;
37 import org.openecomp.sdc.be.model.Service;
38 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
39 import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
40 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
41 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
42 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
43 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
44 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
45 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
46 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
47 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
48 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
49 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
50 import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
51 import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
52 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
53 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
54 import org.testng.annotations.BeforeMethod;
55 import org.testng.annotations.Test;
56
57 import fj.data.Either;
58
59 // open bug for this class: DE199108 - closed, DE199741
60 public class ComponentInstancePropertyTest extends ComponentBaseTest {
61
62         protected Resource basicVFC;
63         protected Resource vfc1FromBasicVFC;
64         protected Resource vfc2FromVfc1;
65         protected Resource vfResource;
66
67         private List<ComponentInstanceProperty> expectedPropertyList;
68         private List<ComponentInstanceProperty> actualPropertyList;
69         // protected String updatedStringValue = "{Not Default String Value}";
70         protected String updatedStringValue = "Not Default String Value";
71         protected String updatedIntegerValue = "666";
72         protected String updatedBooleanValue = "false";
73         protected String newStringPropName = "stringProp2";
74         protected String newIntegerPropName = "integerProp2";
75         protected String newBooleanPropName = "booleanProp2";
76         // bug DE199741 protected String newStringPropValue = "<second string
77         // value>";
78         protected String newStringPropValue = "second string value";
79         protected String newIntegerPropValue = "888";
80         protected String newBooleanPropValue = "false";
81
82         @BeforeMethod
83         public void init() {
84                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
85                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
86         }
87
88         @Rule
89         public static TestName name = new TestName();
90
91         public ComponentInstancePropertyTest() {
92                 super(name, ComponentInstancePropertyTest.class.getName());
93         }
94
95         // --------------Regular
96         // resource-------------------------------------------------------------------------------
97
98         @Test
99         public void nestedResourceProperty3Levels() throws Exception {
100
101                 // first res
102                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
103                 // second resource
104                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
105                 // third resource
106                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
107                 // verify property
108                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
109                 actualPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, actualPropertyList);
110                 assertTrue("check list size failed, expected 3", actualPropertyList.size() == 3);
111
112         }
113
114         // --------------VF
115         // resource-----------------------------------------------------------
116
117         @Test
118         public void nestedVfResourceProperty3Levels() throws Exception {
119
120                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
121                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
122                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
123
124                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
125                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
126
127                 // create VF + add RI
128                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
129                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
130                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
131                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
132                 // verify property
133                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
134                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
135                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
136         }
137
138         @Test
139         public void nestedVfResourceProperty3LevelsAndCpWithProp() throws Exception {
140
141                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
142                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
143                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
144
145                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
146                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
147
148                 // four resource
149                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
150                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
151                 cpStringProperty.setName("Different Name");
152                 cpStringProperty.setPropertyDefaultValue("Different value from default");
153                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
154                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
155                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
156                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
157                 // create VF + add RI
158                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
159                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
160                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
161                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
162                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
163                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
164                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, cp, expectedPropertyList, vfResource);
165                 // verify property
166                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
167                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
168                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
169         }
170
171         @Test
172         public void nestedCertifiedVfResourceProperty3Levels() throws Exception {
173                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
174                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
175                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CERTIFY, vfc1FromBasicVFC);
176
177                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
178                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
179                 // create VF + add RI
180                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
181                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
182                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
183                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
184                 // verify property
185                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
186                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
187                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
188                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
189                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
190                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
191         }
192
193         @Test
194         public void nestedVfResourceProperty3Levels2SameResInstances() throws Exception {
195
196                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
197                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
198                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
199
200                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
201                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
202                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
203                 // create VF + add RI
204                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
205                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
206                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
207                 // verify property
208                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
209
210                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
211                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
212                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
213                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
214                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
215                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
216         }
217
218         // ------------------update resource
219         // property-----------------------------------
220
221         @Test
222         public void nestedVfResourceProperty3LevelsUpdateFirstLevelProperty() throws Exception {
223                 // first res
224                 basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
225                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addDefaultPropertyToResource(PropertyTypeEnum.STRING, basicVFC, UserRoleEnum.DESIGNER, true);
226                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
227                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
228                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
229
230                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
231                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
232
233                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
234                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
235
236                 // create VF + add RI
237                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
238                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
239                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
240                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
241
242                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
243                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
244
245                 // verify property
246                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
247
248                 // update property
249                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
250                 expectedUpdatePropDetails.setValue(updatedStringValue);
251                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
252                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(vfResource, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
253                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
254
255                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
256
257                 actualPropertyList = new ArrayList<>();
258                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
259
260                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
261                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
262
263         }
264
265         @Test
266         public void nestedVfResourceProperty3LevelsUpdateSecondLevelProperty() throws Exception {
267                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
268
269                 // second resource
270                 vfc1FromBasicVFC = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left().value();
271                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addCustomPropertyToResource(ElementFactory.getDefaultIntegerProperty(), vfc1FromBasicVFC, UserRoleEnum.DESIGNER, true);
272                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
273                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
274                 AtomicOperationUtils.changeComponentState(vfc1FromBasicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
275
276                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
277
278                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
279                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
280
281                 // create VF + add RI
282                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
283                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
284                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
285                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
286                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
287                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
288
289                 // verify property
290                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
291
292                 // update property
293                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
294                 expectedUpdatePropDetails.setValue(updatedIntegerValue);
295                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
296                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(vfResource, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
297                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS + " ,but was " + updatePropertyValueOnResourceInstance.getErrorCode(),
298                                 updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
299
300                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
301
302                 actualPropertyList = new ArrayList<>();
303                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
304                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
305                 assertTrue("property was not updated properly", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
306
307         }
308
309         @Test
310         public void nestedVfResourceProperty3LevelsUpdateThirdLevelProperty() throws Exception {
311
312                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
313                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
314
315                 // third resource
316                 vfc2FromVfc1 = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, vfc1FromBasicVFC, ResourceCategoryEnum.GENERIC_DATABASE, UserRoleEnum.DESIGNER, true).left().value();
317                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addCustomPropertyToResource(ElementFactory.getDefaultBooleanProperty(), vfc2FromVfc1, UserRoleEnum.DESIGNER, true);
318                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
319                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
320                 AtomicOperationUtils.changeComponentState(vfc2FromVfc1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
321
322                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
323                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
324
325                 // create VF + add RI
326                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
327                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
328                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
329                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, 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.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
338                 expectedUpdatePropDetails.setValue(updatedBooleanValue);
339                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
340                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(vfResource, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
341                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
342
343                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
344
345                 actualPropertyList = new ArrayList<>();
346                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
347                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
348                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
349
350         }
351
352         // ---------------------Service------------------------------------------------------------------------
353
354         /**
355          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
356          */
357         @Test
358         public void serviceWithNestedResourceProperty3Levels() throws Exception {
359
360                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
361                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
362                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
363                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
364                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
365
366                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
367                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
368                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
369                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
370                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
371                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
372                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
373                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
374                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
375                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
376                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
377
378         }
379
380         /**
381          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1)
382          */
383         @Test
384         public void serviceWithNestedResourceProperty3LevelsAndVfProperty() throws Exception {
385
386                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
387                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
388                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
389                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
390                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
391
392                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
393                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
394                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
395                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
396                 PropertyReqDetails propDetails = ElementFactory.getDefaultBooleanProperty();
397                 propDetails.setName(newBooleanPropName);
398                 propDetails.setPropertyDefaultValue(newBooleanPropValue);
399                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
400                 propDetails = ElementFactory.getDefaultStringProperty();
401                 propDetails.setName(newStringPropName);
402                 propDetails.setPropertyDefaultValue(newStringPropValue);
403                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
404                 propDetails = ElementFactory.getDefaultIntegerProperty();
405                 propDetails.setName(newIntegerPropName);
406                 propDetails.setPropertyDefaultValue(newIntegerPropValue);
407                 AtomicOperationUtils.addCustomPropertyToResource(propDetails, vfResource, UserRoleEnum.DESIGNER, true);
408                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
409                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
410                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfResource, expectedPropertyList);
411
412                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
413                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
414                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
415                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
416                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
417                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
418
419         }
420
421         /**
422          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1) CP(VF inst) (p5)
423          */
424         @Test
425         public void serviceWithNestedResourceProperty3LevelsAndCp() throws Exception {
426
427                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
428                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
429                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
430                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
431                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
432
433                 // four resource
434                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
435                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
436                 cpStringProperty.setName("Different Name");
437                 cpStringProperty.setPropertyDefaultValue("Different value from default");
438                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
439                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
440                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
441                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
442                 // create VF + add RI
443                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
444                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
445                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
446                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
447                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
448                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
449                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
450                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, cp, expectedPropertyList, vfResource);
451
452                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
453                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
454                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
455                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
456                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
457                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
458
459         }
460
461         /**
462          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1) CP(inst) (p5)
463          */
464         @Test
465         public void serviceWithNestedResourceProperty3LevelsAndCpResInst() throws Exception {
466
467                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
468                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
469                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
470                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
471                 // expectedPropertyList =
472                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
473                 // expectedPropertyList);
474
475                 // four resource
476                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
477                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
478                 cpStringProperty.setName("Different Name");
479                 cpStringProperty.setPropertyDefaultValue("Different value from default");
480                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
481                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
482                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
483                 // create VF + add RI
484                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
485                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
486                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
487                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
488
489                 // Service
490                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
491                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
492                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
493                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
494
495                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
496                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
497                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
498                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
499                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
500                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
501                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
502                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
503                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
504
505         }
506
507         /**
508          * Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) | (p3) (p2) (p1) | (VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
509          * 
510          * VF2(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) | (p3') (p2') (p1') | (VFC(inst)-->VFC-->VFC-->VFC) (p3) (p2) (p1)
511          */
512         @Test
513         public void serviceNestedVfResourceProperty3Levels2SameResInstances() throws Exception {
514
515                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
516                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
517                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
518                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
519
520                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
521                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1, expectedPropertyList);
522
523                 // create VF + add RI
524                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
525                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
526                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
527                 // verify property
528                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
529
530                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
531                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
532                 PropertyRestUtils.updatePropertyListWithPathOnResource(componentInstDetails, vfc2FromVfc1, expectedPropertyList, vfResource);
533                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
534                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
535                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, actualPropertyList, null);
536                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
537
538                 // Service
539                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
540                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
541                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
542                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
543                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
544                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
545                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
546                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
547                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
548                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
549                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
550                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
551                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
552                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
553
554         }
555
556         // service test template
557         /**
558          * Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1)
559          */
560         @Test
561         public void serviceNestedVfResourceProperty3LevelsAndSelfVfProperty() throws Exception {
562
563                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
564                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
565                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
566                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
567
568                 // create VF + add RI
569                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
570                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
571                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
572                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
573                 newProp.setName(newStringPropName);
574                 newProp.setPropertyDefaultValue(newStringPropValue);
575                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
576                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
577                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
578
579                 // Service
580                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
581                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
582                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
583                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
584                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
585                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
586                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
587                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
588                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
589                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
590
591         }
592
593         /**
594          * update property(p4)
595          * 
596          * 
597          * VFC(p1) ^ | VFC(p2) ^ | Service-->VF(inst)-->VF-->(VFC(inst)-->VFC(p3) (p4)
598          */
599         @Test
600         public void serviceNestedVfResourceProperty3LevelsAndSelfVfProperty_UpdateVfproperty() throws Exception {
601                 // Create VFC(check-in state) derived from another resource
602                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
603                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
604                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
605                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
606
607                 // create VF + add RI
608                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
609                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
610
611                 // add property to VF
612                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
613                 newProp.setName(newStringPropName);
614                 newProp.setPropertyDefaultValue(newStringPropValue);
615                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
616                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
617                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
618                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
619                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
620
621                 // Service
622                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
623                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
624                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
625                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
626                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
627                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
628                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
629
630                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
631                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
632                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
633
634                 // update VF instance property
635                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
636                 expectedUpdatePropDetails.setValue(updatedStringValue);
637                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
638                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
639                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
640
641                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
642
643                 actualPropertyList = new ArrayList<>();
644                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
645
646                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
647                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
648
649         }
650
651         /**
652          * update property(p1) Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1)
653          */
654         @Test
655         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance1LevelProperty() throws Exception {
656
657                 basicVFC = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
658                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addDefaultPropertyToResource(PropertyTypeEnum.STRING, basicVFC, UserRoleEnum.DESIGNER, true);
659                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
660                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
661                 AtomicOperationUtils.changeComponentState(basicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
662                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
663                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
664                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
665
666                 // create VF + add RI
667                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
668                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
669                 // verify property
670                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
671                 newProp.setName(newStringPropName);
672                 newProp.setPropertyDefaultValue(newStringPropValue);
673                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
674                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
675                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
676
677                 // Service
678                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
679                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
680                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
681                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
682                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
683                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
684                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
685
686                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
687                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
688                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
689
690                 // update VF property
691                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
692                 expectedUpdatePropDetails.setValue(updatedStringValue);
693                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
694                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
695                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
696
697                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
698
699                 actualPropertyList = new ArrayList<>();
700                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
701
702                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
703                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
704
705         }
706
707         /**
708          * update property(p2) Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1)
709          */
710         @Test
711         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance2LevelProperty() throws Exception {
712
713                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
714                 vfc1FromBasicVFC = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, basicVFC, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left().value();
715                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addCustomPropertyToResource(ElementFactory.getDefaultIntegerProperty(), vfc1FromBasicVFC, UserRoleEnum.DESIGNER, true);
716                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
717                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
718                 AtomicOperationUtils.changeComponentState(vfc1FromBasicVFC, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
719                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
720                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
721
722                 // create VF + add RI
723                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
724                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
725
726                 // verify property
727                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
728                 newProp.setName(newStringPropName);
729                 newProp.setPropertyDefaultValue(newStringPropValue);
730                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
731                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
732                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
733
734                 // Service
735                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
736                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
737                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
738                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
739                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
740                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
741                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
742
743                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
744                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
745                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
746
747                 // update VF property
748                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
749                 expectedUpdatePropDetails.setValue(updatedIntegerValue);
750                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
751                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
752                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
753
754                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
755                 actualPropertyList = new ArrayList<>();
756                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
757                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
758                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
759
760         }
761
762         /**
763          * update property(p3) Service-->VF(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1)
764          */
765         @Test
766         public void serviceNestedVfResourceProperty3LevelsAndSelfVfPropertyUpdateVfInheritance3LevelProperty() throws Exception {
767
768                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
769                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
770                 vfc2FromVfc1 = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, vfc1FromBasicVFC, ResourceCategoryEnum.GENERIC_DATABASE, UserRoleEnum.DESIGNER, true).left().value();
771                 Either<ComponentInstanceProperty, RestResponse> propDetailsToUpdate = AtomicOperationUtils.addCustomPropertyToResource(ElementFactory.getDefaultBooleanProperty(), vfc2FromVfc1, UserRoleEnum.DESIGNER, true);
772                 String propNameToUpdate = propDetailsToUpdate.left().value().getName();
773                 String propTypeToUpdate = propDetailsToUpdate.left().value().getType();
774                 AtomicOperationUtils.changeComponentState(vfc2FromVfc1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
775                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
776
777                 // create VF + add RI
778                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
779                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
780                 // verify property
781                 PropertyReqDetails newProp = ElementFactory.getDefaultStringProperty();
782                 newProp.setName(newStringPropName);
783                 newProp.setPropertyDefaultValue(newStringPropValue);
784                 AtomicOperationUtils.addCustomPropertyToResource(newProp, vfResource, UserRoleEnum.DESIGNER, true);
785                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
786                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
787
788                 // Service
789                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
790                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
791                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
792                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
793                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
794                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
795                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
796
797                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
798                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
799                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
800
801                 // update VF property
802                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getPropFromListByPropNameAndType(actualPropertyList, propNameToUpdate, propTypeToUpdate);
803                 expectedUpdatePropDetails.setValue(updatedBooleanValue);
804                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
805                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
806                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
807
808                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
809
810                 actualPropertyList = new ArrayList<>();
811                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
812
813                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, null);
814                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
815
816         }
817
818         /**
819          * update property p5' Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1) CP(inst on VF) (p5) CP(inst) (p5')
820          */
821         @Test
822         public void serviceWithNestedResourceProperty3LevelsAndCpOnVfUpdateCpInstanceOfService() throws Exception {
823                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
824                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
825                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CHECKIN, vfc1FromBasicVFC);
826                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
827                 // expectedPropertyList =
828                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
829                 // expectedPropertyList);
830
831                 // four resource
832                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
833                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
834                 cpStringProperty.setName("Different Name");
835                 cpStringProperty.setPropertyDefaultValue("Different value from default");
836                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
837                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
838                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
839                 // create VF + add RI
840                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
841                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
842                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
843                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
844                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
845
846                 // Service
847                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
848                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
849                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
850                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
851
852                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
853                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
854                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
855                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
856
857                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
858                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
859                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
860
861                 // service = AtomicOperationUtils.getServiceObject(service,
862                 // UserRoleEnum.DESIGNER);
863                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
864                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
865
866                 String propNameToUpdate = "cidr";
867                 String propTypeToUpdate = "string";
868
869                 // update CP property
870                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(service, componentInstDetails, propNameToUpdate, propTypeToUpdate);
871                 expectedUpdatePropDetails.setValue(updatedStringValue);
872                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
873                 List<String> path = expectedUpdatePropDetails.getPath();
874                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
875                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
876
877                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
878
879                 actualPropertyList = new ArrayList<>();
880                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
881
882                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, path);
883                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
884         }
885
886         /**
887          * update property p5 Service-->VF1(inst)-->VF-->(VFC(inst)-->VFC-->VFC-->VFC) (p4) (p3) (p2) (p1) CP(inst on VF) (p5) CP(inst) (p5')
888          */
889         @Test
890         public void serviceWithNestedResourceProperty3LevelsAndCpOnVfUpdateCpInstanceOfVf() throws Exception {
891                 basicVFC = createResourceWithProperty(ElementFactory.getDefaultStringProperty(), LifeCycleStatesEnum.CERTIFY);
892                 vfc1FromBasicVFC = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultIntegerProperty(), LifeCycleStatesEnum.CERTIFY, basicVFC);
893                 vfc2FromVfc1 = createResourceWithPropertyDerivedFromOtherResource(ElementFactory.getDefaultBooleanProperty(), LifeCycleStatesEnum.CERTIFY, vfc1FromBasicVFC);
894                 vfc2FromVfc1 = AtomicOperationUtils.getResourceObject(vfc2FromVfc1, UserRoleEnum.DESIGNER);
895                 // expectedPropertyList =
896                 // PropertyRestUtils.addResourcePropertiesToList(vfc2FromVfc1,
897                 // expectedPropertyList);
898
899                 // four resource
900                 Resource cp = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
901                 PropertyReqDetails cpStringProperty = ElementFactory.getDefaultStringProperty();
902                 cpStringProperty.setName("Different Name");
903                 cpStringProperty.setPropertyDefaultValue("Different value from default");
904                 AtomicOperationUtils.addCustomPropertyToResource(cpStringProperty, cp, UserRoleEnum.DESIGNER, true);
905                 AtomicOperationUtils.changeComponentState(cp, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
906                 // create VF + add RI
907                 cp = AtomicOperationUtils.getResourceObject(cp, UserRoleEnum.DESIGNER);
908                 vfResource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
909                 ComponentInstance componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfc2FromVfc1, vfResource, UserRoleEnum.DESIGNER, true).left().value();
910                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, vfResource, UserRoleEnum.DESIGNER, true).left().value();
911                 AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
912                 vfResource = AtomicOperationUtils.getResourceObject(vfResource, UserRoleEnum.DESIGNER);
913
914                 // Service
915                 expectedPropertyList = new ArrayList<ComponentInstanceProperty>();
916                 actualPropertyList = new ArrayList<ComponentInstanceProperty>();
917                 expectedPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(vfResource, expectedPropertyList, null);
918                 expectedPropertyList = PropertyRestUtils.addResourcePropertiesToList(cp, expectedPropertyList);
919
920                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
921                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vfResource, service, UserRoleEnum.DESIGNER, true).left().value();
922                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
923                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
924
925                 componentInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(cp, service, UserRoleEnum.DESIGNER, true).left().value();
926                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
927                 PropertyRestUtils.updatePropertyListWithPathOnComponentInstance(componentInstDetails, service, expectedPropertyList);
928
929                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
930                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
931                 PropertyRestUtils.comparePropertyLists(expectedPropertyList, actualPropertyList, false);
932
933                 String propNameToUpdate = "cidr";
934                 String propTypeToUpdate = "string";
935
936                 // update CP property
937                 ComponentInstanceProperty expectedUpdatePropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(service, componentInstDetails, propNameToUpdate, propTypeToUpdate);
938                 expectedUpdatePropDetails.setValue(updatedStringValue);
939                 String propUniqeId = expectedUpdatePropDetails.getUniqueId();
940                 List<String> path = expectedUpdatePropDetails.getPath();
941                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, componentInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), expectedUpdatePropDetails);
942                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + BaseRestUtils.STATUS_CODE_SUCCESS, updatePropertyValueOnResourceInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
943
944                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
945
946                 actualPropertyList = new ArrayList<>();
947                 actualPropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, actualPropertyList, null);
948
949                 ComponentInstanceProperty actualUpdatedPropDetails = PropertyRestUtils.getPropFromListByPropIdAndPath(actualPropertyList, propUniqeId, path);
950                 assertTrue("property was not updated propely", PropertyRestUtils.comparePropertyObjects(expectedUpdatePropDetails, actualUpdatedPropDetails, true));
951         }
952         
953         @Test // US833308
954         public void serviceWithVLINetworkRoleProperty() throws Exception {
955                 
956                 String propName = PropertyNames.NETWORK_ROLE.getPropertyName();
957                 String propType = "string";
958                 String propValue = "myValue";
959                 
960             // create service
961                 Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
962                 Resource vl = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, "ExtVL", "1.0");
963                 // add ExtVL instance 
964                 ComponentInstance vlInstDetails = AtomicOperationUtils.addComponentInstanceToComponentContainer(vl, service, UserRoleEnum.DESIGNER, true).left().value();
965                 // fetch updated service 
966                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
967                 
968                 // update ExtVL network_role property value 
969                 ComponentInstanceProperty propDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(service, vlInstDetails, propName, propType);
970                 propDetails.setValue(propValue);
971                 RestResponse updatePropertyValueOnResourceInstance = ComponentInstanceRestUtils.updatePropertyValueOnResourceInstance(service, vlInstDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), propDetails);
972                 assertTrue("expected updatePropertyValueOnResourceInstance response code: " + HttpStatus.SC_OK, updatePropertyValueOnResourceInstance.getErrorCode() == HttpStatus.SC_OK);
973         
974                 service = AtomicOperationUtils.getServiceObject(service, UserRoleEnum.DESIGNER);
975                 // expected property value after update has service systemName prefixed to user defined value.  
976                 ComponentInstanceProperty updatedPropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(service, vlInstDetails, propName, propType);
977                 String generatedValue = service.getSystemName() + "." + propValue;
978                 assertTrue("property value was updated properly", updatedPropDetails.getValue().equals(generatedValue));
979                 
980                 // update service name 
981                 ServiceReqDetails updatedServiceDetails = new ServiceReqDetails(service);
982                 String newServiceName = "ciServiceWithVLIPropertyValueTest";
983                 updatedServiceDetails.setName(newServiceName);
984                 RestResponse updateServiceResponse = ServiceRestUtils.updateService(updatedServiceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
985                 service = ResponseParser.convertServiceResponseToJavaObject(updateServiceResponse.getResponse());
986                 // expected property value after update has service (updated) systemName prefixed to user defined value. 
987                 generatedValue = newServiceName + "." + propValue;
988                 updatedPropDetails = PropertyRestUtils.getCompPropInstListByInstIdAndPropName(service, vlInstDetails, propName, propType);
989                 assertTrue("property value was updated properly", updatedPropDetails.getValue().equalsIgnoreCase(generatedValue));
990         }
991
992
993         // -------------------Methods--------------------------
994         public static PropertyDataDefinition convertToPropertyDataDefinitionObject(PropertyReqDetails prop) {
995                 PropertyDataDefinition propDataDef = new PropertyDataDefinition();
996                 propDataDef.setDefaultValue(prop.getPropertyDefaultValue());
997                 propDataDef.setType(prop.getPropertyType());
998                 propDataDef.setPassword(prop.getPropertyPassword());
999                 propDataDef.setDescription(prop.getPropertyDescription());
1000                 return propDataDef;
1001         }
1002
1003         protected Resource createResourceWithPropertyDerivedFromOtherResource(PropertyReqDetails propertyReqDetails, LifeCycleStatesEnum state, Resource derivedFromResource) throws Exception {
1004                 Resource resource = AtomicOperationUtils.createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum.VFC, derivedFromResource, ResourceCategoryEnum.APPLICATION_L4_BORDER, UserRoleEnum.DESIGNER, true).left().value();
1005                 if (propertyReqDetails != null) {
1006                         AtomicOperationUtils.addCustomPropertyToResource(propertyReqDetails, resource, UserRoleEnum.DESIGNER, true);
1007                 }
1008                 AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, state, true);
1009                 return AtomicOperationUtils.getResourceObject(resource, UserRoleEnum.DESIGNER);
1010                 // return resource;
1011         }
1012
1013         protected Resource createResourceWithProperty(PropertyReqDetails propertyReqDetails, LifeCycleStatesEnum state) throws Exception {
1014                 Resource resource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_ABSTRACT, UserRoleEnum.DESIGNER, true).left().value();
1015                 if (propertyReqDetails != null) {
1016                         AtomicOperationUtils.addCustomPropertyToResource(propertyReqDetails, resource, UserRoleEnum.DESIGNER, true);
1017                 }
1018                 AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, state, true);
1019                 return AtomicOperationUtils.getResourceObject(resource, UserRoleEnum.DESIGNER);
1020         }
1021
1022 }