Artifact { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final Artifact a = (Artifact) o; if (group != null ? !group.equals(a.group) : a.group != null) return false; if (artifact != null ? !artifact.equals(a.artifact) : a.artifact != null) return false; if (version != null ? !version.equals(a.version) : a.version != null) return false; return true; } Artifact(final String group, final String artifact, final String version); String getGroup(); String getArtifact(); String getVersion(); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void shouldBeEqualIfSame() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = a; assertThat(a.equals(b), is(true)); }
@Test public void shouldNotBeEqualIfArgumentIsNull() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = null; assertThat(a.equals(b), is(false)); }
@Test public void shouldNotBeEqualIfArgumentIsNotAnArtifact() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final String b = " "; assertThat(a.equals(b), is(false)); }
@Test public void shouldNotBeEqualIfTheGroupIsNotEqual() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = new Artifact("com.apacheTest.tinkerpop2","tinkergraph-gremlin","3.0.0"); assertThat(a.equals(b), is(false)); }
@Test public void shouldNotBeEqualIfTheArtifactIsNotEqual() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-artifact","3.0.0"); assertThat(a.equals(b), is(false)); }
@Test public void shouldNotBeEqualIfTheVersionIsNotEqual() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","4.0.0"); assertThat(a.equals(b), is(false)); }
@Test public void shouldBeEqual() { final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); assertThat(a.equals(b), is(true)); }