本文介绍了没有与类java.util.Arrays $ ArrayList的层次结构中的名称流匹配的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用java 8并试图用PowerMock和Mockito编写一些测试。我收到一个 MethodNotFoundException ,并显示以下消息:



没有符合名称的方法(s )在类java.util.Arrays $ ArrayList的类层次结构中找到了流。



我仔细检查了,它看起来肯定会继承来自收藏集的流。这是PowerMockito的问题还是我错过了什么?



有问题的行

  PowerMockito.when(thing.call(services,things))。thenReturn(Arrays.asList(testService)); //如果它是新的ArrayList< String>()))无关紧要; 

然后就这样调用了这样的东西

  services.stream()。filter(x  - > // filter).collect(Collectors.toList())

编辑:经过进一步研究后,这似乎是一个PowerMock问题。非常喜欢解决方案。

解决方案

这似乎是PowerMock 1.5.5中的一个错误,已经在1.5.6中解决了/ p>

参考:


So I am using java 8 and trying to write some tests with PowerMock and Mockito. I am getting a MethodNotFoundException with the message:

No methods matching the name(s) stream were found in the class hierarchy of class java.util.Arrays$ArrayList.

I double checked the ArrayList documentation and it definitely looks like it inherits stream from Collections. Is this a problem with PowerMockito or am I missing something?

Line in question

PowerMockito.when(thing.call("services", "things")).thenReturn(Arrays.asList("testService")); // Doesn't matter if it's new ArrayList<String>()));

Then has something like this called on it

services.stream().filter( x -> //filter).collect(Collectors.toList())

EDIT: After further research this appears to be a PowerMock Problem. Would love a solution.

解决方案

This appeared to be a bug in PowerMock 1.5.5 and has been solved in 1.5.6

Reference: https://github.com/jayway/powermock/issues/536

这篇关于没有与类java.util.Arrays $ ArrayList的层次结构中的名称流匹配的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 14:30