Skip to content

Commit

Permalink
Fix checkstyle (#2279)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Oct 13, 2023
1 parent 9098322 commit 8cec60f
Show file tree
Hide file tree
Showing 250 changed files with 1,779 additions and 1,981 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

public final class ElasticJobConfigurationTest {
class ElasticJobConfigurationTest {

@Test
public void assertAnnotationJob() {
void assertAnnotationJob() {
ElasticJobConfiguration annotation = SimpleTestJob.class.getAnnotation(ElasticJobConfiguration.class);
assertThat(annotation.jobName(), is("SimpleTestJob"));
assertThat(annotation.cron(), is("0/5 * * * * ?"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
shardingTotalCount = 3,
shardingItemParameters = "0=Beijing,1=Shanghai,2=Guangzhou",
jobListenerTypes = {"NOOP", "LOG"},
extraConfigurations = {SimpleTracingConfigurationFactory.class},
extraConfigurations = SimpleTracingConfigurationFactory.class,
props = {
@ElasticJobProp(key = "print.title", value = "test title"),
@ElasticJobProp(key = "print.content", value = "test content")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public final class JobConfigurationTest {
class JobConfigurationTest {

@Test
public void assertBuildAllProperties() {
void assertBuildAllProperties() {
JobConfiguration actual = JobConfiguration.newBuilder("test_job", 3)
.cron("0/1 * * * * ?")
.timeZone("GMT+8")
Expand Down Expand Up @@ -83,12 +83,12 @@ public void assertBuildRequiredProperties() {
}

@Test
public void assertBuildWithEmptyJobName() {
void assertBuildWithEmptyJobName() {
assertThrows(IllegalArgumentException.class, () -> JobConfiguration.newBuilder("", 3).cron("0/1 * * * * ?").build());
}

@Test
public void assertBuildWithInvalidShardingTotalCount() {
void assertBuildWithInvalidShardingTotalCount() {
assertThrows(IllegalArgumentException.class, () -> JobConfiguration.newBuilder("test_job", -1).cron("0/1 * * * * ?").build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public final class CloudJobConfigurationPOJOTest {
class CloudJobConfigurationPOJOTest {

private static final String YAML = "appName: app\n"
+ "cpuCount: 1.0\n"
Expand Down Expand Up @@ -69,7 +69,7 @@ public final class CloudJobConfigurationPOJOTest {
+ "shardingTotalCount: 3\n";

@Test
public void assertToJobConfiguration() {
void assertToJobConfiguration() {
CloudJobConfigurationPOJO pojo = new CloudJobConfigurationPOJO();
pojo.setAppName("app");
pojo.setCpuCount(1d);
Expand Down Expand Up @@ -113,7 +113,7 @@ public void assertToJobConfiguration() {
}

@Test
public void assertFromJobConfiguration() {
void assertFromJobConfiguration() {
JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3)
.cron("0/1 * * * * ?")
.shardingItemParameters("0=A,1=B,2=C").jobParameter("param")
Expand Down Expand Up @@ -145,7 +145,7 @@ public void assertFromJobConfiguration() {
}

@Test
public void assertMarshal() {
void assertMarshal() {
CloudJobConfigurationPOJO actual = new CloudJobConfigurationPOJO();
actual.setAppName("app");
actual.setCpuCount(1d);
Expand All @@ -165,7 +165,7 @@ public void assertMarshal() {
}

@Test
public void assertMarshalWithNullValue() {
void assertMarshalWithNullValue() {
CloudJobConfigurationPOJO actual = new CloudJobConfigurationPOJO();
actual.setAppName("app");
actual.setCpuCount(1d);
Expand All @@ -177,7 +177,7 @@ public void assertMarshalWithNullValue() {
}

@Test
public void assertUnmarshal() {
void assertUnmarshal() {
CloudJobConfigurationPOJO actual = YamlEngine.unmarshal(YAML, CloudJobConfigurationPOJO.class);
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getCron(), is("0/1 * * * * ?"));
Expand All @@ -195,7 +195,7 @@ public void assertUnmarshal() {
}

@Test
public void assertUnmarshalWithNullValue() {
void assertUnmarshalWithNullValue() {
CloudJobConfigurationPOJO actual = YamlEngine.unmarshal(YAML_WITH_NULL, CloudJobConfigurationPOJO.class);
assertThat(actual.getAppName(), is("app"));
assertThat(actual.getCpuCount(), is(1d));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class StatisticRdbRepositoryTest {
class StatisticRdbRepositoryTest {

private StatisticRdbRepository repository;

@BeforeEach
public void setup() throws SQLException {
void setup() throws SQLException {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(org.h2.Driver.class.getName());
dataSource.setUrl("jdbc:h2:mem:");
Expand All @@ -50,36 +50,36 @@ public void setup() throws SQLException {
}

@Test
public void assertAddTaskResultStatistics() {
void assertAddTaskResultStatistics() {
for (StatisticInterval each : StatisticInterval.values()) {
assertTrue(repository.add(new TaskResultStatistics(100, 0, each, new Date())));
}
}

@Test
public void assertAddTaskRunningStatistics() {
void assertAddTaskRunningStatistics() {
assertTrue(repository.add(new TaskRunningStatistics(100, new Date())));
}

@Test
public void assertAddJobRunningStatistics() {
void assertAddJobRunningStatistics() {
assertTrue(repository.add(new TaskRunningStatistics(100, new Date())));
}

@Test
public void assertAddJobRegisterStatistics() {
void assertAddJobRegisterStatistics() {
assertTrue(repository.add(new JobRegisterStatistics(100, new Date())));
}

@Test
public void assertFindTaskResultStatisticsWhenTableIsEmpty() {
void assertFindTaskResultStatisticsWhenTableIsEmpty() {
assertThat(repository.findTaskResultStatistics(new Date(), StatisticInterval.MINUTE).size(), is(0));
assertThat(repository.findTaskResultStatistics(new Date(), StatisticInterval.HOUR).size(), is(0));
assertThat(repository.findTaskResultStatistics(new Date(), StatisticInterval.DAY).size(), is(0));
}

@Test
public void assertFindTaskResultStatisticsWithDifferentFromDate() {
void assertFindTaskResultStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
for (StatisticInterval each : StatisticInterval.values()) {
Expand All @@ -91,7 +91,7 @@ public void assertFindTaskResultStatisticsWithDifferentFromDate() {
}

@Test
public void assertGetSummedTaskResultStatisticsWhenTableIsEmpty() {
void assertGetSummedTaskResultStatisticsWhenTableIsEmpty() {
for (StatisticInterval each : StatisticInterval.values()) {
TaskResultStatistics po = repository.getSummedTaskResultStatistics(new Date(), each);
assertThat(po.getSuccessCount(), is(0));
Expand All @@ -100,7 +100,7 @@ public void assertGetSummedTaskResultStatisticsWhenTableIsEmpty() {
}

@Test
public void assertGetSummedTaskResultStatistics() {
void assertGetSummedTaskResultStatistics() {
for (StatisticInterval each : StatisticInterval.values()) {
Date date = new Date();
repository.add(new TaskResultStatistics(100, 2, each, date));
Expand All @@ -112,14 +112,14 @@ public void assertGetSummedTaskResultStatistics() {
}

@Test
public void assertFindLatestTaskResultStatisticsWhenTableIsEmpty() {
void assertFindLatestTaskResultStatisticsWhenTableIsEmpty() {
for (StatisticInterval each : StatisticInterval.values()) {
assertFalse(repository.findLatestTaskResultStatistics(each).isPresent());
}
}

@Test
public void assertFindLatestTaskResultStatistics() {
void assertFindLatestTaskResultStatistics() {
for (StatisticInterval each : StatisticInterval.values()) {
repository.add(new TaskResultStatistics(100, 2, each, new Date()));
repository.add(new TaskResultStatistics(200, 5, each, new Date()));
Expand All @@ -131,12 +131,12 @@ public void assertFindLatestTaskResultStatistics() {
}

@Test
public void assertFindTaskRunningStatisticsWhenTableIsEmpty() {
void assertFindTaskRunningStatisticsWhenTableIsEmpty() {
assertThat(repository.findTaskRunningStatistics(new Date()).size(), is(0));
}

@Test
public void assertFindTaskRunningStatisticsWithDifferentFromDate() {
void assertFindTaskRunningStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
assertTrue(repository.add(new TaskRunningStatistics(100, yesterday)));
Expand All @@ -146,12 +146,12 @@ public void assertFindTaskRunningStatisticsWithDifferentFromDate() {
}

@Test
public void assertFindLatestTaskRunningStatisticsWhenTableIsEmpty() {
void assertFindLatestTaskRunningStatisticsWhenTableIsEmpty() {
assertFalse(repository.findLatestTaskRunningStatistics().isPresent());
}

@Test
public void assertFindLatestTaskRunningStatistics() {
void assertFindLatestTaskRunningStatistics() {
repository.add(new TaskRunningStatistics(100, new Date()));
repository.add(new TaskRunningStatistics(200, new Date()));
Optional<TaskRunningStatistics> po = repository.findLatestTaskRunningStatistics();
Expand All @@ -160,12 +160,12 @@ public void assertFindLatestTaskRunningStatistics() {
}

@Test
public void assertFindJobRunningStatisticsWhenTableIsEmpty() {
void assertFindJobRunningStatisticsWhenTableIsEmpty() {
assertThat(repository.findJobRunningStatistics(new Date()).size(), is(0));
}

@Test
public void assertFindJobRunningStatisticsWithDifferentFromDate() {
void assertFindJobRunningStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
assertTrue(repository.add(new JobRunningStatistics(100, yesterday)));
Expand All @@ -175,12 +175,12 @@ public void assertFindJobRunningStatisticsWithDifferentFromDate() {
}

@Test
public void assertFindLatestJobRunningStatisticsWhenTableIsEmpty() {
void assertFindLatestJobRunningStatisticsWhenTableIsEmpty() {
assertFalse(repository.findLatestJobRunningStatistics().isPresent());
}

@Test
public void assertFindLatestJobRunningStatistics() {
void assertFindLatestJobRunningStatistics() {
repository.add(new JobRunningStatistics(100, new Date()));
repository.add(new JobRunningStatistics(200, new Date()));
Optional<JobRunningStatistics> po = repository.findLatestJobRunningStatistics();
Expand All @@ -189,12 +189,12 @@ public void assertFindLatestJobRunningStatistics() {
}

@Test
public void assertFindJobRegisterStatisticsWhenTableIsEmpty() {
void assertFindJobRegisterStatisticsWhenTableIsEmpty() {
assertThat(repository.findJobRegisterStatistics(new Date()).size(), is(0));
}

@Test
public void assertFindJobRegisterStatisticsWithDifferentFromDate() {
void assertFindJobRegisterStatisticsWithDifferentFromDate() {
Date now = new Date();
Date yesterday = getYesterday();
assertTrue(repository.add(new JobRegisterStatistics(100, yesterday)));
Expand All @@ -204,12 +204,12 @@ public void assertFindJobRegisterStatisticsWithDifferentFromDate() {
}

@Test
public void assertFindLatestJobRegisterStatisticsWhenTableIsEmpty() {
void assertFindLatestJobRegisterStatisticsWhenTableIsEmpty() {
assertFalse(repository.findLatestJobRegisterStatistics().isPresent());
}

@Test
public void assertFindLatestJobRegisterStatistics() {
void assertFindLatestJobRegisterStatistics() {
repository.add(new JobRegisterStatistics(100, new Date()));
repository.add(new JobRegisterStatistics(200, new Date()));
Optional<JobRegisterStatistics> po = repository.findLatestJobRegisterStatistics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import static org.mockito.Mockito.verify;

@ExtendWith(MockitoExtension.class)
public final class CloudJobFacadeTest {
class CloudJobFacadeTest {

private ShardingContexts shardingContexts;

Expand All @@ -52,7 +52,7 @@ public final class CloudJobFacadeTest {
private JobFacade jobFacade;

@BeforeEach
public void setUp() {
void setUp() {
shardingContexts = getShardingContexts();
jobFacade = new CloudJobFacade(shardingContexts, getJobConfiguration(), jobTracingEventBus);
}
Expand All @@ -68,69 +68,69 @@ private JobConfiguration getJobConfiguration() {
}

@Test
public void assertCheckJobExecutionEnvironment() throws JobExecutionEnvironmentException {
void assertCheckJobExecutionEnvironment() throws JobExecutionEnvironmentException {
jobFacade.checkJobExecutionEnvironment();
}

@Test
public void assertFailoverIfNecessary() {
void assertFailoverIfNecessary() {
jobFacade.failoverIfNecessary();
}

@Test
public void assertRegisterJobBegin() {
void assertRegisterJobBegin() {
jobFacade.registerJobBegin(null);
}

@Test
public void assertRegisterJobCompleted() {
void assertRegisterJobCompleted() {
jobFacade.registerJobCompleted(null);
}

@Test
public void assertGetShardingContext() {
void assertGetShardingContext() {
assertThat(jobFacade.getShardingContexts(), is(shardingContexts));
}

@Test
public void assertMisfireIfNecessary() {
void assertMisfireIfNecessary() {
jobFacade.misfireIfRunning(null);
}

@Test
public void assertClearMisfire() {
void assertClearMisfire() {
jobFacade.clearMisfire(null);
}

@Test
public void assertIsExecuteMisfired() {
void assertIsExecuteMisfired() {
assertFalse(jobFacade.isExecuteMisfired(null));
}

@Test
public void assertIsNeedSharding() {
void assertIsNeedSharding() {
assertFalse(jobFacade.isNeedSharding());
}

@Test
public void assertBeforeJobExecuted() {
void assertBeforeJobExecuted() {
jobFacade.beforeJobExecuted(null);
}

@Test
public void assertAfterJobExecuted() {
void assertAfterJobExecuted() {
jobFacade.afterJobExecuted(null);
}

@Test
public void assertPostJobExecutionEvent() {
void assertPostJobExecutionEvent() {
JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
jobFacade.postJobExecutionEvent(jobExecutionEvent);
verify(jobTracingEventBus).post(jobExecutionEvent);
}

@Test
public void assertPostJobStatusTraceEvent() {
void assertPostJobStatusTraceEvent() {
jobFacade.postJobStatusTraceEvent(String.format("%s@-@0@-@%s@-@fake_slave_id@-@0", "test_job", ExecutionType.READY), State.TASK_RUNNING, "message is empty.");
}
}
Loading

0 comments on commit 8cec60f

Please sign in to comment.