question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: take CharSequence rather than String in get(..), post(...) etc

See original GitHub issue

We are testing our API that uses Katharsis framework with REST Assured. The query parameter naming is a bit verbose, like ?filter[person][name]=tom. So I created a little helper class, that allows me to construct a String representing the API-URL to test like this:

String url = getApiResourceRoute()
            .withFilterParam("name", "Tom")
            .withFilterParam("age", 30)
            .toString();

producing: http://localhost:8080/api/persons?filter[persons][name]=Tom&filter[persons][age]=30

The information that this request is about persons is stored in a field of the test class, in case you were wondering.

Since the get(...) methods and it’s siblings only take types that are final, I’ll always need to do something like toString() as my last method call in the chain. Now, if your get(...) methods would take a CharSequence instead of a String, I could also pass my fancy helper class directly, because it implements CharSequence. I would love to no not have the toString() there.

Would make my tests with Rest Assured even more beautiful to behold 😉.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
weaselmetalcommented, May 5, 2017

I guess it shouldn’t. A String is a CharSequence. Most of the Apache StringUtils methods take a CharSequence.

0reactions
weaselmetalcommented, May 9, 2017

Well, I’d say:

  • Prerequisites that you’ll need to get and compile the code (git, maven, JDK). A few instructions to get you set up.
  • General information about the project (Languages: Java 7(?), Groovy, …), project structure and components
  • Coding conventions if you want to have some conventions, maybe an editorconfig.
  • How to test the fix
  • Git workflow (forking the project into your github account, providing a fix, creating a pull request, I just imagined you’d want it like that).

Basically anything that helps people getting started. Eclipse wasn’t really fond of opening the project (missing gmaven plugin - dunno), so I used IntelliJ (Community Edition) to open it. I’d guess you use IntelliJ too.

I found this: https://help.github.com/articles/setting-guidelines-for-repository-contributors/ which also links to some more extensive contribution guides.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CharSequence VS String in Java? - Stack Overflow
Strings are CharSequences, so you can just use Strings and not worry. ... with using the more general interface rather than a specific...
Read more >
TextUtils - Android Developers
Use listEllipsize(Context, List , String, TextPaint, float, int) instead. ... Returns the length that the specified CharSequence would have if spaces and ...
Read more >
CharSequence vs. String in Java - Baeldung
In this quick article, we're going to have a look at the differences between these types and when to use each one. 2....
Read more >
a one-byte-per-character CharSequence implementation
When implementing our own methods that work on strings, we should generally consider making them accept any CharSequence rather than specifically a String....
Read more >
4. Pattern Matching with Regular Expressions - Java ... - O'Reilly
Regexes can do far more than just character matching. ... int flags ); // Method to get a Matcher for this Pattern public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found