DependencyContainer implements Dependency { @Override public boolean equals(Object obj) { return (obj instanceof Dependency) && getName().equals(((Dependency) obj).getName()) && ( getVersion().equals(((Dependency) obj).getVersion()) || !getVersion().isPresent() || !((Dependency) obj).getVersion().isPresent() ); } DependencyContainer(String name);  DependencyContainer(String name, String version); String getName(); Optional<String> getVersion(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testEqualsToReference() { assertThat(referenceDependency.equals(new DependencyContainer(name, version)), equalTo(equals)); }