diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model-api/src/test/java/com/yahoo/config/model |
Publish
Diffstat (limited to 'config-model-api/src/test/java/com/yahoo/config/model')
3 files changed, 80 insertions, 0 deletions
diff --git a/config-model-api/src/test/java/com/yahoo/config/model/api/HostInfoTest.java b/config-model-api/src/test/java/com/yahoo/config/model/api/HostInfoTest.java new file mode 100644 index 00000000000..53f60d56e92 --- /dev/null +++ b/config-model-api/src/test/java/com/yahoo/config/model/api/HostInfoTest.java @@ -0,0 +1,23 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import org.junit.Test; +import com.google.common.testing.EqualsTester; + +import java.util.Arrays; + +public class HostInfoTest { + @Test + public void testEquals() { + HostInfo a = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "bar", null, null, "config-id", "host-name"))); + HostInfo b = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "bar", null, null, "config-id", "host-name"))); + HostInfo c = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "baz", null, null, "config-id", "host-name"))); + HostInfo d = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("bar", "baz", null, null, "config-id", "host-name"))); + HostInfo e = new HostInfo("bar.yahoo.com", null); + new EqualsTester() + .addEqualityGroup(a, b) + .addEqualityGroup(c) + .addEqualityGroup(d) + .addEqualityGroup(e).testEquals(); + } +} diff --git a/config-model-api/src/test/java/com/yahoo/config/model/api/PortInfoTest.java b/config-model-api/src/test/java/com/yahoo/config/model/api/PortInfoTest.java new file mode 100644 index 00000000000..69577ba52b7 --- /dev/null +++ b/config-model-api/src/test/java/com/yahoo/config/model/api/PortInfoTest.java @@ -0,0 +1,21 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.Arrays; + +public class PortInfoTest { + @Test + public void testEquals() { + PortInfo a = new PortInfo(1234, Arrays.asList("foo")); + PortInfo b = new PortInfo(1234, Arrays.asList("foo")); + PortInfo c = new PortInfo(1234, Arrays.asList("foo", "bar")); + PortInfo d = new PortInfo(12345, Arrays.asList("foo")); + new EqualsTester() + .addEqualityGroup(a, b) + .addEqualityGroup(c) + .addEqualityGroup(d).testEquals(); + } +} diff --git a/config-model-api/src/test/java/com/yahoo/config/model/api/ServiceInfoTest.java b/config-model-api/src/test/java/com/yahoo/config/model/api/ServiceInfoTest.java new file mode 100644 index 00000000000..3548b5a6eb7 --- /dev/null +++ b/config-model-api/src/test/java/com/yahoo/config/model/api/ServiceInfoTest.java @@ -0,0 +1,36 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collections; + + +public class ServiceInfoTest { + + @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(); + } +} |