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 static org.hamcrest.Matchers.containsInAnyOrder;
23 import static org.hamcrest.Matchers.hasSize;
24 import static org.junit.Assert.assertThat;
26 import com.aventstack.extentreports.Status;
27 import java.util.List;
28 import java.util.Optional;
29 import org.openecomp.sdc.ci.tests.pages.PageObject;
30 import org.openecomp.sdc.ci.tests.pages.ResourceLeftSideMenu;
31 import org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage;
32 import org.openqa.selenium.WebDriver;
35 * UI Flow for checking the software version property in a resource
37 public class CheckSoftwareVersionPropertyFlow extends AbstractUiTestFlow {
39 private final List<String> expectedSoftwareVersionList;
41 public CheckSoftwareVersionPropertyFlow(final WebDriver webDriver, final List<String> expectedSoftwareVersionList) {
43 this.expectedSoftwareVersionList = expectedSoftwareVersionList;
47 public Optional<PageObject> run(final PageObject... pageObjects) {
48 final ResourceLeftSideMenu resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver);
49 resourceLeftSideMenu.isLoaded();
51 final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage = accessPropertiesAssignmentPage();
53 checkSoftwareVersionProperty(resourcePropertiesAssignmentPage);
54 return Optional.empty();
58 * Checks if the software_version property values are as expected by the {@link #expectedSoftwareVersionList}.
60 * @param resourcePropertiesAssignmentPage the resource properties assignment page
62 private void checkSoftwareVersionProperty(final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage) {
63 extendTest.log(Status.INFO,
64 String.format("Checking the presence of software versions '%s' in 'software_versions' property",
65 getSoftwareVersionListAsString())
67 final List<String> actualSoftwareVersionList = resourcePropertiesAssignmentPage.getSoftwareVersionProperty();
68 assertThat("Software Version should have the expected size", actualSoftwareVersionList,
69 hasSize(expectedSoftwareVersionList.size()));
70 assertThat("Software Version should be as expected", actualSoftwareVersionList,
71 containsInAnyOrder(expectedSoftwareVersionList.toArray(new String[0])));
75 * Accesses the properties assignment page by clicking in the resource left side menu.
77 * @return the resulting resource properties assignment page
79 private ResourcePropertiesAssignmentPage accessPropertiesAssignmentPage() {
80 final ResourceLeftSideMenu resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver);
81 resourceLeftSideMenu.isLoaded();
83 extendTest.log(Status.INFO,
84 String.format("Accessing the Properties Assignment page to check the software versions '%s'",
85 getSoftwareVersionListAsString())
87 final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage =
88 resourceLeftSideMenu.clickOnPropertiesAssignmentMenuItem();
89 resourcePropertiesAssignmentPage.isLoaded();
90 return resourcePropertiesAssignmentPage;
94 * Converts the {@link #expectedSoftwareVersionList} in a comma + space separated string.
96 * @return the software version list as a comma + space separated string
98 private String getSoftwareVersionListAsString() {
99 return String.join(", ", expectedSoftwareVersionList);