How Can I Get PowerMock to Return the Expected Value from a Static Method
<p>Consider the following field and method from a class i need to test. </p>

<pre><code>private final static String pathToUUID = "path/to/my/file.txt";

public String getUuid () throws Exception {
    return new String(Files.readAllBytes(Paths.get(pathToUUID)));;
}
</code></pre>

<p>The UUID is stored in a file that is created on the application's first run. A <code>file.txt</code> exists in the location indicated by <code>pathToUUID</code>. I am trying (and struggling) to write a unit test for this method.</p>

<pre><code>@RunWith(PowerMockRunner.class)
@PrepareForTest({Files.class})
public class MyTest {

    private final String expected = "19dcd640-0da7-4b1a-9048-1575ee9c5e39";

    @Test
    public void testGetUuid() throws Exception {
        UUIDGetter getter = new UUIDGetter();
        PowerMockito.mockStatic(Files.class);
         when(Files.readAllBytes(any(Path.class)).thenReturn(expected.getBytes());
        String retrieved = getter.getUuid();
        Assert.assertEquals(expectedUUID, retrieved);
    }
}
</code></pre>

<p>Unfortunately <code>when().thenReturn()</code> is not called during testing and the test performs as an integration test, reading the file from the file system and returning its value, rather simply than the mock value i expect.  However, if i spoof a call to <code>Files.readAllBytes()</code> in the test method and echo the result to the console, the <code>expected</code> value displays.</p>

<p>So, how can i get my method under test to properly function with the PowerMock <code>when()-thenReturn()</code> pattern?</p>