ada3410318c33e05ba4e32b42135639abc428334
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / ComponentPage.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19 package org.onap.sdc.frontend.ci.tests.pages;
20
21 import org.onap.sdc.frontend.ci.tests.datatypes.LifeCycleStateEnum;
22 import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
23 import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage;
24 import org.onap.sdc.frontend.ci.tests.pages.home.HomePage;
25 import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper;
26 import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent;
27 import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType;
28 import org.openqa.selenium.WebDriver;
29
30 public class ComponentPage extends AbstractPageObject {
31
32     protected final TopNavComponent topNavComponent;
33     protected final ResourceLeftSideMenu resourceLeftSideMenu;
34     protected final ResourceWorkspaceTopBarComponent workspaceTopBarComponent;
35     protected final LoaderHelper loaderHelper;
36     protected final NotificationComponent notificationComponent;
37
38     public ComponentPage(final WebDriver webDriver) {
39         super(webDriver);
40         topNavComponent = new TopNavComponent(webDriver);
41         resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver);
42         workspaceTopBarComponent = new ResourceWorkspaceTopBarComponent(webDriver);
43         loaderHelper = new LoaderHelper(webDriver);
44         notificationComponent = new NotificationComponent(webDriver);
45     }
46
47     @Override
48     public void isLoaded() {
49         topNavComponent.isLoaded();
50         resourceLeftSideMenu.isLoaded();
51         workspaceTopBarComponent.isLoaded();
52     }
53
54     public HomePage goToHomePage() {
55         return topNavComponent.clickOnHome();
56     }
57
58     public ToscaArtifactsPage goToToscaArtifacts() {
59         return resourceLeftSideMenu.clickOnToscaArtifactsMenuItem();
60     }
61
62     public CompositionPage goToComposition() {
63         return resourceLeftSideMenu.clickOnCompositionMenuItem();
64     }
65
66     /**
67      * Certifies the resource and wait for success notification.
68      */
69     public void certifyComponent() {
70         workspaceTopBarComponent.certifyResource();
71     }
72
73     /**
74      * Creates the resource and wait for success notification.
75      */
76     public void clickOnCreate() {
77         workspaceTopBarComponent.clickOnCreate();
78         loaderHelper.waitForLoader(20);
79         notificationComponent.waitForNotification(NotificationType.SUCCESS, 20);
80     }
81
82     public String getLifecycleState() {
83         return workspaceTopBarComponent.getLifecycleState();
84     }
85
86     public boolean isInDesign() {
87         return LifeCycleStateEnum.IN_DESIGN.getValue().equalsIgnoreCase(getLifecycleState());
88     }
89
90     public AttributesOutputsPage goToAttributesOutputs() {
91         return resourceLeftSideMenu.clickOnAttributesOutputsMenuItem();
92     }
93
94     public AttributesPage goToAttributes() {
95         return resourceLeftSideMenu.clickOnAttributesMenuItem();
96     }
97
98     public <T extends ComponentPage> T clickOnGeneralMenuItem(Class<? extends T> clazz) {
99         return resourceLeftSideMenu.clickOnGeneralMenuItem(clazz);
100     }
101
102     public ResourcePropertiesAssignmentPage goToPropertiesAssignment() {
103         return resourceLeftSideMenu.clickOnPropertiesAssignmentMenuItem();
104     }
105
106     public ResourcePropertiesPage goToProperties() {
107         return resourceLeftSideMenu.clickOnPropertiesMenuItem();
108     }
109 }