[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / product / ProductGetFollowedTest.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.product;
22
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;
36
37 public class ProductGetFollowedTest extends ProductBaseTest {
38
39         protected Product product200;
40         protected Product product400;
41
42         private ProductReqDetails productDetails200;
43         private ProductReqDetails productDetails400;
44
45         @Rule
46         public static TestName name = new TestName();
47
48         public ProductGetFollowedTest() {
49                 super(name, ProductGetFollowedTest.class.getName());
50         }
51
52         @BeforeMethod
53         public void init() throws Exception {
54                 createProducts();
55         }
56
57         @Test
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);
72         }
73
74         @Test
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);
81
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);
87         }
88
89         @Test
90         public void followedPagePmCheckInProduct02() throws Exception {
91                 ProductRestUtils.changeProductLifeCycle(product200, productManager1, LifeCycleStatesEnum.CHECKIN);
92                 ProductRestUtils.changeProductLifeCycle(product400, productManager2, LifeCycleStatesEnum.CHECKIN);
93
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);
101         }
102
103         @Test
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);
108
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);
115         }
116
117         @Test
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);
123
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);
130         }
131
132         @Test
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);
140
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);
146         }
147
148         private void createProducts() throws Exception {
149                 // PM1 (Product manager) create :PR200 (check In State)
150                 // PM2 (Product manager) create :PR400 (check In State)
151
152                 productDetails200 = ElementFactory.getDefaultProduct("CiProd200", defaultCategories);
153                 productDetails400 = ElementFactory.getDefaultProduct("CiProd400", defaultCategories);
154
155                 RestResponse createProduct = ProductRestUtils.createProduct(productDetails200, productManager1);
156                 ResourceRestUtils.checkCreateResponse(createProduct);
157                 product200 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
158
159                 createProduct = ProductRestUtils.createProduct(productDetails400, productManager2);
160                 ResourceRestUtils.checkCreateResponse(createProduct);
161                 product400 = ResponseParser.parseToObjectUsingMapper(createProduct.getResponse(), Product.class);
162         }
163
164 }