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:
Glenn Renfro
2018-01-05 09:30:26 -05:00
committed by Michael Minella
parent c4324b550d
commit 3ad9efe3fe
25 changed files with 36 additions and 46 deletions

View File

@@ -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;

View File

@@ -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");

View File

@@ -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);

View File

@@ -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());

View File

@@ -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() {

View File

@@ -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);
}
}

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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;