dimanche 30 juillet 2017

mockito doesn't match any(type) method

I test this code:

        PublisherCallbackWithLog publisherCallback = new PublisherCallbackWithLog<String>();

        for (SdkRequest.SdkRequest sdkRequest : SdkRequestsList.getRequestList()) {
            final String s = TextFormat.printToUnicodeString(sdkRequest);
            customPublisher.publish(s, publisherCallback);
        }

in my test I have this line:

    verify(customPublisher, times(1)).publish(argThat(eqWithoutRequestId(sdkRequest)), any(PublisherCallbackWithLog.class));

but I get an error, seems about the 2nd argument.

Argument(s) are different! Wanted:
customPublisher.publish(
    ,
    <any>
);
-> at com.w.sdkService.servlets.SdkPollerServlet_PublishTest.readFromSpreadsheet3Rows_shouldPublish2Times(SdkPollerServlet_PublishTest.java:75)
Actual invocation has different arguments:
customPublisher.publish(
    "partner {
  display_name: "WTest"
  android_pkg_name: "com.example.eliran.myapplication"
  sharing_mode: DATA
}
requestId: "3a7458b6-edc0-4d4e-b52e-d2a3847bef0b"
requestType: REMOVE
",
    com.w.sdkService.services.callback.PublisherCallbackWithLog@56f6d40b
);
-> at com.w.sdkService.servlets.SdkPollerServlet.publishAddPartnersRequests(SdkPollerServlet.java:101)

Comparison Failure:  <Click to see difference>

Argument(s) are different! Wanted:
customPublisher.publish(
    ,
    <any>
);
-> at com.w.sdkService.servlets.SdkPollerServlet_PublishTest.readFromSpreadsheet3Rows_shouldPublish2Times(SdkPollerServlet_PublishTest.java:75)
Actual invocation has different arguments:
customPublisher.publish(
    "partner {
  display_name: "WTest"
  android_pkg_name: "com.example.eliran.myapplication"
  sharing_mode: DATA
}
requestId: "3a7458b6-edc0-4d4e-b52e-d2a3847bef0b"
requestType: REMOVE
",
    com.w.sdkService.services.callback.PublisherCallbackWithLog@56f6d40b
);
-> at com.w.sdkService.servlets.SdkPollerServlet.publishAddPartnersRequests(SdkPollerServlet.java:101)

How should I verify the call otherwise?

Aucun commentaire:

Enregistrer un commentaire