Skip to content

Commit

Permalink
Merge pull request #303 from axonivy/format
Browse files Browse the repository at this point in the history
Format and Clean up Java source code as defined in ADR-029
  • Loading branch information
ivy-cst authored Dec 31, 2024
2 parents aa84a61 + ae51820 commit bb7feda
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Accordion toggleTab(String tabName) {
accordionTab(tabName).click();
String tabContentId = StringUtils.removeEnd(accordionTab(tabName).getAttribute("id"), "_header");
$(By.id(tabContentId)).should(match("accordion should not animate",
el -> !el.getAttribute("style").contains("overflow")));
el -> !el.getAttribute("style").contains("overflow")));
$(By.id(tabContentId)).shouldBe(attribute("aria-hidden", previousState));
return this;
}
Expand Down Expand Up @@ -86,6 +86,6 @@ public boolean isTabOpen(String tabName) {

private SelenideElement accordionTab(String tabName) {
return $(By.id(accordionId)).findAll(".ui-accordion-header").find(text(tabName)).shouldBe(visible,
enabled);
enabled);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright (C) 2021 Axon Ivy AG
*
*
* 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
*
*
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ public boolean isDisabled() {
private SelenideElement checkbox() {
return $(By.id(booleanCheckboxId)).find(".ui-chkbox-box").shouldBe(visible);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SelectCheckboxMenu selectAllItems() {
openCheckboxPanel();
$(By.id(checkBoxMenuId + "_panel")).find(".ui-widget-header .ui-chkbox-box").shouldBe(visible).click();
$(By.id(checkBoxMenuId + "_panel")).find(".ui-widget-header .ui-chkbox-box")
.shouldHave(cssClass("ui-state-active"));
.shouldHave(cssClass("ui-state-active"));
closeCheckboxPanel();
return this;
}
Expand Down Expand Up @@ -80,13 +80,13 @@ public SelectCheckboxMenu itemsShouldBeSelected(String... labels) {

private void selectItemInternal(String label) {
$(By.id(checkBoxMenuId + "_panel")).findAll(".ui-selectcheckboxmenu-items li")
.find(text(label)).find(".ui-chkbox-box").shouldBe(visible).click();
.find(text(label)).find(".ui-chkbox-box").shouldBe(visible).click();
checkThatLabelIsSelected(label);
}

private void checkThatLabelIsSelected(String label) {
$(By.id(checkBoxMenuId + "_panel")).findAll(".ui-selectcheckboxmenu-items li")
.find(text(label)).find(".ui-chkbox-box").shouldHave(cssClass("ui-state-active"));
.find(text(label)).find(".ui-chkbox-box").shouldHave(cssClass("ui-state-active"));
}

private void openCheckboxPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ public SelectManyCheckbox(By manyCheckbox) {
@Deprecated
public List<String> getSelectedCheckboxes() {
return $(By.id(manyCheckboxId)).shouldBe(visible).findAll(".ui-chkbox-box")
.filter(cssClass("ui-state-active"))
.asDynamicIterable().stream().map(e -> e.parent().parent().find("label").getText())
.collect(Collectors.toList());
.filter(cssClass("ui-state-active"))
.asDynamicIterable().stream().map(e -> e.parent().parent().find("label").getText())
.collect(Collectors.toList());
}

/**
* The SelectManyCheckbox should match the given collection condition
* @param condition condition
* @return SelectManyCheckbox
*/
public SelectManyCheckbox shouldBe(WebElementsCondition condition) {
public SelectManyCheckbox shouldBe(WebElementsCondition condition) {
var elements = $(By.id(manyCheckboxId)).shouldBe(visible).findAll(".ui-chkbox-box")
.filter(cssClass("ui-state-active"))
.asDynamicIterable().stream().map(e -> e.parent().parent().find("label"))
.collect(Collectors.toList());
.filter(cssClass("ui-state-active"))
.asDynamicIterable().stream().map(e -> e.parent().parent().find("label"))
.collect(Collectors.toList());
var collection = new WebElementsCollectionWrapper(WebDriverRunner.driver(), elements);
new ElementsCollection(collection).shouldBe(condition);
return this;
Expand All @@ -74,7 +74,7 @@ public SelectManyCheckbox shouldBe(WebElementsCondition condition) {
@Deprecated
public boolean isManyCheckboxDisabled() {
return $(By.id(manyCheckboxId)).shouldBe(visible).findAll(".ui-chkbox-box").asDynamicIterable().stream()
.anyMatch(e -> e.has(cssClass("ui-state-disabled")));
.anyMatch(e -> e.has(cssClass("ui-state-disabled")));
}

/**
Expand Down Expand Up @@ -123,6 +123,6 @@ public SelectManyCheckbox clear() {

private SelenideElement getCheckboxForLabel(String value) {
return $(By.id(manyCheckboxId)).findAll("label").find(exactText(value)).parent().find(".ui-chkbox-box")
.shouldBe(visible);
.shouldBe(visible);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getSelectedItem() {
private void selectItem(final String label) {
$(By.id(oneMenuId)).find("span.ui-icon.ui-icon-triangle-1-s").shouldBe(visible).click();
$(By.id(oneMenuId + "_panel")).should(match("menupanel should not animate",
el -> !el.getAttribute("style").contains("opacity")));
el -> !el.getAttribute("style").contains("opacity")));
$(By.id(oneMenuId + "_items")).shouldBe(visible);
$(By.id(oneMenuId + "_items")).findAll("li").find(exactText(label)).shouldBe(visible, enabled).click();
$(By.id(oneMenuId + "_items")).shouldNotBe(visible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ public SelectOneRadio selectItemByLabel(final String label) {
*/
public SelectOneRadio selectedValueShouldBe(WebElementCondition condition) {
$(By.id(oneRadioId)).findAll(".ui-radiobutton-box").find(Condition.cssClass("ui-state-active"))
.parent().find("div > input").shouldBe(condition);
.parent().find("div > input").shouldBe(condition);
return this;
}

@Deprecated
public String getSelectedValue() {
return $(By.id(oneRadioId)).findAll(".ui-radiobutton-box").find(Condition.cssClass("ui-state-active"))
.parent().find("div > input").getValue();
.parent().find("div > input").getValue();
}

private SelenideElement radioById(String id) {
Expand All @@ -89,11 +89,11 @@ private SelenideElement radioById(String id) {

private SelenideElement radioByValue(String value) {
return $(By.cssSelector("input[type='radio'][value='" + value + "']")).parent().parent()
.find("div.ui-radiobutton-box").shouldBe(visible);
.find("div.ui-radiobutton-box").shouldBe(visible);
}

private SelenideElement radioByLabel(String label) {
return $(By.id(oneRadioId)).findAll("label").find(exactText(label)).parent()
.find("div.ui-radiobutton-box").shouldBe(visible);
.find("div.ui-radiobutton-box").shouldBe(visible);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ private void fillInput(By id, String search) {
$(id).shouldBe(visible).clear();
$(id).shouldBe(visible).sendKeys(search);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,92 +18,76 @@
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;

public class ShowcaseUtil
{
public class ShowcaseUtil {
private static String baseShowcaseUrl = "https://primefaces.org/showcase/ui/";

public static Showcase open(Showcase showcase)
{
public static Showcase open(Showcase showcase) {
Selenide.open(baseShowcaseUrl + showcase.url);
return showcase;
}

public static enum Showcase
{
CHECKBOX ("input/booleanCheckbox.xhtml", ".ui-selectbooleancheckbox"),
ONEMENU ("input/oneMenu.xhtml", ".ui-selectonemenu"),
CHECKBOXMENU ("input/checkboxMenu.xhtml", ".ui-selectcheckboxmenu"),
MANYCHECKBOX ("input/manyCheckbox.xhtml", ".ui-selectmanycheckbox"),
ONERADIO ("input/oneRadio.xhtml", ".ui-selectoneradio"),
TABLE ("data/datatable/filter.xhtml", ".ui-datatable"),
ACCORDION ("panel/accordionPanel.xhtml", ".ui-accordion"),
INPUTNUMBER ("input/inputNumber.xhtml", ".ui-inputnumber");

private String url;
private String selector;

Showcase(String url, String selector)
{
public enum Showcase {
CHECKBOX("input/booleanCheckbox.xhtml", ".ui-selectbooleancheckbox"),
ONEMENU("input/oneMenu.xhtml", ".ui-selectonemenu"),
CHECKBOXMENU("input/checkboxMenu.xhtml", ".ui-selectcheckboxmenu"),
MANYCHECKBOX("input/manyCheckbox.xhtml", ".ui-selectmanycheckbox"),
ONERADIO("input/oneRadio.xhtml", ".ui-selectoneradio"),
TABLE("data/datatable/filter.xhtml", ".ui-datatable"),
ACCORDION("panel/accordionPanel.xhtml", ".ui-accordion"),
INPUTNUMBER("input/inputNumber.xhtml", ".ui-inputnumber");

private final String url;
private final String selector;

Showcase(String url, String selector) {
this.url = url;
this.selector = selector;
}

public SelectBooleanCheckbox checkbox(String label)
{
public SelectBooleanCheckbox checkbox(String label) {
return PrimeUi.selectBooleanCheckbox(elementId($$(selector).find(text(label))));
}

public SelectOneMenu oneMenu()
{
public SelectOneMenu oneMenu() {
return PrimeUi.selectOne(firstElement());
}

public SelectOneMenu oneMenuEditable()
{
public SelectOneMenu oneMenuEditable() {
var oneMenuEditable = $$("label").find(exactText("Editable")).parent().find(".ui-selectonemenu");
return PrimeUi.selectOne(elementId(oneMenuEditable));
}


public SelectCheckboxMenu checkboxMenu()
{
public SelectCheckboxMenu checkboxMenu() {
return PrimeUi.selectCheckboxMenu(firstElement());
}

public SelectManyCheckbox manyCheckbox()
{
public SelectManyCheckbox manyCheckbox() {
return PrimeUi.selectManyCheckbox(firstElement());
}

public SelectOneRadio radio()
{
public SelectOneRadio radio() {
return PrimeUi.selectOneRadio(firstElement());
}

public Table table()
{
public Table table() {
return PrimeUi.table(firstElement());
}

public Accordion accordion()
{
public Accordion accordion() {
return PrimeUi.accordion(firstElement());
}

public InputNumber inputNumber()
{
public InputNumber inputNumber() {
return PrimeUi.inputNumber(firstElement());
}

private By firstElement()
{
private By firstElement() {
return elementId($$(selector).filter(visible).first());
}

private By elementId(SelenideElement element)
{
private By elementId(SelenideElement element) {
return By.id(element.attr("id"));
}
}

}
}
Loading

0 comments on commit bb7feda

Please sign in to comment.