2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.execute.devCI;
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertTrue;
26 import org.junit.Rule;
27 import org.junit.rules.TestName;
28 import org.openecomp.sdc.be.model.Component;
29 import org.openecomp.sdc.be.model.Service;
30 import org.openecomp.sdc.be.model.User;
31 import org.openecomp.sdc.be.utils.CommonBeUtils;
32 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
33 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
34 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
37 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
38 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
39 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
40 import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
41 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
42 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
43 import org.testng.annotations.AfterTest;
44 import org.testng.annotations.BeforeTest;
45 import org.testng.annotations.Test;
47 public class ValidateConformanceLevel extends ComponentBaseTest {
50 public static TestName name = new TestName();
52 public ValidateConformanceLevel() {
53 super(name, ValidateConformanceLevel.class.getName());
57 public void testValidateServiceConformanceLevel() throws Exception {
58 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
60 ServiceReqDetails service = ElementFactory.getDefaultService();
61 RestResponse createdService = ServiceRestUtils.createService(service, user);
62 BaseRestUtils.checkCreateResponse(createdService);
63 Service serviceFirstImport = ResponseParser.parseToObjectUsingMapper(createdService.getResponse(), Service.class);
64 Component serviceObject = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
66 RestResponse apiRes = ComponentRestUtils.validateConformanceLevel(serviceObject.getUUID(), user.getUserId());
67 String result = apiRes.getResponse();
68 assertTrue(apiRes.getErrorCode() == 200);
69 assertTrue(result.equals("true"));
73 public void testValidateServiceConformanceLevelForSecondMajorVersion() throws Exception {
74 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
76 ServiceReqDetails service = ElementFactory.getDefaultService();
77 RestResponse createdService = ServiceRestUtils.createService(service, user);
78 BaseRestUtils.checkCreateResponse(createdService);
79 Service serviceFirstImport = ResponseParser.parseToObjectUsingMapper(createdService.getResponse(), Service.class);
80 Component serviceObject = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
81 String uuid1 = serviceObject.getUUID();
82 Component service20Object = AtomicOperationUtils.changeComponentState(serviceFirstImport, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
83 service20Object = AtomicOperationUtils.changeComponentState(service20Object, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
84 String uuid2 = service20Object.getUUID();
86 assertTrue(uuid1 != uuid2);
88 RestResponse apiRes = ComponentRestUtils.validateConformanceLevel(uuid1, user.getUserId());
89 String result = apiRes.getResponse();
90 assertTrue(apiRes.getErrorCode() == 200);
91 assertTrue(result.equals("true"));
93 apiRes = ComponentRestUtils.validateConformanceLevel(uuid2, user.getUserId());
94 result = apiRes.getResponse();
95 assertTrue(apiRes.getErrorCode() == 200);
96 assertTrue(result.equals("true"));
100 public void testValidateConformanceLevel404() throws Exception {
101 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
102 RestResponse apiRes = ComponentRestUtils.validateConformanceLevel("fake-uuid-for-test", user.getUserId());
103 assertTrue(apiRes.getErrorCode() == 404);