Test all fields
@@ -10,6 +10,7 @@ import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.application.RoutingPolicy;
import org.junit.Test;
+import java.util.Iterator;
import java.util.Optional;
import java.util.Set;
@@ -24,9 +25,9 @@ public class RoutingPolicySerializerTest {
@Test
public void test_serialization() {
- ApplicationId owner = ApplicationId.defaultId();
- Set<RotationName> rotations = Set.of(RotationName.from("r1"), RotationName.from("r2"));
- Set<RoutingPolicy> loadBalancers = ImmutableSet.of(new RoutingPolicy(owner,
+ var owner = ApplicationId.defaultId();
+ var rotations = Set.of(RotationName.from("r1"), RotationName.from("r2"));
+ var policies = ImmutableSet.of(new RoutingPolicy(owner,
ClusterSpec.Id.from("my-cluster1"),
ZoneId.from("prod", "us-north-1"),
HostName.from("long-and-ugly-name"),
@@ -38,8 +39,18 @@ public class RoutingPolicySerializerTest {
HostName.from("long-and-ugly-name-2"),
Optional.empty(),
rotations));
- Set<RoutingPolicy> serialized = serializer.fromSlime(owner, serializer.toSlime(loadBalancers));
- assertEquals(loadBalancers, serialized);
+ var serialized = serializer.fromSlime(owner, serializer.toSlime(policies));
+ assertEquals(policies.size(), serialized.size());
+ for (Iterator<RoutingPolicy> it1 = policies.iterator(), it2 = serialized.iterator(); it1.hasNext();) {
+ var expected = it1.next();
+ var actual = it2.next();
+ assertEquals(expected.owner(), actual.owner());
+ assertEquals(expected.cluster(), actual.cluster());
+ assertEquals(expected.zone(), actual.zone());
+ assertEquals(expected.canonicalName(), actual.canonicalName());
+ assertEquals(expected.dnsZone(), actual.dnsZone());
+ assertEquals(expected.rotations(), actual.rotations());
+ }
}
}
