Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 93bb73b

Browse files
committed
Added getter to conditions and created conditions factory test
1 parent 15f5dbb commit 93bb73b

File tree

11 files changed

+278
-35
lines changed

11 files changed

+278
-35
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.PageFragment;
57

@@ -11,27 +13,28 @@
1113
* @see PageFragment#getAttribute(String)
1214
* @since 2.0
1315
*/
16+
@Getter
1417
public class Attribute implements Condition<PageFragment> {
1518

16-
private final String attributeName;
19+
private final String expectedAttributeName;
1720

1821
/**
1922
* Creates a new {@link Attribute} condition. Using the given attribute.
2023
*
21-
* @param attributeName the name of the attribute to check
24+
* @param expectedAttributeName the name of the attribute to check
2225
*/
23-
public Attribute(String attributeName) {
24-
this.attributeName = attributeName;
26+
public Attribute(String expectedAttributeName) {
27+
this.expectedAttributeName = expectedAttributeName;
2528
}
2629

2730
@Override
2831
public boolean test(PageFragment pageFragment) {
29-
return pageFragment.getAttribute(attributeName).isPresent();
32+
return pageFragment.getAttribute(expectedAttributeName).isPresent();
3033
}
3134

3235
@Override
3336
public String toString() {
34-
return String.format("attribute '%s'", attributeName);
37+
return String.format("attribute '%s'", expectedAttributeName);
3538
}
3639

3740
}

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/AttributeWithValue.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Objects;
44

5+
import lombok.Getter;
6+
57
import info.novatec.testit.webtester.conditions.Condition;
68
import info.novatec.testit.webtester.pagefragments.PageFragment;
79

@@ -14,26 +16,27 @@
1416
* @see PageFragment#getAttribute(String)
1517
* @since 2.0
1618
*/
19+
@Getter
1720
public class AttributeWithValue implements Condition<PageFragment> {
1821

19-
private final String attributeName;
22+
private final String expectedAttributeName;
2023
private final String expectedValue;
2124

2225
/**
2326
* Creates a new {@link AttributeWithValue} condition. Using the given attribute name and expected value.
2427
* The value is an Object and it's toString method will be used to extract the value for the comparison.
2528
*
26-
* @param attributeName the name of the attribute to check
29+
* @param expectedAttributeName the name of the attribute to check
2730
* @param expectedValue the value to check
2831
*/
29-
public AttributeWithValue(String attributeName, Object expectedValue) {
30-
this.attributeName = attributeName;
32+
public AttributeWithValue(String expectedAttributeName, Object expectedValue) {
33+
this.expectedAttributeName = expectedAttributeName;
3134
this.expectedValue = String.valueOf(expectedValue);
3235
}
3336

3437
@Override
3538
public boolean test(PageFragment pageFragment) {
36-
return pageFragment.getAttribute(attributeName).filter(this::isExpectedValue).isPresent();
39+
return pageFragment.getAttribute(expectedAttributeName).filter(this::isExpectedValue).isPresent();
3740
}
3841

3942
private boolean isExpectedValue(String value) {
@@ -42,7 +45,7 @@ private boolean isExpectedValue(String value) {
4245

4346
@Override
4447
public String toString() {
45-
return String.format("attribute '%s' with value '%s'", attributeName, expectedValue);
48+
return String.format("attribute '%s' with value '%s'", expectedAttributeName, expectedValue);
4649
}
4750

4851
}

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedIndex.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.SingleSelect;
57

@@ -12,6 +14,7 @@
1214
* @see SingleSelect#getSelectionIndex()
1315
* @since 2.0
1416
*/
17+
@Getter
1518
public class SelectedIndex implements Condition<SingleSelect> {
1619

1720
private final Integer expectedIndex;

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedIndices.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import org.apache.commons.lang.StringUtils;
1010

11+
import lombok.Getter;
12+
1113
import info.novatec.testit.webtester.conditions.Condition;
1214
import info.novatec.testit.webtester.pagefragments.MultiSelect;
1315

@@ -21,20 +23,21 @@
2123
* @see MultiSelect#getSelectionIndices()
2224
* @since 2.0
2325
*/
26+
@Getter
2427
public class SelectedIndices implements Condition<MultiSelect> {
2528

2629
private final Set<Integer> expectedIndices = new HashSet<>();
2730

28-
public SelectedIndices(Integer index) {
29-
this.expectedIndices.add(index);
31+
public SelectedIndices(Integer expectedIndex) {
32+
this.expectedIndices.add(expectedIndex);
3033
}
3134

32-
public SelectedIndices(Integer... indices) {
33-
this.expectedIndices.addAll(Arrays.asList(indices));
35+
public SelectedIndices(Integer... expectedIndices) {
36+
this.expectedIndices.addAll(Arrays.asList(expectedIndices));
3437
}
3538

36-
public SelectedIndices(Collection<Integer> indices) {
37-
this.expectedIndices.addAll(indices);
39+
public SelectedIndices(Collection<Integer> expectedIndices) {
40+
this.expectedIndices.addAll(expectedIndices);
3841
}
3942

4043
@Override

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedText.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.SingleSelect;
57

@@ -12,6 +14,7 @@
1214
* @see SingleSelect#getSelectionText()
1315
* @since 2.0
1416
*/
17+
@Getter
1518
public class SelectedText implements Condition<SingleSelect> {
1619

1720
private final String expectedText;

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedTexts.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import org.apache.commons.lang.StringUtils;
99

10+
import lombok.Getter;
11+
1012
import info.novatec.testit.webtester.conditions.Condition;
1113
import info.novatec.testit.webtester.pagefragments.MultiSelect;
1214

@@ -20,20 +22,21 @@
2022
* @see MultiSelect#getSelectionTexts()
2123
* @since 2.0
2224
*/
25+
@Getter
2326
public class SelectedTexts implements Condition<MultiSelect> {
2427

2528
private final List<String> expectedTexts = new LinkedList<>();
2629

27-
public SelectedTexts(String text) {
28-
this.expectedTexts.add(text);
30+
public SelectedTexts(String expectedText) {
31+
this.expectedTexts.add(expectedText);
2932
}
3033

31-
public SelectedTexts(String... texts) {
32-
this.expectedTexts.addAll(Arrays.asList(texts));
34+
public SelectedTexts(String... expectedTexts) {
35+
this.expectedTexts.addAll(Arrays.asList(expectedTexts));
3336
}
3437

35-
public SelectedTexts(Collection<String> texts) {
36-
this.expectedTexts.addAll(texts);
38+
public SelectedTexts(Collection<String> expectedTexts) {
39+
this.expectedTexts.addAll(expectedTexts);
3740
}
3841

3942
@Override

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedValue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.SingleSelect;
57

@@ -12,6 +14,7 @@
1214
* @see SingleSelect#getSelectionValue()
1315
* @since 2.0
1416
*/
17+
@Getter
1518
public class SelectedValue implements Condition<SingleSelect> {
1619

1720
private final String expectedValue;

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/SelectedValues.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import org.apache.commons.lang.StringUtils;
99

10+
import lombok.Getter;
11+
1012
import info.novatec.testit.webtester.conditions.Condition;
1113
import info.novatec.testit.webtester.pagefragments.MultiSelect;
1214

@@ -20,20 +22,21 @@
2022
* @see MultiSelect#getSelectionTexts()
2123
* @since 2.0
2224
*/
25+
@Getter
2326
public class SelectedValues implements Condition<MultiSelect> {
2427

2528
private final List<String> expectedValues = new LinkedList<>();
2629

27-
public SelectedValues(String value) {
28-
this.expectedValues.add(value);
30+
public SelectedValues(String expectedValue) {
31+
this.expectedValues.add(expectedValue);
2932
}
3033

31-
public SelectedValues(String... values) {
32-
this.expectedValues.addAll(Arrays.asList(values));
34+
public SelectedValues(String... expectedValues) {
35+
this.expectedValues.addAll(Arrays.asList(expectedValues));
3336
}
3437

35-
public SelectedValues(Collection<String> values) {
36-
this.expectedValues.addAll(values);
38+
public SelectedValues(Collection<String> expectedValues) {
39+
this.expectedValues.addAll(expectedValues);
3740
}
3841

3942
@Override
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.PageFragment;
57

@@ -12,22 +14,23 @@
1214
* @see PageFragment#getVisibleText()
1315
* @since 2.0
1416
*/
17+
@Getter
1518
public class VisibleTextContains implements Condition<PageFragment> {
1619

17-
private final String partialText;
20+
private final String expectedPartialText;
1821

19-
public VisibleTextContains(String partialText) {
20-
this.partialText = partialText;
22+
public VisibleTextContains(String expectedPartialText) {
23+
this.expectedPartialText = expectedPartialText;
2124
}
2225

2326
@Override
2427
public boolean test(PageFragment pageFragment) {
25-
return pageFragment.getVisibleText().contains(partialText);
28+
return pageFragment.getVisibleText().contains(expectedPartialText);
2629
}
2730

2831
@Override
2932
public String toString() {
30-
return String.format("visible text contains: %s", partialText);
33+
return String.format("visible text contains: %s", expectedPartialText);
3134
}
3235

3336
}

webtester-core/src/main/java/info/novatec/testit/webtester/conditions/pagefragments/VisibleTextEquals.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package info.novatec.testit.webtester.conditions.pagefragments;
22

3+
import lombok.Getter;
4+
35
import info.novatec.testit.webtester.conditions.Condition;
46
import info.novatec.testit.webtester.pagefragments.PageFragment;
57

@@ -12,6 +14,7 @@
1214
* @see PageFragment#getVisibleText()
1315
* @since 2.0
1416
*/
17+
@Getter
1518
public class VisibleTextEquals implements Condition<PageFragment> {
1619

1720
private final String expectedText;

0 commit comments

Comments
 (0)