OMultiKey { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final OMultiKey oMultiKey = (OMultiKey) o; if(keys.size() != oMultiKey.keys.size()) return false; for (final Object inKey : keys) { if (!oMultiKey.keys.contains(inKey)) return false; } return true; } OMultiKey(final Collection<?> keys); @Override int hashCode(); @Override boolean equals(final Object o); @Override String toString();  }
@Test public void testEqualsDifferentSize() { final OMultiKey multiKey = new OMultiKey(Collections.singletonList("a")); final OMultiKey anotherMultiKey = new OMultiKey(Arrays.asList(new String[]{"a", "b"})); assertFalse(multiKey.equals(anotherMultiKey)); }
@Test public void testEqualsDifferentItems() { final OMultiKey multiKey = new OMultiKey(Arrays.asList(new String[]{"b", "c"})); final OMultiKey anotherMultiKey = new OMultiKey(Arrays.asList(new String[]{"a", "b"})); assertFalse(multiKey.equals(anotherMultiKey)); }
@Test public void testEqualsTheSame() { final OMultiKey multiKey = new OMultiKey(Collections.singletonList("a")); assertTrue(multiKey.equals(multiKey)); }
@Test public void testEqualsNull() { final OMultiKey multiKey = new OMultiKey(Collections.singletonList("a")); assertFalse(multiKey.equals(null)); }
@Test public void testEqualsDifferentClass() { final OMultiKey multiKey = new OMultiKey(Collections.singletonList("a")); assertFalse(multiKey.equals("a")); }