diff options
Diffstat (limited to 'controller-api/src')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockOrganization.java | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockOrganization.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockOrganization.java index 96ee9ecd052..8efbde52d4a 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockOrganization.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockOrganization.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.organization; import com.google.inject.Inject; +import com.yahoo.component.AbstractComponent; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import java.net.URI; @@ -18,7 +19,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * @author jvenstad */ -public class MockOrganization implements Organization { +public class MockOrganization extends AbstractComponent implements Organization { private final Clock clock; private final AtomicLong counter = new AtomicLong(); @@ -89,45 +90,58 @@ public class MockOrganization implements Organization { @Override public URI issueCreationUri(PropertyId propertyId) { - return URI.create("www.issues.tld/" + propertyId.id()); + return properties.getOrDefault(propertyId, new PropertyInfo()).issueUrl; } @Override public URI contactsUri(PropertyId propertyId) { - return URI.create("www.contacts.tld/" + propertyId.id()); + return properties.getOrDefault(propertyId, new PropertyInfo()).contactsUrl; } @Override public URI propertyUri(PropertyId propertyId) { - return URI.create("www.properties.tld/" + propertyId.id()); + return properties.getOrDefault(propertyId, new PropertyInfo()).propertyUrl; } public Map<IssueId, MockIssue> issues() { return Collections.unmodifiableMap(issues); } - public void close(IssueId issueId) { + public MockOrganization close(IssueId issueId) { issues.get(issueId).open = false; touch(issueId); + return this; } - public void setDefaultAssigneeFor(PropertyId propertyId, User defaultAssignee) { - properties.get(propertyId).defaultAssignee = defaultAssignee; + public MockOrganization setContactsFor(PropertyId propertyId, List<List<User>> contacts) { + properties.get(propertyId).contacts = contacts; + return this; } - public void setContactsFor(PropertyId propertyId, List<List<User>> contacts) { - properties.get(propertyId).contacts = contacts; + public MockOrganization setPropertyUrl(PropertyId propertyId, URI url) { + properties.get(propertyId).propertyUrl = url; + return this; + } + + public MockOrganization setContactsUrl(PropertyId propertyId, URI url) { + properties.get(propertyId).contactsUrl = url; + return this; } - public void addProperty(PropertyId propertyId) { + public MockOrganization setIssueUrl(PropertyId propertyId, URI url) { + properties.get(propertyId).issueUrl = url; + return this; + } + + public MockOrganization addProperty(PropertyId propertyId) { properties.put(propertyId, new PropertyInfo()); + return this; } private void touch(IssueId issueId) { issues.get(issueId).updated = clock.instant(); } - public class MockIssue { private Issue issue; @@ -148,11 +162,13 @@ public class MockOrganization implements Organization { } - private class PropertyInfo { private User defaultAssignee; private List<List<User>> contacts = Collections.emptyList(); + private URI issueUrl; + private URI contactsUrl; + private URI propertyUrl; } |