Skip to content

Commit

Permalink
add build workflow (via #109)
Browse files Browse the repository at this point in the history
  • Loading branch information
eroshenkoam authored Apr 18, 2023
1 parent 9f74f32 commit ddec29f
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 50 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build

on:
workflow_dispatch:
pull_request:
branches:
- '*'
push:
branches:
- 'main'

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8.0.x'
- run: ./gradlew build
3 changes: 2 additions & 1 deletion atlas-appium/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ dependencies {
implementation("org.seleniumhq.selenium:selenium-java")
implementation("ru.yandex.qatools.matchers:webdriver-matchers")
implementation("org.awaitility:awaitility")


testImplementation("org.apache.commons:commons-lang3")
testImplementation("org.mockito:mockito-core")
testImplementation("org.assertj:assertj-core")
testImplementation("junit:junit")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.qameta.atlas.appium.extension;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.PerformsTouchActions;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.PointOption;
import io.qameta.atlas.core.AtlasException;
Expand All @@ -19,23 +20,23 @@
import static io.appium.java_client.touch.LongPressOptions.longPressOptions;

/**
* LongPress.
* LongPress.
*/
public class LongPressExtension implements MethodExtension {

private static final Duration LONG_TAP_DURATION = Duration.of(1000, ChronoUnit.MILLIS);

@Override
public boolean test(final Method method) {
return method.getName().equals("longPress");
return "longPress".equals(method.getName());
}

@Override
public Object invoke(final Object proxy, final MethodInfo methodInfo, final Configuration configuration) {
final AppiumDriver driver = configuration.getContext(AppiumDriverContext.class)
.orElseThrow(() -> new AtlasException("AppiumDriver is missing")).getValue();

final TouchAction action = new TouchAction(driver);
final TouchAction action = new TouchAction((PerformsTouchActions) driver);
final Point location = ((WebElement) proxy).getLocation();
final Dimension size = ((WebElement) proxy).getSize();
final int x = location.getX() + size.width / 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.qameta.atlas.appium.extension;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.PerformsTouchActions;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.PointOption;
import io.qameta.atlas.core.AtlasException;
Expand All @@ -26,7 +27,7 @@ public class SwipeDownOnExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals("swipeDownOn");
return "swipeDownOn".equals(method.getName());
}

@Override
Expand All @@ -42,7 +43,7 @@ public Object invoke(final Object proxy, final MethodInfo methodInfo, final Conf
final int endX = size.width / 2;
final int endY = (int) (size.height * TOP.getValue());

final TouchAction touchAction = new TouchAction(driver);
final TouchAction touchAction = new TouchAction((PerformsTouchActions) driver);
touchAction.longPress(new PointOption().withCoordinates(startX, startY))
.moveTo(new PointOption().withCoordinates(endX, endY)).release().perform();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.qameta.atlas.appium.extension;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.PerformsTouchActions;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.PointOption;
import io.qameta.atlas.appium.context.AppiumDriverContext;
Expand All @@ -26,7 +27,7 @@ public class SwipeUpOnExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals("swipeUpOn");
return "swipeUpOn".equals(method.getName());
}

@Override
Expand All @@ -42,7 +43,7 @@ public Object invoke(final Object proxy, final MethodInfo methodInfo, final Conf
final int endX = size.width / 2;
final int endY = (int) (size.height * BOTTOM.getValue());

final TouchAction touchAction = new TouchAction(driver);
final TouchAction touchAction = new TouchAction((PerformsTouchActions) driver);
touchAction.longPress(new PointOption().withCoordinates(startX, startY))
.moveTo(new PointOption().withCoordinates(endX, endY)).release().perform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.qameta.atlas.appium.AtlasMobileElement;
import io.qameta.atlas.webdriver.AtlasWebElement;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.WrapsDriver;

import static org.mockito.Mockito.mock;
Expand All @@ -21,16 +20,16 @@ private ObjectFactory() {
}

public static AppiumDriver mockAppiumDriver() {
return mock(AppiumDriver.class, withSettings().extraInterfaces(WrapsDriver.class, HasInputDevices.class));
return mock(AppiumDriver.class, withSettings().extraInterfaces(WrapsDriver.class));
}

public static AppiumDriver mockAndroidDriver() {
return mock(AndroidDriver.class, withSettings().extraInterfaces(WrapsDriver.class, HasInputDevices.class));
return mock(AndroidDriver.class, withSettings().extraInterfaces(WrapsDriver.class));
}


public static IOSDriver mockIOSDriver() {
return mock(IOSDriver.class, withSettings().extraInterfaces(WrapsDriver.class, HasInputDevices.class));
return mock(IOSDriver.class, withSettings().extraInterfaces(WrapsDriver.class));
}

public static WebElement mockWebElement() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.*;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class TargetMethodTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import io.qameta.atlas.webdriver.extension.ShouldMethodExtension;
import io.qameta.atlas.webdriver.extension.WaitUntilMethodExtension;
import org.hamcrest.Matcher;
import org.openqa.selenium.*;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WrapsElement;
import org.openqa.selenium.interactions.Coordinates;
import org.openqa.selenium.interactions.Locatable;
import org.openqa.selenium.WrapsElement;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface WebPage extends WrapsDriver, SearchContext {
@Override
WebDriver getWrappedDriver();

default void open(String url) {
default void open(final String url) {
getWrappedDriver().get(url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ExecuteJScriptMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(EXECUTE_SCRIPT);
return EXECUTE_SCRIPT.equals(method.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class ExtractMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(EXTRACT)
&& List.class.isAssignableFrom(method.getReturnType());
return EXTRACT.equals(method.getName()) && List.class.isAssignableFrom(method.getReturnType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FilterCollectionExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(FILTER) && List.class.isAssignableFrom(method.getDeclaringClass());
return FILTER.equals(method.getName()) && List.class.isAssignableFrom(method.getDeclaringClass());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ShouldMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(SHOULD);
return SHOULD.equals(method.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ToStringMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(TO_STRING);
return TO_STRING.equals(method.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class WaitUntilMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(WAIT_UNTIL);
return WAIT_UNTIL.equals(method.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class WrappedElementMethodExtension implements MethodExtension {

@Override
public boolean test(final Method method) {
return method.getName().equals(GET_WRAPPED_ELEMENT);
return GET_WRAPPED_ELEMENT.equals(method.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.remote.RemoteWebDriver;

import static io.qameta.atlas.webdriver.testdata.ObjectFactory.mockWebElement;
Expand All @@ -19,7 +18,7 @@ public class ExecuteJScriptMethodExtensionTest {

@Before
public void initElements() {
driver = mock(RemoteWebDriver.class, withSettings().extraInterfaces(WebDriver.class, HasInputDevices.class));
driver = mock(RemoteWebDriver.class, withSettings().extraInterfaces(WebDriver.class));
WebElement originWebElement = mockWebElement();
atlasWebElement = new Atlas(new WebDriverConfiguration(driver))
.create(originWebElement, AtlasWebElement.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.qameta.atlas.webdriver.AtlasWebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Locatable;

import static org.mockito.Mockito.mock;
Expand All @@ -15,7 +14,7 @@ private ObjectFactory() {
}

public static WebDriver mockWebDriver() {
return mock(WebDriver.class, withSettings().extraInterfaces(HasInputDevices.class));
return mock(WebDriver.class, withSettings());
}

public static WebElement mockWebElement() {
Expand Down
30 changes: 9 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,34 @@ buildscript {
val gradleScriptDir by extra("${rootProject.projectDir}/gradle")

tasks.withType(Wrapper::class) {
gradleVersion = "6.0.1"
gradleVersion = "7.5.1"
}

plugins {
java
id("ru.vyarus.quality") version "4.0.0"
id("com.jfrog.bintray") version "1.8.0"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
id("net.researchgate.release") version "2.8.1"
}

release {
tagTemplate = "\${version}"
signing
`java-library`
`maven-publish`
id("ru.vyarus.quality") version "4.9.0"
id("io.spring.dependency-management") version "1.1.0"
}

configure(listOf(rootProject)) {
description = "Atlas"
group = "io.qameta.atlas"
}

val afterReleaseBuild by tasks.existing

configure(subprojects) {
group = "io.qameta.atlas"
version = version

apply(plugin = "java")
apply(plugin = "maven")
apply(plugin = "signing")
apply(plugin = "maven-publish")
apply(plugin = "java-library")
apply(plugin = "ru.vyarus.quality")
apply(plugin = "io.spring.dependency-management")

apply(from = "$gradleScriptDir/maven.gradle")
apply(from = "$gradleScriptDir/bintray.gradle")

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -72,11 +65,6 @@ configure(subprojects) {
artifacts.add("archives", sourceJar)
artifacts.add("archives", javadocJar)

val bintrayUpload by tasks.existing
afterReleaseBuild {
dependsOn(bintrayUpload)
}

configure<DependencyManagementExtension> {
dependencies {
dependency("org.apache.commons:commons-lang3:3.12.0")
Expand All @@ -92,7 +80,7 @@ configure(subprojects) {

dependency("org.hamcrest:hamcrest-all:1.3")
dependency("org.assertj:assertj-core:3.24.2")
dependency("org.mockito:mockito-core:5.3.0")
dependency("org.mockito:mockito-core:4.8.0")
dependency("junit:junit:4.13.2")
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit ddec29f

Please sign in to comment.