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

Add test for query params #27

Merged
merged 1 commit into from
Jul 19, 2019
Merged

Add test for query params #27

merged 1 commit into from
Jul 19, 2019

Conversation

aaron-junot
Copy link
Contributor

Adds a couple of tests around the query params. setLimit is the only portion that's truly generated (everything else that I'm testing here is written directly into the generator template). The rest of the dynamic methods do not have tests around them, but there's no way to exclude them from coverage unless we exclude the entire class (which may be the best option, but I haven't done that just yet).

@aaron-junot aaron-junot requested a review from bhelx July 18, 2019 16:33
@@ -6,7 +6,6 @@
import com.recurly.v3.fixtures.MyRequest;
import com.recurly.v3.fixtures.MyResource;
import org.junit.jupiter.api.Test;
import com.recurly.v3.ApiException;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this unused import

@Test
public void testAdd() {
QueryParams qp = new QueryParams();
qp.add("anothertest", 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want add to be public to the programmer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we did in case we wanted to allow for other arbitrary query params that aren't specified by the API? If not, I can make it private and remove the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you know what? The programmer should be able to add arbitrary query params by specifying them in the HashMap and then setting them with setParams, so even if we made add private, it wouldn't block them from doing that. I still think it's a cool little utility method, but they could work around it by using getParams, adding to the HashMap and then setting it again with setParams.

I'll go ahead and make it private for now, but if someone wants us to make it public someday, I think we ought to go ahead and give them that.

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 worried people might use this over the named / typed methods. Also, if something is missing, that needs to be addressed in the generator.

Copy link
Contributor

@bhelx bhelx Jul 19, 2019

Choose a reason for hiding this comment

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

Suppose someone does params.add("limit", 200) for instance, and we change the name of "limit" to "pageSize" in the next version. The compiler can't help them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense. Then should setParams still be public?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, no.

Copy link
Contributor

@bhelx bhelx Jul 19, 2019

Choose a reason for hiding this comment

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

add and setParams should only be available internally

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. The params hashmap is created when the object is instantiated. getParams will need to be public still, but I don't think anything actually uses setParams at this time. I might be able to just remove it altogether if we're not trying to provide that interface to the programmer

@aaron-junot aaron-junot force-pushed the query-params-test branch 2 times, most recently from 90ccb73 to 109641b Compare July 19, 2019 17:17
@@ -54,6 +54,7 @@
<exclude>**/v3/resources/*</exclude>
<exclude>**/v3/Client.*</exclude>
<exclude>**/v3/exception/*</exclude>
<exclude>**/v3/QueryParams.*</exclude>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exclude from coverage due to the fact that it's a generated file.

Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

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

👍

@bhelx bhelx merged commit eb0daf2 into 3_0_0_beta Jul 19, 2019
@bhelx bhelx deleted the query-params-test branch July 19, 2019 17:27
@joannasese joannasese added the V3 v2019-10-10 Client label Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V3 v2019-10-10 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants