@Test public void testWriteWhenFileExistsShouldNotCreatNewFile() throws IOException { given(file.getParent()).willReturn(DIRECTORIES); given(fileOutputStreamFactory.createFileOutputStream(file)).willReturn(fileOutputStream); given(file.exists()).willReturn(true); underTest.write(inputStream, FILE_NAME, EXCEPTION_MESSAGE); verify(file, Mockito.never()).createNewFile(); }
public void write(final InputStream inputStream, final String fileName, final String exceptionMessage) { boolean isClass = fileName.endsWith(".class"); boolean isJar = fileName.endsWith(".jar"); if (isClass) { writeClass(fileName, inputStream, exceptionMessage); } else if (isJar) { writeJar(fileName, inputStream, exceptionMessage); } else { writeOther(fileName, inputStream, exceptionMessage); } }
FileWriter { public void write(final InputStream inputStream, final String fileName, final String exceptionMessage) { boolean isClass = fileName.endsWith(".class"); boolean isJar = fileName.endsWith(".jar"); if (isClass) { writeClass(fileName, inputStream, exceptionMessage); } else if (isJar) { writeJar(fileName, inputStream, exceptionMessage); } else { writeOther(fileName, inputStream, exceptionMessage); } } }
FileWriter { public void write(final InputStream inputStream, final String fileName, final String exceptionMessage) { boolean isClass = fileName.endsWith(".class"); boolean isJar = fileName.endsWith(".jar"); if (isClass) { writeClass(fileName, inputStream, exceptionMessage); } else if (isJar) { writeJar(fileName, inputStream, exceptionMessage); } else { writeOther(fileName, inputStream, exceptionMessage); } }  }
FileWriter { public void write(final InputStream inputStream, final String fileName, final String exceptionMessage) { boolean isClass = fileName.endsWith(".class"); boolean isJar = fileName.endsWith(".jar"); if (isClass) { writeClass(fileName, inputStream, exceptionMessage); } else if (isJar) { writeJar(fileName, inputStream, exceptionMessage); } else { writeOther(fileName, inputStream, exceptionMessage); } }  void write(final InputStream inputStream, final String fileName, final String exceptionMessage); }
FileWriter { public void write(final InputStream inputStream, final String fileName, final String exceptionMessage) { boolean isClass = fileName.endsWith(".class"); boolean isJar = fileName.endsWith(".jar"); if (isClass) { writeClass(fileName, inputStream, exceptionMessage); } else if (isJar) { writeJar(fileName, inputStream, exceptionMessage); } else { writeOther(fileName, inputStream, exceptionMessage); } }  void write(final InputStream inputStream, final String fileName, final String exceptionMessage);  }