Skip to content

Clean up - #1028

Merged
mykola-mokhnach merged 6 commits into
appium:masterfrom
valfirst:clean-up
Sep 20, 2018
Merged

mykola-mokhnach merged 6 commits into
appium:masterfrom
valfirst:clean-up

Conversation

@valfirst

Copy link
Copy Markdown
Collaborator

Change list

  • Remove redundant 'throws' clauses
  • Simplify assertions in unit tests
  • Replace 'Collection.addAll()' with parametrized constructor call
  • Remove redundant array creation for calling varargs method
  • Remove redundant type arguments

Types of changes

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)


try {
String strategyParameter = value.invoke(mobileBy, new Object[] {}).toString();
String strategyParameter = value.invoke(mobileBy).toString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this call return the same result as the previous one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the method signature is:

java.lang.reflect.Method.invoke(Object, Object...)

so it's not required to pass an empty array as varargs

try {
String strategyParameter = value.invoke(mobileBy, new Object[] {}).toString();
String strategyParameter = value.invoke(mobileBy).toString();
if (!"".equals(strategyParameter)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use isEmpty() here


assertTrue(isRunningTestThread.result.equals(true));
assertTrue(isRunningTestThread2.result.equals(true));
assertEquals(true, isRunningTestThread.result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot we just test that assertTrue(isRunningTestThread.result) ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't: assertTrue requires boolean input parameter, but isRunningTestThread.result is of Object type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use Boolean.valueOf then

@appium appium deleted a comment Sep 20, 2018
@appium appium deleted a comment Sep 20, 2018
@appium appium deleted a comment from mykola-mokhnach Sep 20, 2018
@mykola-mokhnach
mykola-mokhnach merged commit 02aa5d5 into appium:master Sep 20, 2018
@valfirst
valfirst deleted the clean-up branch July 7, 2019 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants