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.product;
23 import org.junit.Rule;
24 import org.junit.rules.TestName;
25 import org.openecomp.sdc.be.model.Product;
26 import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
29 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
30 import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
31 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
32 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
33 import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils;
34 import org.testng.annotations.BeforeMethod;
35 import org.testng.annotations.Test;
37 public class ProductGetFollowedTest extends ProductBaseTest {
39 protected Product product200;
40 protected Product product400;
42 private ProductReqDetails productDetails200;
43 private ProductReqDetails productDetails400;
46 public static TestName name = new TestName();
48 public ProductGetFollowedTest() {
49 super(name, ProductGetFollowedTest.class.getName());
53 public void init() throws Exception {
58 public void followedPageTest() throws Exception { // Actions
59 RestResponse changeLifeCycleResponse;
60 changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN);
61 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
62 changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
63 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
64 // Expected users Followed page
65 ProductValidationUtils.checkUserFollowedPage(productManager1, product200);
66 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400);
67 ProductValidationUtils.checkUserFollowedPage(productManager2, product400);
68 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product200);
69 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400);
70 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
71 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
75 public void followedPagePmCheckedOutProductWasCheckInByOtherPm() throws Exception {
76 ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN);
77 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
78 ProductRestUtils.changeProductLifeCycle(product400, productManager1, LifeCycleStatesEnum.CHECKOUT);
79 RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager2, LifeCycleStatesEnum.CHECKOUT);
80 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
82 ProductValidationUtils.checkUserFollowedPage(productManager1, product400);
83 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400);
84 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400);
85 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
86 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
90 public void followedPagePmCheckInProduct02() throws Exception {
91 ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN);
92 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
94 ProductValidationUtils.checkUserFollowedPage(productManager1, product200);
95 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400);
96 ProductValidationUtils.checkUserFollowedPage(productManager2, product400);
97 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product200);
98 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400);
99 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
100 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
104 public void followedPageAdminCheckoutProductWasCheckedinByPm() throws Exception {
105 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
106 RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKOUT);
107 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
109 ProductValidationUtils.checkUserFollowedPage(productManager1, product200);
110 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400);
111 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400);
112 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200);
113 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
114 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
118 public void followedPageAdminCheckInProduct() throws Exception {
119 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
120 ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKOUT);
121 RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product400, adminUser, LifeCycleStatesEnum.CHECKIN);
122 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
124 ProductValidationUtils.checkUserFollowedPage(productManager1, product200);
125 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product400);
126 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager2, product400);
127 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200);
128 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
129 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
133 public void followedPagePmCheckoutProductWasCheckedinByAdmin() throws Exception {
134 ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN);
135 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
136 ProductRestUtils.changeProductLifeCycle(product200, adminUser, LifeCycleStatesEnum.CHECKOUT);
137 ProductRestUtils.changeProductLifeCycle(product200, adminUser, LifeCycleStatesEnum.CHECKIN);
138 RestResponse changeLifeCycleResponse = ProductRestUtils.changeProductLifeCycle(product200, productManager2, LifeCycleStatesEnum.CHECKOUT);
139 ResourceRestUtils.checkSuccess(changeLifeCycleResponse);
141 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productManager1, product200);
142 ProductValidationUtils.checkUserFollowedPage(productManager2, product200, product400);
143 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(adminUser, product200, product400);
144 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(designerUser, product200, product400);
145 ProductValidationUtils.verifyProductsNotExistInUserFollowedPage(productStrategistUser1, product200, product400);
148 private void createProducts() throws Exception {
149 // PM1 (Product manager) create :PR200 (check In State)
150 // PM2 (Product manager) create :PR400 (check In State)
152 productDetails200 = ElementFactory.getDefaultProduct("CiProd200", defaultCategories);
153 productDetails400 = ElementFactory.getDefaultProduct("CiProd400", defaultCategories);
155 RestResponse createProduct = ProductRestUtils.createProduct(productDetails200, productManager1);
156 ResourceRestUtils.checkCreateResponse(createProduct);
157 product200 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
159 createProduct = ProductRestUtils.createProduct(productDetails400, productManager2);
160 ResourceRestUtils.checkCreateResponse(createProduct);
161 product400 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);