title: Mocking File returns NPE
body: <p>Trying to mock the code but getting NPE. I am using Powermockito v2. I am still learning Mockito, please correct me if you find any incorrect ways of testing.</p>
  <p>Here is the test class:</p>
  <pre class="lang-java prettyprint-override"><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest(CellConfig.class)
  public class CellConfigTest {
      @Test
      public void testCellsMap() throws Exception {
          Map&lt;String, String&gt; cellMap = new HashMap&lt;&gt;();
          cellMap.put(&quot;key1&quot;, &quot;value1&quot;);
  
          CellConfig cellConfigSpy = PowerMockito.spy(new CellConfig());
          PowerMockito.when(cellConfigSpy, PowerMockito.method(cellConfig.class, &quot;cellMap&quot;))
                  .withArguments(Mockito.any(String.class), Mockito.anyList()).thenReturn(cellMap);
          Paths paths = PowerMockito.mock(Paths.class);
          Path path = PowerMockito.mock(Path.class);
  
          Stream&lt;String&gt; mockStream = PowerMockito.mock(Stream.class);
          Files filesMock = PowerMockito.mock(Files.class);
          PowerMockito.when(filesMock.lines(path)).thenReturn(mockStream); // NPE
  
          cellConfigSpy.publicMethod();
  
      }
  }
  </code></pre>
  <p>Here is the method under test:</p>
  <pre class="lang-java prettyprint-override"><code>public Map getCells() {
      //does few things
      Map m = getCellsInfo(dir, cellList);
  
  }
  
  private Map getCellsInfo(String dir, List cList) {
      File[] files = new File(dir).listFiles();
      if (null == files) {
          return Collections.emptyMap();
      }
      return cellMap(dir, cList)
  }
  
  private Map&lt;String, String&gt; cellMap(String cellDir, List&lt;String&gt; cellKeys) {
      Map&lt;String, String&gt; cellMap = new HashMap&lt;&gt;();
      if (null != cellKeys) {
          cellKeys.forEach(key -&gt; {
              try (Stream&lt;String&gt; stream = Files.lines(Paths.get(cellDir + key))) {
                  stream.forEach(value -&gt; cellMap.put(key, value));
              } catch (IOException e) {
  
              }
          });
      }
      return cellMap;
  }
  </code></pre>
  <p>What would be a suggested way to mock this code?</p>