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 function interface to assertItem #1469

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

calvernaz
Copy link

@calvernaz calvernaz commented Dec 18, 2023

Hi all,

This PR is a small add-on on top of the existing methods to make assertions easier.

With this we are allowed to transform and assert as we please instead of the full item and the equals equivalency of the item.

Example

class Person {
    int age;
    String name;
}

UniAssertSubscriber<Person> subscriber = uni
    .subscribe().withSubscriber(UniAssertSubscriber.create());
subscriber.assertSubscribed().assertItem(p -> p.name, person.name);

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (eb76731) 89.37% compared to head (c2570ce) 89.32%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1469      +/-   ##
============================================
- Coverage     89.37%   89.32%   -0.05%     
  Complexity     3365     3365              
============================================
  Files           459      459              
  Lines         13399    13402       +3     
  Branches       1640     1640              
============================================
- Hits          11975    11971       -4     
- Misses          797      801       +4     
- Partials        627      630       +3     
Files Coverage Δ
...llrye/mutiny/helpers/test/UniAssertSubscriber.java 91.97% <0.00%> (-2.06%) ⬇️

... and 9 files with indirect coverage changes

Copy link

@XiangZhouWD XiangZhouWD left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@jponge
Copy link
Member

jponge commented Dec 18, 2023

Note: @XiangZhouWD is not affiliated to this project.

Copy link
Member

@jponge jponge left a comment

Choose a reason for hiding this comment

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

I'm not really sure this adds much to our testing support, and at the very least this is only specific to Uni. Do you have more complex use-cases that would justify this addition?

@calvernaz
Copy link
Author

I'm not really sure this adds much to our testing support, and at the very least this is only specific to Uni. Do you have more complex use-cases that would justify this addition?

This allows for transformation, and individual properties assertion.

@jponge
Copy link
Member

jponge commented Dec 20, 2023

🎄

Let's revisit in January.

@rasmushaglund
Copy link

rasmushaglund commented Apr 3, 2024

I'm thinking about this kind of functionality but for Multi. Maybe something like this:

multi.subscribe().withSubscriber(AssertSubscriber.create())
    .request(1)
    .assertLastItem(p -> {
       assertEquals("name", p.name);
       assertEquals(38, p.age);
    })
    .request(1)
    .assertLastItem(p -> {
       assertEquals("another name", p.name);
    });

Maybe there could also be a assertItems which takes multiple function parameters.

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

Successfully merging this pull request may close these issues.

None yet

4 participants