package de.philipphager.disclosure.util.device;

import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class FileUtilsShould {
  @Mock File mockFile;
  @Mock File mockFileTwo;
  @Mock File mockFileThree;
  @Mock File mockDirectory;
  @Mock File mockDirectoryTwo;
  @InjectMocks FileUtils fileUtils;

  @Before public void setUp() {
    when(mockDirectory.isDirectory()).thenReturn(true);
    when(mockDirectoryTwo.isDirectory()).thenReturn(true);
  }

  @Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
  public void deleteSingleFile() {
    fileUtils.delete(mockFile);
    verify(mockFile, times(1)).delete();
  }

  @Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
  public void deleteAllFilesInDirectory() {
    when(mockDirectory.listFiles()).thenReturn(new File[] {mockFile, mockFileTwo, mockFileThree});

    fileUtils.delete(mockDirectory);

    verify(mockFile, times(1)).delete();
    verify(mockFileTwo, times(1)).delete();
    verify(mockFileThree, times(1)).delete();
    verify(mockDirectory, times(1)).delete();
  }

  @Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
  public void deleteAllFilesInNestedDirectoryStructure() {
    when(mockDirectoryTwo.listFiles()).thenReturn(new File[] {mockFileThree});
    when(mockDirectory.listFiles()).thenReturn(
        new File[] {mockFile, mockFileTwo, mockDirectoryTwo});

    fileUtils.delete(mockDirectory);

    verify(mockFile, times(1)).delete();
    verify(mockFileTwo, times(1)).delete();
    verify(mockFileThree, times(1)).delete();
    verify(mockDirectory, times(1)).delete();
    verify(mockDirectoryTwo, times(1)).delete();
  }

  @Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
  public void doNotFailWhenSubdirectoriesAreNull() {
    when(mockDirectory.listFiles()).thenReturn(null);

    fileUtils.delete(mockDirectory);

    verify(mockDirectory, times(1)).delete();
  }

  @Test(expected = IllegalStateException.class)
  public void throwErrorWhenCalledWithNullFile() {
    fileUtils.delete(null);
  }
}

@@ -439,32 +439,42 @@
 hould %7B%0A  @Mock 
+protected 
 File mockFile;%0A 
@@ -472,32 +472,42 @@
 ckFile;%0A  @Mock 
+protected 
 File mockFileTwo
@@ -508,32 +508,42 @@
 ileTwo;%0A  @Mock 
+protected 
 File mockFileThr
@@ -546,32 +546,42 @@
 eThree;%0A  @Mock 
+protected 
 File mockDirecto
@@ -592,16 +592,26 @@
   @Mock 
+protected 
 File moc
@@ -640,16 +640,26 @@
 ctMocks 
+protected 
 FileUtil

Use explicit scoping