how to check if without creating a new directory?
String st = "exemple";
String path = "exemple";
if (!new File(path).exists() && !new File(path).mkdirs()) {
throw new ComumException("trocaarquivos.erro.exemple", path);
}
my attempts:
@PrepareForTest(File.class )
File myFile = PowerMockito.mock(File.class);
PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(myFile);
PowerMockito.when(!new File(anyString()).exists() && !new File(anyString()).mkdirs()).thenReturn(true);
and
Mockito.when(myFile.exists()).thenReturn(true);
Mockito.when(myFile.mkdirs()).thenReturn(true);
3 days trying to cover this code.