Spring boot Mockito验证mongoTemplate参数

Spring boot Mockito验证mongoTemplate参数,spring-boot,mockito,aggregation,mongotemplate,Spring Boot,Mockito,Aggregation,Mongotemplate,我正在尝试为我的测试用例使用以下代码 verify(mongoTemplate).aggregate(eq(aggregation), eq(AbnormalEvent.class), eq(AbnormalEvent.class)); 但是,出现了以下错误 Argument(s) are different! Wanted: mongoTemplate.aggregate( { "aggregate" : "__collection__", &

我正在尝试为我的测试用例使用以下代码

verify(mongoTemplate).aggregate(eq(aggregation), eq(AbnormalEvent.class), eq(AbnormalEvent.class));
但是,出现了以下错误

Argument(s) are different! Wanted:
mongoTemplate.aggregate(
    { "aggregate" : "__collection__", "pipeline" : [{ "$match" : { "customerId" : "cid", "$and" : [{ "occurrenceTimestamp.timestamp_" : { "$gte" : 1}}, { "occurrenceTimestamp.timestamp_" : { "$lte" : 2}}]}}, { "$sort" : { "occurrenceCount" : -1}}, { "$limit" : 1}]},
    class com.samsung.knox.dai.appservice.document.AbnormalEvent,
    class com.samsung.knox.dai.appservice.document.AbnormalEvent
);
-> at com.samsung.knox.dai.appservice.repository.impl.AppABNEventRepositoryCustomImplTest.testGetTopAbnormalEvents(AppABNEventRepositoryCustomImplTest.java:65)
Actual invocations have different arguments:
mongoTemplate.aggregate(
    { "aggregate" : "__collection__", "pipeline" : [{ "$match" : { "customerId" : "cid", "$and" : [{ "occurrenceTimestamp.timestamp_" : { "$gte" : 1}}, { "occurrenceTimestamp.timestamp_" : { "$lte" : 2}}]}}, { "$sort" : { "occurrenceCount" : -1}}, { "$limit" : 1}]},
    class com.samsung.knox.dai.appservice.document.AbnormalEvent,
    class com.samsung.knox.dai.appservice.document.AbnormalEvent
);
预期值和实际值完全相同。然而,在intellij中,当我单击“查看差异”时,在其中一个值处有一个额外的空格/新行,并且这只在应用聚合时发生,这是mockito中的错误吗


感谢

解决方案使用以下代码:验证(mongoTemplate).aggregate(argThat(新的AggregationMatcher(aggregation))、eq(normalEvent.class)、eq(normalEvent.class));