Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-17316 cldr-apps-webdriver Java formatting with spotless #41

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<ratchetFrom>NONE</ratchetFrom>
<!-- define a language-specific format -->
<java>
<toggleOffOn />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srl295 I'm a little surprised that cldr didn't need this, which enables spotless:on/off comments for disabling formatting of a few long arrays... probably those arrays should be implemented differently anyway but I think this is better than one item per line...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLDR probably needs this but didn't know about it. we just let spotless do what it wants to do. want to file an issue and/or put on the infra agenda?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put it on the agenda. I don't remember any specific instances of anyone being unhappy with the spotless results. I just vaguely recall such issues when various formatting options were being considered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway is this PR okay?

<!-- no need to specify files, inferred automatically, but you can if you want -->
<!-- apply a specific flavor of google-java-format and reflow long strings -->
<googleJavaFormat>
Expand Down
377 changes: 222 additions & 155 deletions src/test/java/org/unicode/cldr/surveydriver/SurveyDriver.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public class SurveyDriverCredentials {
* "[email protected]"
*/
private static final String EMAIL_AT_DOMAIN = "@cldr-apps-webdriver.org";

private static final String EMAIL_PREFIX = "driver-";

/**
* cldr-apps-webdriver/src/test/resources/org/unicode/cldr/surveydriver/surveydriver.properties
* -- not in version control; contains a line WEBDRIVER_PASSWORD=...
*/
private static final String PROPS_FILENAME = "surveydriver.properties";

private static final String PROPS_PASSWORD_KEY = "WEBDRIVER_PASSWORD";
private static String webdriverPassword = null;

Expand All @@ -27,8 +29,8 @@ private SurveyDriverCredentials(String email) {
}

/**
* Get credentials for logging in as a particular user depending on which Selenium slot
* we're running on.
* Get credentials for logging in as a particular user depending on which Selenium slot we're
* running on.
*/
public static SurveyDriverCredentials getForUser(int userIndex) {
String email = EMAIL_PREFIX + userIndex + EMAIL_AT_DOMAIN;
Expand All @@ -43,7 +45,8 @@ public String getPassword() {
if (webdriverPassword != null) {
return webdriverPassword;
}
final InputStream stream = SurveyDriverCredentials.class.getResourceAsStream(PROPS_FILENAME);
final InputStream stream =
SurveyDriverCredentials.class.getResourceAsStream(PROPS_FILENAME);
if (stream == null) {
throw new RuntimeException("File not found: " + PROPS_FILENAME);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.unicode.cldr.surveydriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class SurveyDriverDashboard {

Expand Down Expand Up @@ -53,7 +51,8 @@ private boolean testOne(int i) {
// button is from GeneralInfo.vue, and its class includes "general-open-dash".
// There are other "Open Dashboard" buttons produced in cldrGui.mjs, and a
// "Dashboard" item in the left-sidebar.
// For unknown reasons, clickButtonByXpath with "//button[contains(., 'Open Dashboard')]" fails here.
// For unknown reasons, clickButtonByXpath with "//button[contains(., 'Open Dashboard')]"
// fails here.
if (!s.clickButtonByClassName("general-open-dash", url)) {
return false;
}
Expand Down
64 changes: 32 additions & 32 deletions src/test/java/org/unicode/cldr/surveydriver/SurveyDriverData.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
/**
*
*/
/** */
package org.unicode.cldr.surveydriver;

/**
* Data for SurveyDriver: lists of locales and pages
*/
/** Data for SurveyDriver: lists of locales and pages */
public class SurveyDriverData {

/**
* This list of page names was created by temporarily commenting out the toString function
* in PathHeader.java, and inserting this line into the PageId initialization function:
* This list of page names was created by temporarily commenting out the toString function in
* PathHeader.java, and inserting this line into the PageId initialization function:
* System.out.println("PageId raw name: " + this.toString());
* <p>
* It would be better to have an API for requesting this list from the ST back end at runtime!
* <p>
* There is a PageId enum defined in PathHeader.java. We could link with the
* cldr-apps code and access that enum directly. However, there are difficulties
* with initiation, like "java.lang.RuntimeException: CLDRConfigImpl used before SurveyMain.init() called!"
* "Set -DCLDR_ENVIRONMENT=UNITTEST if you are in the test cases." Follow up on that possibility later.
* In the meantime, we can copy and simplify the enum from PathHeader.java, since all we need here
* is an array of strings.
* <p>
* PageId versus SectionId: PageId.Alphabetic_Information is in the section SectionId.Core_Data
* <p>
* Alphabetic_Information(SectionId.Core_Data, "Alphabetic Information")
* <p>
* Each page is one web page; a section may encompass multiple pages, not all visible at once.
* (There may also be multiple headers in one page. See PathHeader.txt which is a source file.)
*
* <p>It would be better to have an API for requesting this list from the ST back end at
* runtime!
*
* <p>There is a PageId enum defined in PathHeader.java. We could link with the cldr-apps code
* and access that enum directly. However, there are difficulties with initiation, like
* "java.lang.RuntimeException: CLDRConfigImpl used before SurveyMain.init() called!" "Set
* -DCLDR_ENVIRONMENT=UNITTEST if you are in the test cases." Follow up on that possibility
* later. In the meantime, we can copy and simplify the enum from PathHeader.java, since all we
* need here is an array of strings.
*
* <p>PageId versus SectionId: PageId.Alphabetic_Information is in the section
* SectionId.Core_Data
*
* <p>Alphabetic_Information(SectionId.Core_Data, "Alphabetic Information")
*
* <p>Each page is one web page; a section may encompass multiple pages, not all visible at
* once. (There may also be multiple headers in one page. See PathHeader.txt which is a source
* file.)
*/
private static final String[] pages = {
// prettier-ignore
// spotless:off
"Alphabetic_Information", "Numbering_Systems", "LinguisticElements", "Locale_Name_Patterns",
"Languages_A_D", "Languages_E_J", "Languages_K_N", "Languages_O_S", "Languages_T_Z", "Scripts",
"Territories", "T_NAmerica", "T_SAmerica", "T_Africa", "T_Europe", "T_Asia", "T_Oceania", "Locale_Variants",
Expand All @@ -55,23 +54,23 @@ public class SurveyDriverData {
"WeekData", "Measurement", "Language", "RBNF", "Segmentation", "DayPeriod", "Category", "Smileys", "People",
"Animals_Nature", "Food_Drink", "Travel_Places", "Activities", "Objects", "Symbols2", "Flags", "Component",
"Typography",
// spotless:on
};

/**
* These are pages for which special annotation vote resolution is applicable
*/
/** These are pages for which special annotation vote resolution is applicable */
private static final String[] annotationPages = {
// prettier-ignore
// spotless:off
"Category", "Smileys", "People", "Animals_Nature", "Food_Drink",
"Travel_Places", "Activities", "Objects", "Symbols2", "Flags",
// spotless:on
};

/**
* This list of locales was obtained by putting a breakpoint on SurveyAjax.getLocalesSet, getting its
* return value, and adding quotation marks by search/replace.
* This list of locales was obtained by putting a breakpoint on SurveyAjax.getLocalesSet,
* getting its return value, and adding quotation marks by search/replace.
*/
private static final String[] locales = {
// prettier-ignore
// spotless:off
"aa", "aa_DJ", "aa_ER", "aa_ET", "af", "af_NA", "af_ZA", "agq", "agq_CM",
"ak",
"ak_GH", "am", "am_ET", "ar", "ar_001", "ar_AE", "ar_BH", "ar_DJ", "ar_DZ", "ar_EG", "ar_EH", "ar_ER",
Expand Down Expand Up @@ -151,6 +150,7 @@ public class SurveyDriverData {
"yue_Hans", "yue_Hans_CN", "yue_Hant", "yue_Hant_HK", "zgh", "zgh_MA", "zh", "zh_Hans", "zh_Hans_CN",
"zh_Hans_HK", "zh_Hans_MO", "zh_Hans_SG", "zh_Hant", "zh_Hant_HK", "zh_Hant_MO", "zh_Hant_TW", "zu",
"zu_ZA",
// spotless:on
};

public static String[] getPages() {
Expand Down
Loading
Loading