@Test
public void testWriteWhenFileIsAClassFile() throws IOException {

    //GIVEN
    String fileName = "MyClass.class";
    given(byteArrayInputStream.read(Mockito.any(byte[].class))).willReturn(1, -1);
    given(inputStreamUtil.transformToByteArray(inputStream)).willReturn(FILE_AS_BYTES);
    given(byteArrayInputStreamFactory.createByteArrayInputStream(FILE_AS_BYTES)).willReturn(byteArrayInputStream);
    given(classFilePathAssembler.createFilePath(byteArrayInputStream, fileName, EXCEPTION_MESSAGE)).willReturn(fileName);
    given(fileFactory.createFile(fileName)).willReturn(file);
    given(file.getParent()).willReturn(DIRECTORIES);
    given(fileOutputStreamFactory.createFileOutputStream(file)).willReturn(fileOutputStream);
    given(file.exists()).willReturn(true);
    //WHEN
    underTest.write(inputStream, fileName, EXCEPTION_MESSAGE);
    //THEN
    verify(fileFactory).createFile(Mockito.anyString());
    verify(inputStreamUtil).transformToByteArray(inputStream);
    verify(byteArrayInputStreamFactory, times(2)).createByteArrayInputStream(FILE_AS_BYTES);
    verify(classFilePathAssembler).createFilePath(byteArrayInputStream, fileName, EXCEPTION_MESSAGE);
    verify(fileFactory).createFile(fileName);
    verify(file).getParent();
    verify(fileOutputStreamFactory).createFileOutputStream(file);
    verify(file).exists();
}