eBay / ebay-oauth-java-client

eBay OAuth APIs client for Java
https://developer.ebay.com/api-docs/static/oauth-tokens.html
Apache License 2.0
48 stars 34 forks source link

Make token getters return empty optional, instead of null #15

Closed crazed-developer closed 5 years ago

crazed-developer commented 5 years ago

Hi'

I've made a pull request: https://github.com/eBay/ebay-oauth-java-client/pull/14

The reasoning is that the methods:

Returns both null and an optional containing the token. (Depending on the success of the underlying call)

This is kind of fuzzy, and in my opinion beats the purpose of an optional.

And makes it necessary to do both a null check, and an isPresent() check

My change makes it so the two methods either returns:

I've also updated the test:

To expect this empty optional instead of a null value.

In addition i've removed a test from:

The reasoning is that this test is not generally valid. As you can log in with both your preferred username, and email. And you never know which one was used. So if you log in with the email and compare with the preferred username then it's going to fail. But this is a feature, so tests should not fail in this instance (My opinion.)

Okay I hope this pull request is good.

Thanks Steffen Otto Jensen

sengopal commented 5 years ago

@crazed-developer Irrespective of the user's login type, the username will always be returned and the tests does not fail. As you rightly mentioned, this is indeed a feature :) I have merged your other PR. Thanks for the fix.

sengopal commented 5 years ago

Fixed in #14