diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2019-06-06 15:34:17 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2019-06-06 17:04:13 +0200 |
commit | 3780e5ca31f0af3068c354a94181c77234e8c4ed (patch) | |
tree | f2afbc1dec7f15065fc22951b05260bba5599796 /controller-server | |
parent | 8e87988265e846a6d71c1b29d75a2287a92004da (diff) |
Add ZoneApiMock
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneApiMock.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneApiMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneApiMock.java new file mode 100644 index 00000000000..4705982e1f2 --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneApiMock.java @@ -0,0 +1,70 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.integration; + +import com.yahoo.cloud.config.SentinelConfig; +import com.yahoo.config.model.graph.ModelGraphBuilder; +import com.yahoo.config.provision.CloudName; +import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.RegionName; +import com.yahoo.config.provision.SystemName; +import com.yahoo.config.provision.zone.ZoneApi; +import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.messagebus.MessagebusConfig; + +/** + * @author hakonhall + */ +public class ZoneApiMock implements ZoneApi { + private final SystemName systemName; + private final ZoneId id; + private final CloudName cloudName; + + public static Builder newBuilder() { return new Builder(); } + + private ZoneApiMock(SystemName systemName, ZoneId id, CloudName cloudName) { + this.systemName = systemName; + this.id = id; + this.cloudName = cloudName; + } + + public static ZoneApiMock fromId(String id) { + return newBuilder().withId(id).build(); + } + + public static ZoneApiMock from(Environment environment, RegionName region) { + return newBuilder().with(ZoneId.from(environment, region)).build(); + } + + @Override + public SystemName getSystemName() { return systemName; } + + @Override + public ZoneId getId() { return id; } + + @Override + public CloudName getCloudName() { return cloudName; } + + public static class Builder { + private SystemName systemName = SystemName.defaultSystem(); + private ZoneId id = ZoneId.defaultId(); + private CloudName cloudName = CloudName.defaultName(); + + public Builder with(ZoneId id) { + this.id = id; + return this; + } + + public Builder withId(String id) { return with(ZoneId.from(id)); } + + public Builder with(CloudName cloudName) { + this.cloudName = cloudName; + return this; + } + + public Builder withCloud(String cloud) { return with(CloudName.from(cloud)); } + + public ZoneApiMock build() { + return new ZoneApiMock(systemName, id, cloudName); + } + } +} |