### Question:
FileRequestFactory { public static FileRequest create(final URI sourceFile, final URI targetFile) { if (sourceFile == null) { throw new NullPointerException("Source file cannot be null."); } if (targetFile == null) { throw new NullPointerException("Target file cannot be null."); } return new FileRequestImpl(sourceFile, targetFile); }  static FileRequest create(final URI sourceFile, final URI targetFile);  }### Answer:
@Test(expected = NullPointerException.class) public void testNullSourceFile() { FileRequestFactory.create(null, URI.create("http: }
@Test(expected = NullPointerException.class) public void testNullTargetFile() { FileRequestFactory.create(URI.create("http: }
@Test public void testCreate() { final URI source = URI.create("file:/c:/temp/test.txt"); final URI target = URI.create("/temp/target/target.txt"); final FileRequest request = FileRequestFactory.create(source, target); assertEquals("Source URI does not match.", source.toString(), request.getSourceFile().toString()); assertEquals("Target URI does not match.", target.toString(), request.getTargetFile().toString()); }
@Test public void testFileRequestEquals() { final URI source = URI.create("file:/c:/temp/test.txt"); final URI target = URI.create("/temp/target/target.txt"); final FileRequest request = FileRequestFactory.create(source, target); final FileRequest otherRequest = FileRequestFactory.create(source, target); assertThat(request).isNotSameAs(otherRequest); assertThat(request).isEqualTo(otherRequest); }
@Test public void testFileRequestNotEqualNull() { final URI source = URI.create("file:/c:/temp/test.txt"); final URI target = URI.create("/temp/target/target.txt"); final FileRequest request = FileRequestFactory.create(source, target); assertThat(request).isNotEqualTo(null); }
@Test public void testFileRequestNotEqualsObject() { final URI source = URI.create("file:/c:/temp/test.txt"); final URI target = URI.create("/temp/target/target.txt"); final FileRequest request = FileRequestFactory.create(source, target); assertThat(request).isNotEqualTo(new Object()); }
@Test public void testFileRequestEqualsItself() { final URI source = URI.create("file:/c:/temp/test.txt"); final URI target = URI.create("/temp/target/target.txt"); final FileRequest request = FileRequestFactory.create(source, target); assertThat(request).isEqualTo(request); }
@Test public void testFileRequestHashCode() { final URI sourcePrime = URI.create("http: final URI targetPrime = URI.create("http: final URI sourceSecondary = URI.create("http: final FileRequest first = FileRequestFactory.create(sourcePrime, targetPrime); final FileRequest second = FileRequestFactory.create(sourceSecondary, targetPrime); assertThat(first.hashCode()).isNotEqualTo(second.hashCode()); final FileRequest firstDup = FileRequestFactory.create(first.getSourceFile(), first.getTargetFile()); assertThat(firstDup.hashCode()).isEqualTo(first.hashCode()); }