Search code examples
javamockitojava-streampowermockpowermockito

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


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.


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