aboutsummaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java
blob: 82a894f4ebacf5b8a6050279d675e94cfc95c555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.sdc.ci.tests.execute.resource;

import com.google.gson.Gson;
import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;

public class VFResourceInstanceNameCRUD extends ComponentBaseTest {

	protected static ServiceReqDetails serviceDetails;
	protected static ResourceReqDetails resourceDetailsVFC;
	protected static ResourceReqDetails resourceDetailsVL;
	protected static ResourceReqDetails resourceDetailsVF;
	protected static ResourceReqDetails resourceDetailsCP;
	protected static ComponentInstanceReqDetails resourceInstanceReqDetailsVF;
	protected static ComponentInstanceReqDetails resourceInstanceReqDetailsVFC;
	protected static ComponentInstanceReqDetails resourceInstanceReqDetailsVL;
	protected static ComponentInstanceReqDetails resourceInstanceReqDetailsCP;
	protected static User sdncDesignerDetails1;
	protected static User sdncTesterDeatails1;
	protected static User sdncAdminDetails1;
	protected static ArtifactReqDetails heatArtifactDetails;
	protected static ArtifactReqDetails defaultArtifactDetails;
	protected static int maxLength = 50;
	protected static Resource resourceVF = null;

	@Rule
	public static TestName name = new TestName();

	public VFResourceInstanceNameCRUD() {
		super(name, VFResourceInstanceNameCRUD.class.getName());
	}

	@BeforeMethod

	public void init() throws Exception {

		// serviceDetails = ElementFactory.getDefaultService();
		// resourceDetailsVFC =
		// ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VFC.toString(),
		// "resourceVFC");
		// resourceDetailsVF =
		// ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF.toString(),
		// "resourceVF3");
		// resourceDetailsVL =
		// ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VL.toString(),
		// "resourceVL");
		// resourceDetailsCP =
		// ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CP.toString(),
		// "resourceCP");
		sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
		sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
		sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
		// heatArtifactDetails =
		// ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());

		Either<Resource, RestResponse> resourceDetailsCP_01e = AtomicOperationUtils
				.createResourceByType(ResourceTypeEnum.CP, UserRoleEnum.DESIGNER, true);
		AtomicOperationUtils.changeComponentState(resourceDetailsCP_01e.left().value(), UserRoleEnum.DESIGNER,
				LifeCycleStatesEnum.CHECKIN, true);
		resourceDetailsCP = new ResourceReqDetails(resourceDetailsCP_01e.left().value());
		Either<Resource, RestResponse> resourceDetailsVL_01e = AtomicOperationUtils
				.createResourceByType(ResourceTypeEnum.VL, UserRoleEnum.DESIGNER, true);
		AtomicOperationUtils.changeComponentState(resourceDetailsVL_01e.left().value(), UserRoleEnum.DESIGNER,
				LifeCycleStatesEnum.CHECKIN, true);
		resourceDetailsVL = new ResourceReqDetails(resourceDetailsVL_01e.left().value());
		Either<Resource, RestResponse> resourceDetailsVF_01e = AtomicOperationUtils
				.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true);
		resourceDetailsVF = new ResourceReqDetails(resourceDetailsVF_01e.left().value());
		Either<Resource, RestResponse> resourceDetailsVFC_01e = AtomicOperationUtils
				.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true);
		AtomicOperationUtils.changeComponentState(resourceDetailsVFC_01e.left().value(), UserRoleEnum.DESIGNER,
				LifeCycleStatesEnum.CHECKIN, true);
		resourceDetailsVFC = new ResourceReqDetails(resourceDetailsVFC_01e.left().value());

		resourceInstanceReqDetailsVFC = ElementFactory.getDefaultComponentInstance("VFC", resourceDetailsVFC);
		resourceInstanceReqDetailsVF = ElementFactory.getDefaultComponentInstance("VF", resourceDetailsVF);
		resourceInstanceReqDetailsVL = ElementFactory.getDefaultComponentInstance("VL", resourceDetailsVL);
		resourceInstanceReqDetailsCP = ElementFactory.getDefaultComponentInstance("CP", resourceDetailsCP);
		sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
		sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
		sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);

	}

	@Test
	public void addResourceInstanceToVF() throws Exception {

		createVFWithCertifiedResourceInstance(resourceDetailsCP, resourceInstanceReqDetailsCP);
		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsCP.getName() + " 1");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void updateResourceInstanceName() throws Exception {

		// update resource instance name
		String resourceInstanceUpdatedName = "resource New 2";

		ResourceReqDetails updatedResourceDetailsVLC = changeResouceName(resourceDetailsVFC,
				resourceInstanceUpdatedName);
		createVFWithCertifiedResourceInstance(updatedResourceDetailsVLC, resourceInstanceReqDetailsVFC);

		resourceInstanceReqDetailsVFC.setName(resourceInstanceUpdatedName);
		RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
				resourceInstanceReqDetailsVFC, sdncDesignerDetails1, resourceVF.getUniqueId(),
				ComponentTypeEnum.RESOURCE);
		assertTrue(updateResourceInstanceResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);

		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceUpdatedName);
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void updateResourceInstanceNameToNextGeneratedName() throws Exception {

		// update resource instance name
		String resourceInstanceUpdatedName = resourceInstanceReqDetailsCP.getName() + " 2";

		ResourceReqDetails updatedResourceDetailsVL = changeResouceName(resourceDetailsVL, resourceInstanceUpdatedName);
		createVFWithCertifiedResourceInstance(updatedResourceDetailsVL, resourceInstanceReqDetailsVL);
		resourceInstanceReqDetailsCP.setName(resourceInstanceUpdatedName);

		// add second resource instance
		RestResponse response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetailsCP,
				sdncDesignerDetails1, resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());
		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsVL.getName() + " 1");
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsCP.getName() + " 2");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void normolizeUpdatedResourceInstanceName() throws Exception {

		String resourceInstanceUpdatedName = "resource   new -  .2";
		String normalizedName = "resourcenew2";

		ResourceReqDetails updatedResourceDetailsVL = changeResouceName(resourceDetailsVL, resourceInstanceUpdatedName);

		createVFWithCertifiedResourceInstance(updatedResourceDetailsVL, resourceInstanceReqDetailsVL);
		// update resource instance name
		resourceInstanceReqDetailsCP.setName(resourceInstanceUpdatedName);

		// add second resource instance
		RestResponse response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetailsCP,
				sdncDesignerDetails1, resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());
		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsVL.getName() + " 1");
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsCP.getName() + " 2");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void updatedResourceInstanceNameToEmpty() throws Exception {

		createVFWithCertifiedResourceInstance(resourceDetailsVL, resourceInstanceReqDetailsVL);
		String resourceInstanceUpdatedName = "";
		String resourceInstancePreviousName = resourceDetailsCP.getName();

		// add second resource instance
		RestResponse response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetailsCP,
				sdncDesignerDetails1, resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());
		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		resourceInstanceReqDetailsCP.setName(resourceInstanceUpdatedName);
		RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
				resourceInstanceReqDetailsCP, sdncDesignerDetails1, resourceVF.getUniqueId(),
				ComponentTypeEnum.RESOURCE);
		assertEquals("Check response code after RI update request", 200,
				updateResourceInstanceResponse.getErrorCode().intValue());
		// change request
		// ErrorInfo errorInfo =
		// Utils.parseYaml(ActionStatus.MISSING_COMPONENT_NAME.name());
		// utils.validateResponseCode(updateResourceInstanceResponse,
		// errorInfo.getCode(), "update resource instance");
		//
		// List<String> variables = Arrays.asList("Resource Instance");
		// ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_COMPONENT_NAME.name(),
		// variables, updateResourceInstanceResponse.getResponse());

		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsVL.getName() + " 1");
		resourceInstanceExpectedListName.add(resourceInstancePreviousName + " 3");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void updatedResourceNameLengthExceedMaximumCharacters() throws Exception {

		String resourceInstancePreviousName = resourceDetailsCP.getName();
		// update resource instance name
		String resourceInstanceUpdatedName = "a";
		for (int i = 0; i < maxLength; i++) {
			resourceInstanceUpdatedName += "b";
		}
		// ResourceReqDetails updatedResourceDetailsVL =
		// changeResouceName(resourceDetailsVL, resourceInstanceUpdatedName);

		createVFWithCertifiedResourceInstance(resourceDetailsVL, resourceInstanceReqDetailsVL);
		// add second resource instance
		RestResponse response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetailsCP,
				sdncDesignerDetails1, resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());
		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		String prevName = resourceInstanceReqDetailsCP.getName();
		resourceInstanceReqDetailsCP.setName(resourceInstanceUpdatedName);
		RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
				resourceInstanceReqDetailsCP, sdncDesignerDetails1, resourceVF.getUniqueId(),
				ComponentTypeEnum.RESOURCE);
		ErrorInfo errorInfo = ErrorValidationUtils
				.parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name());
		// utils.validateResponseCode(updateResourceInstanceResponse,
		// errorInfo.getCode(), "update resource instance");

		List<String> variables = Arrays.asList("Resource Instance", "50");
		ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), variables,
				updateResourceInstanceResponse.getResponse());

		resourceInstanceReqDetailsCP.setName(prevName);
		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsVL.getName() + " 1");
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsCP.getName() + " 2");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	@Test
	public void updatedResourceNameWithUnSupportedCharacters() throws Exception {

		createVFWithCertifiedResourceInstance(resourceDetailsVL, resourceInstanceReqDetailsVL);
		String resourceInstancePreviousName = resourceDetailsCP.getName();
		// update resource instance name
		String resourceInstanceUpdatedName = "a???<>";

		// add second resource instance
		RestResponse response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetailsCP,
				sdncDesignerDetails1, resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());
		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		String prevValue = resourceInstanceReqDetailsCP.getName();
		resourceInstanceReqDetailsCP.setName(resourceInstanceUpdatedName);
		RestResponse updateResourceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(
				resourceInstanceReqDetailsCP, sdncDesignerDetails1, resourceVF.getUniqueId(),
				ComponentTypeEnum.RESOURCE);
		ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_COMPONENT_NAME.name());
		// ResourceRestUtils.validateResponseCode(updateResourceInstanceResponse,
		// errorInfo.getCode(), "update resource instance");

		List<String> variables = Arrays.asList("Resource Instance");
		ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), variables,
				updateResourceInstanceResponse.getResponse());

		resourceInstanceReqDetailsCP.setName(prevValue);

		// validate RI name
		List<ComponentInstance> resourceInstances = resourceVF.getComponentInstances();
		List<String> resourceInstanceListName = new ArrayList<String>();
		for (int i = 0; i < resourceInstances.size(); i++) {
			resourceInstanceListName.add(resourceInstances.get(i).getName());
		}
		List<String> resourceInstanceExpectedListName = new ArrayList<String>();
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsVL.getName() + " 1");
		resourceInstanceExpectedListName.add(resourceInstanceReqDetailsCP.getName() + " 2");
		String message = "resource instance name";
		Utils.compareArrayLists(resourceInstanceListName, resourceInstanceExpectedListName, message);

	}

	private static ResourceReqDetails changeResouceName(ResourceReqDetails resourceDet,
			String resourceInstanceUpdatedName) throws Exception {

		ResourceReqDetails updatedResourceDetails = new ResourceReqDetails();
		updatedResourceDetails = resourceDet;
		updatedResourceDetails.setName(resourceInstanceUpdatedName);
		List<String> tags = new ArrayList<String>();
		tags.add(resourceInstanceUpdatedName);
		updatedResourceDetails.setTags(tags);
		Gson gson = new Gson();
		String updatedResourceBodyJson = gson.toJson(updatedResourceDetails);
		RestResponse response = LifecycleRestUtils.changeResourceState(resourceDet, sdncDesignerDetails1,
				resourceDet.getVersion(), LifeCycleStatesEnum.CHECKOUT);
		assertTrue("change LS state to CHECKOUT, returned status:" + response.getErrorCode(),
				response.getErrorCode() == 200);
		response = ResourceRestUtils.updateResourceMetadata(updatedResourceBodyJson, sdncDesignerDetails1,
				updatedResourceDetails.getUniqueId());
		assertEquals("Check response code after updateresource name", 200, response.getErrorCode().intValue());
		response = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncDesignerDetails1,
				resourceDet.getVersion(), LifeCycleStatesEnum.CHECKIN);

		return updatedResourceDetails;

	}

	// private Component changeResouceName(Resource resourceDet, String
	// resourceInstanceUpdatedName) throws Exception{
	//
	// User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
	// Resource updatedResourceDetails = resourceDet;
	// RestResponse response =
	// LifecycleRestUtils.changeComponentState(updatedResourceDetails,
	// defaultUser, LifeCycleStatesEnum.CHECKOUT, "state changed");
	// assertTrue("change LS state to CHECKOUT, returned status:" +
	// response.getErrorCode(),response.getErrorCode() == 200);
	// updatedResourceDetails.setName(resourceInstanceUpdatedName);
	// List<String> tags = new ArrayList<String>();
	// tags.add(resourceInstanceUpdatedName);
	// updatedResourceDetails.setTags(tags);
	// Gson gson = new Gson();
	// ResourceReqDetails resourceReqDetails = new
	// ResourceReqDetails(updatedResourceDetails);
	// String updatedResourceBodyJson = gson.toJson(resourceReqDetails);
	// response = ResourceRestUtils.updateResource(updatedResourceBodyJson,
	// defaultUser, updatedResourceDetails.getUniqueId());
	// assertEquals("Check response code after updateresource name", 200,
	// response.getErrorCode().intValue());
	// response =
	// LifecycleRestUtils.changeComponentState(updatedResourceDetails,
	// defaultUser, LifeCycleStatesEnum.CHECKIN, "state changed");
	// assertEquals("Check response code after updateresource name", 200,
	// response.getErrorCode().intValue());
	//
	// return updatedResourceDetails;
	//
	// }

	private void createVFWithCertifiedResourceInstance(ResourceReqDetails resourceDetails,
			ComponentInstanceReqDetails resourceInstanceReqDetails) throws Exception {

		RestResponse response = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails1,
				resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
		assertEquals("Check response code after CHECKOUT", 200, response.getErrorCode().intValue());

		// add heat artifact to resource and certify
		ArtifactReqDetails heatArtifactDetails = ElementFactory
				.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
		response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1,
				resourceDetails.getUniqueId());
		assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),
				response.getErrorCode() == 200);
		response = LifecycleRestUtils.certifyResource(resourceDetails);
		assertEquals("Check response code after CERTIFY request", 200, response.getErrorCode().intValue());

		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);

		resourceInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId());
		response = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails, sdncDesignerDetails1,
				resourceVF);
		assertEquals("Check response code after create RI", 201, response.getErrorCode().intValue());

		resourceVF = convertResourceGetResponseToJavaObject(resourceDetailsVF);
	}

	protected Resource convertResourceGetResponseToJavaObject(ResourceReqDetails resourceDetails) throws IOException {
		RestResponse response = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails1);
		assertEquals("Check response code after get resource", 200, response.getErrorCode().intValue());
		return ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
	}

}