@Test
public void shouldNotIterateFileListIfDirectoryIsEmpty()
{

    File root = Mockito.mock(File.class);
    File emptyDirectory = Mockito.mock(File.class);
    File[] filesList = new File[1];
    filesList[0] = emptyDirectory;
    doReturn(filesList).when(root).listFiles();
    doReturn(null).when(emptyDirectory).listFiles();
    doReturn(true).when(emptyDirectory).isDirectory();
    deviceService.wipeDirectory(root);
    verify(emptyDirectory).delete();
}