Skip to content

Commit

Permalink
Replaced unnecessary code with Lombok annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
slu-it authored and Axel Schüssler committed Oct 23, 2016
1 parent 2c2ecdb commit 5669728
Show file tree
Hide file tree
Showing 48 changed files with 245 additions and 303 deletions.
4 changes: 2 additions & 2 deletions webtester-build-tools/src/main/resources/checkstyle_rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="OneStatementPerLine" />
<module name="FinalClass" />
<module name="HideUtilityClassConstructor" />
<!--<module name="FinalClass" />-->
<!--<module name="HideUtilityClassConstructor" />-->
<module name="ArrayTypeStyle" />
<module name="UpperEll" />
<module name="OuterTypeFilename" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import org.openqa.selenium.SearchContext;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.browser.Browser;
import info.novatec.testit.webtester.internal.PageFragmentFactory;
Expand All @@ -29,9 +31,12 @@
* @since 2.0
*/
@Getter(AccessLevel.PACKAGE)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
public final class AdHocFinder {

@NonNull
private final PageFragmentFactory factory;
@NonNull
private final SearchContext searchContext;

/**
Expand Down Expand Up @@ -65,12 +70,6 @@ public AdHocFinder(PageFragment parent) {
this.searchContext = parent.webElement();
}

// Constructor used for unit tests.
AdHocFinder(PageFragmentFactory factory, SearchContext searchContext) {
this.factory = factory;
this.searchContext = searchContext;
}

/**
* Creates an {@link ByFinder By based finder}. It can be used to create different {@link PageFragment page fragment}
* instance for a fixed CSS-Selector value. In case you want to use an other identification method use {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.openqa.selenium.WebElement;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.internal.PageFragmentFactory;
import info.novatec.testit.webtester.pagefragments.GenericElement;
Expand All @@ -30,19 +32,17 @@
* @see ByFinder#asManyGenerics()
* @since 2.0
*/
@AllArgsConstructor
@Getter(AccessLevel.PACKAGE)
public class ByFinder {

@NonNull
private final PageFragmentFactory factory;
@NonNull
private final SearchContext searchContext;
@NonNull
private final By by;

public ByFinder(PageFragmentFactory factory, SearchContext searchContext, By by) {
this.factory = factory;
this.searchContext = searchContext;
this.by = by;
}

/**
* Creates a {@link GenericElement generic page element} using the finder's {@link By}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.openqa.selenium.WebElement;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.internal.PageFragmentFactory;
import info.novatec.testit.webtester.pagefragments.PageFragment;
Expand All @@ -30,19 +32,17 @@
* @see TypeFinder#manyBy(By)
* @since 2.0
*/
@AllArgsConstructor
@Getter(AccessLevel.PACKAGE)
public class TypeFinder<T extends PageFragment> {

@NonNull
private final PageFragmentFactory factory;
@NonNull
private final SearchContext searchContext;
@NonNull
private final Class<T> fragmentClass;

public TypeFinder(PageFragmentFactory factory, SearchContext searchContext, Class<T> fragmentClass) {
this.factory = factory;
this.searchContext = searchContext;
this.fragmentClass = fragmentClass;
}

/**
* Creates a {@link PageFragment page fragment} using the finder's specified class and the given CSS-Selector
* expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import org.openqa.selenium.WebDriver;

import lombok.AllArgsConstructor;
import lombok.NonNull;

import info.novatec.testit.webtester.browser.Browser;
import info.novatec.testit.webtester.config.Configuration;
import info.novatec.testit.webtester.events.EventSystem;


@AllArgsConstructor
public class BaseBrowserOperation {

@NonNull
private final Browser browser;

protected BaseBrowserOperation(Browser browser) {
this.browser = browser;
}

protected Browser browser() {
return browser;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Collection;

import lombok.experimental.UtilityClass;

import info.novatec.testit.webtester.conditions.pagefragments.Attribute;
import info.novatec.testit.webtester.conditions.pagefragments.AttributeWithValue;
import info.novatec.testit.webtester.conditions.pagefragments.Disabled;
Expand All @@ -27,13 +29,15 @@
import info.novatec.testit.webtester.conditions.syntax.Not;


public final class Conditions {

private Conditions() {
// utility class constructor
}

/* syntax */
/**
* This class provides factory methods for all kinds of {@link Condition} implementations.
* <p>
* It is recommended to static-import the use of any of the provided methods.
*
* @since 2.0
*/
@UtilityClass
public class Conditions {

public static <T> Is<T> is(Condition<T> condition) {
return new Is<>(condition);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.PageFragment;
Expand All @@ -14,19 +16,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class Attribute implements Condition<PageFragment> {

@NonNull
private final String expectedAttributeName;

/**
* Creates a new {@link Attribute} condition. Using the given attribute.
*
* @param expectedAttributeName the name of the attribute to check
*/
public Attribute(String expectedAttributeName) {
this.expectedAttributeName = expectedAttributeName;
}

@Override
public boolean test(PageFragment pageFragment) {
return pageFragment.getAttribute(expectedAttributeName).isPresent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
Expand All @@ -15,14 +17,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class SelectedIndex implements Condition<SingleSelect> {

@NonNull
private final Integer expectedIndex;

public SelectedIndex(Integer expectedIndex) {
this.expectedIndex = expectedIndex;
}

@Override
public boolean test(SingleSelect select) {
return select.getSelectionIndex().filter(expectedIndex::equals).isPresent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
Expand All @@ -15,14 +17,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class SelectedText implements Condition<SingleSelect> {

@NonNull
private final String expectedText;

public SelectedText(String expectedText) {
this.expectedText = expectedText;
}

@Override
public boolean test(SingleSelect select) {
return select.getSelectionText().filter(expectedText::equals).isPresent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
Expand All @@ -15,14 +17,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class SelectedValue implements Condition<SingleSelect> {

@NonNull
private final String expectedValue;

public SelectedValue(String expectedValue) {
this.expectedValue = expectedValue;
}

@Override
public boolean test(SingleSelect select) {
return select.getSelectionValue().filter(expectedValue::equals).isPresent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.PageFragment;
Expand All @@ -15,14 +17,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class VisibleTextContains implements Condition<PageFragment> {

@NonNull
private final String expectedPartialText;

public VisibleTextContains(String expectedPartialText) {
this.expectedPartialText = expectedPartialText;
}

@Override
public boolean test(PageFragment pageFragment) {
return pageFragment.getVisibleText().contains(expectedPartialText);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.novatec.testit.webtester.conditions.pagefragments;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.pagefragments.PageFragment;
Expand All @@ -15,14 +17,12 @@
* @since 2.0
*/
@Getter
@AllArgsConstructor
public class VisibleTextEquals implements Condition<PageFragment> {

@NonNull
private final String expectedText;

public VisibleTextEquals(String expectedText) {
this.expectedText = expectedText;
}

@Override
public boolean test(PageFragment pageFragment) {
return pageFragment.getVisibleText().equals(expectedText);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package info.novatec.testit.webtester.conditions.syntax;

import lombok.AllArgsConstructor;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;


Expand All @@ -14,14 +17,12 @@
* @see Condition
* @since 2.0
*/
@AllArgsConstructor
public class Has<T> implements Condition<T> {

@NonNull
private final Condition<T> condition;

public Has(Condition<T> condition) {
this.condition = condition;
}

@Override
public boolean test(T value) {
return condition.test(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package info.novatec.testit.webtester.conditions.syntax;

import lombok.AllArgsConstructor;
import lombok.NonNull;

import info.novatec.testit.webtester.conditions.Condition;


Expand All @@ -14,14 +17,12 @@
* @see Condition
* @since 2.0
*/
@AllArgsConstructor
public class Is<T> implements Condition<T> {

@NonNull
private final Condition<T> condition;

public Is(Condition<T> condition) {
this.condition = condition;
}

@Override
public boolean test(T value) {
return condition.test(value);
Expand Down
Loading

0 comments on commit 5669728

Please sign in to comment.