Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:30:06+00:00 2026-06-06T02:30:06+00:00

I cant find an answer already on stackoverlow for this. This is the simplest

  • 0

I cant find an answer already on stackoverlow for this. This is the simplest example I can boil it down to.

I have a class which I want to mock and it places calls to this class


public class GetCustomerForUser extends PropertyAction<Customer>
....

PropertyAction:

public abstract class PropertyAction<R> extends AbstractProcessAction<R> implements
ValuedAction<R, R> {

The real calling code looks like this

Customer self = dispatcher.invokeTransactionless(actor, new GetCustomerForUser());

dispatcher is of type ActionDispatcher

In the calling mock

    protected void applyWhenClauses(ActionDispatcher dispatcher, Actor actor) throws ProcessException {
        when(dispatcher.invokeTransactionless(actor, (ProcessAction<Customer>) anyObject())).thenReturn(null);
        ....

dispatcher is of type ActionDispatcherMock

When I run the test I get

     org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
     Invalid use of argument matchers!
     2 matchers expected, 1 recorded.
     This exception may occur if matchers are combined with raw values:
         //incorrect:
         someMethod(anyObject(), "raw String");
     When using matchers, all arguments have to be provided by matchers.
     For example:
         //correct:
         someMethod(anyObject(), eq("String by matcher"));

     For more info see javadoc for Matchers class.

     at com.prolog.test.mock.ActionDispatcherMock2.applyWhenClauses  
           (ActionDispatcherMock2.java:18)
        at com.prolog.test.mock.ActionDispatcherMock.createMockInstance
           (ActionDispatcherMock.java:84)
at com.prolog.test.mock.ActionDispatcherMock.createMockInstance
           (ActionDispatcherMock.java:1)
at com.prolog.test.mockFactory.AbstractPrologInstanceMock.createInstanceMock
           (AbstractPrologInstanceMock.java:11)

I intend to have a when for each class that the dispatcher could invoke.

Does anyone have any words of wisdom about what I’m doing wrong here?

thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:30:08+00:00Added an answer on June 6, 2026 at 2:30 am

    The error message indicates what the issue is: if you’re using any… any you can’t then have a not-any matcher:

     This exception may occur if matchers are combined with raw values:
         //incorrect:
         someMethod(anyObject(), "raw String");
     When using matchers, all arguments have to be provided by matchers.
     For example:
         //correct:
         someMethod(anyObject(), eq("String by matcher"));
    

    See how you’re doing precisely what it says you can’t do? And how it says to correct it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem which I cant seem to find answer to through searches
I have stupid question, on which can't find answer. I tried to install Selenium
Apologies if this has been asked already, I can't find the answer in the
I have the following problem, on which I can't seem to find an answer...
hope this wasn't asked already, but I can't find an answer. I got a
This may be very simplistic question but I can't find the answer. I want
Sorry if this question has already been answered but I can't find an answer.
I'm sure this has been asked already, but I can't find the answer. I
I have finally stumbled across a problem that I can't already find the answer
Been searching all over for this but cant find an answer so thought I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.