|
| 1 | +package org.apache.cloudstack.framework.config; |
| 2 | + |
| 3 | +import org.junit.Assert; |
| 4 | +import org.junit.Test; |
| 5 | + |
| 6 | +import com.google.common.testing.EqualsTester; |
| 7 | + |
| 8 | +import org.apache.cloudstack.framework.config.ConfigKey.Scope; |
| 9 | + |
| 10 | +import com.cloud.utils.exception.CloudRuntimeException; |
| 11 | + |
| 12 | +public class ConfigKeyTest { |
| 13 | + @Test |
| 14 | + public void testEquals() { |
| 15 | + new EqualsTester() |
| 16 | + .addEqualityGroup(new ConfigKey("cat", String.class, "naam", "nick", "bijnaam", true, Scope.Cluster), |
| 17 | + new ConfigKey("hond", Boolean.class, "naam", "truus", "thrown name", false), |
| 18 | + new ConfigKey(Long.class, "naam", "vis", "goud", "zwemt", true, Scope.Account, 3L) |
| 19 | + ) |
| 20 | + .testEquals(); |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + public void testIsSameKeyAs() { |
| 25 | + ConfigKey key = new ConfigKey("cat", String.class, "naam", "nick", "bijnaam", true, Scope.Cluster); |
| 26 | + Assert.assertTrue("1 and one should be considdered the same address", key.isSameKeyAs("naam")); |
| 27 | + } |
| 28 | + |
| 29 | + @Test(expected = CloudRuntimeException.class) |
| 30 | + public void testIsSameKeyAsThrowingCloudRuntimeException() { |
| 31 | + ConfigKey key = new ConfigKey("hond", Boolean.class, "naam", "truus", "thrown name", false); |
| 32 | + Assert.assertFalse("zero and 0L should be considdered the same address", key.isSameKeyAs(0L)); |
| 33 | + } |
| 34 | +} |
0 commit comments