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

best way to convert a JUnit assertion into a assertj fluent assertion? #241

Closed
stefanofornari opened this issue Sep 20, 2014 · 16 comments
Closed

Comments

@stefanofornari
Copy link

Hi,
I would like to convert a JUnit assertion (https://github.com/skyscreamer/JSONassert) creating a fluent assertion for assertj. What's the best way to do it? The final goal would be to support something like this:

JSONObject ref = ...;
JSONObject o = ...;

then(o).isEqualTo(ref);

I read all the available documentation and I am quite familiar with the use of assertj, but I would need some initial directions to start the task. I'll be happy to contribute it to the project if liked.

Thanks in advance,
stefano

@joel-costigliola
Copy link
Member

Hi Stefano,
I already wanted to have JSON assertions (#75) but never had the time to do it. That's great you propose to add some !

It can't be done in assertj-core because it only relies on JDK - no other dependencies - to make avoid dependency version mismatch for users.

It should done in a separate module assertj-json much like assertj-guava, you will need:

  • an entry point class like Assertions
  • a JSONAssert class with clean javadoc for API method (including code example)
  • update AssertJ site

I can create assertj-json repository and give you admin rights on it (I prefer to have modules project on my account, it's easier to manage).

Tell me what you think and if you are happy to contribute, I'll create the repository.

Thanks !

@stefanofornari
Copy link
Author

Hi Joel,
thanks for the hint. I will look into it this week and I will have a look
at the assertj-guava module. then I will propose a first version. It is ok
for me you keep the repository.

Ste

On Sun, Sep 21, 2014 at 1:36 AM, Joel Costigliola notifications@github.com
wrote:

Hi Stefano,
I already wanted to have JSON assertions (#75
#75) but never
had the time to do it. That's great you propose to add some !

It can't be done in assertj-core because it only relies on JDK - no
other dependencies - to make avoid dependency version mismatch for users.

It should done in a separate module assertj-json much like
assertj-guava, you will need:

  • an entry point class like Assertions
  • a JSONAssert class with clean javadoc for API method (including code
    example)
  • update AssertJ site

I can create assertj-json repository and give you admin rights on it (I
prefer to have modules project on my account, it's easier to manage).

Tell me what you think and if you are happy to contribute, I'll create the
repository.

Thanks !


Reply to this email directly or view it on GitHub
#241 (comment)
.

@stefanofornari
Copy link
Author

Hi Joel,
I made some good progress and I have the first assertion in a module
assertj-json. I have a question though: how assertj-core knows about my
org.assertj.json.api.Assertions ? In other word, how can I use it in my
project?

thanks in advance,

Ste

On Mon, Sep 22, 2014 at 12:48 AM, Stefano Fornari <stefano.fornari@gmail.com

wrote:

Hi Joel,
thanks for the hint. I will look into it this week and I will have a look
at the assertj-guava module. then I will propose a first version. It is ok
for me you keep the repository.

Ste

On Sun, Sep 21, 2014 at 1:36 AM, Joel Costigliola <
notifications@github.com> wrote:

Hi Stefano,
I already wanted to have JSON assertions (#75
#75) but never
had the time to do it. That's great you propose to add some !

It can't be done in assertj-core because it only relies on JDK - no
other dependencies - to make avoid dependency version mismatch for users.

It should done in a separate module assertj-json much like
assertj-guava, you will need:

  • an entry point class like Assertions
  • a JSONAssert class with clean javadoc for API method (including
    code example)
  • update AssertJ site

I can create assertj-json repository and give you admin rights on it
(I prefer to have modules project on my account, it's easier to manage).

Tell me what you think and if you are happy to contribute, I'll create
the repository.

Thanks !


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

assertj-core won't know anything from assertj-json to avoid dependencies on third party libraries, users juts have to import Assertions entry point classes from assertj-core and assertj-json.
You have an example of that with assertj-joda-time and assertj-core in mixing_core_and_joda_time_assertions_examples test.

I will create the assertj-json today.

@joel-costigliola
Copy link
Member

I have created assertj-json and given you the right to push commits to it directly (no PR needed).
I have setup project structure and contribution guideline, I have just published new code formaating settings so you might update yours.
welcome aboard !

@stefanofornari
Copy link
Author

Hi Joel,
thanks for your answer. However I want to support the then(...) syntax, not
the assertThat(). How can I do it?

Ste

On Wed, Sep 24, 2014 at 12:21 AM, Joel Costigliola <notifications@github.com

wrote:

assertj-core won't know anything from assertj-json to avoid dependencies
on third party libraries, users juts have to import Assertions entry
point classes from assertj-core and assertj-json.
You have an example of that with assertj-joda-time and assertj-core in
mixing_core_and_joda_time_assertions_examples
https://github.com/joel-costigliola/assertj-examples/blob/master/assertions-examples/src/test/java/org/assertj/examples/JodaTimeAssertionsExamples.java
test.

I will create the assertj-json today.


Reply to this email directly or view it on GitHub
#241 (comment)
.

@stefanofornari
Copy link
Author

Hi Joel,
sorry for the dumb question, but where can I find the coding convention you
mentioned?

Ste

On Wed, Sep 24, 2014 at 12:42 PM, Joel Costigliola <notifications@github.com

wrote:

I have created assertj-json
https://github.com/joel-costigliola/assertj-json and given you the
right to push commits to it directly (no PR needed).
I have setup project structure and contribution guideline, I have just
published new code formaating settings so you might update yours.
welcome aboard !


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

Ahhh my bad ! I forgot to push my changes last night :(
I'll do that this evening and you will have the project structure and the contributing rules.

the code formatting settings is https://github.com/joel-costigliola/assertj-core/blob/master/src/ide-support/assertj-eclipse-formatter.xml

@stefanofornari
Copy link
Author

I use netbeans ;)

can you please also answer my question about using then(...)?

thanks in advance!

Ste

On Wed, Sep 24, 2014 at 11:23 PM, Joel Costigliola <notifications@github.com

wrote:

Ahhh my bad ! I forgot to push my changes last night :(
I'll do that this evening and you will have the project structure and the
contributing rules.

the code formatting settings is
https://github.com/joel-costigliola/assertj-core/blob/master/src/ide-support/assertj-eclipse-formatter.xml


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

hope there is a plugin that takes eclipse preferences ... no big deal, it just makes it harder to compare commits when formatting has changed.

You are welcome the add then along with assertThat methods, just add them in the Assertions class that I will push this evening

@stefanofornari
Copy link
Author

oh, I see... it does not pick it up automatically; I will need to import it
in my classes. I wonder if there could be a autodiscovery of Assertions
classes and then resolve the right ones at runtime...

Ste

On Wed, Sep 24, 2014 at 11:34 PM, Joel Costigliola <notifications@github.com

wrote:

hope there is a plugin that takes eclipse preferences ... no big deal, it
just makes it harder to compare commits when formatting has changed.

You are welcome the add then along with assertThat methods, just add them
in the Assertions class that I will push this evening


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

commit pushed !

@stefanofornari
Copy link
Author

Hi Joel,
thanks for the effort. I have some issues with the conventions. I have a
different style which I do not want to quit. Let me know if you still want
me to push in your repository, otherwise I can just use mine and if you
want to can grab the code.

Ste

On Thu, Sep 25, 2014 at 9:46 AM, Joel Costigliola notifications@github.com
wrote:

commit pushed !


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

That is a problem if the code is in assertj-json repository for future contributors.
What we can do is you code with your convention and create a PR, I will reformat the code before merging it.

@stefanofornari
Copy link
Author

Hi Joel,
I am thinking about it. In the meantime I am writing some more code so we
will better judge what's best to do.

Ste

On Sun, Sep 28, 2014 at 6:03 AM, Joel Costigliola notifications@github.com
wrote:

That is a problem if the code is in assertj-json repository for future
contributors.
What we can do is you code with your convention and create a PR, I will
reformat the code before merging it.


Reply to this email directly or view it on GitHub
#241 (comment)
.

@joel-costigliola
Copy link
Member

closing this issue since assertj-json exists.

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

No branches or pull requests

2 participants