Code cleanup

- Inline variables
- Remove unused variables
- Remove redundant array creation
- Remove redundant `@SuppressWarnings`
- Remove unnecessary exceptions from throws list
- Remove redundant initializers
- Use List.subList().clear() where appropriate
- Use try-with-resources where needed
- Use pattern variables where appropriate
This commit is contained in:
Mahmoud Ben Hassine
2023-07-12 23:25:18 +02:00
parent 4763480c57
commit 52064c0541
103 changed files with 169 additions and 224 deletions

View File

@@ -70,11 +70,10 @@ public class JobScopeTestExecutionListener implements TestExecutionListener {
/**
* Set up a {@link JobExecution} as a test context attribute.
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#prepareTestInstance(TestContext)
*/
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
public void prepareTestInstance(TestContext testContext) {
JobExecution jobExecution = getJobExecution(testContext);
if (jobExecution != null) {
testContext.setAttribute(JOB_EXECUTION, jobExecution);
@@ -83,11 +82,10 @@ public class JobScopeTestExecutionListener implements TestExecutionListener {
/**
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#beforeTestMethod(TestContext)
*/
@Override
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws Exception {
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) {
if (testContext.hasAttribute(JOB_EXECUTION)) {
JobExecution jobExecution = (JobExecution) testContext.getAttribute(JOB_EXECUTION);
JobSynchronizationManager.register(jobExecution);
@@ -97,11 +95,10 @@ public class JobScopeTestExecutionListener implements TestExecutionListener {
/**
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#afterTestMethod(TestContext)
*/
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
public void afterTestMethod(TestContext testContext) {
if (testContext.hasAttribute(JOB_EXECUTION)) {
JobSynchronizationManager.close();
}
@@ -159,7 +156,7 @@ public class JobScopeTestExecutionListener implements TestExecutionListener {
}
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
public void doWith(Method method) throws IllegalArgumentException {
Class<?> type = method.getReturnType();
if (preferredType.isAssignableFrom(type)) {
if (result == null || method.getName().equals(preferredName)) {

View File

@@ -71,11 +71,10 @@ public class StepScopeTestExecutionListener implements TestExecutionListener {
/**
* Set up a {@link StepExecution} as a test context attribute.
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#prepareTestInstance(TestContext)
*/
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
public void prepareTestInstance(TestContext testContext) {
StepExecution stepExecution = getStepExecution(testContext);
if (stepExecution != null) {
@@ -85,11 +84,10 @@ public class StepScopeTestExecutionListener implements TestExecutionListener {
/**
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#beforeTestMethod(TestContext)
*/
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
public void beforeTestMethod(TestContext testContext) {
if (testContext.hasAttribute(STEP_EXECUTION)) {
StepExecution stepExecution = (StepExecution) testContext.getAttribute(STEP_EXECUTION);
@@ -100,11 +98,10 @@ public class StepScopeTestExecutionListener implements TestExecutionListener {
/**
* @param testContext the current test context
* @throws Exception if there is a problem
* @see TestExecutionListener#afterTestMethod(TestContext)
*/
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
public void afterTestMethod(TestContext testContext) {
if (testContext.hasAttribute(STEP_EXECUTION)) {
StepSynchronizationManager.close();
@@ -162,7 +159,7 @@ public class StepScopeTestExecutionListener implements TestExecutionListener {
}
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
public void doWith(Method method) throws IllegalArgumentException {
Class<?> type = method.getReturnType();
if (preferredType.isAssignableFrom(type)) {
if (result == null || method.getName().equals(preferredName)) {