diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-04-13 11:00:14 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-04-13 12:08:10 +0200 |
commit | 6e358730a51199ec2465dfd9cf69f6b6d04fa8bd (patch) | |
tree | 5bb377d5ec122d67e2a2d9ded634ec16f227cc84 | |
parent | 5163c7ddde2f98866e6b922f6d514e4cbf137e2c (diff) |
Add file that was lost by IntelliJ
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockBuildService.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockBuildService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockBuildService.java new file mode 100644 index 00000000000..b942a6baa98 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockBuildService.java @@ -0,0 +1,43 @@ +// 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.stubs; + +import com.yahoo.component.AbstractComponent; +import com.yahoo.vespa.hosted.controller.api.integration.BuildService; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author jvenstad + */ +public class MockBuildService extends AbstractComponent implements BuildService { + + private final List<BuildJob> jobs = Collections.synchronizedList(new ArrayList<>()); + + @Override + public void trigger(BuildJob buildJob) { + jobs.add(buildJob); + } + + @Override + public boolean isRunning(BuildJob buildJob) { + return jobs.contains(buildJob); + } + + /** List all running jobs. */ + public List<BuildJob> jobs() { + return new ArrayList<>(jobs); + } + + /** Clears all running jobs. */ + public void clear() { + jobs.clear(); + } + + /** Removes the given job for the given project and returns whether it was found. */ + public boolean removeJob(long projectId, String jobType) { + return jobs.remove(new BuildJob(projectId, jobType)); + } + +} |