Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
#156 Merge branch 'master' into 156
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiitek committed Apr 25, 2017
2 parents a5259ea + 4d4f1ff commit 5423a51
Show file tree
Hide file tree
Showing 75 changed files with 288 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum RtButton {

private final String css;

private RtButton(String css) {
RtButton(String css) {
this.css = css;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum ModeIcon {

private final String iconName;

private ModeIcon(final String iconName) {
ModeIcon(final String iconName) {
this.iconName = iconName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public enum PageOperation {

private final SidekickSection section;

private PageOperation(final SidekickTab tab, final SidekickSection section,
PageOperation(final SidekickTab tab, final SidekickSection section,
final String operationName) {
this.tab = tab;
this.section = section;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.cognifide.qa.bb.qualifier.FindPageObject;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import com.cognifide.qa.bb.qualifier.Frame;
import com.cognifide.qa.bb.qualifier.PageObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum SidekickTab {

private final String tabName;

private SidekickTab(final String tabName) {
SidekickTab(final String tabName) {
this.tabName = tabName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ public void installAemPackage(String packageName) throws IOException {
public void activateAemPackage(String packageName) throws IOException {
HttpPost upload = builder.createUploadRequest();
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
entityBuilder.addBinaryBody("package", new File(CONTENT_PATH, packageName),
File file = new File(CONTENT_PATH, packageName);
if(!file.exists()) {
throw new IllegalArgumentException("The provided package doesn't exist: " + file.getPath());
}
entityBuilder.addBinaryBody("package", file,
ContentType.DEFAULT_BINARY, packageName);
entityBuilder.addTextBody("force", "true");
upload.setEntity(entityBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public class WcmCommandHandler {
*/
public void activatePage(String assetPath) throws IOException {
triggerAction(Maps.newHashMap(new ImmutableMap.Builder<String, String>()
.put(PATH_PROPERTY, assetPath)
.put(CMD_PROPERTY, ACTIVATE)
.put(CHARSET_PROPERTY, UTF_8).build()), REPLICATE_URL,
.put(PATH_PROPERTY, assetPath)
.put(CMD_PROPERTY, ACTIVATE)
.put(CHARSET_PROPERTY, UTF_8).build()), REPLICATE_URL,
REPLICATION_STARTED_MESSAGE + assetPath);
}

Expand All @@ -98,9 +98,9 @@ public void activatePage(String assetPath) throws IOException {
*/
public void deactivatePage(String assetPath) throws IOException {
triggerAction(Maps.newHashMap(new ImmutableMap.Builder<String, String>()
.put(PATH_PROPERTY, assetPath)
.put(CMD_PROPERTY, DEACTIVATE)
.put(CHARSET_PROPERTY, UTF_8).build()), REPLICATE_URL,
.put(PATH_PROPERTY, assetPath)
.put(CMD_PROPERTY, DEACTIVATE)
.put(CHARSET_PROPERTY, UTF_8).build()), REPLICATE_URL,
REPLICATION_STARTED_MESSAGE + assetPath);
}

Expand Down Expand Up @@ -129,9 +129,9 @@ public void createPage(String parentPath, String title, String template) throws
*/
public void deletePage(String path) throws IOException {
triggerAction(Maps.newHashMap(new ImmutableMap.Builder<String, String>()
.put(CMD_PROPERTY, DELETE_PAGE_COMMAND)
.put(CHARSET_PROPERTY, UTF_8)
.put(PATH_PROPERTY, path.toLowerCase()).build()), WCM_COMMAND_URL,
.put(CMD_PROPERTY, DELETE_PAGE_COMMAND)
.put(CHARSET_PROPERTY, UTF_8)
.put(PATH_PROPERTY, path.toLowerCase()).build()), WCM_COMMAND_URL,
String.format(PAGE_DELETED_SUCCESS_MESSAGE_FORMAT, path.toLowerCase()));
}

Expand All @@ -140,7 +140,7 @@ public void deletePage(String path) throws IOException {
*
* @param postProperties properties map to send
* @param successMessage expected success message
* @param commandUrl command
* @param commandUrl command
* @throws IOException if response doesn't contain desired message
*/
public void triggerAction(Map<String, String> postProperties, String commandUrl,
Expand All @@ -149,9 +149,9 @@ public void triggerAction(Map<String, String> postProperties, String commandUrl,
HttpPost request = new HttpPost(String.format(commandUrl, authorIp));
List<BasicNameValuePair> params = new ArrayList<>();
postProperties.entrySet().stream().
forEach((property) -> {
params.add(new BasicNameValuePair(property.getKey(), property.getValue()));
});
forEach(property ->
params.add(new BasicNameValuePair(property.getKey(), property.getValue()))
);
request.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
sender.sendCrxRequest(request, successMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public Map<String, ComponentConfiguration> getConfigs(String component) {

Map<String, ComponentConfiguration> result = new HashMap<>();

configsData.keySet().stream().forEach((configName) -> {
configsData.keySet().stream().forEach(configName -> {
Map<String, List<FieldConfig>> data = configsData.get(configName);
List<TabConfig> tabsConfig = new ArrayList<>();
data.entrySet().stream().forEach((entry) -> {
tabsConfig.add(new TabConfig(entry.getKey(), entry.getValue()));
});
data.entrySet().stream().forEach(entry ->
tabsConfig.add(new TabConfig(entry.getKey(), entry.getValue()))
);
result.put(configName, new ComponentConfiguration(tabsConfig));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ public List<FieldConfig> getConfigurationForTab(String tab) {
* Returns first {@link FieldConfig} with provided label
*
* @param tabName Tab name in the dialog window
* @param configurationKey key of yaml component configuration
* @param label field label
* @return
*/
public FieldConfig getFieldConfigByLabel(String tabName, String configurationKey, String label) {
public FieldConfig getFieldConfigByLabel(String tabName, String label) {
return getConfigurationForTab(tabName).stream()
.filter(t -> StringUtils.equals(t.getLabel(), label))
.findFirst()
Expand All @@ -63,11 +62,10 @@ public FieldConfig getFieldConfigByLabel(String tabName, String configurationKey
/**
*
* @param tabName Tab name in the dialog window
* @param configurationKey onfigurationKey key of yaml configuration
* @param type field type provided in yaml component configuration
* @return
*/
public List<FieldConfig> getFieldConfigsByType(String tabName, String configurationKey, String type) {
public List<FieldConfig> getFieldConfigsByType(String tabName, String type) {
return getConfigurationForTab(tabName).stream()
.filter(t -> StringUtils.equals(t.getType(), type))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Map<String, String> getExpected(ComponentConfiguration config,
final Map<String, String> result = new HashMap<>();

config.getTabs().stream()
.forEach((tab) -> {
.forEach(tab -> {
List<FieldConfig> fieldConfigs = config.getConfigurationForTab(tab.getTabName());
result.putAll(fieldConfigs.stream()
.filter(fieldConfig -> fieldConfig.getValue() instanceof String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
import static org.openqa.selenium.support.ui.ExpectedConditions.not;

import java.util.List;
import java.util.Map;
import java.util.Objects;

import com.cognifide.qa.bb.qualifier.FindPageObject;
import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -229,12 +226,10 @@ private void verifyParsysRerendered(String parsys) {
}

private void retryLoad() {
conditions.verify(new ExpectedCondition<Object>() {
@Nullable @Override public Object apply(WebDriver driver) {
conditions.verify(ignored -> {
LOG.debug("Retrying page open");
driver.navigate().refresh();
return isLoadedCondition();
}
}, Timeouts.MEDIUM);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public <T> T fromPage(Class<T> component) {
scope = webDriver.findElement(By.cssSelector(selector));
} catch (IllegalAccessException e) {
LOG.info(
"CSS not accessible, page object injected with default scope: {}", component.getName());
"CSS not accessible, page object injected with default scope: {} Exception: {}", component.getName(), e);
} catch (NoSuchFieldException e) {
LOG.info(
"CSS field not present in the page object, page object injected with default scope: {}",
component.getName());
"CSS field not present in the page object, page object injected with default scope: {} Exception: {}",
component.getName(), e);
}
return scope == null ?
pageObjectInjector.inject(component) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ private void tryToSelect() {
private void tryToOpenInsertWindow() {
conditions.verify(ignored -> {
try {
boolean isInsertButtonPresent = driver
boolean isInsertButtonPresent = !driver
.findElements(By.cssSelector(INSERT_BUTTON_SELECTOR))
.size() > 0;
.isEmpty();
if(!isInsertButtonPresent) {
// AEM 6.1
actions.doubleClick(dropArea).perform();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ public interface SiteadminActions {
* @param title
* @return
*/
public SiteadminChildPage getPageFromList(String title);
SiteadminChildPage getPageFromList(String title);

}
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
/*
* Copyright 2016 Cognifide Ltd..
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.cognifide.qa.bb.aem.touch.siteadmin.aem61;

import java.time.LocalDateTime;

import javax.annotation.Nullable;

import org.openqa.selenium.By;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedCondition;

import com.cognifide.qa.bb.aem.touch.siteadmin.SiteadminActions;
import com.cognifide.qa.bb.aem.touch.siteadmin.aem61.list.ChildPageRow;
Expand Down Expand Up @@ -76,7 +71,8 @@ public class SiteadminPage implements Loadable, SiteadminActions {
@LoadableComponent(condClass = IsLoadedCondition.class)
private ChildPageWindow childPageWindow;

@FindBy(css = "nav.foundation-layout-mode2-item.endor-ActionBar.js-granite-endor-ActionBar > div.endor-ActionBar-left")
@FindBy(
css = "nav.foundation-layout-mode2-item.endor-ActionBar.js-granite-endor-ActionBar > div.endor-ActionBar-left")
private SiteadminToolbar toolbar;

@Override
Expand Down Expand Up @@ -120,14 +116,12 @@ public SiteadminActions copyPage(String title, String destination) {

@Override
public SiteadminActions waitForPageCount(int pageCount) {
boolean conditionNotMet = !webElementUtils.isConditionMet(new ExpectedCondition<Object>() {
@Nullable @Override public Object apply(@Nullable WebDriver webDriver) {
try {
return (pageCount == getChildPageWindow().getPageCount());
} catch (StaleElementReferenceException e) {
webDriver.navigate().refresh();
return false;
}
boolean conditionNotMet = !webElementUtils.isConditionMet(webDriver -> {
try {
return pageCount == getChildPageWindow().getPageCount();
} catch (StaleElementReferenceException e) {
webDriver.navigate().refresh();
return false;
}
}, Timeouts.SMALL);
if (conditionNotMet) {
Expand Down Expand Up @@ -231,23 +225,18 @@ private String getSiteAdminUrl() {
}

private void waitForExpectedStatus(final String title, ActivationStatus status) {
wait.withTimeout(Timeouts.MEDIUM).until(new ExpectedCondition<Boolean>() {
@Nullable @Override public Boolean apply(@Nullable WebDriver webDriver) {
webDriver.navigate().refresh();
ChildPageRow childPage = getChildPageWindow().getChildPageRow(title);
PageActivationStatus pageActivationStatusCell = childPage.getPageActivationStatus();
ActivationStatus activationStatus = pageActivationStatusCell.getActivationStatus();
return activationStatus.equals(status);
}
wait.withTimeout(Timeouts.MEDIUM).until(webDriver -> {
webDriver.navigate().refresh();
ChildPageRow childPage = getChildPageWindow().getChildPageRow(title);
PageActivationStatus pageActivationStatusCell = childPage.getPageActivationStatus();
ActivationStatus activationStatus = pageActivationStatusCell.getActivationStatus();
return activationStatus.equals(status);
}, Timeouts.SMALL);
}

private void waitForPageToAppearOnTheList(final String title) {
wait.withTimeout(Timeouts.MEDIUM).until(new ExpectedCondition<Boolean>() {
@Nullable @Override public Boolean apply(@Nullable WebDriver webDriver) {
return getChildPageWindow().containsPage(title);
}
}, Timeouts.SMALL);
wait.withTimeout(Timeouts.MEDIUM).until(webDriver -> getChildPageWindow().containsPage(title),
Timeouts.SMALL);
}

private ChildPageWindow getChildPageWindow() {
Expand All @@ -257,15 +246,11 @@ private ChildPageWindow getChildPageWindow() {
}

private void retryLoad() {
conditions.verify(new ExpectedCondition<Object>() {
@Nullable
@Override
public Object apply(WebDriver driver) {
if (!isLoadedCondition()) {
driver.navigate().refresh();
}
return isLoadedCondition();
conditions.verify(webDriver -> {
if (!isLoadedCondition()) {
webDriver.navigate().refresh();
}
return isLoadedCondition();
}, Timeouts.MEDIUM);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import com.cognifide.qa.bb.loadable.annotation.LoadableComponent;
import com.cognifide.qa.bb.loadable.condition.impl.VisibilityCondition;
import com.cognifide.qa.bb.constants.Timeouts;
import com.cognifide.qa.bb.provider.selenium.BobcatWait;
import com.cognifide.qa.bb.qualifier.Global;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void selectDate(int year, Month month) {
private boolean isDesiredDateSelected(int year, Month month) {
String[] headerParts = yearMonthHeader.getText().toUpperCase().split(" ");
Month selectedMonth = Month.valueOf(headerParts[0]);
int selectedYear = Integer.valueOf(headerParts[1].toUpperCase());
return year == selectedYear && selectedMonth.equals(month);
int selectedYear = Integer.parseInt(headerParts[1].toUpperCase());
return year == selectedYear && selectedMonth == month;
}
}
Loading

0 comments on commit 5423a51

Please sign in to comment.