### Question:
Perforce implements SourceCodeManagementSystem { @Override public void prepareForUpdate(File file) { runPerforceCommandIfNeeded("edit", file); } Perforce();  Perforce(OperatingSystem operatingSystem); @Override String getId(); @Override void prepareForUpdate(File file); @Override void prepareForDelete(File file);  }### Answer:
@Test public void editsReadOnlyFile() throws IOException { File file = someFile(); try { file.setReadOnly(); p4.prepareForUpdate(file); verify(operatingSystem).run("p4 edit " + file.getAbsolutePath()); } finally { IO.delete(file); } }
@Test public void doesntEditWritableFile() throws IOException { File file = someFile(); try { p4.prepareForUpdate(file); verify(operatingSystem, never()).run(anyString()); } finally { IO.delete(file); } }