1

I have the following call to match so as to return an object:

    String[][] parameters = new String[][] {
            new String[]{
                    eq("provider"),
                    eq("myProvider")
            }
    };

    when(supportApiNotificationsProvider.getByServiceName(
            "supportApiNotifications",
            parameters))
            .thenReturn(<an-object>);

but this way the mock always returns null. On the other hand, if I change the parameter offered to the mock as the following:

    String[][] parameters = new String[][] {
            new String[]{
                    anyString(),
                    anyString()
            }
    };

it works! I'm sure about the tho string values passed, hence I guess it's something about the eq matchers I defined.

1
  • What does the method declaration of getByServiceName look like? public <an-object> getByServiceName(String serviceName, String[] parameters){}? Commented Jan 17, 2019 at 12:11

1 Answer 1

2

I think the eq is misplaced, I would rather define parameters like this:

    String[][] parameters = eq(new String[][] {
            new String[]{
                    "provider",
                    "myProvider"
            }
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.