SCT-8: Added NoOpTaskExplorer Set the Junit to test scope.
This commit is contained in:
committed by
Glenn Renfro
parent
bd5dab7bc9
commit
93e4698175
@@ -18,6 +18,11 @@
|
||||
<description>Spring Cloud Task</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.task.configuration;
|
||||
|
||||
import org.springframework.cloud.task.repository.LoggerTaskRepository;
|
||||
import org.springframework.cloud.task.repository.support.LoggerTaskRepository;
|
||||
import org.springframework.cloud.task.repository.TaskRepository;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -14,12 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.task.repository;
|
||||
package org.springframework.cloud.task.repository.support;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.task.repository.TaskExecution;
|
||||
import org.springframework.cloud.task.repository.TaskRepository;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.task.repository.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cloud.task.repository.TaskExecution;
|
||||
import org.springframework.cloud.task.repository.TaskExplorer;
|
||||
|
||||
/**
|
||||
* Provides a no-op TaskExplorer for development purposes.
|
||||
*
|
||||
* @author Michael Minella
|
||||
*/
|
||||
public class NoOpTaskExplorer implements TaskExplorer {
|
||||
|
||||
public TaskExecution getTaskExecution(Long executionId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<TaskExecution> findRunningTaskExecutions(String taskName) {
|
||||
return new HashSet<TaskExecution>(0);
|
||||
}
|
||||
|
||||
public List<String> getTaskNames() {
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
public long getTaskExecutionCount(String taskName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<TaskExecution> getTaskExecutionsByName(String taskName, int start, int count) {
|
||||
return new ArrayList<TaskExecution>(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.task.repository.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.task.repository.TaskExplorer;
|
||||
|
||||
public class NoOpTaskExplorerTest {
|
||||
|
||||
private TaskExplorer taskExplorer;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
taskExplorer = new NoOpTaskExplorer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskExecution() throws Exception {
|
||||
assertNull(taskExplorer.getTaskExecution(3l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindRunningTaskExecutions() throws Exception {
|
||||
assertEquals(taskExplorer.findRunningTaskExecutions("foo").size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskNames() throws Exception {
|
||||
assertEquals(taskExplorer.getTaskNames().size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskExecutionCount() throws Exception {
|
||||
assertEquals(taskExplorer.getTaskExecutionCount("foo"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskExecutionsByName() throws Exception {
|
||||
assertEquals(taskExplorer.getTaskExecutionsByName("foo", 0, 100).size(), 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user