### Question:
FileUtils { static void writeTextTo(String text, File file) { if (text == null) { throw new IllegalArgumentException("text cannot be null"); } assertValidFile(file); try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) { writer.write(text); } catch (IOException e) { throw new IllegalArgumentException("Could not write to " + file, e); } } private  FileUtils();   }### Answer:
@Test public void writeTextToWhenNullThenIllegalArgumentException() { assertThatCode(() -> FileUtils.writeTextTo(this.text, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("file cannot be null"); }
@Test public void writeTextFromWhenDirThenIllegalArgumentException() { assertThatCode(() -> FileUtils.writeTextTo(this.text, this.temp.newFolder())) .isInstanceOf(IllegalArgumentException.class) .hasCauseInstanceOf(IOException.class); }
@Test public void writeTextFromWhenTextNullIllegalArgumentException() { assertThatCode(() -> FileUtils.writeTextTo(null, this.temp.newFile())) .isInstanceOf(IllegalArgumentException.class) .hasMessage("text cannot be null"); }