Resolves checkstyle errors for remaining p (#1091)

* Reduces checkstyle errors in page-object

* Reduces checkstyle errors in partial-response

* Reduces checkstyle errors in pipeline

* Reduces checkstyle errors in poison-pill

* Reduces checkstyle errors in priority-queue

* Reduces checkstyle errors in private-class-data

* Reduces checkstyle errors in property

* Reduces checkstyle errors in prototype

* Reduces checkstyle errors in proxy
This commit is contained in:
Anurag Agarwal
2019-11-16 18:26:26 +05:30
committed by Ilkka Seppälä
parent 1fdc650545
commit 271d7ae9bd
56 changed files with 281 additions and 313 deletions

View File

@ -26,63 +26,60 @@ package com.iluwatar.pageobject;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Page Object pattern wraps an UI component with an application specific API allowing you to
* manipulate the UI elements without having to dig around with the underlying UI technology used. This is
* especially useful for testing as it means your tests will be less brittle. Your tests can concentrate on
* the actual test cases where as the manipulation of the UI can be left to the internals of the page object
* itself.
* manipulate the UI elements without having to dig around with the underlying UI technology used.
* This is especially useful for testing as it means your tests will be less brittle. Your tests can
* concentrate on the actual test cases where as the manipulation of the UI can be left to the
* internals of the page object itself.
*
* <p>
* Due to this reason, it has become very popular within the test automation community.
* In particular, it is very common in that the page object is used to represent the html pages of a
* web application that is under test. This web application is referred to as AUT (Application Under Test).
* A web browser automation tool/framework like Selenium for instance, is then used to drive the automating
* of the browser navigation and user actions journeys through this web application. Your test class would
* therefore only be responsible for particular test cases and page object would be used by the test class
* for UI manipulation required for the tests.
* <p>Due to this reason, it has become very popular within the test automation community. In
* particular, it is very common in that the page object is used to represent the html pages of a
* web application that is under test. This web application is referred to as AUT (Application Under
* Test). A web browser automation tool/framework like Selenium for instance, is then used to drive
* the automating of the browser navigation and user actions journeys through this web application.
* Your test class would therefore only be responsible for particular test cases and page object
* would be used by the test class for UI manipulation required for the tests.
*
* <p>
* In this implementation rather than using Selenium, the HtmlUnit library is used as a replacement to
* represent the specific html elements and to drive the browser. The purpose of this example is just to
* provide a simple version that showcase the intentions of this pattern and how this pattern is used
* in order to understand it.
* <p>In this implementation rather than using Selenium, the HtmlUnit library is used as a
* replacement to represent the specific html elements and to drive the browser. The purpose of this
* example is just to provide a simple version that showcase the intentions of this pattern and how
* this pattern is used in order to understand it.
*/
public final class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private App() {
}
/**
* Application entry point
*
* <p>
* The application under development is a web application. Normally you would probably have a
* backend that is probably implemented in an object-oriented language (e.g. Java) that serves
* the frontend which comprises of a series of HTML, CSS, JS etc...
* <p>The application under development is a web application. Normally you would probably have a
* backend that is probably implemented in an object-oriented language (e.g. Java) that serves the
* frontend which comprises of a series of HTML, CSS, JS etc...
*
* <p>
* For illustrations purposes only, a very simple static html app is used here. This main method
* just fires up this simple web app in a default browser.
* <p>For illustrations purposes only, a very simple static html app is used here. This main
* method just fires up this simple web app in a default browser.
*
* @param args arguments
*/
public static void main(String[] args) {
try {
File applicationFile = new File(App.class.getClassLoader().getResource("sample-ui/login.html").getPath());
File applicationFile =
new File(App.class.getClassLoader().getResource("sample-ui/login.html").getPath());
// should work for unix like OS (mac, unix etc...)
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(applicationFile);
} else {
// java Desktop not supported - above unlikely to work for Windows so try following instead...
// java Desktop not supported - above unlikely to work for Windows so try instead...
Runtime.getRuntime().exec("cmd.exe start " + applicationFile);
}

View File

@ -29,25 +29,23 @@ import java.io.IOException;
/**
* Page Object pattern wraps an UI component with an application specific API allowing you to
* manipulate the UI elements without having to dig around with the underlying UI technology used. This is
* especially useful for testing as it means your tests will be less brittle. Your tests can concentrate on
* the actual test cases where as the manipulation of the UI can be left to the internals of the page object
* itself.
* manipulate the UI elements without having to dig around with the underlying UI technology used.
* This is especially useful for testing as it means your tests will be less brittle. Your tests can
* concentrate on the actual test cases where as the manipulation of the UI can be left to the
* internals of the page object itself.
*
* <p>
* Due to this reason, it has become very popular within the test automation community.
* In particular, it is very common in that the page object is used to represent the html pages of a
* web application that is under test. This web application is referred to as AUT (Application Under Test).
* A web browser automation tool/framework like Selenium for instance, is then used to drive the automating
* of the browser navigation and user actions journeys through this web application. Your test class would
* therefore only be responsible for particular test cases and page object would be used by the test class
* for UI manipulation required for the tests.
* <p>Due to this reason, it has become very popular within the test automation community. In
* particular, it is very common in that the page object is used to represent the html pages of a
* web application that is under test. This web application is referred to as AUT (Application Under
* Test). A web browser automation tool/framework like Selenium for instance, is then used to drive
* the automating of the browser navigation and user actions journeys through this web application.
* Your test class would therefore only be responsible for particular test cases and page object
* would be used by the test class for UI manipulation required for the tests.
*
* <p>
* In this implementation rather than using Selenium, the HtmlUnit library is used as a replacement to
* represent the specific html elements and to drive the browser. The purpose of this example is just to
* provide a simple version that showcase the intentions of this pattern and how this pattern is used
* in order to understand it.
* <p>In this implementation rather than using Selenium, the HtmlUnit library is used as a
* replacement to represent the specific html elements and to drive the browser. The purpose of this
* example is just to provide a simple version that showcase the intentions of this pattern and how
* this pattern is used in order to understand it.
*/
public final class App {
@ -57,21 +55,20 @@ public final class App {
/**
* Application entry point
*
* <p>
* The application under development is a web application. Normally you would probably have a
* backend that is probably implemented in an object-oriented language (e.g. Java) that serves
* the frontend which comprises of a series of HTML, CSS, JS etc...
* <p>The application under development is a web application. Normally you would probably have a
* backend that is probably implemented in an object-oriented language (e.g. Java) that serves the
* frontend which comprises of a series of HTML, CSS, JS etc...
*
* <p>
* For illustrations purposes only, a very simple static html app is used here. This main method
* just fires up this simple web app in a default browser.
* <p>For illustrations purposes only, a very simple static html app is used here. This main
* method just fires up this simple web app in a default browser.
*
* @param args arguments
*/
public static void main(String[] args) {
try {
File applicationFile = new File(App.class.getClassLoader().getResource("sample-ui/login.html").getPath());
File applicationFile =
new File(App.class.getClassLoader().getResource("sample-ui/login.html").getPath());
// should work for unix like OS (mac, unix etc...)
if (Desktop.isDesktopSupported()) {

View File

@ -26,10 +26,8 @@ package com.iluwatar.pageobject;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -46,7 +44,7 @@ public class AlbumListPage extends Page {
/**
* Constructor
* Constructor.
*/
public AlbumListPage(WebClient webClient) {
super(webClient);
@ -54,7 +52,7 @@ public class AlbumListPage extends Page {
/**
* Navigates to the Album List Page
* Navigates to the Album List Page.
*
* @return {@link AlbumListPage}
*/
@ -76,7 +74,7 @@ public class AlbumListPage extends Page {
}
/**
* Selects an album by the given album title
* Selects an album by the given album title.
*
* @param albumTitle the title of the album to click
* @return the album page

View File

@ -23,11 +23,6 @@
package com.iluwatar.pageobject;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlNumberInput;
import com.gargoylesoftware.htmlunit.html.HtmlOption;
@ -35,6 +30,9 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSelect;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Page Object encapsulating the Album Page (album-page.html)
@ -49,7 +47,7 @@ public class AlbumPage extends Page {
/**
* Constructor
* Constructor.
*/
public AlbumPage(WebClient webClient) {
super(webClient);
@ -57,7 +55,7 @@ public class AlbumPage extends Page {
/**
* Navigates to the album page
* Navigates to the album page.
*
* @return {@link AlbumPage}
*/
@ -81,7 +79,7 @@ public class AlbumPage extends Page {
/**
* Sets the album title input text field
* Sets the album title input text field.
*
* @param albumTitle the new album title value to set
* @return {@link AlbumPage}
@ -94,7 +92,7 @@ public class AlbumPage extends Page {
/**
* Sets the artist input text field
* Sets the artist input text field.
*
* @param artist the new artist value to set
* @return {@link AlbumPage}
@ -107,7 +105,7 @@ public class AlbumPage extends Page {
/**
* Selects the select's option value based on the year value given
* Selects the select's option value based on the year value given.
*
* @param year the new year value to set
* @return {@link AlbumPage}
@ -121,7 +119,7 @@ public class AlbumPage extends Page {
/**
* Sets the album rating input text field
* Sets the album rating input text field.
*
* @param albumRating the new album rating value to set
* @return {@link AlbumPage}
@ -133,20 +131,21 @@ public class AlbumPage extends Page {
}
/**
* Sets the number of songs number input field
* Sets the number of songs number input field.
*
* @param numberOfSongs the new number of songs value to be set
* @return {@link AlbumPage}
*/
public AlbumPage changeNumberOfSongs(int numberOfSongs) {
HtmlNumberInput numberOfSongsNumberField = (HtmlNumberInput) page.getElementById("numberOfSongs");
HtmlNumberInput numberOfSongsNumberField =
(HtmlNumberInput) page.getElementById("numberOfSongs");
numberOfSongsNumberField.setText(Integer.toString(numberOfSongs));
return this;
}
/**
* Cancel changes made by clicking the cancel button
* Cancel changes made by clicking the cancel button.
*
* @return {@link AlbumListPage}
*/
@ -162,7 +161,7 @@ public class AlbumPage extends Page {
/**
* Saves changes made by clicking the save button
* Saves changes made by clicking the save button.
*
* @return {@link AlbumPage}
*/

View File

@ -29,7 +29,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,7 +44,7 @@ public class LoginPage extends Page {
private HtmlPage page;
/**
* Constructor
* Constructor.
*
* @param webClient {@link WebClient}
*/
@ -54,7 +53,7 @@ public class LoginPage extends Page {
}
/**
* Navigates to the Login page
* Navigates to the Login page.
*
* @return {@link LoginPage}
*/
@ -77,7 +76,7 @@ public class LoginPage extends Page {
/**
* Enters the username into the username input text field
* Enters the username into the username input text field.
*
* @param username the username to enter
* @return {@link LoginPage}
@ -90,23 +89,24 @@ public class LoginPage extends Page {
/**
* Enters the password into the password input password field
* Enters the password into the password input password field.
*
* @param password the password to enter
* @return {@link LoginPage}
*/
public LoginPage enterPassword(String password) {
HtmlPasswordInput passwordInputPasswordField = (HtmlPasswordInput) page.getElementById("password");
HtmlPasswordInput passwordInputPasswordField =
(HtmlPasswordInput) page.getElementById("password");
passwordInputPasswordField.setText(password);
return this;
}
/**
* Clicking on the login button to 'login'
* Clicking on the login button to 'login'.
*
* @return {@link AlbumListPage}
* - this is the page that user gets navigated to once successfully logged in
* @return {@link AlbumListPage} - this is the page that user gets navigated to once successfully
* logged in
*/
public AlbumListPage login() {
HtmlSubmitInput loginButton = (HtmlSubmitInput) page.getElementById("loginButton");

View File

@ -26,20 +26,19 @@ package com.iluwatar.pageobject;
import com.gargoylesoftware.htmlunit.WebClient;
/**
* Encapsulation for a generic 'Page'
* Encapsulation for a generic 'Page'.
*/
public abstract class Page {
/**
* Application Under Test path
* This directory location is where html web pages are located
* Application Under Test path This directory location is where html web pages are located.
*/
public static final String AUT_PATH = "../sample-application/src/main/resources/sample-ui/";
protected final WebClient webClient;
/**
* Constructor
* Constructor.
*
* @param webClient {@link WebClient}
*/
@ -48,7 +47,7 @@ public abstract class Page {
}
/**
* Checks that the current page is actually the page this page object represents
* Checks that the current page is actually the page this page object represents.
*
* @return true if so, otherwise false
*/