Together-Java / TJ-Bot

TJ-Bot is a Discord Bot used on the Together Java server. It is maintained by the community, anyone can contribute.
https://togetherjava.org
GNU General Public License v3.0
100 stars 87 forks source link

Bump org.mockito:mockito-core from 5.3.1 to 5.10.0 #1015

Closed dependabot[bot] closed 7 months ago

dependabot[bot] commented 8 months ago

Bumps org.mockito:mockito-core from 5.3.1 to 5.10.0.

Release notes

Sourced from org.mockito:mockito-core's releases.

v5.10.0

Changelog generated by Shipkit Changelog Gradle Plugin

5.10.0

v5.9.0

What's Changed

New Contributors

Full Changelog: https://github.com/mockito/mockito/compare/v5.8.0...v5.9.0

v5.8.0

Changelog generated by Shipkit Changelog Gradle Plugin

5.8.0

... (truncated)

Commits
  • 7e1bae8 Bump org.shipkit:shipkit-auto-version from 1.2.2 to 2.0.2 (#3248)
  • cf89d49 Bump org.assertj:assertj-core from 3.25.1 to 3.25.2 (#3247)
  • cc2ca36 Bump org.shipkit:shipkit-changelog from 1.2.0 to 2.0.1 (#3245)
  • ed01de6 Bump com.diffplug.spotless from 6.24.0 to 6.25.0 (#3244)
  • ef3dc8f Improve typing for PluginLoader#loadPlugin(..) (#3242)
  • 33dc48c Bump com.github.ben-manes.versions from 0.50.0 to 0.51.0 (#3241)
  • 9173522 Add support for static mocks on DoNotMockEnforcer (#3220)
  • a021436 Bump com.diffplug.spotless from 6.23.3 to 6.24.0 (#3236)
  • e4fa639 Align Javadoc configuration to Java 21 standards (#3230)
  • 71e2fdb Bump org.gradle.toolchains.foojay-resolver-convention (#3234)
  • Additional commits viewable in compare view


Dependabot compatibility score

You can trigger a rebase of this PR by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Note Automatic rebases have been disabled on this pull request as it has been open for over 30 days.

SquidXTV commented 8 months ago

I just checked for the ping command and it seems like that it fails because of this:

        UnaryOperator<SlashCommandInteractionEvent> mockOperator = event -> {
            SlashCommandInteractionEvent SlashCommandInteractionEvent = spy(event);
            mockInteraction(SlashCommandInteractionEvent);
            return SlashCommandInteractionEvent;
        };

especially the spy(event).

java.lang.IllegalArgumentException: Please don't pass mock here. Spy is not allowed on mock.
    at org.mockito.Mockito.spy(Mockito.java:2188)
    at org.togetherjava.tjbot.jda.JdaTester.lambda$createSlashCommandInteractionEvent$0(JdaTester.java:248)
    at org.togetherjava.tjbot.jda.SlashCommandInteractionEventBuilder.spySlashCommandEvent(SlashCommandInteractionEventBuilder.java:256)
    at org.togetherjava.tjbot.jda.SlashCommandInteractionEventBuilder.build(SlashCommandInteractionEventBuilder.java:250)
    at org.togetherjava.tjbot.features.basic.PingCommandTest.triggerSlashCommand(PingCommandTest.java:19)
    at org.togetherjava.tjbot.features.basic.PingCommandTest.pingRespondsWithPong(PingCommandTest.java:35)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

It seems like it's already a Mock and thus is an illegal argument here. If you check source:

if (MockUtil.isMock(object)) {
    throw new IllegalArgumentException("Please don't pass mock here. Spy is not allowed on mock.");
}

For me it seems like that the spy() is applied twice:

    private SlashCommandInteractionEvent spySlashCommandEvent(String jsonData) {
        SlashCommandInteractionEvent event = spy(new SlashCommandInteractionEvent(jda, 0,
                new SlashCommandInteractionImpl(jda, DataObject.fromJson(jsonData))));
        event = mockOperator.apply(event);

What should I do to fix this? What is even the usage of mockOperator? It seems like that the mockInteraction() method needs it to be a mock, so is this a good idea to do:

        UnaryOperator<SlashCommandInteractionEvent> mockOperator = event -> {
            if (!MockUtil.isMock(event)) {
                event = spy(event);
            }
            mockInteraction(event);
            return event;
        };

it would fix all tests. :D

Taz03 commented 7 months ago

@dependabot rebase

dependabot[bot] commented 7 months ago

Looks like this PR has been edited by someone other than Dependabot. That means Dependabot can't rebase it - sorry!

If you're happy for Dependabot to recreate it from scratch, overwriting any edits, you can request @dependabot recreate.

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

dependabot[bot] commented 7 months ago

A newer version of org.mockito:mockito-core exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

SquidXTV commented 7 months ago

A newer version of org.mockito:mockito-core exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

What should I do about this?

Taz03 commented 7 months ago

What should I do about this?

nothing, after this pr merges everything will be fine (not like we gonna miss something in the new update). And if u really want to upgrade the version manually