-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1780 extract duplicate code to a superclass CaseSensitiveTextCondition
- Loading branch information
Showing
3 changed files
with
30 additions
and
33 deletions.
There are no files selected for viewing
17 changes: 1 addition & 16 deletions
17
src/main/java/com/codeborne/selenide/conditions/CaseSensitiveText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/codeborne/selenide/conditions/CaseSensitiveTextCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.codeborne.selenide.conditions; | ||
|
||
import com.codeborne.selenide.TextCheck; | ||
import com.codeborne.selenide.impl.Html; | ||
|
||
import javax.annotation.CheckReturnValue; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@ParametersAreNonnullByDefault | ||
abstract class CaseSensitiveTextCondition extends TextCondition { | ||
protected CaseSensitiveTextCondition(String name, String expectedText) { | ||
super(name, expectedText); | ||
} | ||
|
||
@CheckReturnValue | ||
@Override | ||
protected boolean match(String actualText, String expectedText) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
protected boolean match(TextCheck textCheck, String actualText, String expectedText) { | ||
return switch (textCheck) { | ||
case FULL_TEXT -> Html.text.equalsCaseSensitive(actualText, expectedText); | ||
case PARTIAL_TEXT -> Html.text.containsCaseSensitive(actualText, expectedText); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters