Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified the StartsActivity by reducing the number of parameters through POJO class #579

Merged
merged 5 commits into from
Feb 25, 2017

Conversation

email2vimalraj
Copy link
Contributor

Simplified the StartsActivity by reducing the number of parameters through POJO class

Change list

Currently the number of startActivity methods are unnecessary which can be solved by one single method with single parameter. So introduced the simple POJO class which in future can be expanded with any number of parameters.

Types of changes

What types of changes are you proposing/introducing to Java client?

  • 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)

Details

The sample usage of new implementation is as follows:

Activity activity = new Activity();
activity.setAppPackage("com.foo");
activity.setAppActivity(".bar");
driver.startActivity(activity);

@email2vimalraj
Copy link
Contributor Author

Could someone please explain why the CI build has failed?
I'm unable to run the build in my machine. Getting compilation error.
Please have a look at the exception that I'm getting: https://gist.github.com/email2vimalraj/171ecdaa966db76e047e0cc7e2942481

@email2vimalraj
Copy link
Contributor Author

@SrinivasanTarget : Kindly help me what I'm supposed to fix in the build error.

@saikrishna321
Copy link
Member

@email2vimalraj you have styling issues. Please fix them

https://travis-ci.org/appium/java-client/builds/204062313#L1987

you can ignore the warnings

@SrinivasanTarget
Copy link
Member

@email2vimalraj Hey buddy sorry just checked your note. please fix the errors to review.

*
* @param appPackage The package containing the activity. [Required]
Copy link
Contributor

Choose a reason for hiding this comment

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

@email2vimalraj I'm against this change as it is. Please mark these methods Deprecated and with the description to use new ones

/**
* This is a simple POJO class to support the {@link StartsActivity}.
*/
public class Activity {
Copy link
Contributor

Choose a reason for hiding this comment

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

I this this POJO should have 2 mandatory parameteres: package and activity. Please add the constructor with these parameters.

*
* @param appPackage The app package value.
*/
public void setAppPackage(String appPackage) {
Copy link
Member

@SrinivasanTarget SrinivasanTarget Feb 22, 2017

Choose a reason for hiding this comment

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

I like the idea behind this but have few things to be discussed here,

Is there a way to remove getters & setters? May be we need to come up with either custom annotation or something like https://github.com/rzwitserloot/lombok. May be not necessarily in this PR but subjective to discussion if there is any scope of improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Read the user review who was using the lombok for more than a year: http://stackoverflow.com/a/12807937/1505987

I would recommend to stay away from lombok, even though I never used it personally. My justification would be obviously a javadoc and everytime we will have to generate the code.

Copy link
Member

Choose a reason for hiding this comment

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

I also don't recommend lombock. But i liked their way of using annotations.

@email2vimalraj
Copy link
Contributor Author

The CI is still pending from long time. Could someone look into it?

@SrinivasanTarget
Copy link
Member

SrinivasanTarget commented Feb 22, 2017

The CI is still pending from long time. Could someone look into it?

Have restarted travisCI job lets see. Anyways we need to wait for Codacy to complete.

@email2vimalraj
Copy link
Contributor Author

email2vimalraj commented Feb 22, 2017

Have restarted travisCI job lets see. Anyways we need to wait for Codacy to complete.

Seems some issue with Travis, it keeps the job in queue, but not running it up.

@SrinivasanTarget
Copy link
Member

Seems some issue with Travis, it keeps the job in queue, but not running it up.

Yes checking

@email2vimalraj
Copy link
Contributor Author

Any updates on CI?

@email2vimalraj
Copy link
Contributor Author

@SrinivasanTarget @TikhomirovSergey : Can any one of you please help on the Travis issue? Seems the travis doesn't like to run my PR :(

@SrinivasanTarget
Copy link
Member

@email2vimalraj I'll check with @imurchie and see if we could do something.

@email2vimalraj
Copy link
Contributor Author

email2vimalraj commented Feb 23, 2017

Seems Travis finally ran my PR and this time build passed. :)

https://travis-ci.org/appium/java-client/builds/204446236#L1990

Copy link
Member

@SrinivasanTarget SrinivasanTarget left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@@ -118,7 +119,10 @@ StartsActivity startsActivity = new StartsActivity() {
}
};

StartsActivity startsActivity.startActivity("your.package.name", ".ActivityName");
Activity activity = new Activity();
activity.setAppPackage("your.package.name");
Copy link
Member

Choose a reason for hiding this comment

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

@email2vimalraj Can you update here too.

Copy link
Member

Choose a reason for hiding this comment

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

@email2vimalraj
Copy link
Contributor Author

@SrinivasanTarget : Fixed, kindly have a look

* @param appPackage The value for the app package.
* @param appActivity The value for the app activity.
*/
public Activity(String appPackage, String appActivity) {
Copy link
Contributor

@TikhomirovSergey TikhomirovSergey Feb 25, 2017

Choose a reason for hiding this comment

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

@email2vimalraj Could you provide these checkings:

import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.commons.lang3.StringUtils.isBlank;
...
public Activity(String appPackage, String appActivity) {
    checkArgument(!isBlank(appPackage), "App package should be defined as not empty or null string");
    checkArgument(!isBlank(appActivity), "App activity should be defined as not empty or null string");
    ...
}

Copy link
Member

Choose a reason for hiding this comment

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

Good catch 👍

@TikhomirovSergey TikhomirovSergey added this to the 5.0.0 milestone Feb 25, 2017
*
* @param appActivity The app activity value.
*/
public void setAppActivity(String appActivity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that it is necessary to keep this method. Maybe it is more senseful to keep only getter for activity and make this field final. @SrinivasanTarget What is your opinion?

*
* @param appPackage The app package value.
*/
public void setAppPackage(String appPackage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that it is necessary to keep this method. Maybe it is more senseful to keep only getter for package and make this field final. @SrinivasanTarget What is your opinion?

Copy link
Member

Choose a reason for hiding this comment

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

+1 - Making this final would be a better option 👍

@TikhomirovSergey
Copy link
Contributor

@email2vimalraj I have finished the reviewing. It is almost ok. @email2vimalraj Could you read comments and make some improvenents?

ping @SrinivasanTarget

…Also made the mandatory parameters final and removed setters.
@email2vimalraj
Copy link
Contributor Author

@TikhomirovSergey and @SrinivasanTarget : Done the changes as recommended

@TikhomirovSergey
Copy link
Contributor

@email2vimalraj I have approved these changes. @SrinivasanTarget ?

@SrinivasanTarget
Copy link
Member

@email2vimalraj It's a merge away. Waiting for Codacy to be happy.

@SrinivasanTarget SrinivasanTarget merged commit 72b9e6a into appium:master Feb 25, 2017
@SrinivasanTarget
Copy link
Member

Thanks @email2vimalraj 👍

TikhomirovSergey added a commit that referenced this pull request Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants