Updated tests to remove deprecated code from tests
* cleanup removing unused headers * Updated asserts in code base that needed messages (marked as deprecated) * left one test that was testing a deprecated constructor. When that code is removed we can remove that test. * some other cleanup resolves #338
This commit is contained in:
committed by
Michael Minella
parent
c4324b550d
commit
3ad9efe3fe
@@ -29,7 +29,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ExitCodeEvent;
|
||||
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi
|
||||
|
||||
@Override
|
||||
public void init(DataSource dataSource) throws Exception {
|
||||
Assert.notNull(dataSource);
|
||||
Assert.notNull(dataSource, "DataSource must not be null");
|
||||
Assert.hasLength(selectClause, "selectClause must be specified");
|
||||
Assert.hasLength(fromClause, "fromClause must be specified");
|
||||
Assert.notEmpty(sortKeys, "sortKey must be specified");
|
||||
|
||||
@@ -212,9 +212,9 @@ public class TaskLifecycleListenerTests {
|
||||
Integer exitCode, Throwable exception, String externalExecutionId,
|
||||
Long parentExecutionId) {
|
||||
|
||||
Sort sort = new Sort("id");
|
||||
Sort sort = Sort.by("id");
|
||||
|
||||
PageRequest request = new PageRequest(0, Integer.MAX_VALUE, sort);
|
||||
PageRequest request = PageRequest.of(0, Integer.MAX_VALUE, sort);
|
||||
|
||||
Page<TaskExecution> taskExecutionsByName = this.taskExplorer.findTaskExecutionsByName("testTask",
|
||||
request);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class JdbcTaskExecutionDaoTests {
|
||||
@DirtiesContext
|
||||
public void testFindAllPageableSort() {
|
||||
initializeRepositoryNotInOrder();
|
||||
Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC,
|
||||
Sort sort = Sort.by(new Sort.Order(Sort.Direction.ASC,
|
||||
"EXTERNAL_EXECUTION_ID"));
|
||||
Iterator<TaskExecution> iter = getPageIterator(0, 2, sort);
|
||||
TaskExecution taskExecution = iter.next();
|
||||
@@ -202,8 +202,8 @@ public class JdbcTaskExecutionDaoTests {
|
||||
|
||||
private Iterator<TaskExecution> getPageIterator(int pageNum, int pageSize, Sort sort) {
|
||||
Pageable pageable = (sort == null) ?
|
||||
new PageRequest(pageNum, pageSize) :
|
||||
new PageRequest(pageNum, pageSize, sort);
|
||||
PageRequest.of(pageNum, pageSize) :
|
||||
PageRequest.of(pageNum, pageSize, sort);
|
||||
Page<TaskExecution> page = dao.findAll(pageable);
|
||||
assertEquals(3, page.getTotalElements());
|
||||
assertEquals(2, page.getTotalPages());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FindAllPagingQueryProviderTests {
|
||||
|
||||
private String databaseProductName;
|
||||
private String expectedQuery;
|
||||
private Pageable pageable = new PageRequest(0, 10);
|
||||
private Pageable pageable = PageRequest.of(0, 10);
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class InvalidPagingQueryProviderTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testInvalidDatabase() throws Exception{
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
String actualQuery = TestDBUtils.getPagingQueryProvider("Invalid").getPageQuery(pageable);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
TestDBUtils.getPagingQueryProvider("Invalid").getPageQuery(pageable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class WhereClausePagingQueryProviderTests {
|
||||
|
||||
private String databaseProductName;
|
||||
private String expectedQuery;
|
||||
private Pageable pageable = new PageRequest(0, 10);
|
||||
private Pageable pageable = PageRequest.of(0, 10);
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
|
||||
@@ -171,7 +171,7 @@ public class SimpleTaskExplorerTests {
|
||||
createTaskExecution(getSimpleTaskExecution());
|
||||
expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution);
|
||||
}
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
|
||||
Page<TaskExecution> actualResults = taskExplorer.findRunningTaskExecutions(TASK_NAME, pageable);
|
||||
assertEquals(String.format(
|
||||
@@ -206,7 +206,7 @@ public class SimpleTaskExplorerTests {
|
||||
expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution);
|
||||
}
|
||||
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
Page<TaskExecution> resultSet = taskExplorer.findTaskExecutionsByName(TASK_NAME, pageable);
|
||||
assertEquals(String.format(
|
||||
"Running task count for task name did not match expected result for testType %s",
|
||||
@@ -239,25 +239,25 @@ public class SimpleTaskExplorerTests {
|
||||
|
||||
@Test
|
||||
public void findAllExecutionsOffBoundry() {
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
verifyPageResults(pageable, 103);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllExecutionsOffBoundryByOne() {
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
verifyPageResults(pageable, 101);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllExecutionsOnBoundry() {
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
verifyPageResults(pageable, 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllExecutionsNoResult() {
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
verifyPageResults(pageable, 0);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public class SimpleTaskExplorerTests {
|
||||
taskPage.getTotalElements());
|
||||
|
||||
//Verify pagination
|
||||
Pageable actualPageable = new PageRequest(0, pageable.getPageSize());
|
||||
Pageable actualPageable = PageRequest.of(0, pageable.getPageSize());
|
||||
boolean hasMorePages = taskPage.hasContent();
|
||||
int pageNumber = 0;
|
||||
int elementCount = 0;
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.springframework.cloud.task.repository.TaskExecution;
|
||||
import org.springframework.cloud.task.repository.TaskRepository;
|
||||
import org.springframework.cloud.task.repository.dao.MapTaskExecutionDao;
|
||||
import org.springframework.cloud.task.util.TaskExecutionCreator;
|
||||
import org.springframework.cloud.task.util.TestDBUtils;
|
||||
import org.springframework.cloud.task.util.TestVerifierUtils;
|
||||
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
|
||||
Reference in New Issue
Block a user