2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 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
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.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.ci.tests.flow;
22 import com.aventstack.extentreports.Status;
23 import org.openecomp.sdc.ci.tests.pages.PageObject;
24 import org.openecomp.sdc.ci.tests.pages.ResourceLeftSideMenu;
25 import org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage;
26 import org.openqa.selenium.WebDriver;
28 import java.util.List;
29 import java.util.Optional;
31 import static org.hamcrest.Matchers.containsInAnyOrder;
32 import static org.hamcrest.Matchers.hasSize;
33 import static org.junit.Assert.assertThat;
36 * UI Flow for checking the software version property in a resource
38 public class CheckSoftwareVersionPropertyFlow extends AbstractUiTestFlow {
40 private final List<String> expectedSoftwareVersionList;
42 public CheckSoftwareVersionPropertyFlow(final WebDriver webDriver, final List<String> expectedSoftwareVersionList) {
44 this.expectedSoftwareVersionList = expectedSoftwareVersionList;
48 public Optional<PageObject> run(final PageObject... pageObjects) {
49 final ResourceLeftSideMenu resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver);
50 resourceLeftSideMenu.isLoaded();
52 final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage = accessPropertiesAssignmentPage();
54 checkSoftwareVersionProperty(resourcePropertiesAssignmentPage);
55 return Optional.empty();
59 * Checks if the software_version property values are as expected by the {@link #expectedSoftwareVersionList}.
61 * @param resourcePropertiesAssignmentPage the resource properties assignment page
63 private void checkSoftwareVersionProperty(final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage) {
64 extendTest.log(Status.INFO,
65 String.format("Checking the presence of software versions '%s' in 'software_versions' property",
66 getSoftwareVersionListAsString())
68 final List<String> actualSoftwareVersionList = resourcePropertiesAssignmentPage.getSoftwareVersionProperty();
69 assertThat("Software Version should have the expected size", actualSoftwareVersionList,
70 hasSize(expectedSoftwareVersionList.size()));
71 assertThat("Software Version should be as expected", actualSoftwareVersionList,
72 containsInAnyOrder(expectedSoftwareVersionList.toArray(new String[0])));
76 * Accesses the properties assignment page by clicking in the resource left side menu.
78 * @return the resulting resource properties assignment page
80 private ResourcePropertiesAssignmentPage accessPropertiesAssignmentPage() {
81 final ResourceLeftSideMenu resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver);
82 resourceLeftSideMenu.isLoaded();
84 extendTest.log(Status.INFO,
85 String.format("Accessing the Properties Assignment page to check the software versions '%s'",
86 getSoftwareVersionListAsString())
88 final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage =
89 resourceLeftSideMenu.clickOnPropertiesAssignmentMenuItem();
90 resourcePropertiesAssignmentPage.isLoaded();
91 return resourcePropertiesAssignmentPage;
95 * Converts the {@link #expectedSoftwareVersionList} in a comma + space separated string.
97 * @return the software version list as a comma + space separated string
99 private String getSoftwareVersionListAsString() {
100 return String.join(", ", expectedSoftwareVersionList);