ResourceImpl implements Resource { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ResourceImpl resource = (ResourceImpl) o; return type == resource.type && !(propertiesMap != null ? !propertiesMap.equals(resource.propertiesMap) : resource.propertiesMap != null); } ResourceImpl(Type type);  ResourceImpl(Resource resource);  ResourceImpl(Resource resource, Set<String> propertyIds); @Override Type getType(); @Override Map<String, Map<String, Object>> getPropertiesMap(); @Override void setProperty(String id, Object value); @Override void addCategory(String id); @Override Object getPropertyValue(String id); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { Resource resource1 = new ResourceImpl(Resource.Type.Cluster); Resource resource2 = new ResourceImpl(Resource.Type.Cluster); Resource resource3 = new ResourceImpl(Resource.Type.Host); Assert.assertTrue(resource1.equals(resource2)); Assert.assertTrue(resource2.equals(resource1)); Assert.assertFalse(resource1.equals(resource3)); Assert.assertFalse(resource3.equals(resource1)); Assert.assertFalse(resource2.equals(resource3)); Assert.assertFalse(resource3.equals(resource2)); resource1.setProperty("p1", "foo"); resource2.setProperty("p1", "bar"); Assert.assertFalse(resource1.equals(resource2)); Assert.assertFalse(resource2.equals(resource1)); resource2.setProperty("p1", "foo"); Assert.assertTrue(resource1.equals(resource2)); Assert.assertTrue(resource2.equals(resource1)); }