Skip to content

Commit

Permalink
Lombok Library Update (#1193)
Browse files Browse the repository at this point in the history
* Code changes for getting all session details

* Revert "Code changes for getting all session details"

This reverts commit 76159eb.

* Updated the comments and recommitting the changes

* Organised import statement as per comments

* Updated as per comments

* Code Changes for Lombok Plugin

* Code Changes for introducing Lombok Library

* as per comments, removed TestCompile & TestAnnotationProcessor
  • Loading branch information
jayandran-Sampath authored and SrinivasanTarget committed Jul 28, 2019
1 parent 891636a commit ac67237
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 285 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,31 @@ apply plugin: 'com.github.johnrengelman.shadow'

configurations {
ecj
lombok
}

dependencies {
ecj 'org.eclipse.jdt:ecj:3.18.0'
lombok 'org.projectlombok:lombok:1.18.8'
}

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8

def ecjJar = configurations.ecj.singleFile
def lombokjar = configurations.lombok.singleFile

options.fork = true
options.fork executable: 'java', jvmArgs: [ '-cp', ecjJar.path, 'org.eclipse.jdt.internal.compiler.batch.Main' ]
options.fork executable: 'java', jvmArgs: [ '-javaagent:'+lombokjar.path+'=ECJ', '-jar', ecjJar.path, '-cp', lombokjar.path]
options.define compilerArgs: [
'-encoding', 'utf-8'
]
}

dependencies {
compileOnly('org.projectlombok:lombok:1.18.8')
annotationProcessor('org.projectlombok:lombok:1.18.8')
compile ("org.seleniumhq.selenium:selenium-java:${project.property('selenium.version')}") {
force = true

Expand Down
14 changes: 4 additions & 10 deletions src/main/java/io/appium/java_client/AppiumCommandInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

package io.appium.java_client;

import lombok.AccessLevel;
import lombok.Getter;
import org.openqa.selenium.remote.CommandInfo;
import org.openqa.selenium.remote.http.HttpMethod;

public class AppiumCommandInfo extends CommandInfo {
private final String url;
private final HttpMethod method;
@Getter(AccessLevel.PUBLIC) private final String url;
@Getter(AccessLevel.PUBLIC) private final HttpMethod method;

/**
* It conntains method and URL of the command.
Expand All @@ -34,12 +36,4 @@ public AppiumCommandInfo(String url, HttpMethod method) {
this.url = url;
this.method = method;
}

public String getUrl() {
return url;
}

public HttpMethod getMethod() {
return method;
}
}
56 changes: 21 additions & 35 deletions src/main/java/io/appium/java_client/AppiumFluentWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.google.common.base.Throwables;

import lombok.AccessLevel;
import lombok.Getter;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.support.ui.FluentWait;
Expand All @@ -35,61 +37,45 @@ public class AppiumFluentWait<T> extends FluentWait<T> {
private Function<IterationInfo, Duration> pollingStrategy = null;

public static class IterationInfo {
private final long number;
private final Duration elapsed;
private final Duration total;
private final Duration interval;

/**
* The class is used to represent information about a single loop iteration in {@link #until(Function)}
* method.
*
* @param number loop iteration number, starts from 1
* @param elapsed the amount of elapsed time since the loop started
* @param total the amount of total time to run the loop
* @param interval the default time interval for each loop iteration
*/
public IterationInfo(long number, Duration elapsed, Duration total, Duration interval) {
this.number = number;
this.elapsed = elapsed;
this.total = total;
this.interval = interval;
}

/**
* The current iteration number.
*
* @return current iteration number. It starts from 1
*/
public long getNumber() {
return number;
}

@Getter(AccessLevel.PUBLIC) private final long number;
/**
* The amount of elapsed time.
*
* @return the amount of elapsed time
*/
public Duration getElapsed() {
return elapsed;
}

@Getter(AccessLevel.PUBLIC) private final Duration elapsed;
/**
* The amount of total time.
*
* @return the amount of total time
*/
public Duration getTotal() {
return total;
}

@Getter(AccessLevel.PUBLIC) private final Duration total;
/**
* The current interval.
*
* @return The actual value of current interval or the default one if it is not set
*/
public Duration getInterval() {
return interval;
@Getter(AccessLevel.PUBLIC) private final Duration interval;

/**
* The class is used to represent information about a single loop iteration in {@link #until(Function)}
* method.
*
* @param number loop iteration number, starts from 1
* @param elapsed the amount of elapsed time since the loop started
* @param total the amount of total time to run the loop
* @param interval the default time interval for each loop iteration
*/
public IterationInfo(long number, Duration elapsed, Duration total, Duration interval) {
this.number = number;
this.elapsed = elapsed;
this.total = total;
this.interval = interval;
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/main/java/io/appium/java_client/MobileBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.appium.java_client;

import lombok.AccessLevel;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.SearchContext;
Expand All @@ -31,7 +33,7 @@ public abstract class MobileBy extends By {
private static final String ERROR_TEXT = "The class %s of the given context "
+ "doesn't implement %s nor %s. Sorry. It is impossible to find something.";

private final String locatorString;
@Getter(AccessLevel.PROTECTED) private final String locatorString;
private final MobileSelector selector;

private static IllegalArgumentException formIllegalArgumentException(Class<?> givenClass,
Expand All @@ -48,19 +50,15 @@ protected MobileBy(MobileSelector selector, String locatorString) {
this.selector = selector;
}

protected String getLocatorString() {
return locatorString;
}

@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
return (List<WebElement>) ((FindsByFluentSelector<?>) context)
.findElements(selector.toString(), getLocatorString());
.findElements(selector.toString(), getLocatorString());
}

@Override public WebElement findElement(SearchContext context) {
return ((FindsByFluentSelector<?>) context)
.findElement(selector.toString(), getLocatorString());
.findElement(selector.toString(), getLocatorString());
}

/**
Expand Down
34 changes: 13 additions & 21 deletions src/main/java/io/appium/java_client/ScreenshotState.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

package io.appium.java_client;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Optional.ofNullable;

Expand All @@ -30,14 +35,20 @@

import javax.imageio.ImageIO;

@Accessors(chain = true)
public class ScreenshotState {
private static final Duration DEFAULT_INTERVAL_MS = Duration.ofMillis(500);

private BufferedImage previousScreenshot;
private final Supplier<BufferedImage> stateProvider;
private final ComparesImages comparator;

private Duration comparisonInterval = DEFAULT_INTERVAL_MS;
/**
* Gets the interval value in ms between similarity verification rounds in <em>verify*</em> methods.
*
* @param comparisonInterval interval value. 500 ms by default
* @return current interval value in ms
*/
@Getter(AccessLevel.PUBLIC) @Setter(AccessLevel.PUBLIC) private Duration comparisonInterval = DEFAULT_INTERVAL_MS;

/**
* The class constructor accepts two arguments. The first one is image comparator, the second
Expand Down Expand Up @@ -79,25 +90,6 @@ public ScreenshotState(ComparesImages comparator) {
this(comparator, null);
}

/**
* Gets the interval value in ms between similarity verification rounds in <em>verify*</em> methods.
*
* @return current interval value in ms
*/
public Duration getComparisonInterval() {
return comparisonInterval;
}

/**
* Sets the interval between similarity verification rounds in <em>verify*</em> methods.
*
* @param comparisonInterval interval value. 500 ms by default
* @return self instance for chaining
*/
public ScreenshotState setComparisonInterval(Duration comparisonInterval) {
this.comparisonInterval = comparisonInterval;
return this;
}

/**
* Call this method to save the initial screenshot state.
Expand Down
Loading

0 comments on commit ac67237

Please sign in to comment.