Catalog alignment
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / GovernorOperationPage.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.pages;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
26 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
27 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 import java.io.IOException;
32
33 public class GovernorOperationPage {
34
35     private static final Logger LOGGER = LoggerFactory.getLogger(GovernorOperationPage.class);
36
37     private GovernorOperationPage() {
38         super();
39     }
40
41     public static void approveService(final String serviceName) {
42         SetupCDTest.getExtendTest()
43             .log(Status.INFO, String.format("Approving the distribution of the service '%s'", serviceName));
44         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE.getValue()).click();
45         GeneralUIUtils.waitForLoader();
46         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE_MESSAGE.getValue())
47                 .sendKeys("service " + serviceName + " tested successfully");
48         GeneralPageElements.clickOKButton();
49         final String distributionApprovedMsg = String.format("The distribution of the service '%s' was approved", serviceName);
50         try {
51             ExtentTestActions
52                 .addScreenshot(Status.INFO,
53                     String.format("governor-distribution-approved-%s", serviceName),
54                     distributionApprovedMsg
55                 );
56         } catch (final IOException e) {
57             LOGGER.error("Could not take screenshot of governor distribution approval", e);
58             SetupCDTest.getExtendTest().log(Status.INFO, distributionApprovedMsg);
59         }
60         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue());
61     }
62
63 }