From caba2a91a5dd29b8343122a90a760f75b84b7abe Mon Sep 17 00:00:00 2001 From: Jason Edstrom Date: Sat, 22 Feb 2020 14:22:07 -0600 Subject: [PATCH] javadoc warnings breaking build --- .../jmaqs/selenium/SeleniumDriverManager.java | 22 +- .../jmaqs/selenium/SeleniumUtilities.java | 81 +-- .../com/magenic/jmaqs/selenium/UIWait.java | 601 ++++++++---------- .../jmaqs/selenium/WebDriverFactory.java | 180 +++--- .../jmaqs/utilities/helper/GenericWait.java | 186 +++--- .../webservices/jdk8/WebServiceDriver.java | 203 +++--- .../webservices/jdk8/WebServiceUtilities.java | 97 ++- 7 files changed, 641 insertions(+), 729 deletions(-) diff --git a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumDriverManager.java b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumDriverManager.java index 64ec72c9f..db946e2fc 100644 --- a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumDriverManager.java +++ b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumDriverManager.java @@ -21,10 +21,11 @@ public class SeleniumDriverManager extends DriverManager { /** - * Initializes a new instance of the class. + * Instantiates a new Selenium driver manager. * - * @param getDriver Function for getting an Selenium web driver - * @param testObject The associated test object + * @param getDriver the get driver + * @param testObject the test object + * @param the type generic */ public SeleniumDriverManager(Supplier getDriver, BaseTestObject testObject) { super(getDriver, testObject); @@ -52,9 +53,9 @@ public void close() { } /** - * Get the web driver. + * Gets web driver. * - * @return The web driver + * @return the web driver */ public WebDriver getWebDriver() { @@ -72,10 +73,10 @@ public WebDriver getWebDriver() { } /** - * Log a verbose message and include the automation specific call stack data. + * Log verbose. * - * @param message The message text - * @param args String format arguments + * @param message the message + * @param args the args */ protected void logVerbose(String message, Object... args) { @@ -97,11 +98,6 @@ protected void logVerbose(String message, Object... args) { System.out.println(messages); } - /** - * Logging startup. - * - * @param webDriver the web driver - */ private void loggingStartup(WebDriver webDriver) { try { WebDriver driver = ((EventFiringWebDriver) webDriver).getWrappedDriver(); diff --git a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumUtilities.java b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumUtilities.java index f5165c9d8..58f4bd7b0 100644 --- a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumUtilities.java +++ b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/SeleniumUtilities.java @@ -27,18 +27,12 @@ import org.openqa.selenium.support.events.EventFiringWebDriver; /** - * Static class for the selenium utilities, ported from MAQS. + * The type Selenium utilities. */ public class SeleniumUtilities { - /** - * Default Date Time Format for appending to files. - */ private static final String DEFAULT_DATE_TIME_FORMAT = "uuuu-MM-dd-HH-mm-ss-SSSS"; - /** - * The constant LOG_MESSAGE_PREFIX. - */ private static final String LOG_MESSAGE_PREFIX = "%s - %s%s"; private SeleniumUtilities() { @@ -56,12 +50,12 @@ public static boolean captureScreenshot(WebDriver webDriver, SeleniumTestObject } /** - * To capture a screenshot during execution. + * Capture screenshot boolean. * - * @param webDriver The WebDriver + * @param webDriver the web driver * @param testObject the test object - * @param appendName Appends a name to the end of a filename - * @return Boolean if the save of the image was successful + * @param appendName the append name + * @return the boolean */ public static boolean captureScreenshot(WebDriver webDriver, SeleniumTestObject testObject, String appendName) { @@ -89,14 +83,13 @@ public static boolean captureScreenshot(WebDriver webDriver, SeleniumTestObject } /** - * To capture a screenshot during execution. + * Capture screenshot string. * - * @param webDriver The WebDriver + * @param webDriver the web driver * @param testObject the test object - * @param directory The directory file path - * @param fileNameWithoutExtension Filename without extension - * @return Path to the log file - * @throws IOException There was a problem creating the screen shot + * @param directory the directory + * @param fileNameWithoutExtension the file name without extension + * @return the string */ public static String captureScreenshot(WebDriver webDriver, SeleniumTestObject testObject, String directory, String fileNameWithoutExtension) { @@ -118,36 +111,28 @@ public static String captureScreenshot(WebDriver webDriver, SeleniumTestObject t return path; } - /** - * Copy file. - * - * @param tempFile the temp file - * @param path the path - * @throws IOException the io exception - */ private static void copyFileToPath(File tempFile, String path) throws IOException { Files.copy(tempFile.toPath(), new File(path).toPath(), StandardCopyOption.COPY_ATTRIBUTES); } /** - * To capture a page source during execution. - * Default parameter appendName of empty string. + * Save page source boolean. * * @param webDriver the web driver - * @param testObject The Appium Test Object - * @return True if saving page source is successful, otherwise false + * @param testObject the test object + * @return the boolean */ public static boolean savePageSource(WebDriver webDriver, SeleniumTestObject testObject) { return savePageSource(webDriver, testObject, ""); } /** - * To capture a page source during execution. + * Save page source boolean. * * @param webDriver the web driver - * @param testObject The Appium Test Object - * @param appendName Appends a name to the end of a filename - * @return True if saving page source is successful, otherwise false + * @param testObject the test object + * @param appendName the append name + * @return the boolean */ public static boolean savePageSource(WebDriver webDriver, SeleniumTestObject testObject, String appendName) { @@ -182,13 +167,13 @@ public static boolean savePageSource(WebDriver webDriver, SeleniumTestObject tes } /** - * To capture Page Source during execution. + * Save page source string. * * @param webDriver the web driver - * @param testObject The Appium Test Object - * @param directory The directory file path - * @param fileNameWithoutExtension File Name Without Extension - * @return Path to the log file + * @param testObject the test object + * @param directory the directory + * @param fileNameWithoutExtension the file name without extension + * @return the string */ public static String savePageSource(WebDriver webDriver, SeleniumTestObject testObject, String directory, String fileNameWithoutExtension) { @@ -214,25 +199,11 @@ public static String savePageSource(WebDriver webDriver, SeleniumTestObject test return path; } - /** - * Calculate file name string. - * - * @param directory the directory - * @param fileNameWithoutExtension the file name without extension - * @param fileExtension the file extension - * @return the string - */ private static String calculateFileName(String directory, String fileNameWithoutExtension, String fileExtension) { return Paths.get(directory, fileNameWithoutExtension + fileExtension).normalize().toString(); } - /** - * Validate directory structure and create if it does not exist. - * - * @param testObject the test object - * @param directory the directory - */ private static void validateDirectoryStructure(SeleniumTestObject testObject, String directory) { try { Path path = new File(directory).toPath(); @@ -246,10 +217,10 @@ private static void validateDirectoryStructure(SeleniumTestObject testObject, St } /** - * Get the web driver from a web element. + * Web element to web driver web driver. * - * @param webElement The web element - * @return The web driver + * @param webElement the web element + * @return the web driver */ public static WebDriver webElementToWebDriver(WebElement webElement) { WebDriver driver; @@ -264,7 +235,7 @@ public static WebDriver webElementToWebDriver(WebElement webElement) { } /** - * Make sure the driver is shut down. + * Kill driver. * * @param webDriver the web driver */ diff --git a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/UIWait.java b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/UIWait.java index 7427e665e..5b86c31d7 100644 --- a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/UIWait.java +++ b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/UIWait.java @@ -27,45 +27,26 @@ import org.openqa.selenium.support.ui.WebDriverWait; /** - * Selenium waiter This is the tool-class used for waiting. It can be used to wait for many - * circumstances (element exist, not exist, be visible, to equal a desired value, etc.. + * The type Ui wait. */ public class UIWait { - /** - * The default value of the Header size... Your header's size may be different. - */ private static final int HEADER_SIZE = 90; - /** - * The default value of the page's body. Your page might have a different Header value. - */ private static final By BODY_BY = By.cssSelector("BODY"); - /** - * The Web driver that the test is currently running on. - */ private WebDriver driver; - /** - * The retry time. - */ private int fluentRetryTime; - /** - * The timeout time. - */ private int timeout; - /** - * The web driver wait that the test is currently running on. - */ private WebDriverWait waitDriver; /** - * Constructor for {@link UIWait} object. + * Instantiates a new Ui wait. * - * @param driver WebDriver + * @param driver the driver */ public UIWait(WebDriver driver) { this(driver, Integer @@ -75,11 +56,11 @@ public UIWait(WebDriver driver) { } /** - * Constructor for SeleniumWait object. + * Instantiates a new Ui wait. * - * @param driver The WebDriver - * @param timeOutInSeconds int value of the total time to wait until timing out - * @param fluentRetryTime int value of seconds to use for fluent retry + * @param driver the driver + * @param timeOutInSeconds the time out in seconds + * @param fluentRetryTime the fluent retry time */ public UIWait(WebDriver driver, final int timeOutInSeconds, final int fluentRetryTime) { this.driver = driver; @@ -89,27 +70,27 @@ public UIWait(WebDriver driver, final int timeOutInSeconds, final int fluentRetr } /** - * Get the WebDriverWait for use outside of this instance class. + * Gets wait driver. * - * @return The WebDriverWait + * @return the wait driver */ public WebDriverWait getWaitDriver() { return this.waitDriver; } /** - * Sets the WebDriverWait. + * Sets wait driver. * - * @param waiter The WebDriverWait + * @param waiter the waiter */ public void setWaitDriver(WebDriverWait waiter) { this.waitDriver = waiter; } /** - * Resets wait default wait driver. + * Reset wait driver web driver wait. * - * @return The WebDriverWait + * @return the web driver wait */ public WebDriverWait resetWaitDriver() { WebDriverWait wait = this.getNewWaitDriver(); @@ -118,22 +99,22 @@ public WebDriverWait resetWaitDriver() { } /** - * Waits until the element is present. + * Wait for present element web element. * - * @param by The by selector - * @return Returns the element if present + * @param by the by + * @return the web element */ public WebElement waitForPresentElement(By by) { return this.waitForPresentElement(by, this.getWaitDriver()); } /** - * Waits until the element is present. + * Wait for present element web element. * - * @param by The by selector - * @param timeOutInMillis The timeout in milliseconds - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return Returns the element if present + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForPresentElement(By by, final int timeOutInMillis, final int sleepInMillis) { @@ -142,35 +123,33 @@ public WebElement waitForPresentElement(By by, final int timeOutInMillis, } /** - * Waits For the element to be present. + * Wait for present element web element. * - * @param by The by selector - * @param wait The wait driver - * @return Returns the element if present + * @param by the by + * @param wait the wait + * @return the web element */ public WebElement waitForPresentElement(By by, WebDriverWait wait) { return wait.until(ExpectedConditions.presenceOfElementLocated(by)); } /** - * Wait for the specified element to be visible on the pages DOM. The first element located with - * the specified By value is returned. + * Wait for visible element web element. * - * @param by Selector to wait for, and return - * @return WebElement - first one found with by + * @param by the by + * @return the web element */ public WebElement waitForVisibleElement(final By by) { return this.waitForVisibleElement(by, getWaitDriver()); } /** - * Wait for the specified element to be visible on the pages DOM. The first element located with - * the specified By value is returned. + * Wait for visible element web element. * - * @param by Selector to wait for, and return - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return WebElement - first one found with by. Null + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForVisibleElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -179,12 +158,11 @@ public WebElement waitForVisibleElement(final By by, final int timeOutInMillis, } /** - * Wait for the specified element to be visible on the pages DOM. The first element located with - * the specified By value is returned. + * Wait for visible element web element. * - * @param by Selector to wait for, and return - * @param wait The wait driver - * @return WebElement - first one found with by. Null + * @param by the by + * @param wait the wait + * @return the web element */ public WebElement waitForVisibleElement(final By by, WebDriverWait wait) { try { @@ -195,22 +173,22 @@ public WebElement waitForVisibleElement(final By by, WebDriverWait wait) { } /** - * Wait until the element exists and is visible. + * Wait until visible element boolean. * - * @param by Selector to wait for - * @return boolean true if element is found + * @param by the by + * @return the boolean */ public boolean waitUntilVisibleElement(final By by) { return waitUntilVisibleElement(by, this.getWaitDriver()); } /** - * Wait until the element exists and is visible. + * Wait until visible element boolean. * - * @param by Selector to wait for - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean true if element is found + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilVisibleElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -219,11 +197,11 @@ public boolean waitUntilVisibleElement(final By by, final int timeOutInMillis, } /** - * Wait until the element exists and is visible. + * Wait until visible element boolean. * - * @param by Selector to wait for - * @param wait The wait driver - * @return boolean true if element is found + * @param by the by + * @param wait the wait + * @return the boolean */ public boolean waitUntilVisibleElement(final By by, WebDriverWait wait) { try { @@ -234,24 +212,22 @@ public boolean waitUntilVisibleElement(final By by, WebDriverWait wait) { } /** - * Wait for the specified element to be present and enabled. The first element located with - * the specified By value is returned. + * Wait for enabled element web element. * - * @param by Selector to wait for, and return - * @return WebElement - first one found with by. Null + * @param by the by + * @return the web element */ public WebElement waitForEnabledElement(final By by) { return waitForEnabledElement(by, this.timeout, this.fluentRetryTime); } /** - * Wait for the specified element to be present and enabled. The first element located with - * the specified By value is returned. + * Wait for enabled element web element. * - * @param by Selector to wait for, and return - * @param timeOutInMillis - the number of milliseconds to wait before failing - * @param sleepInMillis - the number of milliseconds to wait before a recheck - * @return WebElement - first one found with by. Null + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForEnabledElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -263,22 +239,22 @@ public WebElement waitForEnabledElement(final By by, final int timeOutInMillis, } /** - * Wait until the specified element to be present and enabled. + * Wait until enabled element boolean. * - * @param by - Selector to wait for, and return - * @return boolean true if element is found, else false + * @param by the by + * @return the boolean */ public boolean waitUntilEnabledElement(final By by) { return waitUntilEnabledElement(by, this.timeout, this.fluentRetryTime); } /** - * Wait for the specified element to be present and enabled. + * Wait until enabled element boolean. * - * @param by Selector to wait for, and return - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean true if element is found, else false + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilEnabledElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -304,22 +280,22 @@ public boolean waitUntilEnabledElement(final By by, final int timeOutInMillis, } /** - * Waits until the element is disabled. + * Wait until disabled element boolean. * - * @param by the By selector - * @return returns true if the element is disabled, else false + * @param by the by + * @return the boolean */ public boolean waitUntilDisabledElement(By by) { return waitUntilDisabledElement(by, this.timeout, this.fluentRetryTime); } /** - * Waits until the element is disabled. + * Wait until disabled element boolean. * - * @param by the web element - * @param timeOutInMillis he number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return returns true if the element is disabled, else false + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilDisabledElement(By by, final int timeOutInMillis, final int sleepInMillis) { @@ -336,18 +312,20 @@ public boolean waitUntilDisabledElement(By by, final int timeOutInMillis, } /** - * Wait until the element is not displayed or visible. + * Wait for absent element. * - * @param by Selector to not be displayed or visible + * @param by the by */ public void waitForAbsentElement(final By by) { this.waitForAbsentElement(by, this.timeout, this.fluentRetryTime); } /** - * Wait until the element is not displayed or visible. + * Wait for absent element. * - * @param by Selector to not be displayed or visible + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis */ public void waitForAbsentElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -360,21 +338,22 @@ public void waitForAbsentElement(final By by, final int timeOutInMillis, } /** - * Wait until the element is not displayed or visible. + * Wait until absent element boolean. * - * @param by Selector to not be displayed or visible + * @param by the by + * @return the boolean */ public boolean waitUntilAbsentElement(final By by) { return this.waitUntilAbsentElement(by, this.timeout, this.fluentRetryTime); } /** - * Wait until the element is not displayed or visible. + * Wait until absent element boolean. * - * @param by element to not be displayed or visible - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean - true if not displayed + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilAbsentElement(By by, final int timeOutInMillis, final int sleepInMillis) { @@ -399,24 +378,22 @@ public boolean waitUntilAbsentElement(By by, final int timeOutInMillis, final in } /** - * Wait for a selector to present, and then return a list of all WebElements that are located by - * that selector. + * Wait for elements list. * - * @param by Selector value to wait for - * @return List of WebElements - all web elements found by the specified selector + * @param by the by + * @return the list */ public List waitForElements(final By by) { return this.waitForElements(by, getWaitDriver()); } /** - * Wait for a selector to be present and then return a list - * of all WebElements that are located by that selector. + * Wait for elements list. * - * @param by Selector value to wait for - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return List of WebElements - all web elements found by the specified selector + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the list */ public List waitForElements(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -425,23 +402,22 @@ public List waitForElements(final By by, final int timeOutInMillis, } /** - * Wait for a selector to present, and then return a list of all WebElements that are located by - * that selector. + * Wait for elements list. * - * @param by Selector value to wait for - * @param wait The wait driver - * @return List of WebElements - all web elements found by the specified selector + * @param by the by + * @param wait the wait + * @return the list */ public List waitForElements(final By by, WebDriverWait wait) { return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } /** - * Wait for the specified element to have the Exact text. + * Wait for exact text web element. * - * @param by By selector to examine - * @param text String to search for in the text - * @return WebElement - element, null if not found and assert == false + * @param by the by + * @param text the text + * @return the web element */ public WebElement waitForExactText(final By by, final String text) { waitUntilExactText(by, text); @@ -449,24 +425,24 @@ public WebElement waitForExactText(final By by, final String text) { } /** - * Wait until the exact text is present in the specified element. + * Wait until exact text boolean. * - * @param by Selector to examine for the specified text - * @param text String value to verify the specified selector contains - * @return boolean - true if the text was found in the element - else false + * @param by the by + * @param text the text + * @return the boolean */ public boolean waitUntilExactText(final By by, final String text) { return this.waitUntilExactText(by, text, getWaitDriver()); } /** - * Wait until the exact text is present in the specified element. + * Wait until exact text boolean. * - * @param by Selector to examine for the specified text - * @param text String value to verify the specified selector contains - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean - true if the text was found in the element - else false + * @param by the by + * @param text the text + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilExactText(final By by, final String text, final int timeOutInMillis, final int sleepInMillis) { @@ -475,12 +451,12 @@ public boolean waitUntilExactText(final By by, final String text, final int time } /** - * Wait until the exact text is present in the specified element. + * Wait until exact text boolean. * - * @param by Selector to examine for the specified text - * @param text String value to verify the specified selector contains - * @param wait The wait driver - * @return boolean - true if the text was found in the element - else false + * @param by the by + * @param text the text + * @param wait the wait + * @return the boolean */ public boolean waitUntilExactText(final By by, final String text, WebDriverWait wait) { try { @@ -491,11 +467,11 @@ public boolean waitUntilExactText(final By by, final String text, WebDriverWait } /** - * Wait for an element to contain a specified text. + * Wait for contains text web element. * - * @param by Selector to check the containing text - * @param text String that should be contained within the selector - * @return WebElement containing the text + * @param by the by + * @param text the text + * @return the web element */ public WebElement waitForContainsText(final By by, final String text) { if (waitUntilContainsText(by, text, getWaitDriver())) { @@ -506,24 +482,24 @@ public WebElement waitForContainsText(final By by, final String text) { } /** - * Wait until an element contains the specified text. + * Wait until contains text boolean. * - * @param by Selector to check the containing text - * @param text String that should be contained within the selector - * @return boolean - true if the text is contained in the selector, else false + * @param by the by + * @param text the text + * @return the boolean */ public boolean waitUntilContainsText(final By by, final String text) { return this.waitUntilContainsText(by, text, getWaitDriver()); } /** - * Wait until an element contains the specified text. + * Wait until contains text boolean. * - * @param by Selector to check the containing text - * @param text String that should be contained within the selector - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean - true if the text is contained in the selector, else false + * @param by the by + * @param text the text + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilContainsText(final By by, final String text, final int timeOutInMillis, final int sleepInMillis) { @@ -532,12 +508,12 @@ public boolean waitUntilContainsText(final By by, final String text, final int t } /** - * Wait until the element contains the specified text. + * Wait until contains text boolean. * - * @param by Selector to check the containing text - * @param text String that should be contained within the selector - * @param wait int value of seconds to wait before timing out - * @return boolean - true if the text is contained in the selector, else false + * @param by the by + * @param text the text + * @param wait the wait + * @return the boolean */ public boolean waitUntilContainsText(final By by, final String text, WebDriverWait wait) { try { @@ -548,12 +524,12 @@ public boolean waitUntilContainsText(final By by, final String text, WebDriverWa } /** - * Wait until an attribute of the specified selector to be present and equal the desired value. + * Wait until attribute text equals boolean. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @return true if the attribute with the specified text value is found, else false + * @param by the by + * @param attribute the attribute + * @param text the text + * @return the boolean */ public boolean waitUntilAttributeTextEquals(final By by, final String attribute, final String text) { @@ -561,14 +537,14 @@ public boolean waitUntilAttributeTextEquals(final By by, final String attribute, } /** - * Wait until an attribute of the specified selector to be present. + * Wait until attribute text equals boolean. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @param timeOutInMillis - the number of milliseconds to wait before failing - * @param sleepInMillis - the number of milliseconds to wait before a recheck - * @return true if the attribute with the specified text value is found, else false + * @param by the by + * @param attribute the attribute + * @param text the text + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilAttributeTextEquals(final By by, final String attribute, final String text, final int timeOutInMillis, final int sleepInMillis) { @@ -577,12 +553,12 @@ public boolean waitUntilAttributeTextEquals(final By by, final String attribute, } /** - * Wait for an attribute of the specified selector to be present. + * Wait for attribute text equals web element. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @return Webelement of the selector that is found + * @param by the by + * @param attribute the attribute + * @param text the text + * @return the web element */ public WebElement waitForAttributeTextEquals(final By by, final String attribute, final String text) { @@ -590,14 +566,14 @@ public WebElement waitForAttributeTextEquals(final By by, final String attribute } /** - * Wait for an attribute of the specified selector to be present and equal the desired value. + * Wait for attribute text equals web element. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return WebElement of the selector that is found + * @param by the by + * @param attribute the attribute + * @param text the text + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForAttributeTextEquals(final By by, final String attribute, final String text, final int timeOutInMillis, final int sleepInMillis) { @@ -606,13 +582,13 @@ public WebElement waitForAttributeTextEquals(final By by, final String attribute } /** - * Wait for an attribute of the specified selector to be present and equal the desired value. + * Wait for attribute text equals web element. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @param wait int version of the timeout in seconds - * @return WebElement of the selector that is found + * @param by the by + * @param attribute the attribute + * @param text the text + * @param wait the wait + * @return the web element */ public WebElement waitForAttributeTextEquals(final By by, final String attribute, final String text, WebDriverWait wait) { @@ -625,12 +601,12 @@ public WebElement waitForAttributeTextEquals(final By by, final String attribute } /** - * Wait for an attribute of the specified selector to be present, and contain the specified text. + * Wait until attribute text contains boolean. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @return true if the attribute with the specified text value is found, else false + * @param by the by + * @param attribute the attribute + * @param text the text + * @return the boolean */ public boolean waitUntilAttributeTextContains(final By by, final String attribute, final String text) { @@ -638,14 +614,14 @@ public boolean waitUntilAttributeTextContains(final By by, final String attribut } /** - * Wait for an attribute of the specified selector to be present, and contain the specified text. + * Wait until attribute text contains boolean. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return true if the attribute with the specified text value is found, else false + * @param by the by + * @param attribute the attribute + * @param text the text + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilAttributeTextContains(final By by, final String attribute, final String text, final int timeOutInMillis, final int sleepInMillis) { @@ -654,14 +630,14 @@ public boolean waitUntilAttributeTextContains(final By by, final String attribut } /** - * Wait for an attribute of the specified selector to be present, and contain the specified text. + * Wait until attribute boolean. * - * @param by Selector to look for - * @param attribute String value of the attribute to look at on the specified selector - * @param text String value of the text to look for in the attribute - * @param wait The wait driver - * @param contains boolean true if checking if contains, false if exact match - * @return true if the attribute with the specified text value is found, else false + * @param by the by + * @param attribute the attribute + * @param text the text + * @param wait the wait + * @param contains the contains + * @return the boolean */ public boolean waitUntilAttribute(final By by, final String attribute, final String text, WebDriverWait wait, final boolean contains) { @@ -673,22 +649,22 @@ public boolean waitUntilAttribute(final By by, final String attribute, final Str } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait for clickable element and scroll into view web element. * - * @param by Selector to wait for and focus on - * @return WebElement + * @param by the by + * @return the web element */ public WebElement waitForClickableElementAndScrollIntoView(final By by) { return this.waitForClickableElementAndScrollIntoView(by, getWaitDriver()); } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait for clickable element and scroll into view web element. * - * @param by Selector to wait for and focus on - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return WebElement + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForClickableElementAndScrollIntoView(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -697,11 +673,11 @@ public WebElement waitForClickableElementAndScrollIntoView(final By by, final in } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait for clickable element and scroll into view web element. * - * @param by Selector to wait for and focus on - * @param wait int value of seconds to wait for before timing out - * @return WebElement + * @param by the by + * @param wait the wait + * @return the web element */ public WebElement waitForClickableElementAndScrollIntoView(final By by, WebDriverWait wait) { scrollIntoView(by); @@ -710,22 +686,22 @@ public WebElement waitForClickableElementAndScrollIntoView(final By by, WebDrive } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait until clickable element and scroll into view boolean. * - * @param by Selector to wait for and focus on - * @return boolean - true if the element is found and clickable + * @param by the by + * @return the boolean */ public boolean waitUntilClickableElementAndScrollIntoView(final By by) { return this.waitUntilClickableElementAndScrollIntoView(by, getWaitDriver()); } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait until clickable element and scroll into view boolean. * - * @param by Selector to wait for and focus on - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean - true if the element is found and clickable + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilClickableElementAndScrollIntoView(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -734,11 +710,11 @@ public boolean waitUntilClickableElementAndScrollIntoView(final By by, final int } /** - * Scroll an element into view, and wait for it to be clickable. + * Wait until clickable element and scroll into view boolean. * - * @param by Selector to wait for and focus on - * @param wait The wait driver - * @return boolean - true if the element is found and clickable + * @param by the by + * @param wait the wait + * @return the boolean */ public boolean waitUntilClickableElementAndScrollIntoView(final By by, WebDriverWait wait) { scrollIntoView(by); @@ -747,22 +723,22 @@ public boolean waitUntilClickableElementAndScrollIntoView(final By by, WebDriver } /** - * Wait for the specified selector to be clickable. + * Wait until clickable element boolean. * - * @param by Selector to wait for - * @return boolean - true if found and clickable, else false + * @param by the by + * @return the boolean */ public boolean waitUntilClickableElement(final By by) { return this.waitUntilClickableElement(by, getWaitDriver()); } /** - * Wait for the specified selector to be clickable. + * Wait until clickable element boolean. * - * @param by Selector to wait for - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return boolean - true if found and clickable, else false + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilClickableElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -771,11 +747,11 @@ public boolean waitUntilClickableElement(final By by, final int timeOutInMillis, } /** - * Wait for the specified selector to be clickable. + * Wait until clickable element boolean. * - * @param by Selector to wait for - * @param wait The wait driver - * @return boolean - true if found and clickable, else false + * @param by the by + * @param wait the wait + * @return the boolean */ public boolean waitUntilClickableElement(final By by, WebDriverWait wait) { try { @@ -789,22 +765,22 @@ public boolean waitUntilClickableElement(final By by, WebDriverWait wait) { } /** - * Wait for the element specified by the provided selector to be clickable. + * Wait for clickable element web element. * - * @param by Selector to wait for to be clickable - * @return WebElement that is located, or null if none is found + * @param by the by + * @return the web element */ public WebElement waitForClickableElement(final By by) { return this.waitForClickableElement(by, getWaitDriver()); } /** - * Wait for the element specified by the provided selector to be clickable. + * Wait for clickable element web element. * - * @param by Selector to wait for to be clickable - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck - * @return WebElement that is located, or null if none is found + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the web element */ public WebElement waitForClickableElement(final By by, final int timeOutInMillis, final int sleepInMillis) { @@ -814,19 +790,18 @@ public WebElement waitForClickableElement(final By by, final int timeOutInMillis } /** - * Wait for the element specified by the provided selector to be clickable. + * Wait for clickable element web element. * - * @param by Selector to wait for to be clickable - * @param wait The wait driver - * @return WebElement that is located, or null if none is found + * @param by the by + * @param wait the wait + * @return the web element */ public WebElement waitForClickableElement(final By by, WebDriverWait wait) { return wait.until(ExpectedConditions.elementToBeClickable(by)); } /** - * Wait for the page to load by waiting for the source to stop changing for at least a second. - * Asserts the page loads + * Wait for page load. */ public void waitForPageLoad() { if (!this.waitUntilPageLoad()) { @@ -835,9 +810,9 @@ public void waitForPageLoad() { } /** - * Wait for the page to load by waiting for the source to stop changing for at least a second. + * Wait until page load boolean. * - * @return true if it's successfully loaded, false if timed out and not finished loading + * @return the boolean */ public boolean waitUntilPageLoad() { String before = ""; @@ -859,20 +834,22 @@ public boolean waitUntilPageLoad() { } /** - * Waits for the Frame to be available. + * Wait until iframe to load boolean. * - * @param by The frame locator + * @param by the by + * @return the boolean */ public boolean waitUntilIframeToLoad(By by) { return waitUntilIframeToLoad(by, this.getWaitDriver()); } /** - * Waits for the Frame to be available. + * Wait until iframe to load boolean. * - * @param by The frame locator - * @param timeOutInMillis he number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the boolean */ public boolean waitUntilIframeToLoad(By by, final int timeOutInMillis, final int sleepInMillis) { WebDriverWait wait = this.getNewWaitDriver(timeOutInMillis, sleepInMillis); @@ -880,9 +857,11 @@ public boolean waitUntilIframeToLoad(By by, final int timeOutInMillis, final int } /** - * Waits for the Frame to be available. + * Wait until iframe to load boolean. * - * @param by The frame locator + * @param by the by + * @param wait the wait + * @return the boolean */ public boolean waitUntilIframeToLoad(By by, WebDriverWait wait) { @@ -895,20 +874,20 @@ public boolean waitUntilIframeToLoad(By by, WebDriverWait wait) { } /** - * Waits for the Frame to be available. + * Wait for iframe to load. * - * @param by The frame locator + * @param by the by */ public void waitForIframeToLoad(By by) { waitForIframeToLoad(by, this.getWaitDriver()); } /** - * Waits for the Frame to be available. + * Wait for iframe to load. * - * @param by The frame locator - * @param timeOutInMillis the number of milliseconds to wait before failing - * @param sleepInMillis the number of milliseconds to wait before a recheck + * @param by the by + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis */ public void waitForIframeToLoad(By by, final int timeOutInMillis, final int sleepInMillis) { WebDriverWait wait = this.getNewWaitDriver(timeOutInMillis, sleepInMillis); @@ -916,68 +895,71 @@ public void waitForIframeToLoad(By by, final int timeOutInMillis, final int slee } /** - * Waits for the Frame to be available. + * Wait for iframe to load. * - * @param by The frame locator + * @param by the by + * @param wait the wait */ public void waitForIframeToLoad(By by, WebDriverWait wait) { wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(by)); } /** - * Returns the webDriver of this SeleniumWait object. + * Gets web driver. * - * @return the webDriver (type WebDriver) of this SeleniumWait object. + * @return the web driver */ protected WebDriver getWebDriver() { return driver; } /** - * Gets a new WaitDriver using the default timeout. + * Gets new wait driver. * - * @return new WaitDriver + * @param driver the driver + * @return the new wait driver */ protected WebDriverWait getNewWaitDriver(WebDriver driver) { return getNewWaitDriver(driver, this.timeout, this.fluentRetryTime); } /** - * Gets a new WaitDriver using the default timeout. + * Gets new wait driver. * - * @return new WaitDriver + * @return the new wait driver */ protected WebDriverWait getNewWaitDriver() { return getNewWaitDriver(this.getWebDriver(), this.timeout, this.fluentRetryTime); } /** - * Gets a new WaitDriver using the specified timeout. + * Gets new wait driver. * - * @param timeOutInMillis the default timeout - * @return new WaitDriver + * @param timeOutInMillis the time out in millis + * @return the new wait driver */ protected WebDriverWait getNewWaitDriver(int timeOutInMillis) { return getNewWaitDriver(this.getWebDriver(), timeOutInMillis, this.fluentRetryTime); } /** - * Gets a new WaitDriver using the specified timeout. + * Gets new wait driver. * - * @param timeOutInMillis the time to wait before a timeout - * @param sleepInMillis the time to wait before a recheck - * @return new WaitDriver + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the new wait driver */ protected WebDriverWait getNewWaitDriver(int timeOutInMillis, int sleepInMillis) { return getNewWaitDriver(this.getWebDriver(), timeOutInMillis, sleepInMillis); } /** - * Gets a new WaitDriver using the specified timeout. + * Gets new wait driver. * - * @param timeOutInMillis the time to wait before a timeout - * @param sleepInMillis the time to wait before a recheck - * @return new WaitDriver + * @param driver the driver + * @param timeOutInMillis the time out in millis + * @param sleepInMillis the sleep in millis + * @return the new wait driver */ protected WebDriverWait getNewWaitDriver(WebDriver driver, int timeOutInMillis, int sleepInMillis) { @@ -987,11 +969,6 @@ protected WebDriverWait getNewWaitDriver(WebDriver driver, int timeOutInMillis, return wait; } - /** - * Scroll the web page so the selector is visible. - * - * @param by Selector to make visible - */ private void scrollIntoView(By by) { WebElement element = waitForVisibleElement(by); int counter = 0; @@ -1012,16 +989,6 @@ private void scrollIntoView(By by) { } } - /** - * Check the text value of an attribute. - * - * @param driver - web driver - * @param by Selector to get the attribute from - * @param attribute String value of the attribute to examine - * @param text String to check against the attribute - * @param contains boolean - true to see if the string is contained, false if exact match - * @return boolean - true if they match, else false - */ private static boolean attributeMatches(WebDriver driver, By by, String attribute, String text, boolean contains) { try { @@ -1035,13 +1002,6 @@ private static boolean attributeMatches(WebDriver driver, By by, String attribut } } - /** - * Checks if the text of the elements are equal. - * - * @param by Selector to examine - * @param text Text that is being compared to the selector - * @return boolean - true if equal - */ // TODO: should have fuzzy validation incorporated. private boolean doesTextMatch(By by, String text) { try { @@ -1058,13 +1018,6 @@ private boolean doesTextMatch(By by, String text) { return false; } - /** - * Checks if the text of the elements are equal. - * - * @param by Selector to examine - * @param text Text that is being compared to the selector - * @return boolean - true if equal - */ private boolean doesContainsText(By by, String text) { try { WebElement element = this.waitForVisibleElement(by); diff --git a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java index 7a155f778..13376bed5 100644 --- a/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java +++ b/Framework/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java @@ -31,36 +31,31 @@ import org.openqa.selenium.safari.SafariOptions; /** - * Static web driver factory. + * The type Web driver factory. */ public class WebDriverFactory { - /** - * Constant for the maximizing browser size. - */ private static final String WINDOW_MAX = "MAXIMIZE"; - /** - * Private constructor. - */ private WebDriverFactory() { } /** - * Get the default web driver based on the test run configuration. + * Gets default browser. * - * @return A web driver + * @return the default browser + * @throws Exception the exception */ public static WebDriver getDefaultBrowser() throws Exception { return getBrowserWithDefaultConfiguration(SeleniumConfig.getBrowserType()); } /** - * Get the default web driver (for the specified browser type) based on the test run configuration. + * Gets browser with default configuration. * - * @param browser The type of browser - * @return A web driver - * @throws Exception An exception + * @param browser the browser + * @return the browser with default configuration + * @throws Exception the exception */ public static WebDriver getBrowserWithDefaultConfiguration(BrowserType browser) throws Exception { String size = SeleniumConfig.getBrowserSize(); @@ -93,9 +88,9 @@ public static WebDriver getBrowserWithDefaultConfiguration(BrowserType browser) } /** - * Get the default Chrome options. + * Gets default chrome options. * - * @return The default Chrome options + * @return the default chrome options */ public static ChromeOptions getDefaultChromeOptions() { ChromeOptions chromeOptions = new ChromeOptions(); @@ -108,19 +103,19 @@ public static ChromeOptions getDefaultChromeOptions() { } /** - * Get the default headless Chrome options. + * Gets default headless chrome options. * - * @return The default headless Chrome options + * @return the default headless chrome options */ public static ChromeOptions getDefaultHeadlessChromeOptions() { return getDefaultHeadlessChromeOptions(WINDOW_MAX); } /** - * Get the default headless Chrome options. + * Gets default headless chrome options. * - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return The default headless Chrome options + * @param size the size + * @return the default headless chrome options */ public static ChromeOptions getDefaultHeadlessChromeOptions(String size) { ChromeOptions headlessChromeOptions = new ChromeOptions(); @@ -136,9 +131,9 @@ public static ChromeOptions getDefaultHeadlessChromeOptions(String size) { } /** - * Get the default IE options. + * Gets default internet explorer options. * - * @return The default IE options + * @return the default internet explorer options */ public static InternetExplorerOptions getDefaultInternetExplorerOptions() { InternetExplorerOptions options = new InternetExplorerOptions(); @@ -148,9 +143,9 @@ public static InternetExplorerOptions getDefaultInternetExplorerOptions() { } /** - * Get the default Firefox options. + * Gets default firefox options. * - * @return The default Firefox options + * @return the default firefox options */ public static FirefoxOptions getDefaultFirefoxOptions() { FirefoxOptions firefoxOptions = new FirefoxOptions(); @@ -160,9 +155,9 @@ public static FirefoxOptions getDefaultFirefoxOptions() { } /** - * Get the default Edge options. + * Gets default edge options. * - * @return The default Edge options + * @return the default edge options */ public static EdgeOptions getDefaultEdgeOptions() { EdgeOptions edgeOptions = new EdgeOptions(); @@ -172,21 +167,21 @@ public static EdgeOptions getDefaultEdgeOptions() { } /** - * Initialize a new Chrome driver. + * Gets chrome driver. * - * @param chromeOptions Browser options - * @return A new Chrome driver + * @param chromeOptions the chrome options + * @return the chrome driver */ public static WebDriver getChromeDriver(ChromeOptions chromeOptions) { return getChromeDriver(chromeOptions, WINDOW_MAX); } /** - * Initialize a new Chrome driver. + * Gets chrome driver. * - * @param chromeOptions Browser options - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return A new Chrome driver + * @param chromeOptions the chrome options + * @param size the size + * @return the chrome driver */ public static WebDriver getChromeDriver(ChromeOptions chromeOptions, String size) { System.setProperty("webdriver.chrome.driver", @@ -198,10 +193,10 @@ public static WebDriver getChromeDriver(ChromeOptions chromeOptions, String size } /** - * Initialize a new headless Chrome driver. + * Gets headless chrome driver. * - * @param headlessChromeOptions Browser options - * @return A new headless Chrome driver + * @param headlessChromeOptions the headless chrome options + * @return the headless chrome driver */ public static WebDriver getHeadlessChromeDriver(ChromeOptions headlessChromeOptions) { System.setProperty("webdriver.chrome.driver", @@ -211,11 +206,11 @@ public static WebDriver getHeadlessChromeDriver(ChromeOptions headlessChromeOpti } /** - * Initialize a new Firefox driver. + * Gets firefox driver. * - * @param firefoxOptions Browser options - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return A new Firefox driver + * @param firefoxOptions the firefox options + * @param size the size + * @return the firefox driver */ public static WebDriver getFirefoxDriver(FirefoxOptions firefoxOptions, String size) { System.setProperty("webdriver.gecko.driver", @@ -229,11 +224,11 @@ public static WebDriver getFirefoxDriver(FirefoxOptions firefoxOptions, String s } /** - * Initialize a new Edge driver. + * Gets edge driver. * - * @param edgeOptions Browser options - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return A new Edge driver + * @param edgeOptions the edge options + * @param size the size + * @return the edge driver */ public static WebDriver getEdgeDriver(EdgeOptions edgeOptions, String size) { String driverLocation = getDriverLocation(WebDriverFile.EDGE.getFileName(), @@ -252,11 +247,11 @@ public static WebDriver getEdgeDriver(EdgeOptions edgeOptions, String size) { } /** - * Get a new IE driver. + * Gets internet explorer driver. * - * @param internetExplorerOptions Browser options - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return A new IE driver + * @param internetExplorerOptions the internet explorer options + * @param size the size + * @return the internet explorer driver */ public static WebDriver getInternetExplorerDriver(InternetExplorerOptions internetExplorerOptions, String size) { @@ -270,9 +265,9 @@ public static WebDriver getInternetExplorerDriver(InternetExplorerOptions intern } /** - * Get the default remote driver options - Default values are pulled from the configuration. + * Gets default remote options. * - * @return The remote driver options + * @return the default remote options */ public static MutableCapabilities getDefaultRemoteOptions() { RemoteBrowserType remoteBrowser = SeleniumConfig.getRemoteBrowserType(); @@ -285,21 +280,21 @@ public static MutableCapabilities getDefaultRemoteOptions() { } /** - * Get the remote driver options. + * Gets remote options. * - * @param remoteBrowser The remote browser type - * @return The remote driver options + * @param remoteBrowser the remote browser + * @return the remote options */ public static MutableCapabilities getRemoteOptions(RemoteBrowserType remoteBrowser) { return getRemoteOptions(remoteBrowser, "", "", null); } /** - * Get the remote driver options. + * Gets remote options. * - * @param remoteBrowser The remote browser type - * @param remoteCapabilities Additional remote capabilities - * @return The remote driver options + * @param remoteBrowser the remote browser + * @param remoteCapabilities the remote capabilities + * @return the remote options */ public static MutableCapabilities getRemoteOptions(RemoteBrowserType remoteBrowser, Map remoteCapabilities) { @@ -307,13 +302,13 @@ public static MutableCapabilities getRemoteOptions(RemoteBrowserType remoteBrows } /** - * Get the remote driver options. + * Gets remote options. * - * @param remoteBrowser The remote browser type - * @param remotePlatform The remote platform - * @param remoteBrowserVersion The remote browser version - * @param remoteCapabilities Additional remote capabilities - * @return The remote driver options + * @param remoteBrowser the remote browser + * @param remotePlatform the remote platform + * @param remoteBrowserVersion the remote browser version + * @param remoteCapabilities the remote capabilities + * @return the remote options */ public static MutableCapabilities getRemoteOptions(RemoteBrowserType remoteBrowser, String remotePlatform, String remoteBrowserVersion, Map remoteCapabilities) { @@ -366,10 +361,10 @@ public static MutableCapabilities getRemoteOptions(RemoteBrowserType remoteBrows } /** - * Add additional capabilities to the driver options. + * Sets driver options. * - * @param driverOptions The driver option you want to add capabilities to - * @param additionalCapabilities Capabilities to add + * @param driverOptions the driver options + * @param additionalCapabilities the additional capabilities */ public static void setDriverOptions(MutableCapabilities driverOptions, Map additionalCapabilities) { @@ -386,14 +381,10 @@ public static void setDriverOptions(MutableCapabilities driverOptions, } /** - * Sets the browser size based on the provide string value. - * Browser size is expected to be: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080). - * MAXIMIZE just maximizes the browser. - * DEFAULT does not change the current size. - * #x# sets a custom size. + * Sets browser size. * - * @param webDriver the webDriver from the Browser method - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) + * @param webDriver the web driver + * @param size the size */ public static void setBrowserSize(WebDriver webDriver, String size) { size = size.toUpperCase(); @@ -406,10 +397,10 @@ public static void setBrowserSize(WebDriver webDriver, String size) { } /** - * Get the browser/browser size as a string. + * Gets headless window size string. * - * @param size Browser size in the following format: MAXIMIZE, DEFAULT, or #x# (such as 1920x1080) - * @return The browser size as a string - Specifically for headless Chrome options + * @param size the size + * @return the headless window size string */ public static String getHeadlessWindowSizeString(String size) { if (size.equals(WINDOW_MAX) || size.equals("DEFAULT")) { @@ -422,10 +413,10 @@ public static String getHeadlessWindowSizeString(String size) { } /** - * Get the window size as a Dimension object. + * Extract dimension from string dimension. * - * @param size The size in a #X# format - * @return The dimension object with width and height defined + * @param size the size + * @return the dimension */ public static Dimension extractDimensionFromString(String size) { String[] sizes = size.split("[xX]"); @@ -446,34 +437,33 @@ public static Dimension extractDimensionFromString(String size) { } /** - * Get the web driver location. + * Gets driver location. * - * @param driverFile The web driver file, including extension - * @return The path to the web driver + * @param driverFile the driver file + * @return the driver location */ public static String getDriverLocation(String driverFile) { return getDriverLocation(driverFile, "", true); } /** - * Get the web driver location. + * Gets driver location. * - * @param driverFile The web driver file, including extension - * @param defaultHintPath The default location for the specific driver - * @return The path to the web driver + * @param driverFile the driver file + * @param defaultHintPath the default hint path + * @return the driver location */ public static String getDriverLocation(String driverFile, String defaultHintPath) { return getDriverLocation(driverFile, defaultHintPath, true); } /** - * Get the web driver location. + * Gets driver location. * - * @param driverFile The web driver file, including extension - * @param defaultHintPath The default location for the specific driver - * @param mustExist Do we need to know where this drive is located, - * if this is true and the file is not found an error will be thrown - * @return The path to the web driver + * @param driverFile the driver file + * @param defaultHintPath the default hint path + * @param mustExist the must exist + * @return the driver location */ public static String getDriverLocation(String driverFile, String defaultHintPath, boolean mustExist) { @@ -515,10 +505,10 @@ public static String getDriverLocation(String driverFile, String defaultHintPath } /** - * Get the file path for the Edge driver pre-installed on the system. + * Gets windows edge driver location. * - * @param file The file we are looking for - * @return The parent folder of the given file or the empty string if the file is not found + * @param file the file + * @return the windows edge driver location */ static String getWindowsEdgeDriverLocation(String file) { String edgeDriverFolder = "Microsoft Web Driver"; diff --git a/Framework/jmaqs-utilities/src/main/java/com/magenic/jmaqs/utilities/helper/GenericWait.java b/Framework/jmaqs-utilities/src/main/java/com/magenic/jmaqs/utilities/helper/GenericWait.java index de1891e79..c6a1a6a3f 100644 --- a/Framework/jmaqs-utilities/src/main/java/com/magenic/jmaqs/utilities/helper/GenericWait.java +++ b/Framework/jmaqs-utilities/src/main/java/com/magenic/jmaqs/utilities/helper/GenericWait.java @@ -12,33 +12,27 @@ import java.util.function.Supplier; /** - * Generic Wait class. + * The type Generic wait. */ public final class GenericWait { - /** - * Hide the default public constructor. - */ private GenericWait() { throw new IllegalStateException("Utility class"); } - /** - * Default retry time for the configuration file. - */ private static long retryTimeFromConfig = Long.parseLong(Config.getGeneralValue("WaitTime", "0")); - /** - * Default timeout time from the configuration file. - */ private static long timeoutFromConfig = Long.parseLong(Config.getGeneralValue("Timeout", "0")); /** - * Wait until the wait for true function returns true or times out. + * Wait until boolean. * - * @param waitForTrue The function we are waiting to return true - * @param arg Parameter to pass to the wait for true function - * @return True if the waitForTrue function returned true before the timeout + * @param the type parameter + * @param waitForTrue the wait for true + * @param arg the arg + * @return the boolean + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception */ public static boolean waitUntil(Predicate waitForTrue, T arg) throws InterruptedException, FunctionException { @@ -46,10 +40,12 @@ public static boolean waitUntil(Predicate waitForTrue, T arg) } /** - * Wait until the wait for true function returns true or times out. + * Wait until boolean. * - * @param waitForTrue The function we are waiting to return true - * @return True if the wait for true function returned true before timing out + * @param waitForTrue the wait for true + * @return the boolean + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception */ public static boolean waitUntil(BooleanSupplier waitForTrue) throws InterruptedException, FunctionException { @@ -57,10 +53,12 @@ public static boolean waitUntil(BooleanSupplier waitForTrue) } /** - * Wait until the wait for true function returns true, an exception will be thrown if the - * wait times out. + * Wait for true. * - * @param waitForTrue The function we are waiting to return true + * @param waitForTrue the wait for true + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception + * @throws TimeoutException the timeout exception */ public static void waitForTrue(BooleanSupplier waitForTrue) throws InterruptedException, FunctionException, TimeoutException { @@ -70,11 +68,14 @@ public static void waitForTrue(BooleanSupplier waitForTrue) } /** - * Wait until the wait for true function returns true, an exception will be thrown if the - * wait times out. + * Wait for true. * - * @param waitForTrue The function we are waiting to return true - * @param arg Parameter to pass to the wait for true function + * @param the type parameter + * @param waitForTrue the wait for true + * @param arg the arg + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception + * @throws TimeoutException the timeout exception */ public static void waitForTrue(Predicate waitForTrue, T arg) throws InterruptedException, FunctionException, TimeoutException { @@ -84,12 +85,13 @@ public static void waitForTrue(Predicate waitForTrue, T arg) } /** - * Waits for a function with a return type T to return a value that is to an argument of the - * same type. If it times out it returns the value of the function. + * Wait until match t. * - * @param waitForTrue Function that returns type T - * @param comparativeValue value of the same type as T - * @return if it returned before the timeout occurred + * @param the type parameter + * @param waitForTrue the wait for true + * @param comparativeValue the comparative value + * @return the t + * @throws InterruptedException the interrupted exception */ public static T waitUntilMatch(Supplier waitForTrue, T comparativeValue) throws InterruptedException { @@ -121,15 +123,15 @@ public static T waitUntilMatch(Supplier waitForTrue, T comparativeValue) } /** - * Waits for a function with a return type T to return a value that is to an argument - * of the same type. - * If it times out it returns the value of the function. + * Wait until match t. * - * @param waitForTrue Function that returns type T - * @param retryTime time to wait between retries - * @param timeout how long before timing out - * @param comparativeValue value of the same type as T - * @return if it returned before the timeout occurred + * @param the type parameter + * @param waitForTrue the wait for true + * @param retryTime the retry time + * @param timeout the timeout + * @param comparativeValue the comparative value + * @return the t + * @throws InterruptedException the interrupted exception */ public static T waitUntilMatch(Supplier waitForTrue, long retryTime, long timeout, T comparativeValue) throws InterruptedException { @@ -158,11 +160,13 @@ public static T waitUntilMatch(Supplier waitForTrue, long retryTime, long } /** - * Waits for a Function with a type T to return a value that is equal to a - * comparative value of type T. + * Wait for match. * - * @param waitForTrue Method to wait for - * @param comparativeValue value of the same type as T + * @param the type parameter + * @param waitForTrue the wait for true + * @param comparativeValue the comparative value + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static void waitForMatch(Supplier waitForTrue, T comparativeValue) throws InterruptedException, TimeoutException { @@ -190,12 +194,15 @@ public static void waitForMatch(Supplier waitForTrue, T comparativeValue) } /** - * Waits for a Function with a type T to return a value that is equal to a comparative value of type T. + * Wait for match. * - * @param waitForTrue Method to wait for - * @param retryTime time to wait between retries - * @param timeout how long before timing out - * @param comparativeValue The value to compare to what comes out of waitForTrue + * @param the type parameter + * @param waitForTrue the wait for true + * @param retryTime the retry time + * @param timeout the timeout + * @param comparativeValue the comparative value + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static void waitForMatch(Supplier waitForTrue, long retryTime, long timeout, T comparativeValue) throws InterruptedException, TimeoutException { @@ -221,21 +228,28 @@ public static void waitForMatch(Supplier waitForTrue, long retryTime, lon } /** - * Wait until the wait for function returns the expected type, an exception will be thrown if the wait times out. + * Wait for t. * - * @param waitFor The wait for function - * @return The wait for function return value + * @param the type parameter + * @param waitFor the wait for + * @return the t + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static T waitFor(Supplier waitFor) throws InterruptedException, TimeoutException { return wait(waitFor, retryTimeFromConfig, timeoutFromConfig); } /** - * Wait until the wait for function returns the expected type, an exception will be thrown if the wait times out. + * Wait for t. * - * @param waitFor The wait for function - * @param arg The wait for function argument - * @return The wait for function return value + * @param the type parameter + * @param the type parameter + * @param waitFor the wait for + * @param arg the arg + * @return the t + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static T waitFor(Function waitFor, U arg) throws InterruptedException, TimeoutException { @@ -243,14 +257,17 @@ public static T waitFor(Function waitFor, U arg) } /** - * Wait until the wait for true function returns true or times out. + * Wait boolean. * - * @param waitForTrue The function we are waiting to return true - * @param retryTime How long do we wait before retrying the wait for true function - * @param timeout Max timeout for the check - * @param throwException If the last check failed because of an exception should we throw the exception - * @param arg Parameter to pass to the wait for true function - * @return True if the wait for true function returned true before timing out + * @param the type parameter + * @param waitForTrue the wait for true + * @param retryTime the retry time + * @param timeout the timeout + * @param throwException the throw exception + * @param arg the arg + * @return the boolean + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception */ public static boolean wait(Predicate waitForTrue, long retryTime, long timeout, boolean throwException, T arg) throws InterruptedException, FunctionException { @@ -288,13 +305,15 @@ public static boolean wait(Predicate waitForTrue, long retryTime, long ti } /** - * Wait until the wait for true function returns true or times out. + * Wait boolean. * - * @param waitForTrue The function we are waiting to return true - * @param retryTime How long do we wait before retrying the wait for true function - * @param timeout Max timeout for the check - * @param throwException If the last check failed because of an exception should we throw the exception - * @return True if the wait for true function returned true before timing out + * @param waitForTrue the wait for true + * @param retryTime the retry time + * @param timeout the timeout + * @param throwException the throw exception + * @return the boolean + * @throws InterruptedException the interrupted exception + * @throws FunctionException the function exception */ public static boolean wait(BooleanSupplier waitForTrue, long retryTime, long timeout, boolean throwException) throws InterruptedException, FunctionException { @@ -332,12 +351,15 @@ public static boolean wait(BooleanSupplier waitForTrue, long retryTime, long tim } /** - * Wait until the wait for function returns the expected type, an exception will be thrown if the wait times out. + * Wait t. * - * @param waitFor The wait for function - * @param retryTime How long do we wait before retrying the wait for true function - * @param timeout Max timeout for the check - * @return Return value of the wait for function + * @param the type parameter + * @param waitFor the wait for + * @param retryTime the retry time + * @param timeout the timeout + * @return the t + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static T wait(Supplier waitFor, long retryTime, long timeout) throws InterruptedException, TimeoutException { @@ -365,13 +387,17 @@ public static T wait(Supplier waitFor, long retryTime, long timeout) } /** - * Wait until the wait for function returns the expected type, an exception will be thrown if the wait times out. + * Wait t. * - * @param waitFor The wait for function - * @param retryTime How long do we wait before retrying the wait for true function - * @param timeout Max timeout for the check - * @param arg MArguments to pass into the wait for function - * @return Return value of the wait for function + * @param the type parameter + * @param the type parameter + * @param waitFor the wait for + * @param retryTime the retry time + * @param timeout the timeout + * @param arg the arg + * @return the t + * @throws InterruptedException the interrupted exception + * @throws TimeoutException the timeout exception */ public static T wait(Function waitFor, long retryTime, long timeout, U arg) throws InterruptedException, TimeoutException { @@ -393,12 +419,6 @@ public static T wait(Function waitFor, long retryTime, long timeout throw new TimeoutException("Timed out waiting for the function to return", exception); } - /** - * Checks that the objects all match. - * - * @param param objects passed in - * @return parameters are all equal as a boolean - */ private static boolean paramsEqual(Object... param) { // For each item for (Object item : param) { diff --git a/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceDriver.java b/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceDriver.java index 846d23a55..9f7627438 100644 --- a/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceDriver.java +++ b/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceDriver.java @@ -29,60 +29,55 @@ import org.apache.http.message.BasicHeader; /** - * The Web Service Driver. + * The type Web service driver. */ public class WebServiceDriver { - /** - * The base HTTP client control. - */ private CloseableHttpClient baseHttpClient; - /** - * The URI to be stored for the Web Service. - */ private URI baseAddress; /** - * Constructor. + * Instantiates a new Web service driver. * - * @param baseAddress The base URI address to use - * @throws URISyntaxException URI syntax is invalid + * @param baseAddress the base address + * @throws URISyntaxException the uri syntax exception */ public WebServiceDriver(String baseAddress) throws URISyntaxException { this(new URI(baseAddress)); } /** - * Constructor. + * Instantiates a new Web service driver. * - * @param baseAddress The base URI address to use + * @param baseAddress the base address */ public WebServiceDriver(URI baseAddress) { this.baseAddress = baseAddress; } /** - * Class Constructor that sets the http Client. + * Instantiates a new Web service driver. * - * @param newHttpClient the http client to be set. + * @param newHttpClient the new http client */ public WebServiceDriver(CloseableHttpClient newHttpClient) { this.baseHttpClient = newHttpClient; } /** - * Set the HTTP client. + * Sets http client. * - * @param httpClient The HTTP client + * @param httpClient the http client */ public void setHttpClient(CloseableHttpClient httpClient) { this.baseHttpClient = httpClient; } /** - * Get the HTTP client. + * Gets http client. * - * @return the HttpClient to interact with + * @param mediaType the media type + * @return the http client */ public CloseableHttpClient getHttpClient(String mediaType) { if (this.baseHttpClient == null) { @@ -95,32 +90,33 @@ public CloseableHttpClient getHttpClient(String mediaType) { } /** - * Get the base URI. + * Gets base web service address. * - * @return A URI containing the Web Service Address. + * @return the base web service address */ public URI getBaseWebServiceAddress() { return this.baseAddress; } /** - * Sets the base Web Service address for the Web Service Driver. + * Sets base web service address. * - * @param address The string to set the URI to - * @throws URISyntaxException thrown when the string can't be parsed into a URI object + * @param address the address + * @throws URISyntaxException the uri syntax exception */ public void setBaseWebServiceAddress(String address) throws URISyntaxException { this.baseAddress = new URI(address); } /** - * Do a web service get. + * Gets content. * - * @param requestUri The request URI - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the content + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse getContent(String requestUri, ContentType returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -128,13 +124,14 @@ public CloseableHttpResponse getContent(String requestUri, ContentType returnMed } /** - * Do a web service get. + * Gets content. * - * @param requestUri The request URI - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the content + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse getContent(String requestUri, String returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -144,14 +141,15 @@ public CloseableHttpResponse getContent(String requestUri, String returnMediaTyp } /** - * Do a web service put. + * Put content closeable http response. * - * @param requestUri The request URI - * @param content Put content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse putContent(String requestUri, HttpEntity content, ContentType returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -159,14 +157,15 @@ public CloseableHttpResponse putContent(String requestUri, HttpEntity content, } /** - * Do a web service put. + * Put content closeable http response. * - * @param requestUri The request URI - * @param content Put content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse putContent(String requestUri, HttpEntity content, String returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -176,14 +175,15 @@ public CloseableHttpResponse putContent(String requestUri, HttpEntity content, } /** - * Do a web service patch. + * Patch content closeable http response. * - * @param requestUri The request URI - * @param content Patch content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse patchContent(String requestUri, HttpEntity content, ContentType returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -191,14 +191,15 @@ public CloseableHttpResponse patchContent(String requestUri, HttpEntity content, } /** - * Do a web service patch. + * Patch content closeable http response. * - * @param requestUri The request URI - * @param content Patch content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse patchContent(String requestUri, HttpEntity content, String returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -208,14 +209,15 @@ public CloseableHttpResponse patchContent(String requestUri, HttpEntity content, } /** - * Do a web service post. + * Post content closeable http response. * - * @param requestUri The request URI - * @param content Post content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse postContent(String requestUri, HttpEntity content, ContentType returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -223,14 +225,15 @@ public CloseableHttpResponse postContent(String requestUri, HttpEntity content, } /** - * Do a web service post. + * Post content closeable http response. * - * @param requestUri The request URI - * @param content Post content - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param content the content + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse postContent(String requestUri, HttpEntity content, String returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -241,13 +244,14 @@ public CloseableHttpResponse postContent(String requestUri, HttpEntity content, } /** - * Do a web service delete. + * Delete content closeable http response. * - * @param requestUri The request URI - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse deleteContent(String requestUri, ContentType returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -255,13 +259,14 @@ public CloseableHttpResponse deleteContent(String requestUri, ContentType return } /** - * Do a web service delete. + * Delete content closeable http response. * - * @param requestUri The request URI - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception + * @param requestUri the request uri + * @param returnMediaType the return media type + * @param expectSuccess the expect success + * @return the closeable http response + * @throws IOException the io exception + * @throws URISyntaxException the uri syntax exception */ public CloseableHttpResponse deleteContent(String requestUri, String returnMediaType, boolean expectSuccess) throws IOException, URISyntaxException { @@ -271,15 +276,6 @@ public CloseableHttpResponse deleteContent(String requestUri, String returnMedia return executeRequest(newDelete, returnMediaType, expectSuccess); } - /** - * Execute a web service call. - * - * @param request The web service call to execute - * @param returnMediaType The return media type - * @param expectSuccess Check to make sure a success code was returned, if not throw an exception - * @return An HTTP response - * @throws Exception A web service call exception - */ private CloseableHttpResponse executeRequest(HttpUriRequest request, String returnMediaType, boolean expectSuccess) throws IOException { @@ -293,12 +289,6 @@ private CloseableHttpResponse executeRequest(HttpUriRequest request, String retu return response; } - /** - * Ensure the response returned a success code. - * - * @param response And HTTP response - * @throws Exception If the response was null or returned with an error code - */ private static void ensureSuccessStatusCode(final HttpResponse response) throws HttpResponseException { // Make sure a response was returned @@ -318,11 +308,6 @@ private static void ensureSuccessStatusCode(final HttpResponse response) } - /** - * Get the request configuration. - * - * @return The request configuration - */ private RequestConfig getRequestTimeouts() { return RequestConfig.copy(RequestConfig.DEFAULT) diff --git a/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceUtilities.java b/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceUtilities.java index 03dbbd398..5a2e09bd1 100644 --- a/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceUtilities.java +++ b/Framework/jmaqs-webservices-jdk8/src/main/java/com/magenic/jmaqs/webservices/jdk8/WebServiceUtilities.java @@ -19,17 +19,11 @@ import org.apache.http.util.EntityUtils; /** - * Web service utilities. + * The type Web service utilities. */ public final class WebServiceUtilities { - /** - * ObjecMapper for serializing and deserializing json. - */ private static final ObjectMapper objectMapper = new ObjectMapper(); - /** - * XmlMapper used for serializing and deserializing xml. - */ private static final ObjectMapper xmlMapper = new XmlMapper(); // private constructor @@ -37,12 +31,11 @@ private WebServiceUtilities() { } /** - * Get the body from a HTTP response. + * Gets response body. * - * @param response The response - * @return The response body - * @throws ParseException There was an error parsing the response as a string - * @throws IOException There was a problem reading the response + * @param response the response + * @return the response body + * @throws IOException the io exception */ public static String getResponseBody(CloseableHttpResponse response) throws IOException { HttpEntity entity = response.getEntity(); @@ -50,14 +43,14 @@ public static String getResponseBody(CloseableHttpResponse response) throws IOEx } /** - * Get the body from a HTTP response. + * Gets response body. * - * @param response The response - * @param contentType The content type of the request - * @param type The type the response is being deserialized to - * @return The response body - * @throws ParseException There was an error parsing the response as a string - * @throws IOException There was a problem reading the response + * @param the type parameter + * @param response the response + * @param contentType the content type + * @param type the type + * @return the response body + * @throws IOException the io exception */ public static T getResponseBody(CloseableHttpResponse response, ContentType contentType, Type type) throws IOException { @@ -76,12 +69,14 @@ public static T getResponseBody(CloseableHttpResponse response, ContentType } /** - * Create the string entity. + * Create string entity string entity. * - * @param body The body being set in the entity - * @param encoding The charset encoding of the message - * @param mediaType The mime type of the message - * @return The string entity + * @param the type parameter + * @param body the body + * @param encoding the encoding + * @param mediaType the media type + * @return the string entity + * @throws JsonProcessingException the json processing exception */ public static StringEntity createStringEntity(T body, Charset encoding, String mediaType) throws JsonProcessingException { @@ -90,13 +85,13 @@ public static StringEntity createStringEntity(T body, Charset encoding, Stri } /** - * Creates the string content. + * Create string entity string entity. * - * @param body The body being set in the entity - * @param contentType The content type of the - * @param The type of the body - * @return The string entity - * @throws JsonProcessingException If the json or xml failed to deserialize + * @param the type parameter + * @param body the body + * @param contentType the content type + * @return the string entity + * @throws JsonProcessingException the json processing exception */ public static StringEntity createStringEntity(T body, ContentType contentType) throws JsonProcessingException { @@ -111,36 +106,37 @@ public static StringEntity createStringEntity(T body, ContentType contentTyp } /** - * Gets the json object as a string. + * Serialize json string. * - * @param body The body being serialized to a string - * @param The type of the body - * @return The body as a json string - * @throws JsonProcessingException If the json serialization fails + * @param the type parameter + * @param body the body + * @return the string + * @throws JsonProcessingException the json processing exception */ public static String serializeJson(T body) throws JsonProcessingException { return objectMapper.writeValueAsString(body); } /** - * Gets the xml object as a string. + * Serialize xml string. * - * @param body The body being serialized to a string - * @param The type of the body - * @return The body as an xml string - * @throws JsonProcessingException If the xml serialization fails + * @param the type parameter + * @param body the body + * @return the string + * @throws JsonProcessingException the json processing exception */ public static String serializeXml(T body) throws JsonProcessingException { return xmlMapper.writeValueAsString(body); } /** - * Deserialzizes the response to the object specified. + * Deserialize json t. * - * @param message The httpresponse message being deserialized - * @param The type the message will be deserialized to - * @return The json as the type specified - * @throws IOException If the object can't be written to that type + * @param the type parameter + * @param message the message + * @param type the type + * @return the t + * @throws IOException the io exception */ public static T deserializeJson(CloseableHttpResponse message, Type type) throws IOException { String responseEntity = getResponseBody(message); @@ -149,12 +145,13 @@ public static T deserializeJson(CloseableHttpResponse message, Type type) th } /** - * Deserializes the response to the object specified. + * Deserialize xml t. * - * @param message The http response message being deserialized - * @param The tyep the message will be deserialied to - * @return The json as the type specified - * @throws IOException If the object can't be written to that type + * @param the type parameter + * @param message the message + * @param type the type + * @return the t + * @throws IOException the io exception */ public static T deserializeXml(CloseableHttpResponse message, Type type) throws IOException { String responseEntity = getResponseBody(message);