diff options
author | Martin Polden <mpolden@mpolden.no> | 2018-06-08 16:07:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-08 16:07:10 +0200 |
commit | 8232481e8cf9c1df4c6f98fa8e3dacd0f226cf0e (patch) | |
tree | ed76ab96acfd0911aa05fe0bcab713296a508848 | |
parent | 1c2bb4f30460f7676361b235cf09cb27d37c9c39 (diff) | |
parent | a9313c716d1eb0ed197e7f51321cc60627d2d618 (diff) |
Merge pull request #6139 from vespa-engine/revert-6137-mpolden/org-interface-changes
Revert "Organization interface changes"
2 files changed, 28 insertions, 46 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java index 086487b8be7..37356f2c2a6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java @@ -1,12 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.organization; -import com.google.common.collect.ImmutableList; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.util.Objects; import java.util.Optional; @@ -20,54 +16,46 @@ public class Issue { private final String summary; private final String description; - private final List<String> labels; + private final String label; private final User assignee; private final PropertyId propertyId; private final Type type; - private Issue(String summary, String description, List<String> labels, User assignee, PropertyId propertyId, Type type) { + private Issue(String summary, String description, String label, User assignee, PropertyId propertyId, Type type) { if (summary.isEmpty()) throw new IllegalArgumentException("Issue summary can not be empty!"); if (description.isEmpty()) throw new IllegalArgumentException("Issue description can not be empty!"); Objects.requireNonNull(propertyId, "An issue must belong to a property!"); this.summary = summary; this.description = description; - this.labels = ImmutableList.copyOf(labels); + this.label = label; this.assignee = assignee; this.propertyId = propertyId; this.type = type; } public Issue(String summary, String description, PropertyId propertyId) { - this(summary, description, Collections.emptyList(), null, propertyId, Type.defect); + this(summary, description, null, null, propertyId, Type.defect); } public Issue append(String appendage) { - return new Issue(summary, description + appendage, labels, assignee, propertyId, type); + return new Issue(summary, description + appendage, label, assignee, propertyId, type); } public Issue with(String label) { - List<String> labels = new ArrayList<>(this.labels); - labels.add(label); - return new Issue(summary, description, labels, assignee, propertyId, type); - } - - public Issue with(List<String> labels) { - List<String> newLabels = new ArrayList<>(this.labels); - newLabels.addAll(labels); - return new Issue(summary, description, newLabels, assignee, propertyId, type); + return new Issue(summary, description, label, assignee, propertyId, type); } public Issue with(User assignee) { - return new Issue(summary, description, labels, assignee, propertyId, type); + return new Issue(summary, description, label, assignee, propertyId, type); } public Issue with(PropertyId propertyId) { - return new Issue(summary, description, labels, assignee, propertyId, type); + return new Issue(summary, description, label, assignee, propertyId, type); } public Issue with(Type type) { - return new Issue(summary, description, labels, assignee, propertyId, type); + return new Issue(summary, description, label, assignee, propertyId, type); } public String summary() { @@ -78,8 +66,8 @@ public class Issue { return description; } - public List<String> labels() { - return labels; + public Optional<String> label() { + return Optional.ofNullable(label); } public Optional<User> assignee() { 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..5584f8a95fb 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 @@ -15,15 +15,12 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; -/** - * @author jvenstad - */ public class MockOrganization implements Organization { private final Clock clock; - private final AtomicLong counter = new AtomicLong(); - private final Map<IssueId, MockIssue> issues = new HashMap<>(); - private final Map<PropertyId, PropertyInfo> properties = new HashMap<>(); + private final AtomicLong counter; + private final HashMap<IssueId, WrappedIssue> issues; + private final HashMap<PropertyId, PropertyInfo> properties; @Inject @SuppressWarnings("unused") @@ -33,21 +30,25 @@ public class MockOrganization implements Organization { public MockOrganization(Clock clock) { this.clock = clock; + + counter = new AtomicLong(); + issues = new HashMap<>(); + properties = new HashMap<>(); } @Override public IssueId file(Issue issue) { IssueId issueId = IssueId.from("" + counter.incrementAndGet()); - issues.put(issueId, new MockIssue(issue)); + issues.put(issueId, new WrappedIssue(issue)); return issueId; } @Override public Optional<IssueId> findBySimilarity(Issue issue) { return issues.entrySet().stream() - .filter(entry -> entry.getValue().issue.summary().equals(issue.summary())) - .findFirst() - .map(Map.Entry::getKey); + .filter(entry -> entry.getValue().issue.summary().equals(issue.summary())) + .findFirst() + .map(Map.Entry::getKey); } @Override @@ -102,10 +103,6 @@ public class MockOrganization implements Organization { return URI.create("www.properties.tld/" + propertyId.id()); } - public Map<IssueId, MockIssue> issues() { - return Collections.unmodifiableMap(issues); - } - public void close(IssueId issueId) { issues.get(issueId).open = false; touch(issueId); @@ -128,23 +125,20 @@ public class MockOrganization implements Organization { } - public class MockIssue { + private class WrappedIssue { private Issue issue; private Instant updated; private boolean open; private User assignee; - private MockIssue(Issue issue) { + private WrappedIssue(Issue issue) { this.issue = issue; - this.updated = clock.instant(); - this.open = true; - this.assignee = issue.assignee().orElse(properties.get(issue.propertyId()).defaultAssignee); - } - public Issue issue() { return issue; } - public User assignee() { return assignee; } - public boolean isOpen() { return open; } + updated = clock.instant(); + open = true; + assignee = issue.assignee().orElse(properties.get(issue.propertyId()).defaultAssignee); + } } |