Skip to content

Commit 50ba57d

Browse files
code cleaning up
1 parent 06a7fb8 commit 50ba57d

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public void zoom(int x, int y) {
335335
@Override public String getContext() {
336336
String contextName =
337337
String.valueOf(execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE).getValue());
338-
if (contextName.equals("null")) {
338+
if ("null".equalsIgnoreCase(String.valueOf(contextName))) {
339339
return null;
340340
}
341341
return contextName;

src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939

4040
class AppiumElementLocator implements CacheableLocator {
4141

42-
final boolean shouldCache;
43-
final By by;
44-
final TimeOutDuration timeOutDuration;
42+
private final boolean shouldCache;
43+
private final By by;
44+
private final TimeOutDuration timeOutDuration;
4545
private final TimeOutDuration originalTimeOutDuration;
46-
final WebDriver originalWebDriver;
46+
private final WebDriver originalWebDriver;
4747
private final SearchContext searchContext;
4848
private final WaitingFunction waitingFunction;
4949
private WebElement cachedElement;

src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,13 @@ protected List<WebElement> proxyForListLocator(ClassLoader ignored,
149149

150150
Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0];
151151

152-
boolean result = false;
153152
for (Class<? extends WebElement> webElementClass : availableElementClasses) {
154153
if (!webElementClass.equals(listType)) {
155154
continue;
156155
}
157-
result = true;
158-
break;
156+
return true;
159157
}
160-
return result;
158+
return false;
161159
}
162160
};
163161

src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private static By buildMobileBy(LocatorGroupStrategy locatorGroupStrategy, Annot
198198

199199
if (isWindows()) {
200200
WindowsFindBy[] windowsFindByArray = annotatedElement.getAnnotationsByType(WindowsFindBy.class);
201-
result = buildMobileBy(howToUseLocators != null ? howToUseLocators.iOSAutomation() : null,
201+
result = buildMobileBy(howToUseLocators != null ? howToUseLocators.windowsAutomation() : null,
202202
windowsFindByArray);
203203
}
204204

src/main/java/io/appium/java_client/pagefactory/OverrideWidgetReader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ static Class<? extends Widget> getMobileNativeWidgetClass(Class<? extends Widget
7474
String transformedPlatform = String.valueOf(platform).toUpperCase().trim();
7575
String transformedAutomation = String.valueOf(automation).toUpperCase().trim();
7676

77-
if (ANDROID.toUpperCase().equals(transformedPlatform) && AutomationName.SELENDROID
78-
.toUpperCase().equals(transformedAutomation)) {
77+
if (ANDROID.equalsIgnoreCase(transformedPlatform) && AutomationName.SELENDROID
78+
.equalsIgnoreCase(transformedAutomation)) {
7979
return getConvenientClass(declaredClass, annotatedElement, SELENDROID);
8080
}
8181

82-
if (ANDROID.toUpperCase().equals(transformedPlatform)) {
82+
if (ANDROID.equalsIgnoreCase(transformedPlatform)) {
8383
return getConvenientClass(declaredClass, annotatedElement, ANDROID_UI_AUTOMATOR);
8484
}
8585

86-
if (IOS.toUpperCase().equals(transformedPlatform)) {
86+
if (IOS.equalsIgnoreCase(transformedPlatform)) {
8787
return getConvenientClass(declaredClass, annotatedElement, IOS_UI_AUTOMATION);
8888
}
8989

@@ -105,7 +105,7 @@ private static Constructor<? extends Widget> getConstructorOfAMobileNativeWidget
105105
return findConvenientConstructor(clazz);
106106
}
107107

108-
static Map<ContentType, Constructor<? extends Widget>> read(
108+
protected static Map<ContentType, Constructor<? extends Widget>> read(
109109
Class<? extends Widget> declaredClass, AnnotatedElement annotatedElement, String platform,
110110
String automation) {
111111
Map<ContentType, Constructor<? extends Widget>> result = new HashMap<>();

src/main/java/io/appium/java_client/pagefactory/ThrowableUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class ThrowableUtil {
2525
private static final String INVALID_SELECTOR_PATTERN = "Invalid locator strategy:";
2626

27-
static boolean isInvalidSelectorRootCause(Throwable e) {
27+
protected static boolean isInvalidSelectorRootCause(Throwable e) {
2828
if (e == null) {
2929
return false;
3030
}
@@ -41,7 +41,7 @@ static boolean isInvalidSelectorRootCause(Throwable e) {
4141
return isInvalidSelectorRootCause(e.getCause());
4242
}
4343

44-
static boolean isStaleElementReferenceException(Throwable e) {
44+
protected static boolean isStaleElementReferenceException(Throwable e) {
4545
if (e == null) {
4646
return false;
4747
}
@@ -53,7 +53,7 @@ static boolean isStaleElementReferenceException(Throwable e) {
5353
return isStaleElementReferenceException(e.getCause());
5454
}
5555

56-
static Throwable extractReadableException(Throwable e) {
56+
protected static Throwable extractReadableException(Throwable e) {
5757
if (!RuntimeException.class.equals(e.getClass()) && !InvocationTargetException.class
5858
.equals(e.getClass())) {
5959
return e;

src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* - https://code.google.com/p/selenium/wiki/PageFactory
4242
*/
4343
public abstract class AppiumByBuilder extends AbstractAnnotations {
44-
static final Class<?>[] DEFAULT_ANNOTATION_METHOD_ARGUMENTS = new Class<?>[] {};
44+
protected static final Class<?>[] DEFAULT_ANNOTATION_METHOD_ARGUMENTS = new Class<?>[] {};
4545

4646
private static final List<String> METHODS_TO_BE_EXCLUDED_WHEN_ANNOTATION_IS_READ =
4747
new ArrayList<String>() {

src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public AppiumServiceBuilder withStartUpTimeOut(long time, TimeUnit timeUnit) {
289289
return this;
290290
}
291291

292-
void checkAppiumJS() {
292+
private void checkAppiumJS() {
293293
if (appiumJS != null) {
294294
validateNodeStructure(appiumJS);
295295
return;

src/test/java/io/appium/java_client/pagefactory_tests/AndroidPageObjectTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ public class AndroidPageObjectTest extends BaseAndroidTest {
235235
assertNotEquals(null, mobileElementView.getAttribute("text"));
236236
}
237237

238-
@Test public void areMobileElements_FindByTest() {
238+
@Test public void areMobileElementsFindByTest() {
239239
assertNotEquals(0, mobiletextVieWs.size());
240240
}
241241

242-
@Test public void isMobileElement_FindByTest() {
242+
@Test public void isMobileElementFindByTest() {
243243
assertNotEquals(null, mobiletextVieW.getAttribute("text"));
244244
}
245245

@@ -259,11 +259,11 @@ public class AndroidPageObjectTest extends BaseAndroidTest {
259259
assertNotEquals(null, chainElementView.getAttribute("text"));
260260
}
261261

262-
@Test public void checkThatElementsWereNotFoundByIOSUIAutomator_Chain() {
262+
@Test public void checkThatElementsWereNotFoundByIOSUIAutomatorChain() {
263263
assertEquals(0, iosChainTextViews.size());
264264
}
265265

266-
@Test public void checkThatElementWasNotFoundByIOSUIAutomator_Chain() {
266+
@Test public void checkThatElementWasNotFoundByIOSUIAutomatorChain() {
267267
NoSuchElementException nsee = null;
268268
try {
269269
iosChainTextView.getAttribute("text");
@@ -273,11 +273,11 @@ public class AndroidPageObjectTest extends BaseAndroidTest {
273273
assertNotNull(nsee);
274274
}
275275

276-
@Test public void androidOrIOSFindByElementsTest_ChainSearches() {
276+
@Test public void androidOrIOSFindByElementsTestChainSearches() {
277277
assertNotEquals(0, chainAndroidOrIOSUIAutomatorViews.size());
278278
}
279279

280-
@Test public void androidOrIOSFindByElementTest_ChainSearches() {
280+
@Test public void androidOrIOSFindByElementTestChainSearches() {
281281
assertNotEquals(null, chainAndroidOrIOSUIAutomatorView.getAttribute("text"));
282282
}
283283

@@ -311,7 +311,7 @@ public class AndroidPageObjectTest extends BaseAndroidTest {
311311
throw new RuntimeException(NoSuchElementException.class.getName() + " has been expected.");
312312
}
313313

314-
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy_List() {
314+
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindByList() {
315315
assertEquals(0, elementsWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.size());
316316
}
317317

src/test/java/io/appium/java_client/pagefactory_tests/IOSPageFactoryTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ public class IOSPageFactoryTest extends AppIOSTest {
200200
assertNotEquals(null, mobileButton.getText());
201201
}
202202

203-
@Test public void areMobileElements_FindByTest() {
203+
@Test public void areMobileElementsFindByTest() {
204204
assertNotEquals(0, mobiletFindByButtons.size());
205205
}
206206

207-
@Test public void isMobileElement_FindByTest() {
207+
@Test public void isMobileElementFindByTest() {
208208
assertNotEquals(null, mobiletFindByButton.getText());
209209
}
210210

@@ -216,11 +216,11 @@ public class IOSPageFactoryTest extends AppIOSTest {
216216
assertNotEquals(null, remotetextVieW.getText());
217217
}
218218

219-
@Test public void checkThatElementsWereNotFoundByAndroidUIAutomator_Chain() {
219+
@Test public void checkThatElementsWereNotFoundByAndroidUIAutomatorChain() {
220220
assertEquals(0, chainElementViews.size());
221221
}
222222

223-
@Test public void checkThatElementWasNotFoundByAndroidUIAutomator_Chain() {
223+
@Test public void checkThatElementWasNotFoundByAndroidUIAutomatorChain() {
224224
NoSuchElementException nsee = null;
225225
try {
226226
chainElementView.getText();
@@ -234,7 +234,7 @@ public class IOSPageFactoryTest extends AppIOSTest {
234234
assertNotEquals(null, iosButton.getText());
235235
}
236236

237-
@Test public void areIOSElements_FindByTest() {
237+
@Test public void areIOSElementsFindByTest() {
238238
assertNotEquals(0, iosButtons.size());
239239
}
240240

@@ -257,7 +257,7 @@ public class IOSPageFactoryTest extends AppIOSTest {
257257
throw new RuntimeException(NoSuchElementException.class.getName() + " has been expected.");
258258
}
259259

260-
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy_List() {
260+
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindByList() {
261261
assertEquals(0, elementsWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.size());
262262
}
263263
}

0 commit comments

Comments
 (0)