FileDataInVersion implements DataInVersion { @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } FileDataInVersion that = (FileDataInVersion) o; if (file != null) { if (!file.equals(that.file)) { return false; } } else if (that.file != null) { return false; } return true; } FileDataInVersion(File file);  FileDataInVersion(File file, DataImport dataImport); @Override void storeIn(File versionFolder); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void equalsFileDataWithSameFile() throws Exception { FileDataInVersion dataInVersion = new FileDataInVersion(folder.getRoot()); FileDataInVersion dataInVersion2 = new FileDataInVersion(folder.getRoot()); assertThat(dataInVersion.equals(dataInVersion2), is(true)); }
@Test public void doesNotEqualDataWithDifferentFile() throws Exception { FileDataInVersion dataInVersion = new FileDataInVersion(folder.newFile()); FileDataInVersion dataInVersion2 = new FileDataInVersion(folder.newFile()); assertThat(dataInVersion.equals(dataInVersion2), is(false)); }