ServiceInfo { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceInfo that = (ServiceInfo) o; if (ports != null ? !ports.equals(that.ports) : that.ports != null) return false; if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false; if (!serviceName.equals(that.serviceName)) return false; if (!serviceType.equals(that.serviceType)) return false; if (!configId.equals(that.configId)) return false; if (!hostName.equals(that.hostName)) return false; return true; } ServiceInfo(String serviceName, String serviceType, Collection<PortInfo> ports, Map<String, String> properties,
                       String configId, String hostName); String getServiceName(); String getConfigId(); String getServiceType(); Optional<String> getProperty(String propertyName); Collection<PortInfo> getPorts(); String getHostName(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { String commonConfigId = "common-config-id"; String commonHostName = "common-host"; ServiceInfo a = new ServiceInfo("0", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), commonConfigId, commonHostName); ServiceInfo b = new ServiceInfo("0", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), commonConfigId, commonHostName); ServiceInfo c = new ServiceInfo("0", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "baz"), commonConfigId, commonHostName); ServiceInfo d = new ServiceInfo("0", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("bar", "bar"), commonConfigId, commonHostName); ServiceInfo e = new ServiceInfo("0", "1", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), commonConfigId, commonHostName); ServiceInfo f = new ServiceInfo("1", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), commonConfigId, commonHostName); ServiceInfo g = new ServiceInfo("1", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), "different-config-id", commonHostName); ServiceInfo h = new ServiceInfo("1", "0", Arrays.asList(new PortInfo(33, null)), Collections.singletonMap("foo", "bar"), commonConfigId, "different-host"); new EqualsTester() .addEqualityGroup(a, b) .addEqualityGroup(c) .addEqualityGroup(d) .addEqualityGroup(e) .addEqualityGroup(f) .addEqualityGroup(g) .addEqualityGroup(h).testEquals(); }