From 8cec60f6912c6ef53f78840215265a1380cb3744 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sat, 14 Oct 2023 01:29:12 +0800 Subject: [PATCH] Fix checkstyle (#2279) --- .../ElasticJobConfigurationTest.java | 4 +- .../annotation/job/impl/SimpleTestJob.java | 2 +- .../elasticjob/api/JobConfigurationTest.java | 8 +- .../pojo/CloudJobConfigurationPOJOTest.java | 14 +- .../rdb/StatisticRdbRepositoryTest.java | 48 +- .../executor/facade/CloudJobFacadeTest.java | 30 +- .../executor/local/LocalTaskExecutorTest.java | 10 +- .../prod/DaemonTaskSchedulerTest.java | 12 +- .../cloud/executor/prod/TaskExecutorTest.java | 24 +- .../executor/prod/TaskExecutorThreadTest.java | 6 +- .../console/AbstractCloudControllerTest.java | 6 +- .../controller/CloudAppControllerTest.java | 24 +- .../controller/CloudJobControllerTest.java | 56 +-- .../console/controller/CloudLoginTest.java | 8 +- .../CloudOperationControllerTest.java | 10 +- .../search/JobEventRdbSearchTest.java | 8 +- .../CloudAppConfigurationListenerTest.java | 14 +- .../app/CloudAppConfigurationNodeTest.java | 4 +- .../app/CloudAppConfigurationServiceTest.java | 16 +- .../pojo/CloudAppConfigurationPOJOTest.java | 6 +- .../CloudJobConfigurationListenerTest.java | 26 +- .../job/CloudJobConfigurationNodeTest.java | 4 +- .../job/CloudJobConfigurationServiceTest.java | 18 +- .../scheduler/context/JobContextTest.java | 4 +- .../env/BootstrapEnvironmentTest.java | 22 +- .../scheduler/ha/FrameworkIDServiceTest.java | 8 +- .../mesos/AppConstraintEvaluatorTest.java | 22 +- .../scheduler/mesos/FacadeServiceTest.java | 62 +-- .../scheduler/mesos/JobTaskRequestTest.java | 28 +- .../scheduler/mesos/LaunchingTasksTest.java | 6 +- .../scheduler/mesos/LeasesQueueTest.java | 4 +- .../mesos/MesosStateServiceTest.java | 8 +- .../scheduler/mesos/ReconcileServiceTest.java | 10 +- .../scheduler/mesos/SchedulerEngineTest.java | 48 +- .../scheduler/mesos/SchedulerServiceTest.java | 12 +- .../mesos/SupportedExtractionTypeTest.java | 4 +- .../scheduler/mesos/TaskInfoDataTest.java | 8 +- .../mesos/TaskLaunchScheduledServiceTest.java | 14 +- .../scheduler/producer/ProducerJobTest.java | 6 +- .../producer/ProducerManagerTest.java | 26 +- .../TransientProducerRepositoryTest.java | 12 +- .../TransientProducerSchedulerTest.java | 10 +- .../app/CloudAppDisableListenerTest.java | 20 +- .../state/disable/app/DisableAppNodeTest.java | 4 +- .../disable/app/DisableAppServiceTest.java | 12 +- .../job/CloudJobDisableListenerTest.java | 20 +- .../state/disable/job/DisableJobNodeTest.java | 4 +- .../disable/job/DisableJobServiceTest.java | 12 +- .../state/failover/FailoverNodeTest.java | 6 +- .../state/failover/FailoverServiceTest.java | 28 +- .../scheduler/state/ready/ReadyNodeTest.java | 4 +- .../state/ready/ReadyServiceTest.java | 52 +- .../state/running/RunningNodeTest.java | 6 +- .../state/running/RunningServiceTest.java | 28 +- .../statistics/StatisticManagerTest.java | 42 +- .../statistics/StatisticsSchedulerTest.java | 8 +- .../statistics/TaskResultMetaDataTest.java | 8 +- .../statistics/job/BaseStatisticJobTest.java | 10 +- .../job/JobRunningStatisticJobTest.java | 14 +- .../job/RegisteredJobStatisticJobTest.java | 14 +- .../job/TaskResultStatisticJobTest.java | 14 +- .../util/StatisticTimeUtilsTest.java | 14 +- .../cloud/scheduler/util/IOUtilsTest.java | 11 +- ...obErrorHandlerPropertiesValidatorTest.java | 10 +- .../dingtalk/DingtalkJobErrorHandlerTest.java | 18 +- ...obErrorHandlerPropertiesValidatorTest.java | 10 +- .../email/EmailJobErrorHandlerTest.java | 10 +- .../handler/JobErrorHandlerFactoryTest.java | 8 +- .../JobErrorHandlerReloadableTest.java | 10 +- .../general/IgnoreJobErrorHandlerTest.java | 4 +- .../general/LogJobErrorHandlerTest.java | 8 +- .../general/ThrowJobErrorHandlerTest.java | 8 +- ...obErrorHandlerPropertiesValidatorTest.java | 10 +- .../wechat/WechatJobErrorHandlerTest.java | 16 +- .../executor/ElasticJobExecutorTest.java | 28 +- .../item/JobItemExecutorFactoryTest.java | 12 +- .../executor/DataflowJobExecutorTest.java | 10 +- .../http/executor/HttpJobExecutorTest.java | 24 +- .../script/ScriptJobExecutorTest.java | 12 +- .../executor/SimpleJobExecutorTest.java | 8 +- .../tracing/JobTracingEventBusTest.java | 8 +- .../tracing/event/JobExecutionEventTest.java | 8 +- .../listener/TracingListenerFactoryTest.java | 8 +- .../TracingStorageConverterFactoryTest.java | 6 +- ...YamlTracingConfigurationConverterTest.java | 4 +- .../DataSourceConfigurationTest.java | 18 +- .../datasource/DataSourceRegistryTest.java | 6 +- ...DataSourceTracingStorageConverterTest.java | 8 +- .../RDBTracingListenerConfigurationTest.java | 6 +- .../rdb/listener/RDBTracingListenerTest.java | 8 +- .../rdb/storage/RDBJobEventStorageTest.java | 26 +- ...lDataSourceConfigurationConverterTest.java | 4 +- .../ElasticJobExecutorServiceTest.java | 4 +- .../ExecutorServiceReloadableTest.java | 10 +- .../context/ShardingItemParametersTest.java | 10 +- .../infra/context/TaskContextTest.java | 28 +- .../infra/env/HostExceptionTest.java | 4 +- .../elasticjob/infra/env/IpUtilsTest.java | 12 +- .../elasticjob/infra/env/TimeServiceTest.java | 4 +- .../infra/exception/ExceptionUtilsTest.java | 8 +- .../JobConfigurationExceptionTest.java | 6 +- .../JobExecutionEnvironmentExceptionTest.java | 4 +- .../exception/JobStatisticExceptionTest.java | 4 +- .../exception/JobSystemExceptionTest.java | 8 +- .../handler/sharding/JobInstanceTest.java | 8 +- .../JobShardingStrategyFactoryTest.java | 8 +- ...rageAllocationJobShardingStrategyTest.java | 14 +- ...vitySortByNameJobShardingStrategyTest.java | 6 +- ...teServerByNameJobShardingStrategyTest.java | 8 +- .../JobExecutorServiceHandlerFactoryTest.java | 8 +- ...CPUUsageJobExecutorServiceHandlerTest.java | 4 +- ...leThreadJobExecutorServiceHandlerTest.java | 4 +- .../infra/json/GsonFactoryTest.java | 12 +- .../ElasticJobListenerFactoryTest.java | 6 +- .../infra/listener/ShardingContextsTest.java | 4 +- .../infra/pojo/JobConfigurationPOJOTest.java | 14 +- .../spi/ElasticJobServiceLoaderTest.java | 16 +- .../JobPropertiesValidateRuleTest.java | 14 +- .../elasticjob/infra/yaml/YamlEngineTest.java | 10 +- ...YamlConfigurationConverterFactoryTest.java | 5 +- .../ConnectionStateChangedEventListener.java | 2 +- .../transaction/TransactionOperationTest.java | 10 +- .../exception/RegExceptionHandlerTest.java | 8 +- .../zookeeper/ZookeeperConfigurationTest.java | 4 +- .../ZookeeperElectionServiceTest.java | 6 +- ...eperRegistryCenterExecuteInLeaderTest.java | 8 +- .../ZookeeperRegistryCenterForAuthTest.java | 10 +- ...ookeeperRegistryCenterInitFailureTest.java | 4 +- .../ZookeeperRegistryCenterListenerTest.java | 24 +- ...keeperRegistryCenterMiscellaneousTest.java | 12 +- .../ZookeeperRegistryCenterModifyTest.java | 18 +- ...eeperRegistryCenterQueryWithCacheTest.java | 10 +- ...erRegistryCenterQueryWithoutCacheTest.java | 18 +- ...ookeeperRegistryCenterTransactionTest.java | 10 +- .../ZookeeperRegistryCenterWatchTest.java | 10 +- ...erCuratorIgnoredExceptionProviderTest.java | 4 +- .../util/ZookeeperRegistryCenterTestUtil.java | 2 +- .../restful/annotation/ParamSource.java | 2 +- .../restful/RegexPathMatcherTest.java | 10 +- .../restful/RegexUrlPatternMapTest.java | 8 +- .../RequestBodyDeserializerFactoryTest.java | 6 +- .../filter/DefaultFilterChainTest.java | 18 +- .../FilterChainInboundHandlerTest.java | 8 +- .../pipeline/HandlerParameterDecoderTest.java | 6 +- .../pipeline/HttpRequestDispatcherTest.java | 4 +- .../pipeline/NettyRestfulServiceTest.java | 36 +- ...ulServiceTrailingSlashInsensitiveTest.java | 4 +- ...tfulServiceTrailingSlashSensitiveTest.java | 10 +- .../ResponseBodySerializerFactoryTest.java | 6 +- .../wrapper/QueryParameterMapTest.java | 8 +- .../internal/reconcile/ReconcileService.java | 2 +- .../impl/OneOffJobBootstrapTest.java | 14 +- .../DistributeOnceElasticJobListenerTest.java | 16 +- .../api/registry/JobInstanceRegistryTest.java | 22 +- .../lite/integrate/BaseIntegrateTest.java | 6 +- .../OneOffDisabledJobIntegrateTest.java | 6 +- .../ScheduleDisabledJobIntegrateTest.java | 6 +- .../enable/EnabledJobIntegrateTest.java | 2 +- .../enable/OneOffEnabledJobIntegrateTest.java | 6 +- .../ScheduleEnabledJobIntegrateTest.java | 6 +- .../annotation/JobAnnotationBuilderTest.java | 4 +- .../integrate/BaseAnnotationTest.java | 6 +- .../integrate/OneOffEnabledJobTest.java | 8 +- .../integrate/ScheduleEnabledJobTest.java | 8 +- .../config/ConfigurationNodeTest.java | 4 +- .../config/ConfigurationServiceTest.java | 24 +- .../config/RescheduleListenerManagerTest.java | 14 +- .../election/ElectionListenerManagerTest.java | 26 +- .../internal/election/LeaderNodeTest.java | 6 +- .../internal/election/LeaderServiceTest.java | 24 +- .../failover/FailoverListenerManagerTest.java | 30 +- .../internal/failover/FailoverNodeTest.java | 12 +- .../failover/FailoverServiceTest.java | 40 +- .../GuaranteeListenerManagerTest.java | 18 +- .../internal/guarantee/GuaranteeNodeTest.java | 14 +- .../guarantee/GuaranteeServiceTest.java | 40 +- .../internal/instance/InstanceNodeTest.java | 18 +- .../instance/InstanceServiceTest.java | 16 +- .../instance/ShutdownListenerManagerTest.java | 20 +- .../listener/ListenerManagerTest.java | 6 +- .../listener/ListenerNotifierManagerTest.java | 6 +- ...stryCenterConnectionStateListenerTest.java | 14 +- .../reconcile/ReconcileServiceTest.java | 8 +- .../internal/schedule/JobRegistryTest.java | 24 +- .../schedule/JobScheduleControllerTest.java | 54 +- .../schedule/JobTriggerListenerTest.java | 10 +- .../internal/schedule/LiteJobFacadeTest.java | 38 +- .../schedule/SchedulerFacadeTest.java | 8 +- .../lite/internal/server/ServerNodeTest.java | 14 +- .../internal/server/ServerServiceTest.java | 26 +- .../DefaultJobClassNameProviderTest.java | 6 +- .../JobClassNameProviderFactoryTest.java | 4 +- .../lite/internal/setup/SetUpFacadeTest.java | 8 +- .../sharding/ExecutionContextServiceTest.java | 10 +- .../sharding/ExecutionServiceTest.java | 44 +- .../MonitorExecutionListenerManagerTest.java | 12 +- .../sharding/ShardingListenerManagerTest.java | 26 +- .../internal/sharding/ShardingNodeTest.java | 10 +- .../sharding/ShardingServiceTest.java | 38 +- .../snapshot/BaseSnapshotServiceTest.java | 6 +- .../snapshot/SnapshotServiceDisableTest.java | 10 +- .../snapshot/SnapshotServiceEnableTest.java | 14 +- .../internal/storage/JobNodePathTest.java | 14 +- .../internal/storage/JobNodeStorageTest.java | 40 +- .../trigger/TriggerListenerManagerTest.java | 16 +- .../internal/util/SensitiveInfoUtilsTest.java | 6 +- .../AbstractEmbedZookeeperBaseTest.java | 2 +- .../lite/lifecycle/api/JobAPIFactoryTest.java | 14 +- .../lifecycle/domain/ShardingStatusTest.java | 10 +- .../operate/JobOperateAPIImplTest.java | 30 +- .../operate/ShardingOperateAPIImplTest.java | 8 +- .../reg/RegistryCenterFactoryTest.java | 8 +- .../settings/JobConfigurationAPIImplTest.java | 20 +- .../statistics/JobStatisticsAPIImplTest.java | 22 +- .../ServerStatisticsAPIImplTest.java | 8 +- .../ShardingStatisticsAPIImplTest.java | 6 +- ...ElasticJobConfigurationPropertiesTest.java | 13 +- .../job/ElasticJobSpringBootScannerTest.java | 6 +- .../boot/job/ElasticJobSpringBootTest.java | 22 +- .../boot/reg/ZookeeperPropertiesTest.java | 10 +- ...icJobSnapshotServiceConfigurationTest.java | 6 +- .../tracing/TracingConfigurationTest.java | 6 +- .../JobClassNameProviderFactoryTest.java | 10 +- .../spring/core/util/AopTargetUtilsTest.java | 8 +- .../lite/spring/core/util/TargetJob.java | 1 - .../job/AbstractJobSpringIntegrateTest.java | 6 +- .../AbstractOneOffJobSpringIntegrateTest.java | 6 +- ...bSpringNamespaceWithEventTraceRdbTest.java | 4 +- .../JobSpringNamespaceWithJobHandlerTest.java | 4 +- ...ringNamespaceWithListenerAndCglibTest.java | 4 +- ...aceWithListenerAndJdkDynamicProxyTest.java | 4 +- .../JobSpringNamespaceWithListenerTest.java | 4 +- .../job/JobSpringNamespaceWithRefTest.java | 8 +- .../job/JobSpringNamespaceWithTypeTest.java | 6 +- ...JobSpringNamespaceWithoutListenerTest.java | 4 +- ...bSpringNamespaceWithEventTraceRdbTest.java | 4 +- ...fJobSpringNamespaceWithJobHandlerTest.java | 4 +- ...ringNamespaceWithListenerAndCglibTest.java | 4 +- ...aceWithListenerAndJdkDynamicProxyTest.java | 4 +- ...OffJobSpringNamespaceWithListenerTest.java | 4 +- .../OneOffJobSpringNamespaceWithRefTest.java | 8 +- .../OneOffJobSpringNamespaceWithTypeTest.java | 6 +- ...JobSpringNamespaceWithoutListenerTest.java | 4 +- .../AbstractJobSpringIntegrateTest.java | 7 +- .../SnapshotSpringNamespaceDisableTest.java | 4 +- .../SnapshotSpringNamespaceEnableTest.java | 4 +- ...okeeperJUnitJupiterSpringContextTests.java | 4 +- pom.xml | 4 +- src/resources/checkstyle.xml | 463 ++++++++++-------- src/resources/checkstyle_ci.xml | 238 --------- 250 files changed, 1779 insertions(+), 1981 deletions(-) delete mode 100644 src/resources/checkstyle_ci.xml diff --git a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfigurationTest.java b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfigurationTest.java index 8c4692ee22..fad66da5f7 100644 --- a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfigurationTest.java +++ b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/ElasticJobConfigurationTest.java @@ -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 * * * * ?")); diff --git a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/job/impl/SimpleTestJob.java b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/job/impl/SimpleTestJob.java index 3a9c01dcaa..af2b4dda9f 100644 --- a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/job/impl/SimpleTestJob.java +++ b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/annotation/job/impl/SimpleTestJob.java @@ -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") diff --git a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java index 1e7412c21c..6fda7ad19f 100644 --- a/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java +++ b/elasticjob-api/src/test/java/org/apache/shardingsphere/elasticjob/api/JobConfigurationTest.java @@ -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") @@ -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()); } } diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/config/pojo/CloudJobConfigurationPOJOTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/config/pojo/CloudJobConfigurationPOJOTest.java index 7921eff7a4..17ace6fca6 100644 --- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/config/pojo/CloudJobConfigurationPOJOTest.java +++ b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/config/pojo/CloudJobConfigurationPOJOTest.java @@ -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" @@ -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); @@ -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") @@ -145,7 +145,7 @@ public void assertFromJobConfiguration() { } @Test - public void assertMarshal() { + void assertMarshal() { CloudJobConfigurationPOJO actual = new CloudJobConfigurationPOJO(); actual.setAppName("app"); actual.setCpuCount(1d); @@ -165,7 +165,7 @@ public void assertMarshal() { } @Test - public void assertMarshalWithNullValue() { + void assertMarshalWithNullValue() { CloudJobConfigurationPOJO actual = new CloudJobConfigurationPOJO(); actual.setAppName("app"); actual.setCpuCount(1d); @@ -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 * * * * ?")); @@ -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)); diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/statistics/rdb/StatisticRdbRepositoryTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/statistics/rdb/StatisticRdbRepositoryTest.java index e18977d85c..6a03ce09cc 100755 --- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/statistics/rdb/StatisticRdbRepositoryTest.java +++ b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/statistics/rdb/StatisticRdbRepositoryTest.java @@ -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:"); @@ -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()) { @@ -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)); @@ -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)); @@ -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())); @@ -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))); @@ -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 po = repository.findLatestTaskRunningStatistics(); @@ -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))); @@ -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 po = repository.findLatestJobRunningStatistics(); @@ -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))); @@ -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 po = repository.findLatestJobRegisterStatistics(); diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/facade/CloudJobFacadeTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/facade/CloudJobFacadeTest.java index 2fd7214f47..6a7a3c1a0e 100755 --- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/facade/CloudJobFacadeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/facade/CloudJobFacadeTest.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class CloudJobFacadeTest { +class CloudJobFacadeTest { private ShardingContexts shardingContexts; @@ -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); } @@ -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."); } } diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutorTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutorTest.java index a2c6e5e7bf..48df5fbeb9 100755 --- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutorTest.java +++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutorTest.java @@ -32,10 +32,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class LocalTaskExecutorTest { +class LocalTaskExecutorTest { @Test - public void assertSimpleJob() { + void assertSimpleJob() { TestSimpleJob simpleJob = new TestSimpleJob(); new LocalTaskExecutor(simpleJob, JobConfiguration.newBuilder(TestSimpleJob.class.getSimpleName(), 3) .cron("*/2 * * * * ?").shardingItemParameters("0=A,1=B").build(), 1).execute(); @@ -43,7 +43,7 @@ public void assertSimpleJob() { } @Test - public void assertDataflowJob() { + void assertDataflowJob() { TestDataflowJob dataflowJob = new TestDataflowJob(); new LocalTaskExecutor(dataflowJob, JobConfiguration.newBuilder(TestDataflowJob.class.getSimpleName(), 3) .cron("*/2 * * * * ?").setProperty(DataflowJobProperties.STREAM_PROCESS_KEY, Boolean.FALSE.toString()).build(), 1).execute(); @@ -52,13 +52,13 @@ public void assertDataflowJob() { } @Test - public void assertScriptJob() { + void assertScriptJob() { new LocalTaskExecutor(new TestDataflowJob(), JobConfiguration.newBuilder("TestScriptJob", 3) .cron("*/2 * * * * ?").setProperty(ScriptJobProperties.SCRIPT_KEY, "echo test").build(), 1).execute(); } @Test - public void assertNotExistsJobType() { + void assertNotExistsJobType() { assertThrows(JobConfigurationException.class, () -> new LocalTaskExecutor("not exist", JobConfiguration.newBuilder("not exist", 3).cron("*/2 * * * * ?").build(), 1).execute()); } } diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/DaemonTaskSchedulerTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/DaemonTaskSchedulerTest.java index 56658ee244..1aa0258afa 100755 --- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/DaemonTaskSchedulerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/DaemonTaskSchedulerTest.java @@ -45,7 +45,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DaemonTaskSchedulerTest { +class DaemonTaskSchedulerTest { @Mock private CloudJobFacade jobFacade; @@ -70,7 +70,7 @@ public final class DaemonTaskSchedulerTest { private DaemonJob daemonJob; @BeforeEach - public void setUp() { + void setUp() { daemonJob = new DaemonJob(); daemonJob.setJobFacade(jobFacade); daemonJob.setElasticJobType("SCRIPT"); @@ -79,7 +79,7 @@ public void setUp() { } @Test - public void assertJobRun() { + void assertJobRun() { when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); when(jobFacade.loadJobConfiguration(true)).thenReturn(createJobConfiguration()); daemonJob.execute(jobExecutionContext); @@ -90,7 +90,7 @@ public void assertJobRun() { } @Test - public void assertJobRunWithEventSampling() { + void assertJobRunWithEventSampling() { when(shardingContexts.getJobEventSamplingCount()).thenReturn(2); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); when(jobFacade.loadJobConfiguration(true)).thenReturn(createJobConfiguration()); @@ -111,7 +111,7 @@ private JobConfiguration createJobConfiguration() { @Test @SneakyThrows - public void assertInit() { + void assertInit() { DaemonTaskScheduler scheduler = createScheduler(); scheduler.init(); Field field = DaemonTaskScheduler.class.getDeclaredField("RUNNING_SCHEDULERS"); @@ -122,7 +122,7 @@ public void assertInit() { @Test @SneakyThrows - public void assertShutdown() { + void assertShutdown() { DaemonTaskScheduler scheduler = createScheduler(); scheduler.init(); DaemonTaskScheduler.shutdown(taskId); diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java index 1450e0b78e..411b29eaee 100755 --- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java +++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java @@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class TaskExecutorTest { +class TaskExecutorTest { @Mock private ExecutorDriver executorDriver; @@ -61,7 +61,7 @@ public final class TaskExecutorTest { private TaskExecutor taskExecutor; @BeforeEach - public void setUp() { + void setUp() { taskExecutor = new TaskExecutor(new TestSimpleJob()); setExecutorService(); executorInfo = ExecutorInfo.getDefaultInstance(); @@ -75,14 +75,14 @@ private void setExecutorService() { } @Test - public void assertKillTask() { + void assertKillTask() { TaskID taskID = Protos.TaskID.newBuilder().setValue("task_id").build(); taskExecutor.killTask(executorDriver, taskID); verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskID).setState(Protos.TaskState.TASK_KILLED).build()); } @Test - public void assertRegisteredWithoutData() { + void assertRegisteredWithoutData() { // CHECKSTYLE:OFF HashMap data = new HashMap<>(4, 1); // CHECKSTYLE:ON @@ -96,44 +96,44 @@ public void assertRegisteredWithoutData() { } @Test - public void assertRegisteredWithData() { + void assertRegisteredWithData() { taskExecutor.registered(executorDriver, executorInfo, frameworkInfo, slaveInfo); } @Test - public void assertLaunchTask() { + void assertLaunchTask() { taskExecutor.launchTask(executorDriver, TaskInfo.newBuilder().setName("test_job") .setTaskId(TaskID.newBuilder().setValue("fake_task_id")).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build()); } @Test - public void assertReregistered() { + void assertReregistered() { taskExecutor.reregistered(executorDriver, slaveInfo); } @Test - public void assertDisconnected() { + void assertDisconnected() { taskExecutor.disconnected(executorDriver); } @Test - public void assertFrameworkMessage() { + void assertFrameworkMessage() { taskExecutor.frameworkMessage(executorDriver, null); } @Test - public void assertShutdown() { + void assertShutdown() { taskExecutor.shutdown(executorDriver); } @Test - public void assertError() { + void assertError() { taskExecutor.error(executorDriver, ""); } @Test @SneakyThrows - public void assertConstructor() { + void assertConstructor() { TestSimpleJob testSimpleJob = new TestSimpleJob(); taskExecutor = new TaskExecutor(testSimpleJob); Field fieldElasticJob = TaskExecutor.class.getDeclaredField("elasticJob"); diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorThreadTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorThreadTest.java index ad0d521e96..ddbcf156a9 100755 --- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorThreadTest.java +++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorThreadTest.java @@ -43,7 +43,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class TaskExecutorThreadTest { +class TaskExecutorThreadTest { @Mock private ExecutorDriver executorDriver; @@ -51,7 +51,7 @@ public final class TaskExecutorThreadTest { private final String taskId = String.format("%s@-@0@-@%s@-@fake_slave_id@-@0", "test_job", ExecutionType.READY); @Test - public void assertLaunchTaskWithDaemonTaskAndJavaSimpleJob() { + void assertLaunchTaskWithDaemonTaskAndJavaSimpleJob() { TaskInfo taskInfo = buildJavaTransientTaskInfo(); TaskThread taskThread = new TaskExecutor(new TestSimpleJob()).new TaskThread(executorDriver, taskInfo); taskThread.run(); @@ -60,7 +60,7 @@ public void assertLaunchTaskWithDaemonTaskAndJavaSimpleJob() { } @Test - public void assertLaunchTaskWithDaemonTaskAndJavaScriptJob() { + void assertLaunchTaskWithDaemonTaskAndJavaScriptJob() { TaskInfo taskInfo = buildSpringScriptTransientTaskInfo(); TaskThread taskThread = new TaskExecutor(new TestSimpleJob()).new TaskThread(executorDriver, taskInfo); taskThread.run(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/AbstractCloudControllerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/AbstractCloudControllerTest.java index 7215f7a570..4a8dbcf237 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/AbstractCloudControllerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/AbstractCloudControllerTest.java @@ -57,7 +57,7 @@ public abstract class AbstractCloudControllerTest { private static RestfulService slaveServer; @BeforeAll - public static void setUpClass() { + static void setUpClass() { initRestfulServer(); initMesosServer(); } @@ -86,7 +86,7 @@ private static void initMesosServer() { } @AfterAll - public static void tearDown() { + static void tearDown() { consoleBootstrap.stop(); masterServer.shutdown(); slaveServer.shutdown(); @@ -94,7 +94,7 @@ public static void tearDown() { } @BeforeEach - public void setUp() { + void setUp() { reset(regCenter); reset(jobEventRdbSearch); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudAppControllerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudAppControllerTest.java index 65873c4d80..3980396e6c 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudAppControllerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudAppControllerTest.java @@ -35,7 +35,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class CloudAppControllerTest extends AbstractCloudControllerTest { +class CloudAppControllerTest extends AbstractCloudControllerTest { private static final String YAML = "appCacheEnable: true\n" + "appName: test_app\n" @@ -46,14 +46,14 @@ public class CloudAppControllerTest extends AbstractCloudControllerTest { + "memoryMB: 128.0\n"; @Test - public void assertRegister() { + void assertRegister() { when(getRegCenter().isExisted("/config/app/test_app")).thenReturn(false); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/app", CloudAppJsonConstants.getAppJson("test_app")), is(200)); verify(getRegCenter()).persist("/config/app/test_app", YAML); } @Test - public void assertRegisterWithExistedName() { + void assertRegisterWithExistedName() { when(getRegCenter().isExisted("/config/app/test_app")).thenReturn(false); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/app", CloudAppJsonConstants.getAppJson("test_app")), is(200)); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); @@ -61,12 +61,12 @@ public void assertRegisterWithExistedName() { } @Test - public void assertRegisterWithBadRequest() { + void assertRegisterWithBadRequest() { assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/app", "\"{\"appName\":\"wrong_job\"}"), is(500)); } @Test - public void assertUpdate() { + void assertUpdate() { when(getRegCenter().isExisted("/config/app/test_app")).thenReturn(true); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); assertThat(HttpTestUtil.put("http://127.0.0.1:19000/api/app", CloudAppJsonConstants.getAppJson("test_app")), is(200)); @@ -74,21 +74,21 @@ public void assertUpdate() { } @Test - public void assertDetail() { + void assertDetail() { when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/app/test_app"), is(CloudAppJsonConstants.getAppJson("test_app"))); verify(getRegCenter()).get("/config/app/test_app"); } @Test - public void assertDetailWithNotExistedJob() { + void assertDetailWithNotExistedJob() { Map content = new HashMap<>(1); content.put("appName", ""); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/app/notExistedJobName", content), is("")); } @Test - public void assertFindAllJobs() { + void assertFindAllJobs() { when(getRegCenter().isExisted("/config/app")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/app")).thenReturn(Collections.singletonList("test_app")); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); @@ -99,20 +99,20 @@ public void assertFindAllJobs() { } @Test - public void assertDeregister() { + void assertDeregister() { when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); assertThat(HttpTestUtil.delete("http://127.0.0.1:19000/api/app/test_app"), is(200)); verify(getRegCenter()).get("/config/app/test_app"); } @Test - public void assertIsDisabled() { + void assertIsDisabled() { when(getRegCenter().isExisted("/state/disable/app/test_app")).thenReturn(true); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/app/test_app/disable"), is("true")); } @Test - public void assertDisable() { + void assertDisable() { when(getRegCenter().isExisted("/config/job")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); @@ -123,7 +123,7 @@ public void assertDisable() { } @Test - public void assertEnable() { + void assertEnable() { when(getRegCenter().isExisted("/config/job")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudJobControllerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudJobControllerTest.java index bfa30436cb..61948b1eb1 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudJobControllerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudJobControllerTest.java @@ -49,7 +49,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class CloudJobControllerTest extends AbstractCloudControllerTest { +class CloudJobControllerTest extends AbstractCloudControllerTest { private static final String YAML = "appName: test_app\n" + "cpuCount: 1.0\n" @@ -70,7 +70,7 @@ public class CloudJobControllerTest extends AbstractCloudControllerTest { + "shardingTotalCount: 10\n"; @Test - public void assertRegister() { + void assertRegister() { when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); when(getRegCenter().isExisted("/config/job/test_job")).thenReturn(false); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/register", CloudJsonConstants.getJobJson()), is(200)); @@ -79,13 +79,13 @@ public void assertRegister() { } @Test - public void assertRegisterWithoutApp() { + void assertRegisterWithoutApp() { when(getRegCenter().isExisted("/config/job/test_job")).thenReturn(false); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/register", CloudJsonConstants.getJobJson()), is(500)); } @Test - public void assertRegisterWithExistedName() { + void assertRegisterWithExistedName() { when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); when(getRegCenter().get("/config/job/test_job")).thenReturn(null, CloudJsonConstants.getJobJson()); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/register", CloudJsonConstants.getJobJson()), is(200)); @@ -94,13 +94,13 @@ public void assertRegisterWithExistedName() { } @Test - public void assertRegisterWithBadRequest() { + void assertRegisterWithBadRequest() { when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/register", "\"{\"jobName\":\"wrong_job\"}"), is(500)); } @Test - public void assertUpdate() { + void assertUpdate() { when(getRegCenter().isExisted("/config/job/test_job")).thenReturn(true); when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); assertThat(HttpTestUtil.put("http://127.0.0.1:19000/api/job/update", CloudJsonConstants.getJobJson()), is(200)); @@ -109,33 +109,33 @@ public void assertUpdate() { } @Test - public void assertDeregister() { + void assertDeregister() { when(getRegCenter().isExisted("/config/job/test_job")).thenReturn(false); assertThat(HttpTestUtil.delete("http://127.0.0.1:19000/api/job/test_job/deregister"), is(200)); verify(getRegCenter(), times(3)).get("/config/job/test_job"); } @Test - public void assertTriggerWithDaemonJob() { + void assertTriggerWithDaemonJob() { when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson(CloudJobExecutionType.DAEMON)); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/trigger", "test_job"), is(500)); } @Test - public void assertTriggerWithTransientJob() { + void assertTriggerWithTransientJob() { when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/job/trigger", "test_job"), is(200)); } @Test - public void assertDetail() { + void assertDetail() { when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/jobs/test_job"), is(CloudJsonConstants.getJobJson())); verify(getRegCenter()).get("/config/job/test_job"); } @Test - public void assertFindAllJobs() { + void assertFindAllJobs() { when(getRegCenter().isExisted("/config/job")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); @@ -146,7 +146,7 @@ public void assertFindAllJobs() { } @Test - public void assertFindAllRunningTasks() { + void assertFindAllRunningTasks() { RunningService runningService = new RunningService(getRegCenter()); TaskContext actualTaskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); when(getRegCenter().get("/config/job/" + actualTaskContext.getMetaInfo().getJobName())).thenReturn(CloudJsonConstants.getJobJson()); @@ -155,7 +155,7 @@ public void assertFindAllRunningTasks() { } @Test - public void assertFindAllReadyTasks() { + void assertFindAllReadyTasks() { when(getRegCenter().isExisted("/state/ready")).thenReturn(true); when(getRegCenter().getChildrenKeys("/state/ready")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/state/ready/test_job")).thenReturn("1"); @@ -170,7 +170,7 @@ public void assertFindAllReadyTasks() { } @Test - public void assertFindAllFailoverTasks() { + void assertFindAllFailoverTasks() { when(getRegCenter().isExisted("/state/failover")).thenReturn(true); when(getRegCenter().getChildrenKeys("/state/failover")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().getChildrenKeys("/state/failover/test_job")).thenReturn(Collections.singletonList("test_job@-@0")); @@ -186,7 +186,7 @@ public void assertFindAllFailoverTasks() { } @Test - public void assertFindJobExecutionEventsWhenNotConfigRDB() { + void assertFindJobExecutionEventsWhenNotConfigRDB() { ReflectionUtils.setStaticFieldValue(CloudJobController.class, "jobEventRdbSearch", null); Map query = new HashMap<>(); query.put("per_page", "10"); @@ -196,19 +196,19 @@ public void assertFindJobExecutionEventsWhenNotConfigRDB() { } @Test - public void assertGetTaskResultStatistics() { + void assertGetTaskResultStatistics() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/results"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertGetTaskResultStatisticsWithSinceParameter() { + void assertGetTaskResultStatisticsWithSinceParameter() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/results?since=last24hours"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertGetTaskResultStatisticsWithPathParameter() { + void assertGetTaskResultStatisticsWithPathParameter() { String[] parameters = {"online", "lastWeek", "lastHour", "lastMinute"}; for (String each : parameters) { String result = HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/results/" + each); @@ -219,7 +219,7 @@ public void assertGetTaskResultStatisticsWithPathParameter() { } @Test - public void assertGetTaskResultStatisticsWithErrorPathParameter() { + void assertGetTaskResultStatisticsWithErrorPathParameter() { String result = HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/results/errorPath"); TaskResultStatistics taskResultStatistics = GsonFactory.getGson().fromJson(result, TaskResultStatistics.class); assertThat(taskResultStatistics.getSuccessCount(), is(0)); @@ -227,7 +227,7 @@ public void assertGetTaskResultStatisticsWithErrorPathParameter() { } @Test - public void assertGetJobExecutionTypeStatistics() { + void assertGetJobExecutionTypeStatistics() { String result = HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/jobs/executionType"); JobExecutionTypeStatistics jobExecutionTypeStatistics = GsonFactory.getGson().fromJson(result, JobExecutionTypeStatistics.class); assertThat(jobExecutionTypeStatistics.getDaemonJobCount(), is(0)); @@ -235,43 +235,43 @@ public void assertGetJobExecutionTypeStatistics() { } @Test - public void assertFindTaskRunningStatistics() { + void assertFindTaskRunningStatistics() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/running"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertFindTaskRunningStatisticsWeekly() { + void assertFindTaskRunningStatisticsWeekly() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/tasks/running?since=lastWeek"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertFindJobRunningStatistics() { + void assertFindJobRunningStatistics() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/jobs/running"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertFindJobRunningStatisticsWeekly() { + void assertFindJobRunningStatisticsWeekly() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/jobs/running?since=lastWeek"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertFindJobRegisterStatisticsSinceOnline() { + void assertFindJobRegisterStatisticsSinceOnline() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/statistics/jobs/register"), is(GsonFactory.getGson().toJson(Collections.emptyList()))); } @Test - public void assertIsDisabled() { + void assertIsDisabled() { when(getRegCenter().isExisted("/state/disable/job/test_job")).thenReturn(true); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/job/test_job/disable"), is("true")); } @Test - public void assertDisable() { + void assertDisable() { when(getRegCenter().isExisted("/config/job")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); @@ -281,7 +281,7 @@ public void assertDisable() { } @Test - public void assertEnable() { + void assertEnable() { when(getRegCenter().isExisted("/config/job")).thenReturn(true); when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job")); when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudLoginTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudLoginTest.java index 67197221ca..c47b897d8a 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudLoginTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudLoginTest.java @@ -37,10 +37,10 @@ import static org.hamcrest.MatcherAssert.assertThat; @ExtendWith(MockitoExtension.class) -public class CloudLoginTest extends AbstractCloudControllerTest { +class CloudLoginTest extends AbstractCloudControllerTest { @Test - public void assertLoginSuccess() throws IOException { + void assertLoginSuccess() throws IOException { Map authInfo = new HashMap<>(); authInfo.put("username", "root"); authInfo.put("password", "pwd"); @@ -53,7 +53,7 @@ public void assertLoginSuccess() throws IOException { } @Test - public void assertLoginFail() { + void assertLoginFail() { Map authInfo = new HashMap<>(); authInfo.put("username", "root"); authInfo.put("password", ""); @@ -62,7 +62,7 @@ public void assertLoginFail() { } @Test - public void assertUnauthorized() { + void assertUnauthorized() { assertThat(HttpTestUtil.unauthorizedGet("http://127.0.0.1:19000/api/unauthorized"), is(401)); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudOperationControllerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudOperationControllerTest.java index d39f9cd0b8..95d306303a 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudOperationControllerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/CloudOperationControllerTest.java @@ -30,24 +30,24 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class CloudOperationControllerTest extends AbstractCloudControllerTest { +class CloudOperationControllerTest extends AbstractCloudControllerTest { @Test - public void assertExplicitReconcile() { + void assertExplicitReconcile() { ReflectionUtils.setFieldValue(new CloudOperationController(), "lastReconcileTime", 0); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/operate/reconcile/explicit", ""), is(200)); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/operate/reconcile/explicit", ""), is(500)); } @Test - public void assertImplicitReconcile() { + void assertImplicitReconcile() { ReflectionUtils.setFieldValue(new CloudOperationController(), "lastReconcileTime", 0); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/operate/reconcile/implicit", ""), is(200)); assertThat(HttpTestUtil.post("http://127.0.0.1:19000/api/operate/reconcile/implicit", ""), is(500)); } @Test - public void assertSandbox() { + void assertSandbox() { when(getRegCenter().getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000"); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/operate/sandbox?appName=foo_app"), is("[{\"hostname\":\"127.0.0.1\"," + "\"path\":\"/slaves/d8701508-41b7-471e-9b32-61cf824a660d-S0/frameworks/d8701508-41b7-471e-9b32-61cf824a660d-0000/executors/foo_app@-@" @@ -55,7 +55,7 @@ public void assertSandbox() { } @Test - public void assertNoFrameworkSandbox() { + void assertNoFrameworkSandbox() { assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/operate/sandbox?appName=foo_app"), is("[]")); when(getRegCenter().getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("not-exists"); assertThat(HttpTestUtil.get("http://127.0.0.1:19000/api/operate/sandbox?appName=foo_app"), is("[]")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/search/JobEventRdbSearchTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/search/JobEventRdbSearchTest.java index c143b5165b..3352a42d52 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/search/JobEventRdbSearchTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/console/controller/search/JobEventRdbSearchTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobEventRdbSearchTest { +class JobEventRdbSearchTest { @Mock private DataSource dataSource; @@ -61,7 +61,7 @@ public final class JobEventRdbSearchTest { private JobEventRdbSearch jobEventRdbSearch; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { jobEventRdbSearch = new JobEventRdbSearch(dataSource); when(dataSource.getConnection()).thenReturn(conn); when(conn.prepareStatement(any())).thenReturn(preparedStatement); @@ -72,7 +72,7 @@ public void setUp() throws Exception { @Test @SneakyThrows - public void assertFindJobExecutionEvents() { + void assertFindJobExecutionEvents() { when(resultSet.getString(5)).thenReturn("TestJobName"); when(resultSet.getString(6)).thenReturn("FAILOVER"); when(resultSet.getString(7)).thenReturn("1"); @@ -90,7 +90,7 @@ public void assertFindJobExecutionEvents() { @Test @SneakyThrows - public void assertFindJobStatusTraceEvents() { + void assertFindJobStatusTraceEvents() { when(resultSet.getString(2)).thenReturn("TestJobName"); when(resultSet.getString(6)).thenReturn("LITE_EXECUTOR"); when(resultSet.getString(9)).thenReturn("TASK_RUNNING"); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationListenerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationListenerTest.java index 91ae56658a..29d8bd676a 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationListenerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationListenerTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class CloudAppConfigurationListenerTest { +class CloudAppConfigurationListenerTest { private static ZookeeperRegistryCenter regCenter; @@ -54,7 +54,7 @@ public final class CloudAppConfigurationListenerTest { private CloudAppConfigurationListener cloudAppConfigurationListener; @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(cloudAppConfigurationListener, "producerManager", producerManager); ReflectionUtils.setFieldValue(cloudAppConfigurationListener, "mesosStateService", mesosStateService); initRegistryCenter(); @@ -72,7 +72,7 @@ private void initRegistryCenter() { } @Test - public void assertRemoveWithInvalidPath() { + void assertRemoveWithInvalidPath() { cloudAppConfigurationListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/other/test_app", null, "".getBytes()), new ChildData("/other/test_app", null, "".getBytes())); verify(mesosStateService, times(0)).executors(ArgumentMatchers.any()); @@ -80,7 +80,7 @@ public void assertRemoveWithInvalidPath() { } @Test - public void assertRemoveWithNoAppNamePath() { + void assertRemoveWithNoAppNamePath() { cloudAppConfigurationListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/config/app", null, "".getBytes()), new ChildData("/config/app", null, "".getBytes())); verify(mesosStateService, times(0)).executors(ArgumentMatchers.any()); @@ -88,19 +88,19 @@ public void assertRemoveWithNoAppNamePath() { } @Test - public void assertRemoveApp() { + void assertRemoveApp() { cloudAppConfigurationListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/config/app/test_app", null, "".getBytes()), new ChildData("/config/app/test_app", null, "".getBytes())); verify(mesosStateService).executors("test_app"); } @Test - public void start() { + void start() { cloudAppConfigurationListener.start(); } @Test - public void stop() { + void stop() { regCenter.addCacheData(CloudAppConfigurationNode.ROOT); ReflectionUtils.setFieldValue(cloudAppConfigurationListener, "regCenter", regCenter); cloudAppConfigurationListener.stop(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationNodeTest.java index fb4372febb..bbc9dd4318 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationNodeTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class CloudAppConfigurationNodeTest { +class CloudAppConfigurationNodeTest { @Test - public void assertGetRootNodePath() { + void assertGetRootNodePath() { assertThat(CloudAppConfigurationNode.getRootNodePath("test_job_app"), is("/config/app/test_job_app")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationServiceTest.java index de655e58b8..d873b22f96 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/CloudAppConfigurationServiceTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class CloudAppConfigurationServiceTest { +class CloudAppConfigurationServiceTest { private static final String YAML = "appCacheEnable: true\n" + "appName: test_app\n" @@ -56,28 +56,28 @@ public final class CloudAppConfigurationServiceTest { private CloudAppConfigurationService configService; @Test - public void assertAdd() { + void assertAdd() { CloudAppConfigurationPOJO appConfig = CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app"); configService.add(appConfig); verify(regCenter).persist("/config/app/test_app", YAML); } @Test - public void assertUpdate() { + void assertUpdate() { CloudAppConfigurationPOJO appConfig = CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app"); configService.update(appConfig); verify(regCenter).update("/config/app/test_app", YAML); } @Test - public void assertLoadAllWithoutRootNode() { + void assertLoadAllWithoutRootNode() { when(regCenter.isExisted("/config/app")).thenReturn(false); assertTrue(configService.loadAll().isEmpty()); verify(regCenter).isExisted("/config/app"); } @Test - public void assertLoadAllWithRootNode() { + void assertLoadAllWithRootNode() { when(regCenter.isExisted("/config/app")).thenReturn(true); when(regCenter.getChildrenKeys(CloudAppConfigurationNode.ROOT)).thenReturn(Arrays.asList("test_app_1", "test_app_2")); when(regCenter.get("/config/app/test_app_1")).thenReturn(CloudAppJsonConstants.getAppJson("test_app_1")); @@ -91,12 +91,12 @@ public void assertLoadAllWithRootNode() { } @Test - public void assertLoadWithoutConfig() { + void assertLoadWithoutConfig() { assertFalse(configService.load("test_app").isPresent()); } @Test - public void assertLoadWithConfig() { + void assertLoadWithConfig() { when(regCenter.get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app")); Optional actual = configService.load("test_app"); assertTrue(actual.isPresent()); @@ -104,7 +104,7 @@ public void assertLoadWithConfig() { } @Test - public void assertRemove() { + void assertRemove() { configService.remove("test_app"); verify(regCenter).remove("/config/app/test_app"); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/pojo/CloudAppConfigurationPOJOTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/pojo/CloudAppConfigurationPOJOTest.java index bbb076386e..366390d504 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/pojo/CloudAppConfigurationPOJOTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/app/pojo/CloudAppConfigurationPOJOTest.java @@ -24,10 +24,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class CloudAppConfigurationPOJOTest { +class CloudAppConfigurationPOJOTest { @Test - public void assertToCloudAppConfiguration() { + void assertToCloudAppConfiguration() { CloudAppConfigurationPOJO pojo = new CloudAppConfigurationPOJO(); pojo.setAppName("app"); pojo.setAppURL("url"); @@ -43,7 +43,7 @@ public void assertToCloudAppConfiguration() { } @Test - public void assertFromCloudAppConfiguration() { + void assertFromCloudAppConfiguration() { CloudAppConfigurationPOJO actual = CloudAppConfigurationPOJO.fromCloudAppConfiguration(new CloudAppConfiguration("app", "url", "start.sh")); assertThat(actual.getAppName(), is("app")); assertThat(actual.getAppURL(), is("url")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationListenerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationListenerTest.java index 328e2c09e0..34bdcfba27 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationListenerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationListenerTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class CloudJobConfigurationListenerTest { +public class CloudJobConfigurationListenerTest { private static ZookeeperRegistryCenter regCenter; @@ -55,7 +55,7 @@ public final class CloudJobConfigurationListenerTest { private CloudJobConfigurationListener cloudJobConfigurationListener; @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(cloudJobConfigurationListener, "producerManager", producerManager); ReflectionUtils.setFieldValue(cloudJobConfigurationListener, "readyService", readyService); initRegistryCenter(); @@ -73,7 +73,7 @@ private void initRegistryCenter() { } @Test - public void assertChildEventWhenIsNotConfigPath() { + void assertChildEventWhenIsNotConfigPath() { cloudJobConfigurationListener.event(Type.NODE_CHANGED, null, new ChildData("/other/test_job", null, "".getBytes())); verify(producerManager, times(0)).schedule(ArgumentMatchers.any()); verify(producerManager, times(0)).reschedule(ArgumentMatchers.any()); @@ -81,7 +81,7 @@ public void assertChildEventWhenIsNotConfigPath() { } @Test - public void assertChildEventWhenIsRootConfigPath() { + void assertChildEventWhenIsRootConfigPath() { cloudJobConfigurationListener.event(Type.NODE_DELETED, new ChildData("/config/job", null, "".getBytes()), new ChildData("/config/job", null, "".getBytes())); verify(producerManager, times(0)).schedule(ArgumentMatchers.any()); @@ -90,7 +90,7 @@ public void assertChildEventWhenIsRootConfigPath() { } @Test - public void assertChildEventWhenStateIsAddAndIsConfigPathAndInvalidData() { + void assertChildEventWhenStateIsAddAndIsConfigPathAndInvalidData() { cloudJobConfigurationListener.event(Type.NODE_CREATED, null, new ChildData("/config/job/test_job", null, "".getBytes())); verify(producerManager, times(0)).schedule(ArgumentMatchers.any()); verify(producerManager, times(0)).reschedule(ArgumentMatchers.any()); @@ -98,51 +98,51 @@ public void assertChildEventWhenStateIsAddAndIsConfigPathAndInvalidData() { } @Test - public void assertChildEventWhenStateIsAddAndIsConfigPath() { + void assertChildEventWhenStateIsAddAndIsConfigPath() { cloudJobConfigurationListener.event(Type.NODE_CREATED, null, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson().getBytes())); verify(producerManager).schedule(ArgumentMatchers.any()); } @Test - public void assertChildEventWhenStateIsUpdateAndIsConfigPathAndTransientJob() { + void assertChildEventWhenStateIsUpdateAndIsConfigPathAndTransientJob() { cloudJobConfigurationListener.event(Type.NODE_CHANGED, null, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson().getBytes())); verify(readyService, times(0)).remove(Collections.singletonList("test_job")); verify(producerManager).reschedule(ArgumentMatchers.any()); } @Test - public void assertChildEventWhenStateIsUpdateAndIsConfigPathAndDaemonJob() { + void assertChildEventWhenStateIsUpdateAndIsConfigPathAndDaemonJob() { cloudJobConfigurationListener.event(Type.NODE_CHANGED, null, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson(CloudJobExecutionType.DAEMON).getBytes())); verify(readyService).remove(Collections.singletonList("test_job")); verify(producerManager).reschedule(ArgumentMatchers.any()); } @Test - public void assertChildEventWhenStateIsUpdateAndIsConfigPathAndMisfireDisabled() { + void assertChildEventWhenStateIsUpdateAndIsConfigPathAndMisfireDisabled() { cloudJobConfigurationListener.event(Type.NODE_CHANGED, null, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson(false).getBytes())); verify(readyService).setMisfireDisabled("test_job"); verify(producerManager).reschedule(ArgumentMatchers.any()); } @Test - public void assertChildEventWhenStateIsRemovedAndIsJobConfigPath() { + void assertChildEventWhenStateIsRemovedAndIsJobConfigPath() { cloudJobConfigurationListener.event(Type.NODE_DELETED, new ChildData("/config/job/test_job", null, "".getBytes()), new ChildData("/config/job/test_job", null, "".getBytes())); verify(producerManager).unschedule("test_job"); } @Test - public void assertChildEventWhenStateIsUpdateAndIsConfigPath() { + void assertChildEventWhenStateIsUpdateAndIsConfigPath() { cloudJobConfigurationListener.event(Type.NODE_CHANGED, null, new ChildData("/config/job/test_job", null, "".getBytes())); } @Test - public void assertStart() { + void assertStart() { cloudJobConfigurationListener.start(); } @Test - public void assertStop() { + void assertStop() { regCenter.addCacheData(CloudJobConfigurationNode.ROOT); ReflectionUtils.setFieldValue(cloudJobConfigurationListener, "regCenter", regCenter); cloudJobConfigurationListener.stop(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationNodeTest.java index 5045f5e471..baec18760a 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationNodeTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class CloudJobConfigurationNodeTest { +class CloudJobConfigurationNodeTest { @Test - public void assertGetRootNodePath() { + void assertGetRootNodePath() { assertThat(CloudJobConfigurationNode.getRootNodePath("test_job"), is("/config/job/test_job")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationServiceTest.java index eb01b20109..6132905c3e 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/config/job/CloudJobConfigurationServiceTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class CloudJobConfigurationServiceTest { +class CloudJobConfigurationServiceTest { private static final String YAML = "appName: test_app\n" + "cpuCount: 1.0\n" @@ -66,28 +66,28 @@ public final class CloudJobConfigurationServiceTest { private CloudJobConfigurationService configService; @Test - public void assertAdd() { + void assertAdd() { CloudJobConfigurationPOJO cloudJobConfig = CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"); configService.add(cloudJobConfig); verify(regCenter).persist("/config/job/test_job", YAML); } @Test - public void assertUpdate() { + void assertUpdate() { CloudJobConfigurationPOJO cloudJobConfig = CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"); configService.update(cloudJobConfig); verify(regCenter).update("/config/job/test_job", YAML); } @Test - public void assertLoadAllWithoutRootNode() { + void assertLoadAllWithoutRootNode() { when(regCenter.isExisted("/config/job")).thenReturn(false); assertTrue(configService.loadAll().isEmpty()); verify(regCenter).isExisted("/config/job"); } @Test - public void assertLoadAllWithRootNode() { + void assertLoadAllWithRootNode() { when(regCenter.isExisted("/config/job")).thenReturn(true); when(regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT)).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.get("/config/job/test_job_1")).thenReturn(CloudJsonConstants.getJobJson("test_job_1")); @@ -101,12 +101,12 @@ public void assertLoadAllWithRootNode() { } @Test - public void assertLoadWithoutConfig() { + void assertLoadWithoutConfig() { assertFalse(configService.load("test_job").isPresent()); } @Test - public void assertLoadWithConfig() { + void assertLoadWithConfig() { when(regCenter.get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); Optional actual = configService.load("test_job"); assertTrue(actual.isPresent()); @@ -114,14 +114,14 @@ public void assertLoadWithConfig() { } @Test - public void assertLoadWithSpringConfig() { + void assertLoadWithSpringConfig() { when(regCenter.get("/config/job/test_spring_job")).thenReturn(CloudJsonConstants.getSpringJobJson()); Optional actual = configService.load("test_spring_job"); assertTrue(actual.isPresent()); } @Test - public void assertRemove() { + void assertRemove() { configService.remove("test_job"); verify(regCenter).remove("/config/job/test_job"); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/context/JobContextTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/context/JobContextTest.java index 7d820a004c..35228cad2f 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/context/JobContextTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/context/JobContextTest.java @@ -25,10 +25,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobContextTest { +class JobContextTest { @Test - public void assertFrom() { + void assertFrom() { CloudJobConfiguration cloudJobConfig = CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job").toCloudJobConfiguration(); JobContext actual = JobContext.from(cloudJobConfig, ExecutionType.READY); assertThat(actual.getAssignedShardingItems().size(), is(10)); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java index e140d416cd..1fc195cfb4 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java @@ -31,12 +31,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; -public final class BootstrapEnvironmentTest { +class BootstrapEnvironmentTest { private final BootstrapEnvironment bootstrapEnvironment = BootstrapEnvironment.getINSTANCE(); @Test - public void assertGetMesosConfiguration() { + void assertGetMesosConfiguration() { MesosConfiguration mesosConfig = bootstrapEnvironment.getMesosConfiguration(); assertThat(mesosConfig.getHostname(), is("localhost")); assertThat(mesosConfig.getUser(), is("")); @@ -44,7 +44,7 @@ public void assertGetMesosConfiguration() { } @Test - public void assertGetZookeeperConfiguration() { + void assertGetZookeeperConfiguration() { Properties properties = new Properties(); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.ZOOKEEPER_DIGEST.getKey(), "test"); ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", properties); @@ -55,19 +55,19 @@ public void assertGetZookeeperConfiguration() { } @Test - public void assertGetRestfulServerConfiguration() { + void assertGetRestfulServerConfiguration() { RestfulServerConfiguration restfulServerConfig = bootstrapEnvironment.getRestfulServerConfiguration(); assertThat(restfulServerConfig.getPort(), is(8899)); } @Test - public void assertGetFrameworkConfiguration() { + void assertGetFrameworkConfiguration() { FrameworkConfiguration frameworkConfig = bootstrapEnvironment.getFrameworkConfiguration(); assertThat(frameworkConfig.getJobStateQueueSize(), is(10000)); } @Test - public void assertGetEventTraceRdbConfiguration() { + void assertGetEventTraceRdbConfiguration() { Properties properties = new Properties(); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.EVENT_TRACE_RDB_DRIVER.getKey(), "org.h2.Driver"); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.EVENT_TRACE_RDB_URL.getKey(), "jdbc:h2:mem:job_event_trace"); @@ -78,12 +78,12 @@ public void assertGetEventTraceRdbConfiguration() { } @Test - public void assertWithoutEventTraceRdbConfiguration() { + void assertWithoutEventTraceRdbConfiguration() { assertFalse(bootstrapEnvironment.getTracingConfiguration().isPresent()); } @Test - public void assertGetEventTraceRdbConfigurationMap() { + void assertGetEventTraceRdbConfigurationMap() { Properties properties = new Properties(); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.EVENT_TRACE_RDB_DRIVER.getKey(), "org.h2.Driver"); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.EVENT_TRACE_RDB_URL.getKey(), "jdbc:h2:mem:job_event_trace"); @@ -98,7 +98,7 @@ public void assertGetEventTraceRdbConfigurationMap() { } @Test - public void assertReconcileConfiguration() { + void assertReconcileConfiguration() { FrameworkConfiguration configuration = bootstrapEnvironment.getFrameworkConfiguration(); assertThat(configuration.getReconcileIntervalMinutes(), is(-1)); assertFalse(configuration.isEnabledReconcile()); @@ -111,7 +111,7 @@ public void assertReconcileConfiguration() { } @Test - public void assertGetMesosRole() { + void assertGetMesosRole() { assertThat(bootstrapEnvironment.getMesosRole(), is(Optional.empty())); Properties properties = new Properties(); properties.setProperty(BootstrapEnvironment.EnvironmentArgument.MESOS_ROLE.getKey(), "0"); @@ -120,7 +120,7 @@ public void assertGetMesosRole() { } @Test - public void assertGetFrameworkHostPort() { + void assertGetFrameworkHostPort() { Properties properties = new Properties(); ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", properties); assertThat(bootstrapEnvironment.getFrameworkHostPort(), is("localhost:8899")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/ha/FrameworkIDServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/ha/FrameworkIDServiceTest.java index db0cf36921..9a43a4171d 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/ha/FrameworkIDServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/ha/FrameworkIDServiceTest.java @@ -33,7 +33,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class FrameworkIDServiceTest { +class FrameworkIDServiceTest { @Mock private CoordinatorRegistryCenter registryCenter; @@ -41,12 +41,12 @@ public class FrameworkIDServiceTest { private FrameworkIDService frameworkIDService; @BeforeEach - public void init() { + void init() { frameworkIDService = new FrameworkIDService(registryCenter); } @Test - public void assertFetch() { + void assertFetch() { when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("1"); Optional frameworkIDOptional = frameworkIDService.fetch(); assertTrue(frameworkIDOptional.isPresent()); @@ -55,7 +55,7 @@ public void assertFetch() { } @Test - public void assertSave() { + void assertSave() { when(registryCenter.isExisted(HANode.FRAMEWORK_ID_NODE)).thenReturn(false); frameworkIDService.save("1"); verify(registryCenter).isExisted(HANode.FRAMEWORK_ID_NODE); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java index c8db6d3e0f..a90e1a1ceb 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java @@ -49,7 +49,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public final class AppConstraintEvaluatorTest { +class AppConstraintEvaluatorTest { private static final double SUFFICIENT_CPU = 1.0 * 13; @@ -64,24 +64,24 @@ public final class AppConstraintEvaluatorTest { private TaskScheduler taskScheduler; @BeforeAll - public static void init() { + static void init() { facadeService = mock(FacadeService.class); AppConstraintEvaluator.init(facadeService); } @BeforeEach - public void setUp() { + void setUp() { taskScheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(1000000000L).withLeaseRejectAction(virtualMachineLease -> { }).build(); } @AfterEach - public void tearDown() { + void tearDown() { AppConstraintEvaluator.getInstance().clearAppRunningState(); } @Test - public void assertFirstLaunch() { + void assertFirstLaunch() { SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, SUFFICIENT_CPU, SUFFICIENT_MEM), getLease(1, SUFFICIENT_CPU, SUFFICIENT_MEM))); assertThat(result.getResultMap().size(), is(2)); assertThat(result.getFailures().size(), is(0)); @@ -89,21 +89,21 @@ public void assertFirstLaunch() { } @Test - public void assertFirstLaunchLackCpu() { + void assertFirstLaunchLackCpu() { SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, INSUFFICIENT_CPU, SUFFICIENT_MEM), getLease(1, INSUFFICIENT_CPU, SUFFICIENT_MEM))); assertThat(result.getResultMap().size(), is(2)); assertThat(getAssignedTaskNumber(result), is(18)); } @Test - public void assertFirstLaunchLackMem() { + void assertFirstLaunchLackMem() { SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, SUFFICIENT_CPU, INSUFFICIENT_MEM), getLease(1, SUFFICIENT_CPU, INSUFFICIENT_MEM))); assertThat(result.getResultMap().size(), is(2)); assertThat(getAssignedTaskNumber(result), is(18)); } @Test - public void assertExistExecutorOnS0() { + void assertExistExecutorOnS0() { when(facadeService.loadExecutorInfo()).thenReturn(Collections.singletonList(new ExecutorStateInfo("foo-app@-@S0", "S0"))); AppConstraintEvaluator.getInstance().loadAppRunningState(); SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, INSUFFICIENT_CPU, INSUFFICIENT_MEM), getLease(1, INSUFFICIENT_CPU, INSUFFICIENT_MEM))); @@ -112,7 +112,7 @@ public void assertExistExecutorOnS0() { } @Test - public void assertGetExecutorError() { + void assertGetExecutorError() { when(facadeService.loadExecutorInfo()).thenThrow(JsonParseException.class); AppConstraintEvaluator.getInstance().loadAppRunningState(); SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, INSUFFICIENT_CPU, INSUFFICIENT_MEM), getLease(1, INSUFFICIENT_CPU, INSUFFICIENT_MEM))); @@ -121,7 +121,7 @@ public void assertGetExecutorError() { } @Test - public void assertLackJobConfig() { + void assertLackJobConfig() { when(facadeService.load("test")).thenReturn(Optional.empty()); SchedulingResult result = taskScheduler.scheduleOnce(Collections.singletonList(getTask("test")), Collections.singletonList(getLease(0, 1.5, 192))); assertThat(result.getResultMap().size(), is(1)); @@ -129,7 +129,7 @@ public void assertLackJobConfig() { } @Test - public void assertLackAppConfig() { + void assertLackAppConfig() { when(facadeService.load("test")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test"))); when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.empty()); SchedulingResult result = taskScheduler.scheduleOnce(Collections.singletonList(getTask("test")), Collections.singletonList(getLease(0, 1.5, 192))); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java index 21f72f1b59..ae00cfb4cd 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java @@ -59,7 +59,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class FacadeServiceTest { +class FacadeServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -91,7 +91,7 @@ public final class FacadeServiceTest { private FacadeService facadeService; @BeforeEach - public void setUp() { + void setUp() { facadeService = new FacadeService(regCenter); ReflectionUtils.setFieldValue(facadeService, "jobConfigService", jobConfigService); ReflectionUtils.setFieldValue(facadeService, "appConfigService", appConfigService); @@ -104,13 +104,13 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { facadeService.start(); verify(runningService).start(); } @Test - public void assertGetEligibleJobContext() { + void assertGetEligibleJobContext() { Collection failoverJobContexts = Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder .createCloudJobConfiguration("failover_job").toCloudJobConfiguration(), ExecutionType.FAILOVER)); Collection readyJobContexts = Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder @@ -136,7 +136,7 @@ public void assertGetEligibleJobContext() { } @Test - public void assertRemoveLaunchTasksFromQueue() { + void assertRemoveLaunchTasksFromQueue() { facadeService.removeLaunchTasksFromQueue(Arrays.asList( TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()), TaskContext.from(TaskNode.builder().build().getTaskNodeValue()))); @@ -145,21 +145,21 @@ public void assertRemoveLaunchTasksFromQueue() { } @Test - public void assertAddRunning() { + void assertAddRunning() { TaskContext taskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); facadeService.addRunning(taskContext); verify(runningService).add(taskContext); } @Test - public void assertUpdateDaemonStatus() { + void assertUpdateDaemonStatus() { TaskContext taskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); facadeService.updateDaemonStatus(taskContext, true); verify(runningService).updateIdle(taskContext, true); } @Test - public void assertRemoveRunning() { + void assertRemoveRunning() { String taskNodeValue = TaskNode.builder().build().getTaskNodeValue(); TaskContext taskContext = TaskContext.from(taskNodeValue); facadeService.removeRunning(taskContext); @@ -167,7 +167,7 @@ public void assertRemoveRunning() { } @Test - public void assertRecordFailoverTaskWhenJobConfigNotExisted() { + void assertRecordFailoverTaskWhenJobConfigNotExisted() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(jobConfigService.load("test_job")).thenReturn(Optional.empty()); facadeService.recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue())); @@ -175,7 +175,7 @@ public void assertRecordFailoverTaskWhenJobConfigNotExisted() { } @Test - public void assertRecordFailoverTaskWhenIsFailoverDisabled() { + void assertRecordFailoverTaskWhenIsFailoverDisabled() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createOtherCloudJobConfiguration("test_job"))); facadeService.recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue())); @@ -183,7 +183,7 @@ public void assertRecordFailoverTaskWhenIsFailoverDisabled() { } @Test - public void assertRecordFailoverTaskWhenIsFailoverDisabledAndIsDaemonJob() { + void assertRecordFailoverTaskWhenIsFailoverDisabledAndIsDaemonJob() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); facadeService.recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue())); @@ -191,7 +191,7 @@ public void assertRecordFailoverTaskWhenIsFailoverDisabledAndIsDaemonJob() { } @Test - public void assertRecordFailoverTaskWhenIsFailoverEnabled() { + void assertRecordFailoverTaskWhenIsFailoverEnabled() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue()); @@ -200,76 +200,76 @@ public void assertRecordFailoverTaskWhenIsFailoverEnabled() { } @Test - public void assertLoadAppConfig() { + void assertLoadAppConfig() { Optional appConfigOptional = Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app")); when(appConfigService.load("test_app")).thenReturn(appConfigOptional); assertThat(facadeService.loadAppConfig("test_app"), is(appConfigOptional)); } @Test - public void assertLoadJobConfig() { + void assertLoadJobConfig() { Optional cloudJobConfig = Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")); when(jobConfigService.load("test_job")).thenReturn(cloudJobConfig); assertThat(facadeService.load("test_job"), is(cloudJobConfig)); } @Test - public void assertLoadAppConfigWhenAbsent() { + void assertLoadAppConfigWhenAbsent() { when(appConfigService.load("test_app")).thenReturn(Optional.empty()); assertThat(facadeService.loadAppConfig("test_app"), is(Optional.empty())); } @Test - public void assertLoadJobConfigWhenAbsent() { + void assertLoadJobConfigWhenAbsent() { when(jobConfigService.load("test_job")).thenReturn(Optional.empty()); assertThat(facadeService.load("test_job"), is(Optional.empty())); } @Test - public void assertAddDaemonJobToReadyQueue() { + void assertAddDaemonJobToReadyQueue() { when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); facadeService.addDaemonJobToReadyQueue("test_job"); verify(readyService).addDaemon("test_job"); } @Test - public void assertIsRunningForReadyJobAndNotRunning() { + void assertIsRunningForReadyJobAndNotRunning() { when(runningService.getRunningTasks("test_job")).thenReturn(Collections.emptyList()); assertFalse(facadeService.isRunning(TaskContext.from(TaskNode.builder().type(ExecutionType.READY).build().getTaskNodeValue()))); } @Test - public void assertIsRunningForFailoverJobAndNotRunning() { + void assertIsRunningForFailoverJobAndNotRunning() { when(runningService.isTaskRunning(TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()).getMetaInfo())).thenReturn(false); assertFalse(facadeService.isRunning(TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()))); } @Test - public void assertIsRunningForFailoverJobAndRunning() { + void assertIsRunningForFailoverJobAndRunning() { when(runningService.isTaskRunning(TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()).getMetaInfo())).thenReturn(true); assertTrue(facadeService.isRunning(TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()))); } @Test - public void assertAddMapping() { + void assertAddMapping() { facadeService.addMapping("taskId", "localhost"); verify(runningService).addMapping("taskId", "localhost"); } @Test - public void assertPopMapping() { + void assertPopMapping() { facadeService.popMapping("taskId"); verify(runningService).popMapping("taskId"); } @Test - public void assertStop() { + void assertStop() { facadeService.stop(); verify(runningService).clear(); } @Test - public void assertGetFailoverTaskId() { + void assertGetFailoverTaskId() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue()); @@ -280,7 +280,7 @@ public void assertGetFailoverTaskId() { } @Test - public void assertJobDisabledWhenAppEnabled() { + void assertJobDisabledWhenAppEnabled() { when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); when(disableAppService.isDisabled("test_app")).thenReturn(false); when(disableJobService.isDisabled("test_job")).thenReturn(true); @@ -288,20 +288,20 @@ public void assertJobDisabledWhenAppEnabled() { } @Test - public void assertIsJobEnabled() { + void assertIsJobEnabled() { when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); assertFalse(facadeService.isJobDisabled("test_job")); } @Test - public void assertIsJobDisabledWhenAppDisabled() { + void assertIsJobDisabledWhenAppDisabled() { when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); when(disableAppService.isDisabled("test_app")).thenReturn(true); assertTrue(facadeService.isJobDisabled("test_job")); } @Test - public void assertIsJobDisabledWhenAppEnabled() { + void assertIsJobDisabledWhenAppEnabled() { when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); when(disableAppService.isDisabled("test_app")).thenReturn(false); when(disableJobService.isDisabled("test_job")).thenReturn(true); @@ -309,19 +309,19 @@ public void assertIsJobDisabledWhenAppEnabled() { } @Test - public void assertEnableJob() { + void assertEnableJob() { facadeService.enableJob("test_job"); verify(disableJobService).remove("test_job"); } @Test - public void assertDisableJob() { + void assertDisableJob() { facadeService.disableJob("test_job"); verify(disableJobService).add("test_job"); } @Test - public void assertLoadExecutor() { + void assertLoadExecutor() { facadeService.loadExecutorInfo(); verify(mesosStateService).executors(); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/JobTaskRequestTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/JobTaskRequestTest.java index c9d4a4d192..a5d918fe89 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/JobTaskRequestTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/JobTaskRequestTest.java @@ -30,75 +30,75 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class JobTaskRequestTest { +class JobTaskRequestTest { private final JobTaskRequest jobTaskRequest = new JobTaskRequest(new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "unassigned-slave"), CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job").toCloudJobConfiguration()); @Test - public void assertGetId() { + void assertGetId() { assertThat(jobTaskRequest.getId(), StringStartsWith.startsWith("test_job@-@0@-@READY@-@unassigned-slave")); } @Test - public void assertTaskGroupName() { + void assertTaskGroupName() { assertThat(jobTaskRequest.taskGroupName(), is("")); } @Test - public void assertGetCPUs() { + void assertGetCPUs() { assertThat(jobTaskRequest.getCPUs(), is(1.0d)); } @Test - public void assertGetMemory() { + void assertGetMemory() { assertThat(jobTaskRequest.getMemory(), is(128.0d)); } @Test - public void assertGetNetworkMbps() { + void assertGetNetworkMbps() { assertThat(jobTaskRequest.getNetworkMbps(), is(0d)); } @Test - public void assertGetDisk() { + void assertGetDisk() { assertThat(jobTaskRequest.getDisk(), is(10d)); } @Test - public void assertGetPorts() { + void assertGetPorts() { assertThat(jobTaskRequest.getPorts(), is(1)); } @Test - public void assertGetScalarRequests() { + void assertGetScalarRequests() { assertNull(jobTaskRequest.getScalarRequests()); } @Test - public void assertGetHardConstraints() { + void assertGetHardConstraints() { AppConstraintEvaluator.init(null); assertThat(jobTaskRequest.getHardConstraints().size(), is(1)); } @Test - public void assertGetSoftConstraints() { + void assertGetSoftConstraints() { assertNull(jobTaskRequest.getSoftConstraints()); } @Test - public void assertSetAssignedResources() { + void assertSetAssignedResources() { jobTaskRequest.setAssignedResources(null); } @Test - public void assertGetAssignedResources() { + void assertGetAssignedResources() { assertNull(jobTaskRequest.getAssignedResources()); } @Test - public void assertGetCustomNamedResources() { + void assertGetCustomNamedResources() { assertThat(jobTaskRequest.getCustomNamedResources(), is(Collections.emptyMap())); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LaunchingTasksTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LaunchingTasksTest.java index 290fe0b927..4f57d79f20 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LaunchingTasksTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LaunchingTasksTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class LaunchingTasksTest { +class LaunchingTasksTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -61,7 +61,7 @@ public final class LaunchingTasksTest { private LaunchingTasks launchingTasks; @BeforeEach - public void setUp() { + void setUp() { FacadeService facadeService = new FacadeService(regCenter); ReflectionUtils.setFieldValue(facadeService, "jobConfigService", jobConfigService); ReflectionUtils.setFieldValue(facadeService, "readyService", readyService); @@ -74,7 +74,7 @@ public void setUp() { } @Test - public void assertGetPendingTasks() { + void assertGetPendingTasks() { List actual = launchingTasks.getPendingTasks(); assertThat(actual.size(), is(20)); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LeasesQueueTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LeasesQueueTest.java index c7e379135e..1b3cc80052 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LeasesQueueTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/LeasesQueueTest.java @@ -24,12 +24,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class LeasesQueueTest { +class LeasesQueueTest { private final LeasesQueue leasesQueue = LeasesQueue.getInstance(); @Test - public void assertOperate() { + void assertOperate() { assertTrue(leasesQueue.drainTo().isEmpty()); leasesQueue.offer(OfferBuilder.createOffer("offer_1")); leasesQueue.offer(OfferBuilder.createOffer("offer_2")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java index 54d887969b..0c7aca9588 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java @@ -34,13 +34,13 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class MesosStateServiceTest extends AbstractCloudControllerTest { +class MesosStateServiceTest extends AbstractCloudControllerTest { @Mock private CoordinatorRegistryCenter registryCenter; @Test - public void assertSandbox() { + void assertSandbox() { when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000"); MesosStateService service = new MesosStateService(registryCenter); Collection> sandbox = service.sandbox("foo_app"); @@ -51,7 +51,7 @@ public void assertSandbox() { } @Test - public void assertExecutors() { + void assertExecutors() { when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000"); MesosStateService service = new MesosStateService(registryCenter); Collection executorStateInfo = service.executors("foo_app"); @@ -62,7 +62,7 @@ public void assertExecutors() { } @Test - public void assertAllExecutors() { + void assertAllExecutors() { when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000"); MesosStateService service = new MesosStateService(registryCenter); Collection executorStateInfo = service.executors(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/ReconcileServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/ReconcileServiceTest.java index ced647cba3..fbcbe0b8f8 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/ReconcileServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/ReconcileServiceTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ReconcileServiceTest { +class ReconcileServiceTest { @Mock private SchedulerDriver schedulerDriver; @@ -55,24 +55,24 @@ public final class ReconcileServiceTest { private ArgumentCaptor> taskStatusCaptor; @BeforeEach - public void setUp() { + void setUp() { reconcileService = new ReconcileService(schedulerDriver, facadeService); } @Test - public void assertRunOneIteration() { + void assertRunOneIteration() { reconcileService.runOneIteration(); verify(schedulerDriver).reconcileTasks(Collections.emptyList()); } @Test - public void assertImplicitReconcile() { + void assertImplicitReconcile() { reconcileService.implicitReconcile(); verify(schedulerDriver).reconcileTasks(Collections.emptyList()); } @Test - public void assertExplicitReconcile() { + void assertExplicitReconcile() { Map> runningTaskMap = new HashMap<>(); runningTaskMap.put("transient_test_job", Sets.newHashSet( TaskContext.from("transient_test_job@-@0@-@READY@-@SLAVE-S0@-@UUID"), TaskContext.from("transient_test_job@-@1@-@READY@-@SLAVE-S0@-@UUID"))); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerEngineTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerEngineTest.java index 316eaafe5d..c0ba180d37 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerEngineTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerEngineTest.java @@ -51,7 +51,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class SchedulerEngineTest { +class SchedulerEngineTest { @Mock private TaskScheduler taskScheduler; @@ -68,7 +68,7 @@ public final class SchedulerEngineTest { private SchedulerEngine schedulerEngine; @BeforeEach - public void setUp() { + void setUp() { schedulerEngine = new SchedulerEngine(taskScheduler, facadeService, new JobTracingEventBus(), frameworkIDService, statisticManager); ReflectionUtils.setFieldValue(schedulerEngine, "facadeService", facadeService); lenient().when(facadeService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); @@ -76,20 +76,20 @@ public void setUp() { } @Test - public void assertRegistered() { + void assertRegistered() { schedulerEngine.registered(null, Protos.FrameworkID.newBuilder().setValue("1").build(), Protos.MasterInfo.getDefaultInstance()); verify(taskScheduler).expireAllLeases(); verify(frameworkIDService).save("1"); } @Test - public void assertReregistered() { + void assertReregistered() { schedulerEngine.reregistered(null, Protos.MasterInfo.getDefaultInstance()); verify(taskScheduler).expireAllLeases(); } @Test - public void assertResourceOffers() { + void assertResourceOffers() { SchedulerDriver schedulerDriver = mock(SchedulerDriver.class); List offers = Arrays.asList(OfferBuilder.createOffer("offer_0"), OfferBuilder.createOffer("offer_1")); schedulerEngine.resourceOffers(schedulerDriver, offers); @@ -97,13 +97,13 @@ public void assertResourceOffers() { } @Test - public void assertOfferRescinded() { + void assertOfferRescinded() { schedulerEngine.offerRescinded(null, Protos.OfferID.newBuilder().setValue("myOffer").build()); verify(taskScheduler).expireLease("myOffer"); } @Test - public void assertRunningStatusUpdateForDaemonJobBegin() { + void assertRunningStatusUpdateForDaemonJobBegin() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())) .setState(Protos.TaskState.TASK_RUNNING).setMessage("BEGIN").setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build()); @@ -111,7 +111,7 @@ public void assertRunningStatusUpdateForDaemonJobBegin() { } @Test - public void assertRunningStatusUpdateForDaemonJobComplete() { + void assertRunningStatusUpdateForDaemonJobComplete() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())) .setState(Protos.TaskState.TASK_RUNNING).setMessage("COMPLETE").setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build()); @@ -119,7 +119,7 @@ public void assertRunningStatusUpdateForDaemonJobComplete() { } @Test - public void assertRunningStatusUpdateForOther() { + void assertRunningStatusUpdateForOther() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())) .setState(Protos.TaskState.TASK_RUNNING).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build()); @@ -127,7 +127,7 @@ public void assertRunningStatusUpdateForOther() { } @Test - public void assertFinishedStatusUpdateWithoutLaunchedTasks() { + void assertFinishedStatusUpdateWithoutLaunchedTasks() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())) .setState(Protos.TaskState.TASK_FINISHED).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build()); @@ -136,7 +136,7 @@ public void assertFinishedStatusUpdateWithoutLaunchedTasks() { } @Test - public void assertFinishedStatusUpdate() { + void assertFinishedStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -150,7 +150,7 @@ public void assertFinishedStatusUpdate() { } @Test - public void assertKilledStatusUpdate() { + void assertKilledStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -164,7 +164,7 @@ public void assertKilledStatusUpdate() { } @Test - public void assertFailedStatusUpdate() { + void assertFailedStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -179,7 +179,7 @@ public void assertFailedStatusUpdate() { } @Test - public void assertErrorStatusUpdate() { + void assertErrorStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -194,7 +194,7 @@ public void assertErrorStatusUpdate() { } @Test - public void assertLostStatusUpdate() { + void assertLostStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -209,7 +209,7 @@ public void assertLostStatusUpdate() { } @Test - public void assertDroppedStatusUpdate() { + void assertDroppedStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -225,7 +225,7 @@ public void assertDroppedStatusUpdate() { } @Test - public void assertGoneStatusUpdate() { + void assertGoneStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -240,7 +240,7 @@ public void assertGoneStatusUpdate() { } @Test - public void assertGoneByOperatorStatusUpdate() { + void assertGoneByOperatorStatusUpdate() { @SuppressWarnings("unchecked") Action2 taskUnAssigner = mock(Action2.class); when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner); @@ -256,7 +256,7 @@ public void assertGoneByOperatorStatusUpdate() { } @Test - public void assertUnknownStatusUpdate() { + void assertUnknownStatusUpdate() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder() .setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_UNKNOWN) @@ -265,7 +265,7 @@ public void assertUnknownStatusUpdate() { } @Test - public void assertUnReachedStatusUpdate() { + void assertUnReachedStatusUpdate() { TaskNode taskNode = TaskNode.builder().build(); schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder() .setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_UNREACHABLE) @@ -274,23 +274,23 @@ public void assertUnReachedStatusUpdate() { } @Test - public void assertFrameworkMessage() { + void assertFrameworkMessage() { schedulerEngine.frameworkMessage(null, null, Protos.SlaveID.newBuilder().setValue("slave-S0").build(), new byte[1]); } @Test - public void assertSlaveLost() { + void assertSlaveLost() { schedulerEngine.slaveLost(null, Protos.SlaveID.newBuilder().setValue("slave-S0").build()); verify(taskScheduler).expireAllLeasesByVMId("slave-S0"); } @Test - public void assertExecutorLost() { + void assertExecutorLost() { schedulerEngine.executorLost(null, Protos.ExecutorID.newBuilder().setValue("test_job@-@0@-@00").build(), Protos.SlaveID.newBuilder().setValue("slave-S0").build(), 0); } @Test - public void assertError() { + void assertError() { schedulerEngine.error(null, null); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerServiceTest.java index 1d1e01044c..c06632f705 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SchedulerServiceTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class SchedulerServiceTest { +class SchedulerServiceTest { @Mock private BootstrapEnvironment env; @@ -82,7 +82,7 @@ public class SchedulerServiceTest { private SchedulerService schedulerService; @BeforeEach - public void setUp() { + void setUp() { schedulerService = new SchedulerService(env, facadeService, schedulerDriver, producerManager, statisticManager, cloudJobConfigurationListener, taskLaunchScheduledService, consoleBootstrap, reconcileService, cloudJobDisableListener, @@ -90,7 +90,7 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { setReconcileEnabled(true); schedulerService.start(); InOrder inOrder = getInOrder(); @@ -105,7 +105,7 @@ public void assertStart() { } @Test - public void assertStartWithoutReconcile() { + void assertStartWithoutReconcile() { setReconcileEnabled(false); schedulerService.start(); InOrder inOrder = getInOrder(); @@ -120,7 +120,7 @@ public void assertStartWithoutReconcile() { } @Test - public void assertStop() { + void assertStop() { setReconcileEnabled(true); schedulerService.stop(); InOrder inOrder = getInOrder(); @@ -135,7 +135,7 @@ public void assertStop() { } @Test - public void assertStopWithoutReconcile() { + void assertStopWithoutReconcile() { setReconcileEnabled(false); schedulerService.stop(); InOrder inOrder = getInOrder(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SupportedExtractionTypeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SupportedExtractionTypeTest.java index 4ef76e04af..ee31b68a9a 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SupportedExtractionTypeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/SupportedExtractionTypeTest.java @@ -22,10 +22,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class SupportedExtractionTypeTest { +class SupportedExtractionTypeTest { @Test - public void assertIsExtraction() { + void assertIsExtraction() { assertTrue(SupportedExtractionType.isExtraction("http://localhost:8080/test.tar")); assertTrue(SupportedExtractionType.isExtraction("http://localhost:8080/test.tar.gz")); assertTrue(SupportedExtractionType.isExtraction("http://localhost:8080/test.tar.bz2")); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskInfoDataTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskInfoDataTest.java index bf1dad3f6c..7bdc6c6738 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskInfoDataTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskInfoDataTest.java @@ -29,24 +29,24 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; -public final class TaskInfoDataTest { +class TaskInfoDataTest { private final ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 3, "test_param", Collections.emptyMap()); @Test - public void assertSerializeSimpleJob() { + void assertSerializeSimpleJob() { TaskInfoData actual = new TaskInfoData(shardingContexts, CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job").toCloudJobConfiguration()); assertSerialize(SerializationUtils.deserialize(actual.serialize())); } @Test - public void assertSerializeDataflowJob() { + void assertSerializeDataflowJob() { TaskInfoData actual = new TaskInfoData(shardingContexts, CloudJobConfigurationBuilder.createDataflowCloudJobConfiguration("test_job")); assertSerialize(SerializationUtils.deserialize(actual.serialize())); } @Test - public void assertSerializeScriptJob() { + void assertSerializeScriptJob() { TaskInfoData actual = new TaskInfoData(shardingContexts, CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("test_job").toCloudJobConfiguration()); assertSerialize(SerializationUtils.deserialize(actual.serialize())); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java index 3faa3f4b25..8b8d1b83ac 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java @@ -59,7 +59,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class TaskLaunchScheduledServiceTest { +class TaskLaunchScheduledServiceTest { @Mock private SchedulerDriver schedulerDriver; @@ -76,19 +76,19 @@ public final class TaskLaunchScheduledServiceTest { private TaskLaunchScheduledService taskLaunchScheduledService; @BeforeEach - public void setUp() { + void setUp() { lenient().when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app"))); taskLaunchScheduledService = new TaskLaunchScheduledService(schedulerDriver, taskScheduler, facadeService, jobTracingEventBus); taskLaunchScheduledService.startUp(); } @AfterEach - public void tearDown() { + void tearDown() { taskLaunchScheduledService.shutDown(); } @Test - public void assertRunOneIteration() { + void assertRunOneIteration() { when(facadeService.getEligibleJobContext()).thenReturn( Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER))); Map vmAssignmentResultMap = new HashMap<>(); @@ -105,7 +105,7 @@ public void assertRunOneIteration() { } @Test - public void assertRunOneIterationWithScriptJob() { + void assertRunOneIterationWithScriptJob() { when(facadeService.getEligibleJobContext()).thenReturn( Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1).toCloudJobConfiguration(), ExecutionType.READY))); Map vmAssignmentResultMap = new HashMap<>(); @@ -129,12 +129,12 @@ private TaskAssignmentResult mockTaskAssignmentResult(final String taskName, fin } @Test - public void assertScheduler() { + void assertScheduler() { assertThat(taskLaunchScheduledService.scheduler(), instanceOf(Scheduler.class)); } @Test - public void assertServiceName() { + void assertServiceName() { assertThat(taskLaunchScheduledService.serviceName(), is("task-launch-processor")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerJobTest.java index f06957a58b..b9ab1cd5e5 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerJobTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerJobTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ProducerJobTest { +class ProducerJobTest { @Mock private JobExecutionContext jobExecutionContext; @@ -44,14 +44,14 @@ public final class ProducerJobTest { private TransientProducerScheduler.ProducerJob producerJob; @BeforeEach - public void setUp() { + void setUp() { producerJob = new TransientProducerScheduler.ProducerJob(); producerJob.setRepository(repository); producerJob.setReadyService(readyService); } @Test - public void assertExecute() { + void assertExecute() { when(jobExecutionContext.getJobDetail()).thenReturn(JobBuilder.newJob(TransientProducerScheduler.ProducerJob.class).withIdentity("0/30 * * * * ?").build()); repository.put(JobKey.jobKey("0/30 * * * * ?"), "test_job"); producerJob.execute(jobExecutionContext); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java index 0b634254fa..285a705dcf 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java @@ -51,7 +51,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ProducerManagerTest { +class ProducerManagerTest { @Mock private SchedulerDriver schedulerDriver; @@ -86,7 +86,7 @@ public final class ProducerManagerTest { private final CloudJobConfigurationPOJO daemonJobConfig = CloudJobConfigurationBuilder.createCloudJobConfiguration("daemon_test_job", CloudJobExecutionType.DAEMON); @BeforeEach - public void setUp() { + void setUp() { producerManager = new ProducerManager(schedulerDriver, regCenter); ReflectionUtils.setFieldValue(producerManager, "appConfigService", appConfigService); ReflectionUtils.setFieldValue(producerManager, "configService", configService); @@ -97,7 +97,7 @@ public void setUp() { } @Test - public void assertStartup() { + void assertStartup() { when(configService.loadAll()).thenReturn(Arrays.asList(transientJobConfig, daemonJobConfig)); producerManager.startup(); verify(configService).loadAll(); @@ -106,7 +106,7 @@ public void assertStartup() { } @Test - public void assertRegisterJobWithoutApp() { + void assertRegisterJobWithoutApp() { assertThrows(AppConfigurationException.class, () -> { when(appConfigService.load("test_app")).thenReturn(Optional.empty()); producerManager.register(transientJobConfig); @@ -114,7 +114,7 @@ public void assertRegisterJobWithoutApp() { } @Test - public void assertRegisterExistedJob() { + void assertRegisterExistedJob() { assertThrows(JobConfigurationException.class, () -> { when(appConfigService.load("test_app")).thenReturn(Optional.of(appConfig)); when(configService.load("transient_test_job")).thenReturn(Optional.of(transientJobConfig)); @@ -123,7 +123,7 @@ public void assertRegisterExistedJob() { } @Test - public void assertRegisterDisabledJob() { + void assertRegisterDisabledJob() { assertThrows(JobConfigurationException.class, () -> { when(disableJobService.isDisabled("transient_test_job")).thenReturn(true); producerManager.register(transientJobConfig); @@ -131,7 +131,7 @@ public void assertRegisterDisabledJob() { } @Test - public void assertRegisterTransientJob() { + void assertRegisterTransientJob() { when(appConfigService.load("test_app")).thenReturn(Optional.of(appConfig)); when(configService.load("transient_test_job")).thenReturn(Optional.empty()); producerManager.register(transientJobConfig); @@ -140,7 +140,7 @@ public void assertRegisterTransientJob() { } @Test - public void assertRegisterDaemonJob() { + void assertRegisterDaemonJob() { when(appConfigService.load("test_app")).thenReturn(Optional.of(appConfig)); when(configService.load("daemon_test_job")).thenReturn(Optional.empty()); producerManager.register(daemonJobConfig); @@ -149,7 +149,7 @@ public void assertRegisterDaemonJob() { } @Test - public void assertUpdateNotExisted() { + void assertUpdateNotExisted() { assertThrows(JobConfigurationException.class, () -> { when(configService.load("transient_test_job")).thenReturn(Optional.empty()); producerManager.update(transientJobConfig); @@ -157,7 +157,7 @@ public void assertUpdateNotExisted() { } @Test - public void assertUpdateExisted() { + void assertUpdateExisted() { when(configService.load("transient_test_job")).thenReturn(Optional.of(transientJobConfig)); List taskContexts = Arrays.asList( TaskContext.from("transient_test_job@-@0@-@READY@-@SLAVE-S0@-@UUID"), TaskContext.from("transient_test_job@-@1@-@READY@-@SLAVE-S0@-@UUID")); @@ -172,14 +172,14 @@ public void assertUpdateExisted() { } @Test - public void assertDeregisterNotExisted() { + void assertDeregisterNotExisted() { when(configService.load("transient_test_job")).thenReturn(Optional.empty()); producerManager.deregister("transient_test_job"); verify(configService, times(0)).remove("transient_test_job"); } @Test - public void assertDeregisterExisted() { + void assertDeregisterExisted() { when(configService.load("transient_test_job")).thenReturn(Optional.of(transientJobConfig)); List taskContexts = Arrays.asList( TaskContext.from("transient_test_job@-@0@-@READY@-@SLAVE-S0@-@UUID"), TaskContext.from("transient_test_job@-@1@-@READY@-@SLAVE-S0@-@UUID")); @@ -195,7 +195,7 @@ public void assertDeregisterExisted() { } @Test - public void assertShutdown() { + void assertShutdown() { producerManager.shutdown(); verify(transientProducerScheduler).shutdown(); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerRepositoryTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerRepositoryTest.java index d5f9178a8d..70a82a3a8a 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerRepositoryTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerRepositoryTest.java @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ExtendWith(MockitoExtension.class) -public final class TransientProducerRepositoryTest { +class TransientProducerRepositoryTest { private final JobKey jobKey = JobKey.jobKey("0/45 * * * * ?"); @@ -37,14 +37,14 @@ public final class TransientProducerRepositoryTest { private final TransientProducerRepository transientProducerRepository = new TransientProducerRepository(); @Test - public void assertPutJobKey() { + void assertPutJobKey() { transientProducerRepository.put(jobKey, jobName); assertThat(transientProducerRepository.get(jobKey).get(0), is(jobName)); transientProducerRepository.remove(jobName); } @Test - public void assertPutJobWithChangedCron() { + void assertPutJobWithChangedCron() { transientProducerRepository.put(jobKey, jobName); JobKey newJobKey = JobKey.jobKey("0/15 * * * * ?"); transientProducerRepository.put(newJobKey, jobName); @@ -54,7 +54,7 @@ public void assertPutJobWithChangedCron() { } @Test - public void assertPutMoreJobWithChangedCron() { + void assertPutMoreJobWithChangedCron() { String jobName2 = "other_test_job"; transientProducerRepository.put(jobKey, jobName); transientProducerRepository.put(jobKey, jobName2); @@ -67,14 +67,14 @@ public void assertPutMoreJobWithChangedCron() { } @Test - public void assertRemoveJobKey() { + void assertRemoveJobKey() { transientProducerRepository.put(jobKey, jobName); transientProducerRepository.remove(jobName); assertTrue(transientProducerRepository.get(jobKey).isEmpty()); } @Test - public void assertContainsKey() { + void assertContainsKey() { transientProducerRepository.put(jobKey, jobName); assertTrue(transientProducerRepository.containsKey(jobKey)); transientProducerRepository.remove(jobName); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerSchedulerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerSchedulerTest.java index a9ba189700..80c7214196 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerSchedulerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerSchedulerTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class TransientProducerSchedulerTest { +class TransientProducerSchedulerTest { @Mock private ReadyService readyService; @@ -59,13 +59,13 @@ public final class TransientProducerSchedulerTest { .build(); @BeforeEach - public void setUp() { + void setUp() { transientProducerScheduler = new TransientProducerScheduler(readyService); ReflectionUtils.setFieldValue(transientProducerScheduler, "scheduler", scheduler); } @Test - public void assertRegister() throws SchedulerException { + void assertRegister() throws SchedulerException { when(scheduler.checkExists(jobDetail.getKey())).thenReturn(false); transientProducerScheduler.register(cloudJobConfig); verify(scheduler).checkExists(jobDetail.getKey()); @@ -73,13 +73,13 @@ public void assertRegister() throws SchedulerException { } @Test - public void assertDeregister() throws SchedulerException { + void assertDeregister() throws SchedulerException { transientProducerScheduler.deregister(cloudJobConfig); verify(scheduler).unscheduleJob(TriggerKey.triggerKey(cloudJobConfig.getCron())); } @Test - public void assertShutdown() throws SchedulerException { + void assertShutdown() throws SchedulerException { transientProducerScheduler.shutdown(); verify(scheduler).isShutdown(); verify(scheduler).shutdown(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/CloudAppDisableListenerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/CloudAppDisableListenerTest.java index 65656321c9..1c385a8455 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/CloudAppDisableListenerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/CloudAppDisableListenerTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class CloudAppDisableListenerTest { +public class CloudAppDisableListenerTest { private static ZookeeperRegistryCenter regCenter; @@ -52,7 +52,7 @@ public final class CloudAppDisableListenerTest { private CloudAppDisableListener cloudAppDisableListener; @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(cloudAppDisableListener, "producerManager", producerManager); initRegistryCenter(); ReflectionUtils.setFieldValue(cloudAppDisableListener, "regCenter", regCenter); @@ -70,27 +70,27 @@ private void initRegistryCenter() { } @Test - public void assertDisableWithInvalidPath() { + void assertDisableWithInvalidPath() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/other/test_app", null, "".getBytes())); verify(jobConfigService, times(0)).loadAll(); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); } @Test - public void assertDisableWithNoAppNamePath() { + void assertDisableWithNoAppNamePath() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/state/disable/app", null, "".getBytes())); verify(jobConfigService, times(0)).loadAll(); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); } @Test - public void assertDisable() { + void assertDisable() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/state/disable/app/app_test", null, "".getBytes())); verify(jobConfigService).loadAll(); } @Test - public void assertEnableWithInvalidPath() { + void assertEnableWithInvalidPath() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/other/test_app", null, "".getBytes()), new ChildData("/other/test_app", null, "".getBytes())); verify(jobConfigService, times(0)).loadAll(); @@ -98,7 +98,7 @@ public void assertEnableWithInvalidPath() { } @Test - public void assertEnableWithNoAppNamePath() { + void assertEnableWithNoAppNamePath() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/state/disable/app", null, "".getBytes()), new ChildData("/state/disable/app", null, "".getBytes())); verify(jobConfigService, times(0)).loadAll(); @@ -106,19 +106,19 @@ public void assertEnableWithNoAppNamePath() { } @Test - public void assertEnable() { + void assertEnable() { cloudAppDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/state/disable/app/app_test", null, "".getBytes()), new ChildData("/state/disable/app/app_test", null, "".getBytes())); verify(jobConfigService).loadAll(); } @Test - public void start() { + void start() { cloudAppDisableListener.start(); } @Test - public void stop() { + void stop() { regCenter.addCacheData("/state/disable/app"); ReflectionUtils.setFieldValue(cloudAppDisableListener, "regCenter", regCenter); cloudAppDisableListener.stop(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppNodeTest.java index e8eab8a26e..a79bfb5e3b 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppNodeTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class DisableAppNodeTest { +class DisableAppNodeTest { @Test - public void assertGetDisableAppNodePath() { + void assertGetDisableAppNodePath() { assertThat(DisableAppNode.getDisableAppNodePath("test_app0000000001"), is("/state/disable/app/test_app0000000001")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppServiceTest.java index f4c5bc4d84..bdb681b181 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/app/DisableAppServiceTest.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DisableAppServiceTest { +class DisableAppServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -38,32 +38,32 @@ public final class DisableAppServiceTest { private DisableAppService disableAppService; @BeforeEach - public void setUp() { + void setUp() { disableAppService = new DisableAppService(regCenter); } @Test - public void assertAdd() { + void assertAdd() { disableAppService.add("test_app"); verify(regCenter).isExisted("/state/disable/app/test_app"); verify(regCenter).persist("/state/disable/app/test_app", "test_app"); } @Test - public void assertRemove() { + void assertRemove() { disableAppService.remove("test_app"); verify(regCenter).remove("/state/disable/app/test_app"); } @Test - public void assertIsDisabled() { + void assertIsDisabled() { when(regCenter.isExisted("/state/disable/app/test_app")).thenReturn(true); assertTrue(disableAppService.isDisabled("test_app")); verify(regCenter).isExisted("/state/disable/app/test_app"); } @Test - public void assertIsEnabled() { + void assertIsEnabled() { when(regCenter.isExisted("/state/disable/app/test_app")).thenReturn(false); assertFalse(disableAppService.isDisabled("test_app")); verify(regCenter).isExisted("/state/disable/app/test_app"); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/CloudJobDisableListenerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/CloudJobDisableListenerTest.java index 22fd4773d6..212ad33904 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/CloudJobDisableListenerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/CloudJobDisableListenerTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class CloudJobDisableListenerTest { +class CloudJobDisableListenerTest { private static ZookeeperRegistryCenter regCenter; @@ -49,7 +49,7 @@ public final class CloudJobDisableListenerTest { private CloudJobDisableListener cloudJobDisableListener; @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(cloudJobDisableListener, "producerManager", producerManager); initRegistryCenter(); ReflectionUtils.setFieldValue(cloudJobDisableListener, "regCenter", regCenter); @@ -66,27 +66,27 @@ private void initRegistryCenter() { } @Test - public void assertDisableWithInvalidPath() { + void assertDisableWithInvalidPath() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/other/test_job", null, "".getBytes())); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); verify(producerManager, times(0)).reschedule(ArgumentMatchers.any()); } @Test - public void assertDisableWithNoJobNamePath() { + void assertDisableWithNoJobNamePath() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/state/disable/job", null, "".getBytes())); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); verify(producerManager, times(0)).reschedule(ArgumentMatchers.any()); } @Test - public void assertDisable() { + void assertDisable() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_CREATED, null, new ChildData("/state/disable/job/job_test", null, "".getBytes())); verify(producerManager).unschedule(eq("job_test")); } @Test - public void assertEnableWithInvalidPath() { + void assertEnableWithInvalidPath() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/other/test_job", null, "".getBytes()), new ChildData("/other/test_job", null, "".getBytes())); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); @@ -94,7 +94,7 @@ public void assertEnableWithInvalidPath() { } @Test - public void assertEnableWithNoJobNamePath() { + void assertEnableWithNoJobNamePath() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/state/disable/job", null, "".getBytes()), new ChildData("/state/disable/job", null, "".getBytes())); verify(producerManager, times(0)).unschedule(ArgumentMatchers.any()); @@ -102,19 +102,19 @@ public void assertEnableWithNoJobNamePath() { } @Test - public void assertEnable() { + void assertEnable() { cloudJobDisableListener.event(CuratorCacheListener.Type.NODE_DELETED, new ChildData("/state/disable/job/job_test", null, "".getBytes()), new ChildData("/state/disable/job/job_test", null, "".getBytes())); verify(producerManager).reschedule(eq("job_test")); } @Test - public void assertStart() { + void assertStart() { cloudJobDisableListener.start(); } @Test - public void assertStop() { + void assertStop() { regCenter.addCacheData("/state/disable/job"); ReflectionUtils.setFieldValue(cloudJobDisableListener, "regCenter", regCenter); cloudJobDisableListener.stop(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobNodeTest.java index bf62aad7ba..a4f5a4b193 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobNodeTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class DisableJobNodeTest { +class DisableJobNodeTest { @Test - public void assertGetDisableAppNodePath() { + void assertGetDisableAppNodePath() { assertThat(DisableJobNode.getDisableJobNodePath("test_job0000000001"), is("/state/disable/job/test_job0000000001")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobServiceTest.java index c0c7f41115..bbac784d71 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/disable/job/DisableJobServiceTest.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DisableJobServiceTest { +class DisableJobServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -38,32 +38,32 @@ public final class DisableJobServiceTest { private DisableJobService disableJobService; @BeforeEach - public void setUp() { + void setUp() { disableJobService = new DisableJobService(regCenter); } @Test - public void assertAdd() { + void assertAdd() { disableJobService.add("test_job"); verify(regCenter).isExisted("/state/disable/job/test_job"); verify(regCenter).persist("/state/disable/job/test_job", "test_job"); } @Test - public void assertRemove() { + void assertRemove() { disableJobService.remove("test_job"); verify(regCenter).remove("/state/disable/job/test_job"); } @Test - public void assertIsDisabled() { + void assertIsDisabled() { when(regCenter.isExisted("/state/disable/job/test_job")).thenReturn(true); assertTrue(disableJobService.isDisabled("test_job")); verify(regCenter).isExisted("/state/disable/job/test_job"); } @Test - public void assertIsEnabled() { + void assertIsEnabled() { when(regCenter.isExisted("/state/disable/job/test_job")).thenReturn(false); assertFalse(disableJobService.isDisabled("test_job")); verify(regCenter).isExisted("/state/disable/job/test_job"); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNodeTest.java index 56c418729a..e6443690bc 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNodeTest.java @@ -24,15 +24,15 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class FailoverNodeTest { +class FailoverNodeTest { @Test - public void assertGetFailoverJobNodePath() { + void assertGetFailoverJobNodePath() { assertThat(FailoverNode.getFailoverJobNodePath("test_job"), is("/state/failover/test_job")); } @Test - public void assertGetFailoverTaskNodePath() { + void assertGetFailoverTaskNodePath() { String jobNodePath = TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodePath(); assertThat(FailoverNode.getFailoverTaskNodePath(jobNodePath), is("/state/failover/test_job/" + jobNodePath)); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java index c7fc2ecd8d..7fa55733a0 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java @@ -49,7 +49,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class FailoverServiceTest { +class FailoverServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -63,14 +63,14 @@ public final class FailoverServiceTest { private FailoverService failoverService; @BeforeEach - public void setUp() { + void setUp() { failoverService = new FailoverService(regCenter); ReflectionUtils.setFieldValue(failoverService, "configService", configService); ReflectionUtils.setFieldValue(failoverService, "runningService", runningService); } @Test - public void assertAddWhenJobIsOverQueueSize() { + void assertAddWhenJobIsOverQueueSize() { when(regCenter.getNumChildren(FailoverNode.ROOT)).thenReturn(BootstrapEnvironment.getINSTANCE().getFrameworkConfiguration().getJobStateQueueSize() + 1); TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); failoverService.add(TaskContext.from(taskNode.getTaskNodeValue())); @@ -78,7 +78,7 @@ public void assertAddWhenJobIsOverQueueSize() { } @Test - public void assertAddWhenExisted() { + void assertAddWhenExisted() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(true); failoverService.add(TaskContext.from(taskNode.getTaskNodeValue())); @@ -87,7 +87,7 @@ public void assertAddWhenExisted() { } @Test - public void assertAddWhenNotExistedAndTaskIsRunning() { + void assertAddWhenNotExistedAndTaskIsRunning() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(false); when(runningService.isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(true); @@ -98,7 +98,7 @@ public void assertAddWhenNotExistedAndTaskIsRunning() { } @Test - public void assertAddWhenNotExistedAndTaskIsNotRunning() { + void assertAddWhenNotExistedAndTaskIsNotRunning() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(false); when(runningService.isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(false); @@ -109,14 +109,14 @@ public void assertAddWhenNotExistedAndTaskIsNotRunning() { } @Test - public void assertGetAllEligibleJobContextsWithoutRootNode() { + void assertGetAllEligibleJobContextsWithoutRootNode() { when(regCenter.isExisted("/state/failover")).thenReturn(false); assertTrue(failoverService.getAllEligibleJobContexts().isEmpty()); verify(regCenter).isExisted("/state/failover"); } @Test - public void assertGetAllEligibleJobContextsWithRootNode() { + void assertGetAllEligibleJobContextsWithRootNode() { when(regCenter.isExisted("/state/failover")).thenReturn(true); when(regCenter.getChildrenKeys("/state/failover")).thenReturn(Arrays.asList("task_empty_job", "not_existed_job", "eligible_job")); when(regCenter.getChildrenKeys("/state/failover/task_empty_job")).thenReturn(Collections.emptyList()); @@ -139,7 +139,7 @@ public void assertGetAllEligibleJobContextsWithRootNode() { } @Test - public void assertRemove() { + void assertRemove() { String jobNodePath1 = TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodePath(); String jobNodePath2 = TaskNode.builder().shardingItem(1).type(ExecutionType.FAILOVER).build().getTaskNodePath(); failoverService.remove(Arrays.asList(MetaInfo.from(jobNodePath1), MetaInfo.from(jobNodePath2))); @@ -148,7 +148,7 @@ public void assertRemove() { } @Test - public void assertGetTaskId() { + void assertGetTaskId() { TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build(); failoverService.add(TaskContext.from(taskNode.getTaskNodeValue())); when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(true); @@ -160,14 +160,14 @@ public void assertGetTaskId() { } @Test - public void assertGetAllFailoverTasksWithoutRootNode() { + void assertGetAllFailoverTasksWithoutRootNode() { when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(false); assertTrue(failoverService.getAllFailoverTasks().isEmpty()); verify(regCenter).isExisted(FailoverNode.ROOT); } @Test - public void assertGetAllFailoverTasksWhenRootNodeHasNoChild() { + void assertGetAllFailoverTasksWhenRootNodeHasNoChild() { when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(true); when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Collections.emptyList()); assertTrue(failoverService.getAllFailoverTasks().isEmpty()); @@ -176,7 +176,7 @@ public void assertGetAllFailoverTasksWhenRootNodeHasNoChild() { } @Test - public void assertGetAllFailoverTasksWhenJobNodeHasNoChild() { + void assertGetAllFailoverTasksWhenJobNodeHasNoChild() { when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(true); when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Collections.singletonList("test_job")); when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job"))).thenReturn(Collections.emptyList()); @@ -187,7 +187,7 @@ public void assertGetAllFailoverTasksWhenJobNodeHasNoChild() { } @Test - public void assertGetAllFailoverTasksWithRootNode() { + void assertGetAllFailoverTasksWithRootNode() { String uuid1 = UUID.randomUUID().toString(); String uuid2 = UUID.randomUUID().toString(); String uuid3 = UUID.randomUUID().toString(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyNodeTest.java index 1f685a12f7..aa59c75ad5 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyNodeTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ReadyNodeTest { +class ReadyNodeTest { @Test - public void assertGetReadyJobNodePath() { + void assertGetReadyJobNodePath() { assertThat(ReadyNode.getReadyJobNodePath("test_job0000000001"), is("/state/ready/test_job0000000001")); } } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java index b07513ae83..bf03950ca1 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ReadyServiceTest { +class ReadyServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -61,14 +61,14 @@ public final class ReadyServiceTest { private ReadyService readyService; @BeforeEach - public void setUp() { + void setUp() { readyService = new ReadyService(regCenter); ReflectionUtils.setFieldValue(readyService, "configService", configService); ReflectionUtils.setFieldValue(readyService, "runningService", runningService); } @Test - public void assertAddTransientWithJobConfigIsNotPresent() { + void assertAddTransientWithJobConfigIsNotPresent() { when(configService.load("test_job")).thenReturn(Optional.empty()); readyService.addTransient("test_job"); verify(regCenter, times(0)).isExisted("/state/ready"); @@ -76,7 +76,7 @@ public void assertAddTransientWithJobConfigIsNotPresent() { } @Test - public void assertAddTransientWithJobConfigIsNotTransient() { + void assertAddTransientWithJobConfigIsNotTransient() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); readyService.addTransient("test_job"); verify(regCenter, times(0)).isExisted("/state/ready"); @@ -84,7 +84,7 @@ public void assertAddTransientWithJobConfigIsNotTransient() { } @Test - public void assertAddTransientWhenJobExistedAndEnableMisfired() { + void assertAddTransientWhenJobExistedAndEnableMisfired() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); when(regCenter.getDirectly("/state/ready/test_job")).thenReturn("1"); readyService.addTransient("test_job"); @@ -92,7 +92,7 @@ public void assertAddTransientWhenJobExistedAndEnableMisfired() { } @Test - public void assertAddTransientWhenJobExistedAndDisableMisfired() { + void assertAddTransientWhenJobExistedAndDisableMisfired() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", false))); when(regCenter.getDirectly("/state/ready/test_job")).thenReturn("1"); readyService.addTransient("test_job"); @@ -100,28 +100,28 @@ public void assertAddTransientWhenJobExistedAndDisableMisfired() { } @Test - public void assertAddTransientWhenJobNotExisted() { + void assertAddTransientWhenJobNotExisted() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); readyService.addTransient("test_job"); verify(regCenter).persist("/state/ready/test_job", "1"); } @Test - public void assertAddTransientWithOverJobQueueSize() { + void assertAddTransientWithOverJobQueueSize() { when(regCenter.getNumChildren(ReadyNode.ROOT)).thenReturn(BootstrapEnvironment.getINSTANCE().getFrameworkConfiguration().getJobStateQueueSize() + 1); readyService.addTransient("test_job"); verify(regCenter, times(0)).persist("/state/ready/test_job", "1"); } @Test - public void assertAddDaemonWithOverJobQueueSize() { + void assertAddDaemonWithOverJobQueueSize() { when(regCenter.getNumChildren(ReadyNode.ROOT)).thenReturn(BootstrapEnvironment.getINSTANCE().getFrameworkConfiguration().getJobStateQueueSize() + 1); readyService.addDaemon("test_job"); verify(regCenter, times(0)).persist("/state/ready/test_job", "1"); } @Test - public void assertAddDaemonWithJobConfigIsNotPresent() { + void assertAddDaemonWithJobConfigIsNotPresent() { when(configService.load("test_job")).thenReturn(Optional.empty()); readyService.addDaemon("test_job"); verify(regCenter, times(0)).isExisted("/state/ready"); @@ -129,7 +129,7 @@ public void assertAddDaemonWithJobConfigIsNotPresent() { } @Test - public void assertAddDaemonWithJobConfigIsNotDaemon() { + void assertAddDaemonWithJobConfigIsNotDaemon() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); readyService.addDaemon("test_job"); verify(regCenter, times(0)).isExisted("/state/ready"); @@ -137,21 +137,21 @@ public void assertAddDaemonWithJobConfigIsNotDaemon() { } @Test - public void assertAddDaemonWithoutRootNode() { + void assertAddDaemonWithoutRootNode() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); readyService.addDaemon("test_job"); verify(regCenter).persist("/state/ready/test_job", "1"); } @Test - public void assertAddDaemonWithSameJobName() { + void assertAddDaemonWithSameJobName() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); readyService.addDaemon("test_job"); verify(regCenter).persist(ArgumentMatchers.any(), ArgumentMatchers.eq("1")); } @Test - public void assertAddRunningDaemon() { + void assertAddRunningDaemon() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); when(runningService.isJobRunning("test_job")).thenReturn(true); readyService.addDaemon("test_job"); @@ -159,35 +159,35 @@ public void assertAddRunningDaemon() { } @Test - public void assertAddDaemonWithoutSameJobName() { + void assertAddDaemonWithoutSameJobName() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON))); readyService.addDaemon("test_job"); verify(regCenter).persist("/state/ready/test_job", "1"); } @Test - public void assertGetAllEligibleJobContextsWithoutRootNode() { + void assertGetAllEligibleJobContextsWithoutRootNode() { when(regCenter.isExisted("/state/ready")).thenReturn(false); assertTrue(readyService.getAllEligibleJobContexts(Collections.emptyList()).isEmpty()); verify(regCenter).isExisted("/state/ready"); } @Test - public void assertSetMisfireDisabledWhenJobIsNotExisted() { + void assertSetMisfireDisabledWhenJobIsNotExisted() { when(configService.load("test_job")).thenReturn(Optional.empty()); readyService.setMisfireDisabled("test_job"); verify(regCenter, times(0)).persist("/state/ready/test_job", "1"); } @Test - public void assertSetMisfireDisabledWhenReadyNodeNotExisted() { + void assertSetMisfireDisabledWhenReadyNodeNotExisted() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); readyService.setMisfireDisabled("test_job"); verify(regCenter, times(0)).persist("/state/ready/test_job", "1"); } @Test - public void assertSetMisfireDisabledWhenReadyNodeExisted() { + void assertSetMisfireDisabledWhenReadyNodeExisted() { when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job"))); when(regCenter.getDirectly("/state/ready/test_job")).thenReturn("100"); readyService.setMisfireDisabled("test_job"); @@ -195,7 +195,7 @@ public void assertSetMisfireDisabledWhenReadyNodeExisted() { } @Test - public void assertGetAllEligibleJobContextsWithRootNode() { + void assertGetAllEligibleJobContextsWithRootNode() { when(regCenter.isExisted("/state/ready")).thenReturn(true); when(regCenter.getChildrenKeys("/state/ready")).thenReturn(Arrays.asList("not_existed_job", "running_job", "ineligible_job", "eligible_job")); when(configService.load("not_existed_job")).thenReturn(Optional.empty()); @@ -214,7 +214,7 @@ public void assertGetAllEligibleJobContextsWithRootNode() { } @Test - public void assertGetAllEligibleJobContextsWithRootNodeAndDaemonJob() { + void assertGetAllEligibleJobContextsWithRootNodeAndDaemonJob() { when(regCenter.isExisted("/state/ready")).thenReturn(true); when(regCenter.getChildrenKeys("/state/ready")).thenReturn(Arrays.asList("not_existed_job", "running_job")); when(configService.load("not_existed_job")).thenReturn(Optional.empty()); @@ -228,7 +228,7 @@ public void assertGetAllEligibleJobContextsWithRootNodeAndDaemonJob() { } @Test - public void assertRemove() { + void assertRemove() { when(regCenter.getDirectly("/state/ready/test_job_1")).thenReturn("1"); when(regCenter.getDirectly("/state/ready/test_job_2")).thenReturn("2"); readyService.remove(Arrays.asList("test_job_1", "test_job_2")); @@ -239,7 +239,7 @@ public void assertRemove() { } @Test - public void assertGetAllTasksWithoutRootNode() { + void assertGetAllTasksWithoutRootNode() { when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(false); assertTrue(readyService.getAllReadyTasks().isEmpty()); verify(regCenter).isExisted(ReadyNode.ROOT); @@ -248,7 +248,7 @@ public void assertGetAllTasksWithoutRootNode() { } @Test - public void assertGetAllTasksWhenRootNodeHasNoChild() { + void assertGetAllTasksWhenRootNodeHasNoChild() { when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(true); when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Collections.emptyList()); assertTrue(readyService.getAllReadyTasks().isEmpty()); @@ -258,7 +258,7 @@ public void assertGetAllTasksWhenRootNodeHasNoChild() { } @Test - public void assertGetAllTasksWhenNodeIsEmpty() { + void assertGetAllTasksWhenNodeIsEmpty() { when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(true); when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Collections.singletonList("test_job")); when(regCenter.get(ReadyNode.getReadyJobNodePath("test_job"))).thenReturn(""); @@ -269,7 +269,7 @@ public void assertGetAllTasksWhenNodeIsEmpty() { } @Test - public void assertGetAllTasksWithRootNode() { + void assertGetAllTasksWithRootNode() { when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(true); when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.get(ReadyNode.getReadyJobNodePath("test_job_1"))).thenReturn("1"); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNodeTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNodeTest.java index 320a806e50..a0df3815ba 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNodeTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNodeTest.java @@ -23,15 +23,15 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class RunningNodeTest { +class RunningNodeTest { @Test - public void assertGetRunningJobNodePath() { + void assertGetRunningJobNodePath() { assertThat(RunningNode.getRunningJobNodePath("test_job"), is("/state/running/test_job")); } @Test - public void assertGetRunningTaskNodePath() { + void assertGetRunningTaskNodePath() { String nodePath = TaskNode.builder().build().getTaskNodePath(); assertThat(RunningNode.getRunningTaskNodePath(nodePath), is("/state/running/test_job/" + nodePath)); } diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java index 9e209afe6d..bfcadc93b8 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java @@ -44,7 +44,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class RunningServiceTest { +class RunningServiceTest { private TaskContext taskContext; @@ -56,7 +56,7 @@ public final class RunningServiceTest { private RunningService runningService; @BeforeEach - public void setUp() { + void setUp() { when(regCenter.get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson(CloudJobExecutionType.DAEMON)); when(regCenter.get("/config/job/test_job_t")).thenReturn(CloudJsonConstants.getJobJson("test_job_t")); runningService = new RunningService(regCenter); @@ -72,12 +72,12 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { runningService.clear(); } @Test - public void assertStart() { + void assertStart() { TaskNode taskNode1 = TaskNode.builder().jobName("test_job").shardingItem(0).slaveId("111").type(ExecutionType.READY).uuid(UUID.randomUUID().toString()).build(); TaskNode taskNode2 = TaskNode.builder().jobName("test_job").shardingItem(1).slaveId("222").type(ExecutionType.FAILOVER).uuid(UUID.randomUUID().toString()).build(); when(regCenter.getChildrenKeys(RunningNode.ROOT)).thenReturn(Collections.singletonList("test_job")); @@ -89,7 +89,7 @@ public void assertStart() { } @Test - public void assertAddWithoutData() { + void assertAddWithoutData() { assertThat(runningService.getRunningTasks("test_job").size(), is(1)); assertThat(runningService.getRunningTasks("test_job").iterator().next(), is(taskContext)); assertThat(runningService.getRunningTasks("test_job_t").size(), is(1)); @@ -97,7 +97,7 @@ public void assertAddWithoutData() { } @Test - public void assertAddWithData() { + void assertAddWithData() { when(regCenter.get("/config/job/other_job")).thenReturn(CloudJsonConstants.getJobJson("other_job")); TaskNode taskNode = TaskNode.builder().jobName("other_job").build(); runningService.add(TaskContext.from(taskNode.getTaskNodeValue())); @@ -106,14 +106,14 @@ public void assertAddWithData() { } @Test - public void assertUpdateIdle() { + void assertUpdateIdle() { runningService.updateIdle(taskContext, true); assertThat(runningService.getRunningTasks("test_job").size(), is(1)); assertTrue(runningService.getRunningTasks("test_job").iterator().next().isIdle()); } @Test - public void assertRemoveByJobName() { + void assertRemoveByJobName() { runningService.remove("test_job"); assertTrue(runningService.getRunningTasks("test_job").isEmpty()); verify(regCenter).remove(RunningNode.getRunningJobNodePath("test_job")); @@ -122,7 +122,7 @@ public void assertRemoveByJobName() { } @Test - public void assertRemoveByTaskContext() { + void assertRemoveByTaskContext() { when(regCenter.isExisted(RunningNode.getRunningJobNodePath("test_job"))).thenReturn(true); when(regCenter.getChildrenKeys(RunningNode.getRunningJobNodePath("test_job"))).thenReturn(Collections.emptyList()); runningService.remove(taskContext); @@ -133,22 +133,22 @@ public void assertRemoveByTaskContext() { } @Test - public void assertIsJobRunning() { + void assertIsJobRunning() { assertTrue(runningService.isJobRunning("test_job")); } @Test - public void assertIsTaskRunning() { + void assertIsTaskRunning() { assertTrue(runningService.isTaskRunning(MetaInfo.from(TaskNode.builder().build().getTaskNodePath()))); } @Test - public void assertIsTaskNotRunning() { + void assertIsTaskNotRunning() { assertFalse(runningService.isTaskRunning(MetaInfo.from(TaskNode.builder().shardingItem(2).build().getTaskNodePath()))); } @Test - public void assertMappingOperate() { + void assertMappingOperate() { String taskId = TaskNode.builder().build().getTaskNodeValue(); assertNull(runningService.popMapping(taskId)); runningService.addMapping(taskId, "localhost"); @@ -157,7 +157,7 @@ public void assertMappingOperate() { } @Test - public void assertClear() { + void assertClear() { assertFalse(runningService.getRunningTasks("test_job").isEmpty()); runningService.addMapping(TaskNode.builder().build().getTaskNodeValue(), "localhost"); runningService.clear(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java index e86db674c8..de9ef44749 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java @@ -50,7 +50,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class StatisticManagerTest { +class StatisticManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -67,12 +67,12 @@ public final class StatisticManagerTest { private StatisticManager statisticManager; @BeforeEach - public void setUp() { + void setUp() { statisticManager = StatisticManager.getInstance(regCenter, null); } @AfterEach - public void tearDown() { + void tearDown() { statisticManager.shutdown(); ReflectionUtils.setStaticFieldValue(StatisticManager.class, "instance", null); reset(configurationService); @@ -80,37 +80,37 @@ public void tearDown() { } @Test - public void assertGetInstance() { + void assertGetInstance() { assertThat(statisticManager, is(StatisticManager.getInstance(regCenter, null))); } @Test - public void assertStartupWhenRdbIsNotConfigured() { + void assertStartupWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); statisticManager.startup(); } @Test - public void assertStartupWhenRdbIsConfigured() { + void assertStartupWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); statisticManager.startup(); } @Test - public void assertShutdown() { + void assertShutdown() { ReflectionUtils.setFieldValue(statisticManager, "scheduler", scheduler); statisticManager.shutdown(); verify(scheduler).shutdown(); } @Test - public void assertTaskRun() { + void assertTaskRun() { statisticManager.taskRunSuccessfully(); statisticManager.taskRunFailed(); } @Test - public void assertTaskResultStatisticsWhenRdbIsNotConfigured() { + void assertTaskResultStatisticsWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); assertThat(statisticManager.getTaskResultStatisticsWeekly().getSuccessCount(), is(0)); assertThat(statisticManager.getTaskResultStatisticsWeekly().getFailedCount(), is(0)); @@ -119,7 +119,7 @@ public void assertTaskResultStatisticsWhenRdbIsNotConfigured() { } @Test - public void assertTaskResultStatisticsWhenRdbIsConfigured() { + void assertTaskResultStatisticsWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); when(rdbRepository.getSummedTaskResultStatistics(any(Date.class), any(StatisticInterval.class))) .thenReturn(new TaskResultStatistics(10, 10, StatisticInterval.DAY, new Date())); @@ -131,7 +131,7 @@ public void assertTaskResultStatisticsWhenRdbIsConfigured() { } @Test - public void assertJobExecutionTypeStatistics() { + void assertJobExecutionTypeStatistics() { ReflectionUtils.setFieldValue(statisticManager, "configurationService", configurationService); when(configurationService.loadAll()).thenReturn(Arrays.asList( CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job_1", CloudJobExecutionType.DAEMON), @@ -142,13 +142,13 @@ public void assertJobExecutionTypeStatistics() { } @Test - public void assertFindTaskRunningStatisticsWhenRdbIsNotConfigured() { + void assertFindTaskRunningStatisticsWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); assertTrue(statisticManager.findTaskRunningStatisticsWeekly().isEmpty()); } @Test - public void assertFindTaskRunningStatisticsWhenRdbIsConfigured() { + void assertFindTaskRunningStatisticsWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); when(rdbRepository.findTaskRunningStatistics(any(Date.class))).thenReturn(Collections.singletonList(new TaskRunningStatistics(10, new Date()))); assertThat(statisticManager.findTaskRunningStatisticsWeekly().size(), is(1)); @@ -156,13 +156,13 @@ public void assertFindTaskRunningStatisticsWhenRdbIsConfigured() { } @Test - public void assertFindJobRunningStatisticsWhenRdbIsNotConfigured() { + void assertFindJobRunningStatisticsWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); assertTrue(statisticManager.findJobRunningStatisticsWeekly().isEmpty()); } @Test - public void assertFindJobRunningStatisticsWhenRdbIsConfigured() { + void assertFindJobRunningStatisticsWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); when(rdbRepository.findJobRunningStatistics(any(Date.class))).thenReturn(Collections.singletonList(new JobRunningStatistics(10, new Date()))); assertThat(statisticManager.findJobRunningStatisticsWeekly().size(), is(1)); @@ -170,13 +170,13 @@ public void assertFindJobRunningStatisticsWhenRdbIsConfigured() { } @Test - public void assertFindJobRegisterStatisticsWhenRdbIsNotConfigured() { + void assertFindJobRegisterStatisticsWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); assertTrue(statisticManager.findJobRegisterStatisticsSinceOnline().isEmpty()); } @Test - public void assertFindJobRegisterStatisticsWhenRdbIsConfigured() { + void assertFindJobRegisterStatisticsWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); when(rdbRepository.findJobRegisterStatistics(any(Date.class))).thenReturn(Collections.singletonList(new JobRegisterStatistics(10, new Date()))); assertThat(statisticManager.findJobRegisterStatisticsSinceOnline().size(), is(1)); @@ -184,7 +184,7 @@ public void assertFindJobRegisterStatisticsWhenRdbIsConfigured() { } @Test - public void assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured() { + void assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); for (StatisticInterval each : StatisticInterval.values()) { TaskResultStatistics actual = statisticManager.findLatestTaskResultStatistics(each); @@ -194,7 +194,7 @@ public void assertFindLatestTaskResultStatisticsWhenRdbIsNotConfigured() { } @Test - public void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() { + void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); for (StatisticInterval each : StatisticInterval.values()) { when(rdbRepository.findLatestTaskResultStatistics(each)) @@ -207,13 +207,13 @@ public void assertFindLatestTaskResultStatisticsWhenRdbIsConfigured() { } @Test - public void assertFindTaskResultStatisticsDailyWhenRdbIsNotConfigured() { + void assertFindTaskResultStatisticsDailyWhenRdbIsNotConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", null); assertTrue(statisticManager.findTaskResultStatisticsDaily().isEmpty()); } @Test - public void assertFindTaskResultStatisticsDailyWhenRdbIsConfigured() { + void assertFindTaskResultStatisticsDailyWhenRdbIsConfigured() { ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository); when(rdbRepository.findTaskResultStatistics(any(Date.class), any(StatisticInterval.class))) .thenReturn(Collections.singletonList(new TaskResultStatistics(10, 5, StatisticInterval.MINUTE, new Date()))); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticsSchedulerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticsSchedulerTest.java index 039d60c9b5..24a594c79a 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticsSchedulerTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticsSchedulerTest.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class StatisticsSchedulerTest { +class StatisticsSchedulerTest { private StatisticsScheduler statisticsScheduler; @@ -40,20 +40,20 @@ public class StatisticsSchedulerTest { private Scheduler scheduler; @BeforeEach - public void setUp() { + void setUp() { statisticsScheduler = new StatisticsScheduler(); ReflectionUtils.setFieldValue(statisticsScheduler, "scheduler", scheduler); } @Test - public void assertRegister() throws SchedulerException { + void assertRegister() throws SchedulerException { StatisticJob job = new TestStatisticJob(); statisticsScheduler.register(job); verify(scheduler).scheduleJob(job.buildJobDetail(), job.buildTrigger()); } @Test - public void assertShutdown() throws SchedulerException { + void assertShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(false); statisticsScheduler.shutdown(); when(scheduler.isShutdown()).thenReturn(true); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/TaskResultMetaDataTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/TaskResultMetaDataTest.java index 8047204227..6fed73a2b8 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/TaskResultMetaDataTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/TaskResultMetaDataTest.java @@ -23,17 +23,17 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public class TaskResultMetaDataTest { +class TaskResultMetaDataTest { private TaskResultMetaData metaData; @BeforeEach - public void setUp() { + void setUp() { metaData = new TaskResultMetaData(); } @Test - public void assertIncrementAndGet() { + void assertIncrementAndGet() { for (int i = 0; i < 100; i++) { assertThat(metaData.incrementAndGetSuccessCount(), is(i + 1)); assertThat(metaData.incrementAndGetFailedCount(), is(i + 1)); @@ -43,7 +43,7 @@ public void assertIncrementAndGet() { } @Test - public void assertReset() { + void assertReset() { for (int i = 0; i < 100; i++) { metaData.incrementAndGetSuccessCount(); metaData.incrementAndGetFailedCount(); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/BaseStatisticJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/BaseStatisticJobTest.java index f732f2a909..922409aabc 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/BaseStatisticJobTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/BaseStatisticJobTest.java @@ -27,27 +27,27 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public class BaseStatisticJobTest { +class BaseStatisticJobTest { private TestStatisticJob testStatisticJob; @BeforeEach - public void setUp() { + void setUp() { testStatisticJob = new TestStatisticJob(); } @Test - public void assertGetTriggerName() { + void assertGetTriggerName() { assertThat(testStatisticJob.getTriggerName(), is(TestStatisticJob.class.getSimpleName() + "Trigger")); } @Test - public void assertGetJobName() { + void assertGetJobName() { assertThat(testStatisticJob.getJobName(), is(TestStatisticJob.class.getSimpleName())); } @Test - public void assertFindBlankStatisticTimes() { + void assertFindBlankStatisticTimes() { for (StatisticInterval each : StatisticInterval.values()) { int num = -2; for (Date eachTime : testStatisticJob.findBlankStatisticTimes(StatisticTimeUtils.getStatisticTime(each, num - 1), each)) { diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/JobRunningStatisticJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/JobRunningStatisticJobTest.java index 82103b9b99..0ffdc5a98e 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/JobRunningStatisticJobTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/JobRunningStatisticJobTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class JobRunningStatisticJobTest { +class JobRunningStatisticJobTest { @Mock private RunningService runningService; @@ -58,31 +58,31 @@ public class JobRunningStatisticJobTest { private JobRunningStatisticJob jobRunningStatisticJob; @BeforeEach - public void setUp() { + void setUp() { jobRunningStatisticJob = new JobRunningStatisticJob(); jobRunningStatisticJob.setRunningService(runningService); jobRunningStatisticJob.setRepository(repository); } @Test - public void assertBuildJobDetail() { + void assertBuildJobDetail() { assertThat(jobRunningStatisticJob.buildJobDetail().getKey().getName(), is(JobRunningStatisticJob.class.getSimpleName())); } @Test - public void assertBuildTrigger() { + void assertBuildTrigger() { Trigger trigger = jobRunningStatisticJob.buildTrigger(); assertThat(trigger.getKey().getName(), is(JobRunningStatisticJob.class.getSimpleName() + "Trigger")); } @Test - public void assertGetDataMap() { + void assertGetDataMap() { assertThat(jobRunningStatisticJob.getDataMap().get("runningService"), is(runningService)); assertThat(jobRunningStatisticJob.getDataMap().get("repository"), is(repository)); } @Test - public void assertExecuteWhenRepositoryIsEmpty() { + void assertExecuteWhenRepositoryIsEmpty() { Optional latestJobRunningStatistics = Optional.empty(); Optional latestTaskRunningStatistics = Optional.empty(); when(repository.findLatestJobRunningStatistics()).thenReturn(latestJobRunningStatistics); @@ -98,7 +98,7 @@ public void assertExecuteWhenRepositoryIsEmpty() { } @Test - public void assertExecute() { + void assertExecute() { Optional latestJobRunningStatistics = Optional.of(new JobRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3))); Optional latestTaskRunningStatistics = Optional.of(new TaskRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3))); when(repository.findLatestJobRunningStatistics()).thenReturn(latestJobRunningStatistics); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java index db32d5eb90..53593f5f37 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class RegisteredJobStatisticJobTest { +class RegisteredJobStatisticJobTest { @Mock private CloudJobConfigurationService configurationService; @@ -52,31 +52,31 @@ public class RegisteredJobStatisticJobTest { private RegisteredJobStatisticJob registeredJobStatisticJob; @BeforeEach - public void setUp() { + void setUp() { registeredJobStatisticJob = new RegisteredJobStatisticJob(); registeredJobStatisticJob.setConfigurationService(configurationService); registeredJobStatisticJob.setRepository(repository); } @Test - public void assertBuildJobDetail() { + void assertBuildJobDetail() { assertThat(registeredJobStatisticJob.buildJobDetail().getKey().getName(), is(RegisteredJobStatisticJob.class.getSimpleName())); } @Test - public void assertBuildTrigger() { + void assertBuildTrigger() { Trigger trigger = registeredJobStatisticJob.buildTrigger(); assertThat(trigger.getKey().getName(), is(RegisteredJobStatisticJob.class.getSimpleName() + "Trigger")); } @Test - public void assertGetDataMap() { + void assertGetDataMap() { assertThat(registeredJobStatisticJob.getDataMap().get("configurationService"), is(configurationService)); assertThat(registeredJobStatisticJob.getDataMap().get("repository"), is(repository)); } @Test - public void assertExecuteWhenRepositoryIsEmpty() { + void assertExecuteWhenRepositoryIsEmpty() { Optional latestOne = Optional.empty(); when(repository.findLatestJobRegisterStatistics()).thenReturn(latestOne); when(repository.add(any(JobRegisterStatistics.class))).thenReturn(true); @@ -88,7 +88,7 @@ public void assertExecuteWhenRepositoryIsEmpty() { } @Test - public void assertExecute() { + void assertExecute() { Optional latestOne = Optional.of(new JobRegisterStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.DAY, -3))); when(repository.findLatestJobRegisterStatistics()).thenReturn(latestOne); when(repository.add(any(JobRegisterStatistics.class))).thenReturn(true); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/TaskResultStatisticJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/TaskResultStatisticJobTest.java index c06375aeba..e4f340e160 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/TaskResultStatisticJobTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/TaskResultStatisticJobTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class TaskResultStatisticJobTest { +class TaskResultStatisticJobTest { private final StatisticInterval statisticInterval = StatisticInterval.MINUTE; @@ -51,7 +51,7 @@ public class TaskResultStatisticJobTest { private TaskResultStatisticJob taskResultStatisticJob; @BeforeEach - public void setUp() { + void setUp() { taskResultStatisticJob = new TaskResultStatisticJob(); sharedData = new TaskResultMetaData(); taskResultStatisticJob.setStatisticInterval(statisticInterval); @@ -60,12 +60,12 @@ public void setUp() { } @Test - public void assertBuildJobDetail() { + void assertBuildJobDetail() { assertThat(taskResultStatisticJob.buildJobDetail().getKey().getName(), is(TaskResultStatisticJob.class.getSimpleName() + "_" + statisticInterval)); } @Test - public void assertBuildTrigger() { + void assertBuildTrigger() { for (StatisticInterval each : StatisticInterval.values()) { taskResultStatisticJob.setStatisticInterval(each); Trigger trigger = taskResultStatisticJob.buildTrigger(); @@ -74,14 +74,14 @@ public void assertBuildTrigger() { } @Test - public void assertGetDataMap() { + void assertGetDataMap() { assertThat(taskResultStatisticJob.getDataMap().get("statisticInterval"), is(statisticInterval)); assertThat(taskResultStatisticJob.getDataMap().get("sharedData"), is(sharedData)); assertThat(taskResultStatisticJob.getDataMap().get("repository"), is(repository)); } @Test - public void assertExecuteWhenRepositoryIsEmpty() { + void assertExecuteWhenRepositoryIsEmpty() { Optional latestOne = Optional.empty(); for (StatisticInterval each : StatisticInterval.values()) { taskResultStatisticJob.setStatisticInterval(each); @@ -94,7 +94,7 @@ public void assertExecuteWhenRepositoryIsEmpty() { } @Test - public void assertExecute() { + void assertExecute() { for (StatisticInterval each : StatisticInterval.values()) { taskResultStatisticJob.setStatisticInterval(each); Optional latestOne = Optional.of(new TaskResultStatistics(0, 0, each, StatisticTimeUtils.getStatisticTime(each, -3))); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/util/StatisticTimeUtilsTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/util/StatisticTimeUtilsTest.java index 0e92ba7901..b13a1463e1 100755 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/util/StatisticTimeUtilsTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/util/StatisticTimeUtilsTest.java @@ -17,26 +17,26 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.statistics.util; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import org.apache.shardingsphere.elasticjob.cloud.statistics.StatisticInterval; +import org.junit.jupiter.api.Test; import java.text.SimpleDateFormat; import java.util.Date; -import org.apache.shardingsphere.elasticjob.cloud.statistics.StatisticInterval; -import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; -public class StatisticTimeUtilsTest { +class StatisticTimeUtilsTest { @Test - public void assertGetCurrentStatisticTime() { + void assertGetCurrentStatisticTime() { assertThat(getTimeStr(StatisticTimeUtils.getCurrentStatisticTime(StatisticInterval.MINUTE), StatisticInterval.MINUTE), is(getTimeStr(getNow(), StatisticInterval.MINUTE))); assertThat(getTimeStr(StatisticTimeUtils.getCurrentStatisticTime(StatisticInterval.HOUR), StatisticInterval.HOUR), is(getTimeStr(getNow(), StatisticInterval.HOUR))); assertThat(getTimeStr(StatisticTimeUtils.getCurrentStatisticTime(StatisticInterval.DAY), StatisticInterval.DAY), is(getTimeStr(getNow(), StatisticInterval.DAY))); } @Test - public void assertGetStatisticTime() { + void assertGetStatisticTime() { assertThat(getTimeStr(StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -1), StatisticInterval.MINUTE), is(getTimeStr(getLastMinute(), StatisticInterval.MINUTE))); assertThat(getTimeStr(StatisticTimeUtils.getStatisticTime(StatisticInterval.HOUR, -1), StatisticInterval.HOUR), is(getTimeStr(getLastHour(), StatisticInterval.HOUR))); assertThat(getTimeStr(StatisticTimeUtils.getStatisticTime(StatisticInterval.DAY, -1), StatisticInterval.DAY), is(getTimeStr(getYesterday(), StatisticInterval.DAY))); diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/util/IOUtilsTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/util/IOUtilsTest.java index 79567d986c..6a1f3591be 100644 --- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/util/IOUtilsTest.java +++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/util/IOUtilsTest.java @@ -17,34 +17,35 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.util; +import org.junit.jupiter.api.Test; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; -import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class IOUtilsTest { +class IOUtilsTest { @Test - public void assertToStringFromInputStream() throws Exception { + void assertToStringFromInputStream() throws Exception { byte[] b = "toStringFromInputStream".getBytes(StandardCharsets.UTF_8); InputStream in = new ByteArrayInputStream(b); assertThat(IOUtils.toString(in, null), is("toStringFromInputStream")); } @Test - public void assertToStringFromInputStreamWithEncoding() throws Exception { + void assertToStringFromInputStreamWithEncoding() throws Exception { byte[] b = "toStringFromInputStream".getBytes(StandardCharsets.UTF_8); InputStream in = new ByteArrayInputStream(b); assertThat(IOUtils.toString(in, "UTF-8"), is("toStringFromInputStream")); } @Test - public void assertToStringFromReader() throws Exception { + void assertToStringFromReader() throws Exception { byte[] b = "toStringFromReader".getBytes(StandardCharsets.UTF_8); InputStream is = new ByteArrayInputStream(b); Reader inr = new InputStreamReader(is, StandardCharsets.UTF_8); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java index ec384a48f3..7cac93132b 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java @@ -28,15 +28,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class DingtalkJobErrorHandlerPropertiesValidatorTest { +class DingtalkJobErrorHandlerPropertiesValidatorTest { @BeforeEach - public void startup() { + void startup() { ElasticJobServiceLoader.registerTypedService(JobErrorHandlerPropertiesValidator.class); } @Test - public void assertValidateWithNormal() { + void assertValidateWithNormal() { Properties properties = new Properties(); properties.setProperty(DingtalkPropertiesConstants.WEBHOOK, "webhook"); properties.setProperty(DingtalkPropertiesConstants.READ_TIMEOUT_MILLISECONDS, "1000"); @@ -46,7 +46,7 @@ public void assertValidateWithNormal() { } @Test - public void assertValidateWithPropsIsNull() { + void assertValidateWithPropsIsNull() { assertThrows(NullPointerException.class, () -> { DingtalkJobErrorHandlerPropertiesValidator actual = getValidator(); actual.validate(null); @@ -54,7 +54,7 @@ public void assertValidateWithPropsIsNull() { } @Test - public void assertValidateWithWebhookIsNull() { + void assertValidateWithWebhookIsNull() { DingtalkJobErrorHandlerPropertiesValidator actual = getValidator(); try { actual.validate(new Properties()); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerTest.java index 2b78aa26e6..cf971e3a7a 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerTest.java @@ -38,7 +38,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class DingtalkJobErrorHandlerTest { +class DingtalkJobErrorHandlerTest { private static final int PORT = 9875; @@ -50,7 +50,7 @@ public final class DingtalkJobErrorHandlerTest { @SuppressWarnings({"unchecked", "rawtypes"}) @BeforeAll - public static void init() { + static void init() { NettyRestfulServiceConfiguration config = new NettyRestfulServiceConfiguration(PORT); config.setHost(HOST); config.addControllerInstances(new DingtalkInternalController()); @@ -62,19 +62,19 @@ public static void init() { } @BeforeEach - public void setUp() { + void setUp() { appenderList.clear(); } @AfterAll - public static void close() { + static void close() { if (null != restfulService) { restfulService.shutdown(); } } @Test - public void assertHandleExceptionWithNotifySuccessful() { + void assertHandleExceptionWithNotifySuccessful() { DingtalkJobErrorHandler actual = getDingtalkJobErrorHandler(createConfigurationProperties("http://localhost:9875/send?access_token=mocked_token")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -84,7 +84,7 @@ public void assertHandleExceptionWithNotifySuccessful() { } @Test - public void assertHandleExceptionWithWrongToken() { + void assertHandleExceptionWithWrongToken() { DingtalkJobErrorHandler actual = getDingtalkJobErrorHandler(createConfigurationProperties("http://localhost:9875/send?access_token=wrong_token")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -94,7 +94,7 @@ public void assertHandleExceptionWithWrongToken() { } @Test - public void assertHandleExceptionWithUrlIsNotFound() { + void assertHandleExceptionWithUrlIsNotFound() { DingtalkJobErrorHandler actual = getDingtalkJobErrorHandler(createConfigurationProperties("http://localhost:9875/404")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -104,7 +104,7 @@ public void assertHandleExceptionWithUrlIsNotFound() { } @Test - public void assertHandleExceptionWithWrongUrl() { + void assertHandleExceptionWithWrongUrl() { DingtalkJobErrorHandler actual = getDingtalkJobErrorHandler(createNoSignJobConfigurationProperties("http://wrongUrl")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -114,7 +114,7 @@ public void assertHandleExceptionWithWrongUrl() { } @Test - public void assertHandleExceptionWithNoSign() { + void assertHandleExceptionWithNoSign() { DingtalkJobErrorHandler actual = getDingtalkJobErrorHandler(createNoSignJobConfigurationProperties("http://localhost:9875/send?access_token=mocked_token")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java index adb0839a41..8fd94190f5 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java @@ -28,15 +28,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class EmailJobErrorHandlerPropertiesValidatorTest { +class EmailJobErrorHandlerPropertiesValidatorTest { @BeforeEach - public void startup() { + void startup() { ElasticJobServiceLoader.registerTypedService(JobErrorHandlerPropertiesValidator.class); } @Test - public void assertValidateWithNormal() { + void assertValidateWithNormal() { Properties properties = new Properties(); properties.setProperty(EmailPropertiesConstants.HOST, "host"); properties.setProperty(EmailPropertiesConstants.SSL_TRUST, "*"); @@ -50,7 +50,7 @@ public void assertValidateWithNormal() { } @Test - public void assertValidateWithPropsIsNull() { + void assertValidateWithPropsIsNull() { assertThrows(NullPointerException.class, () -> { EmailJobErrorHandlerPropertiesValidator actual = getValidator(); actual.validate(null); @@ -58,7 +58,7 @@ public void assertValidateWithPropsIsNull() { } @Test - public void assertValidateWithHostIsNull() { + void assertValidateWithHostIsNull() { EmailJobErrorHandlerPropertiesValidator actual = getValidator(); try { actual.validate(new Properties()); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java index bb2a4b5289..169f022872 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java @@ -46,7 +46,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class EmailJobErrorHandlerTest { +class EmailJobErrorHandlerTest { private static List appenderList; @@ -58,19 +58,19 @@ public final class EmailJobErrorHandlerTest { @SuppressWarnings({"unchecked", "rawtypes"}) @BeforeAll - public static void init() { + static void init() { ch.qos.logback.classic.Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(EmailJobErrorHandler.class); ListAppender appender = (ListAppender) log.getAppender("EmailJobErrorHandlerTestAppender"); appenderList = appender.list; } @BeforeEach - public void setUp() { + void setUp() { appenderList.clear(); } @Test - public void assertHandleExceptionWithMessagingException() { + void assertHandleExceptionWithMessagingException() { EmailJobErrorHandler emailJobErrorHandler = getEmailJobErrorHandler(createConfigurationProperties()); Throwable cause = new RuntimeException("test"); String jobName = "test_job"; @@ -82,7 +82,7 @@ public void assertHandleExceptionWithMessagingException() { @Test @SneakyThrows - public void assertHandleExceptionSucceedInSendingEmail() { + void assertHandleExceptionSucceedInSendingEmail() { EmailJobErrorHandler emailJobErrorHandler = getEmailJobErrorHandler(createConfigurationProperties()); setUpMockSession(session); setFieldValue(emailJobErrorHandler, "session", session); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java index c81f994dc4..d715f9dc94 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java @@ -28,20 +28,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class JobErrorHandlerFactoryTest { +class JobErrorHandlerFactoryTest { @Test - public void assertGetDefaultHandler() { + void assertGetDefaultHandler() { assertThat(JobErrorHandlerFactory.createHandler("", new Properties()).orElse(null), instanceOf(LogJobErrorHandler.class)); } @Test - public void assertGetInvalidHandler() { + void assertGetInvalidHandler() { assertThrows(JobConfigurationException.class, () -> JobErrorHandlerFactory.createHandler("INVALID", new Properties()).orElseThrow(() -> new JobConfigurationException(""))); } @Test - public void assertGetHandler() { + void assertGetHandler() { assertThat(JobErrorHandlerFactory.createHandler("THROW", new Properties()).orElse(null), instanceOf(ThrowJobErrorHandler.class)); } } diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerReloadableTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerReloadableTest.java index 0456d27c48..c574986ba3 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerReloadableTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerReloadableTest.java @@ -38,13 +38,13 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class JobErrorHandlerReloadableTest { +class JobErrorHandlerReloadableTest { @Mock private JobErrorHandler mockJobErrorHandler; @Test - public void assertInitialize() { + void assertInitialize() { JobErrorHandlerReloadable jobErrorHandlerReloadable = new JobErrorHandlerReloadable(); String jobErrorHandlerType = "IGNORE"; JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobErrorHandlerType(jobErrorHandlerType).build(); @@ -57,7 +57,7 @@ public void assertInitialize() { } @Test - public void assertReload() { + void assertReload() { JobErrorHandlerReloadable jobErrorHandlerReloadable = new JobErrorHandlerReloadable(); setField(jobErrorHandlerReloadable, "jobErrorHandler", mockJobErrorHandler); setField(jobErrorHandlerReloadable, "jobErrorHandlerType", "mock"); @@ -72,7 +72,7 @@ public void assertReload() { } @Test - public void assertUnnecessaryToReload() { + void assertUnnecessaryToReload() { JobErrorHandlerReloadable jobErrorHandlerReloadable = new JobErrorHandlerReloadable(); String jobErrorHandlerType = "IGNORE"; JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobErrorHandlerType(jobErrorHandlerType).build(); @@ -84,7 +84,7 @@ public void assertUnnecessaryToReload() { } @Test - public void assertShutdown() { + void assertShutdown() { JobErrorHandlerReloadable jobErrorHandlerReloadable = new JobErrorHandlerReloadable(); setField(jobErrorHandlerReloadable, "jobErrorHandler", mockJobErrorHandler); jobErrorHandlerReloadable.close(); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/IgnoreJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/IgnoreJobErrorHandlerTest.java index 054ec2437c..fb92dbbe22 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/IgnoreJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/IgnoreJobErrorHandlerTest.java @@ -23,10 +23,10 @@ import java.util.Properties; -public final class IgnoreJobErrorHandlerTest { +class IgnoreJobErrorHandlerTest { @Test - public void assertHandleException() { + void assertHandleException() { JobErrorHandlerFactory.createHandler("IGNORE", new Properties()) .orElseThrow(() -> new JobConfigurationException("IGNORE error handler not found.")).handleException("test_job", new RuntimeException("test")); } diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/LogJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/LogJobErrorHandlerTest.java index d487643763..f5bf335124 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/LogJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/LogJobErrorHandlerTest.java @@ -33,25 +33,25 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class LogJobErrorHandlerTest { +class LogJobErrorHandlerTest { private static List appenderList; @SuppressWarnings({"unchecked", "rawtypes"}) @BeforeAll - public static void setupLogger() { + static void setupLogger() { ch.qos.logback.classic.Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(LogJobErrorHandler.class); ListAppender appender = (ListAppender) log.getAppender("LogJobErrorHandlerTestAppender"); appenderList = appender.list; } @BeforeEach - public void setUp() { + void setUp() { appenderList.clear(); } @Test - public void assertHandleException() { + void assertHandleException() { LogJobErrorHandler actual = (LogJobErrorHandler) JobErrorHandlerFactory.createHandler("LOG", new Properties()).orElseThrow(() -> new JobConfigurationException("LOG error handler not found.")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/ThrowJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/ThrowJobErrorHandlerTest.java index 86b1ac5504..c9bfaa7d47 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/ThrowJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/general/ThrowJobErrorHandlerTest.java @@ -26,11 +26,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ThrowJobErrorHandlerTest { +class ThrowJobErrorHandlerTest { @Test - public void assertHandleException() { - assertThrows(JobSystemException.class, () -> JobErrorHandlerFactory.createHandler("THROW", new Properties()).orElseThrow(() -> new JobConfigurationException("THROW error handler not found.")) - .handleException("test_job", new RuntimeException("test"))); + void assertHandleException() { + assertThrows(JobSystemException.class, () -> JobErrorHandlerFactory.createHandler("THROW", new Properties()) + .orElseThrow(() -> new JobConfigurationException("THROW error handler not found.")).handleException("test_job", new RuntimeException("test"))); } } diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java index 20e3353f2b..590ede1cbe 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java @@ -28,15 +28,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class WechatJobErrorHandlerPropertiesValidatorTest { +class WechatJobErrorHandlerPropertiesValidatorTest { @BeforeEach - public void startup() { + void startup() { ElasticJobServiceLoader.registerTypedService(JobErrorHandlerPropertiesValidator.class); } @Test - public void assertValidateWithNormal() { + void assertValidateWithNormal() { Properties properties = new Properties(); properties.setProperty(WechatPropertiesConstants.WEBHOOK, "webhook"); properties.setProperty(WechatPropertiesConstants.READ_TIMEOUT_MILLISECONDS, "1000"); @@ -46,7 +46,7 @@ public void assertValidateWithNormal() { } @Test - public void assertValidateWithPropsIsNull() { + void assertValidateWithPropsIsNull() { assertThrows(NullPointerException.class, () -> { WechatJobErrorHandlerPropertiesValidator actual = getValidator(); actual.validate(null); @@ -54,7 +54,7 @@ public void assertValidateWithPropsIsNull() { } @Test - public void assertValidateWithWebhookIsNull() { + void assertValidateWithWebhookIsNull() { WechatJobErrorHandlerPropertiesValidator actual = getValidator(); try { actual.validate(new Properties()); diff --git a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java index 790d19c6e4..b477210d45 100644 --- a/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java +++ b/elasticjob-ecosystem/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java @@ -38,7 +38,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class WechatJobErrorHandlerTest { +class WechatJobErrorHandlerTest { private static final int PORT = 9872; @@ -50,7 +50,7 @@ public final class WechatJobErrorHandlerTest { @SuppressWarnings({"unchecked", "rawtypes"}) @BeforeAll - public static void init() { + static void init() { NettyRestfulServiceConfiguration configuration = new NettyRestfulServiceConfiguration(PORT); configuration.setHost(HOST); configuration.addControllerInstances(new WechatInternalController()); @@ -62,19 +62,19 @@ public static void init() { } @BeforeEach - public void setUp() { + void setUp() { appenderList.clear(); } @AfterAll - public static void close() { + static void close() { if (null != restfulService) { restfulService.shutdown(); } } @Test - public void assertHandleExceptionWithNotifySuccessful() { + void assertHandleExceptionWithNotifySuccessful() { WechatJobErrorHandler actual = getWechatJobErrorHandler(createConfigurationProperties("http://localhost:9872/send?key=mocked_key")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -84,7 +84,7 @@ public void assertHandleExceptionWithNotifySuccessful() { } @Test - public void assertHandleExceptionWithWrongToken() { + void assertHandleExceptionWithWrongToken() { WechatJobErrorHandler actual = getWechatJobErrorHandler(createConfigurationProperties("http://localhost:9872/send?key=wrong_key")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -94,7 +94,7 @@ public void assertHandleExceptionWithWrongToken() { } @Test - public void assertHandleExceptionWithWrongUrl() { + void assertHandleExceptionWithWrongUrl() { WechatJobErrorHandler actual = getWechatJobErrorHandler(createConfigurationProperties("http://wrongUrl")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); @@ -104,7 +104,7 @@ public void assertHandleExceptionWithWrongUrl() { } @Test - public void assertHandleExceptionWithUrlIsNotFound() { + void assertHandleExceptionWithUrlIsNotFound() { WechatJobErrorHandler actual = getWechatJobErrorHandler(createConfigurationProperties("http://localhost:9872/404")); Throwable cause = new RuntimeException("test"); actual.handleException("test_job", cause); diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/ElasticJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/ElasticJobExecutorTest.java index 46628780c6..2e3abe8cd8 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/ElasticJobExecutorTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/ElasticJobExecutorTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ElasticJobExecutorTest { +class ElasticJobExecutorTest { @Mock private FooJob fooJob; @@ -63,7 +63,7 @@ public final class ElasticJobExecutorTest { private ElasticJobExecutor elasticJobExecutor; @BeforeEach - public void setUp() { + void setUp() { jobConfig = createJobConfiguration(); when(jobFacade.loadJobConfiguration(anyBoolean())).thenReturn(jobConfig); elasticJobExecutor = new ElasticJobExecutor(fooJob, jobConfig, jobFacade); @@ -83,7 +83,7 @@ private void setJobItemExecutor() { } @Test - public void assertExecuteWhenCheckMaxTimeDiffSecondsIntolerable() { + void assertExecuteWhenCheckMaxTimeDiffSecondsIntolerable() { assertThrows(JobSystemException.class, () -> { doThrow(JobExecutionEnvironmentException.class).when(jobFacade).checkJobExecutionEnvironment(); try { @@ -95,7 +95,7 @@ public void assertExecuteWhenCheckMaxTimeDiffSecondsIntolerable() { } @Test - public void assertExecuteWhenPreviousJobStillRunning() { + void assertExecuteWhenPreviousJobStillRunning() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 3, "", Collections.emptyMap()); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true); @@ -107,7 +107,7 @@ public void assertExecuteWhenPreviousJobStillRunning() { } @Test - public void assertExecuteWhenShardingItemsIsEmpty() { + void assertExecuteWhenShardingItemsIsEmpty() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 3, "", Collections.emptyMap()); prepareForIsNotMisfire(jobFacade, shardingContexts); elasticJobExecutor.execute(); @@ -117,12 +117,12 @@ public void assertExecuteWhenShardingItemsIsEmpty() { } @Test - public void assertExecuteFailureWhenThrowExceptionForSingleShardingItem() { + void assertExecuteFailureWhenThrowExceptionForSingleShardingItem() { assertThrows(JobSystemException.class, () -> assertExecuteFailureWhenThrowException(createSingleShardingContexts())); } @Test - public void assertExecuteFailureWhenThrowExceptionForMultipleShardingItems() { + void assertExecuteFailureWhenThrowExceptionForMultipleShardingItems() { assertExecuteFailureWhenThrowException(createMultipleShardingContexts()); } @@ -148,12 +148,12 @@ private String getErrorMessage(final ShardingContexts shardingContexts) { } @Test - public void assertExecuteSuccessForSingleShardingItems() { + void assertExecuteSuccessForSingleShardingItems() { assertExecuteSuccess(createSingleShardingContexts()); } @Test - public void assertExecuteSuccessForMultipleShardingItems() { + void assertExecuteSuccessForMultipleShardingItems() { assertExecuteSuccess(createMultipleShardingContexts()); } @@ -167,7 +167,7 @@ private void assertExecuteSuccess(final ShardingContexts shardingContexts) { } @Test - public void assertExecuteWithMisfireIsEmpty() { + void assertExecuteWithMisfireIsEmpty() { ShardingContexts shardingContexts = createMultipleShardingContexts(); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); elasticJobExecutor.execute(); @@ -176,7 +176,7 @@ public void assertExecuteWithMisfireIsEmpty() { } @Test - public void assertExecuteWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() { + void assertExecuteWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() { ShardingContexts shardingContexts = createMultipleShardingContexts(); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); elasticJobExecutor.execute(); @@ -186,7 +186,7 @@ public void assertExecuteWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() { } @Test - public void assertExecuteWithMisfire() { + void assertExecuteWithMisfire() { ShardingContexts shardingContexts = createMultipleShardingContexts(); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true, false); @@ -200,7 +200,7 @@ public void assertExecuteWithMisfire() { } @Test - public void assertBeforeJobExecutedFailure() { + void assertBeforeJobExecutedFailure() { assertThrows(JobSystemException.class, () -> { ShardingContexts shardingContexts = createMultipleShardingContexts(); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); @@ -214,7 +214,7 @@ public void assertBeforeJobExecutedFailure() { } @Test - public void assertAfterJobExecutedFailure() { + void assertAfterJobExecutedFailure() { assertThrows(JobSystemException.class, () -> { ShardingContexts shardingContexts = createMultipleShardingContexts(); when(jobFacade.getShardingContexts()).thenReturn(shardingContexts); diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/item/JobItemExecutorFactoryTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/item/JobItemExecutorFactoryTest.java index 08c0fe09b6..bd6b3dd158 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/item/JobItemExecutorFactoryTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-kernel/src/test/java/org/apache/shardingsphere/elasticjob/executor/item/JobItemExecutorFactoryTest.java @@ -29,30 +29,30 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class JobItemExecutorFactoryTest { +class JobItemExecutorFactoryTest { @Test - public void assertGetExecutorByClassFailureWithInvalidType() { + void assertGetExecutorByClassFailureWithInvalidType() { assertThrows(JobConfigurationException.class, () -> JobItemExecutorFactory.getExecutor(FailedJob.class)); } @Test - public void assertGetExecutorByClassSuccessWithCurrentClass() { + void assertGetExecutorByClassSuccessWithCurrentClass() { assertThat(JobItemExecutorFactory.getExecutor(FooJob.class), instanceOf(ClassedFooJobExecutor.class)); } @Test - public void assertGetExecutorByClassSuccessWithSubClass() { + void assertGetExecutorByClassSuccessWithSubClass() { assertThat(JobItemExecutorFactory.getExecutor(DetailedFooJob.class), instanceOf(ClassedFooJobExecutor.class)); } @Test - public void assertGetExecutorByTypeFailureWithInvalidType() { + void assertGetExecutorByTypeFailureWithInvalidType() { assertThrows(JobConfigurationException.class, () -> JobItemExecutorFactory.getExecutor("FAIL")); } @Test - public void assertGetExecutorByTypeSuccess() { + void assertGetExecutorByTypeSuccess() { assertThat(JobItemExecutorFactory.getExecutor("FOO"), instanceOf(TypedFooJobExecutor.class)); } } diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-dataflow-executor/src/test/java/org/apache/shardingsphere/elasticjob/dataflow/executor/DataflowJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-dataflow-executor/src/test/java/org/apache/shardingsphere/elasticjob/dataflow/executor/DataflowJobExecutorTest.java index 7f1ed741f5..fa24700ed8 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-dataflow-executor/src/test/java/org/apache/shardingsphere/elasticjob/dataflow/executor/DataflowJobExecutorTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-dataflow-executor/src/test/java/org/apache/shardingsphere/elasticjob/dataflow/executor/DataflowJobExecutorTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DataflowJobExecutorTest { +class DataflowJobExecutorTest { private DataflowJobExecutor jobExecutor; @@ -59,13 +59,13 @@ public final class DataflowJobExecutorTest { private Properties properties; @BeforeEach - public void createJobExecutor() { + void createJobExecutor() { jobExecutor = new DataflowJobExecutor(); } @SuppressWarnings("unchecked") @Test - public void assertProcessWithStreamingExecute() { + void assertProcessWithStreamingExecute() { List data = Arrays.asList("DataflowJob1", "DataflowJob2"); when(jobConfig.getProps()).thenReturn(properties); when(properties.getOrDefault(DataflowJobProperties.STREAM_PROCESS_KEY, false)).thenReturn("true"); @@ -77,7 +77,7 @@ public void assertProcessWithStreamingExecute() { @SuppressWarnings("unchecked") @Test - public void assertProcessWithOneOffExecute() { + void assertProcessWithOneOffExecute() { List data = Arrays.asList("DataflowJob1", "DataflowJob2"); when(jobConfig.getProps()).thenReturn(properties); when(properties.getOrDefault(DataflowJobProperties.STREAM_PROCESS_KEY, false)).thenReturn("false"); @@ -87,7 +87,7 @@ public void assertProcessWithOneOffExecute() { } @Test - public void assertGetElasticJobClass() { + void assertGetElasticJobClass() { assertThat(jobExecutor.getElasticJobClass(), is(DataflowJob.class)); } } diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java index 2d6b4c9c69..f025ef231d 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java @@ -45,7 +45,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class HttpJobExecutorTest { +class HttpJobExecutorTest { private static final int PORT = 9876; @@ -72,7 +72,7 @@ public final class HttpJobExecutorTest { private HttpJobExecutor jobExecutor; @BeforeAll - public static void init() { + static void init() { NettyRestfulServiceConfiguration configuration = new NettyRestfulServiceConfiguration(PORT); configuration.setHost(HOST); configuration.addControllerInstances(new InternalController()); @@ -81,20 +81,20 @@ public static void init() { } @BeforeEach - public void setUp() { + void setUp() { lenient().when(jobConfig.getProps()).thenReturn(properties); jobExecutor = new HttpJobExecutor(); } @AfterAll - public static void close() { + static void close() { if (null != restfulService) { restfulService.shutdown(); } } @Test - public void assertUrlEmpty() { + void assertUrlEmpty() { assertThrows(JobConfigurationException.class, () -> { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(""); jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext); @@ -102,7 +102,7 @@ public void assertUrlEmpty() { } @Test - public void assertMethodEmpty() { + void assertMethodEmpty() { assertThrows(JobConfigurationException.class, () -> { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/getName")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn(""); @@ -111,7 +111,7 @@ public void assertMethodEmpty() { } @Test - public void assertProcessWithoutSuccessCode() { + void assertProcessWithoutSuccessCode() { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/unknownMethod")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("GET"); when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn(""); @@ -121,7 +121,7 @@ public void assertProcessWithoutSuccessCode() { } @Test - public void assertProcessWithGet() { + void assertProcessWithGet() { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/getName")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("GET"); when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn(""); @@ -131,7 +131,7 @@ public void assertProcessWithGet() { } @Test - public void assertProcessHeader() { + void assertProcessHeader() { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/getShardingContext")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("GET"); when(jobConfig.getProps().getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, "3000")).thenReturn("4000"); @@ -140,7 +140,7 @@ public void assertProcessHeader() { } @Test - public void assertProcessWithPost() { + void assertProcessWithPost() { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/updateName")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("POST"); when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn("name=elasticjob"); @@ -151,7 +151,7 @@ public void assertProcessWithPost() { } @Test - public void assertProcessWithIOException() { + void assertProcessWithIOException() { assertThrows(JobExecutionException.class, () -> { when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn(getRequestUri("/postWithTimeout")); when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("POST"); @@ -163,7 +163,7 @@ public void assertProcessWithIOException() { } @Test - public void assertGetType() { + void assertGetType() { assertThat(jobExecutor.getType(), is("HTTP")); } diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java index 3f3a9dfdd7..ea614cff1b 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ScriptJobExecutorTest { +class ScriptJobExecutorTest { @Mock private ElasticJob elasticJob; @@ -60,12 +60,12 @@ public final class ScriptJobExecutorTest { private ScriptJobExecutor jobExecutor; @BeforeEach - public void setUp() { + void setUp() { jobExecutor = new ScriptJobExecutor(); } @Test - public void assertProcessWithJobConfigurationException() { + void assertProcessWithJobConfigurationException() { assertThrows(JobConfigurationException.class, () -> { when(jobConfig.getProps()).thenReturn(properties); jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext); @@ -73,7 +73,7 @@ public void assertProcessWithJobConfigurationException() { } @Test - public void assertProcessWithJobSystemException() { + void assertProcessWithJobSystemException() { assertThrows(JobSystemException.class, () -> { when(jobConfig.getProps()).thenReturn(properties); when(properties.getProperty(ScriptJobProperties.SCRIPT_KEY)).thenReturn("demo.sh"); @@ -82,7 +82,7 @@ public void assertProcessWithJobSystemException() { } @Test - public void assertProcess() { + void assertProcess() { when(jobConfig.getProps()).thenReturn(properties); when(properties.getProperty(ScriptJobProperties.SCRIPT_KEY)).thenReturn(determineCommandByPlatform()); jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext); @@ -101,7 +101,7 @@ private String getEcho() { } @Test - public void assertGetType() { + void assertGetType() { assertThat(jobExecutor.getType(), is("SCRIPT")); } } diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-simple-executor/src/test/java/org/apache/shardingsphere/elasticjob/simple/executor/SimpleJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-simple-executor/src/test/java/org/apache/shardingsphere/elasticjob/simple/executor/SimpleJobExecutorTest.java index a0cd5667a0..3a5b202a7d 100644 --- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-simple-executor/src/test/java/org/apache/shardingsphere/elasticjob/simple/executor/SimpleJobExecutorTest.java +++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-simple-executor/src/test/java/org/apache/shardingsphere/elasticjob/simple/executor/SimpleJobExecutorTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class SimpleJobExecutorTest { +class SimpleJobExecutorTest { @Mock private FooSimpleJob fooSimpleJob; @@ -48,18 +48,18 @@ public final class SimpleJobExecutorTest { private SimpleJobExecutor jobExecutor; @BeforeEach - public void setUp() { + void setUp() { jobExecutor = new SimpleJobExecutor(); } @Test - public void assertProcess() { + void assertProcess() { jobExecutor.process(fooSimpleJob, jobConfig, jobFacade, any()); verify(fooSimpleJob, times(1)).execute(any()); } @Test - public void assertGetElasticJobClass() { + void assertGetElasticJobClass() { assertThat(jobExecutor.getElasticJobClass(), is(SimpleJob.class)); } } diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/JobTracingEventBusTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/JobTracingEventBusTest.java index b85cc30a46..d1ba019871 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/JobTracingEventBusTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/JobTracingEventBusTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class JobTracingEventBusTest { +class JobTracingEventBusTest { @Mock private JobEventCaller jobEventCaller; @@ -49,13 +49,13 @@ public final class JobTracingEventBusTest { private JobTracingEventBus jobTracingEventBus; @Test - public void assertRegisterFailure() { + void assertRegisterFailure() { jobTracingEventBus = new JobTracingEventBus(new TracingConfiguration<>("FAIL", null)); assertIsRegistered(false); } @Test - public void assertPost() throws InterruptedException { + void assertPost() throws InterruptedException { jobTracingEventBus = new JobTracingEventBus(new TracingConfiguration<>("TEST", jobEventCaller)); assertIsRegistered(true); jobTracingEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)); @@ -66,7 +66,7 @@ public void assertPost() throws InterruptedException { } @Test - public void assertPostWithoutListener() throws ReflectiveOperationException { + void assertPostWithoutListener() throws ReflectiveOperationException { jobTracingEventBus = new JobTracingEventBus(); assertIsRegistered(false); Field field = JobTracingEventBus.class.getDeclaredField("eventBus"); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java index 7a10039fe1..e83d4b886e 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java @@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class JobExecutionEventTest { +class JobExecutionEventTest { @Test - public void assertNewJobExecutionEvent() { + void assertNewJobExecutionEvent() { JobExecutionEvent actual = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getSource(), is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER)); @@ -42,7 +42,7 @@ public void assertNewJobExecutionEvent() { } @Test - public void assertExecutionSuccess() { + void assertExecutionSuccess() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); JobExecutionEvent successEvent = startEvent.executionSuccess(); assertNotNull(successEvent.getCompleteTime()); @@ -50,7 +50,7 @@ public void assertExecutionSuccess() { } @Test - public void assertExecutionFailure() { + void assertExecutionFailure() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure"); assertNotNull(failureEvent.getCompleteTime()); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/listener/TracingListenerFactoryTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/listener/TracingListenerFactoryTest.java index c284f5e553..f6ab431e9c 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/listener/TracingListenerFactoryTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/listener/TracingListenerFactoryTest.java @@ -27,20 +27,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class TracingListenerFactoryTest { +class TracingListenerFactoryTest { @Test - public void assertGetListenerWithNullType() { + void assertGetListenerWithNullType() { assertThrows(TracingConfigurationException.class, () -> TracingListenerFactory.getListener(new TracingConfiguration<>("", null))); } @Test - public void assertGetInvalidListener() { + void assertGetInvalidListener() { assertThrows(TracingConfigurationException.class, () -> TracingListenerFactory.getListener(new TracingConfiguration<>("INVALID", null))); } @Test - public void assertGetListener() throws TracingConfigurationException { + void assertGetListener() throws TracingConfigurationException { assertThat(TracingListenerFactory.getListener(new TracingConfiguration<>("TEST", new JobEventCallerConfiguration(() -> { }))), instanceOf(TestTracingListener.class)); } diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/storage/TracingStorageConverterFactoryTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/storage/TracingStorageConverterFactoryTest.java index 4f31edb5f1..760fc956a0 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/storage/TracingStorageConverterFactoryTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/storage/TracingStorageConverterFactoryTest.java @@ -23,15 +23,15 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class TracingStorageConverterFactoryTest { +class TracingStorageConverterFactoryTest { @Test - public void assertConverterExists() { + void assertConverterExists() { assertTrue(TracingStorageConverterFactory.findConverter(JobEventCaller.class).isPresent()); } @Test - public void assertConverterNotFound() { + void assertConverterNotFound() { assertFalse(TracingStorageConverterFactory.findConverter(AClassWithoutCorrespondingConverter.class).isPresent()); } diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/yaml/YamlTracingConfigurationConverterTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/yaml/YamlTracingConfigurationConverterTest.java index 5cefd95961..3c14e97c6e 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/yaml/YamlTracingConfigurationConverterTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/yaml/YamlTracingConfigurationConverterTest.java @@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class YamlTracingConfigurationConverterTest { +class YamlTracingConfigurationConverterTest { @Test - public void assertConvertTracingConfiguration() { + void assertConvertTracingConfiguration() { JobEventCaller expectedStorage = () -> { }; TracingConfiguration tracingConfiguration = new TracingConfiguration<>("TEST", expectedStorage); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceConfigurationTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceConfigurationTest.java index 442ec49f34..b8ddd1e149 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceConfigurationTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceConfigurationTest.java @@ -35,10 +35,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; -public final class DataSourceConfigurationTest { +class DataSourceConfigurationTest { @Test - public void assertGetDataSourceConfiguration() throws SQLException { + void assertGetDataSourceConfiguration() throws SQLException { HikariDataSource actualDataSource = new HikariDataSource(); actualDataSource.setDriverClassName("org.h2.Driver"); actualDataSource.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL"); @@ -55,7 +55,7 @@ public void assertGetDataSourceConfiguration() throws SQLException { } @Test - public void assertCreateDataSource() { + void assertCreateDataSource() { Map props = new HashMap<>(16, 1); props.put("driverClassName", "org.h2.Driver"); props.put("jdbcUrl", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL"); @@ -73,7 +73,7 @@ public void assertCreateDataSource() { } @Test - public void assertEquals() { + void assertEquals() { DataSourceConfiguration originalDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); DataSourceConfiguration targetDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); assertThat(originalDataSourceConfig, is(originalDataSourceConfig)); @@ -84,7 +84,7 @@ public void assertEquals() { } @Test - public void assertNotEquals() { + void assertNotEquals() { DataSourceConfiguration originalDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); DataSourceConfiguration targetDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); originalDataSourceConfig.getProps().put("username", "root"); @@ -93,12 +93,12 @@ public void assertNotEquals() { } @Test - public void assertEqualsWithNull() { + void assertEqualsWithNull() { assertFalse(new DataSourceConfiguration(HikariDataSource.class.getName()).equals(null)); } @Test - public void assertSameHashCode() { + void assertSameHashCode() { DataSourceConfiguration originalDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); DataSourceConfiguration targetDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); assertThat(originalDataSourceConfig.hashCode(), is(targetDataSourceConfig.hashCode())); @@ -111,7 +111,7 @@ public void assertSameHashCode() { } @Test - public void assertDifferentHashCode() { + void assertDifferentHashCode() { DataSourceConfiguration originalDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); DataSourceConfiguration targetDataSourceConfig = new DataSourceConfiguration(HikariDataSource.class.getName()); originalDataSourceConfig.getProps().put("username", "root"); @@ -125,7 +125,7 @@ public void assertDifferentHashCode() { @SuppressWarnings("unchecked") @Test - public void assertGetDataSourceConfigurationWithConnectionInitSqls() { + void assertGetDataSourceConfigurationWithConnectionInitSqls() { BasicDataSource actualDataSource = new BasicDataSource(); actualDataSource.setDriverClassName("org.h2.Driver"); actualDataSource.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL"); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceRegistryTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceRegistryTest.java index f2e4e863b2..f419a081dc 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceRegistryTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceRegistryTest.java @@ -32,13 +32,13 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DataSourceRegistryTest { +class DataSourceRegistryTest { @Mock private DataSourceConfiguration dataSourceConfiguration; @Test - public void assertGetDataSourceBySameConfiguration() { + void assertGetDataSourceBySameConfiguration() { when(dataSourceConfiguration.createDataSource()).then(invocation -> mock(DataSource.class)); DataSource expected = DataSourceRegistry.getInstance().getDataSource(dataSourceConfiguration); DataSource actual = DataSourceRegistry.getInstance().getDataSource(dataSourceConfiguration); @@ -47,7 +47,7 @@ public void assertGetDataSourceBySameConfiguration() { } @Test - public void assertGetDataSourceWithDifferentConfiguration() { + void assertGetDataSourceWithDifferentConfiguration() { when(dataSourceConfiguration.createDataSource()).then(invocation -> mock(DataSource.class)); DataSourceConfiguration anotherDataSourceConfiguration = mock(DataSourceConfiguration.class); when(anotherDataSourceConfiguration.createDataSource()).then(invocation -> mock(DataSource.class)); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceTracingStorageConverterTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceTracingStorageConverterTest.java index 5fcc05194b..0c467b6a5c 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceTracingStorageConverterTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/datasource/DataSourceTracingStorageConverterTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DataSourceTracingStorageConverterTest { +class DataSourceTracingStorageConverterTest { @Mock private DataSource dataSource; @@ -52,7 +52,7 @@ public final class DataSourceTracingStorageConverterTest { private DatabaseMetaData databaseMetaData; @Test - public void assertConvert() throws SQLException { + void assertConvert() throws SQLException { when(dataSource.getConnection()).thenReturn(connection); when(connection.getMetaData()).thenReturn(databaseMetaData); when(databaseMetaData.getURL()).thenReturn("jdbc:url"); @@ -62,7 +62,7 @@ public void assertConvert() throws SQLException { } @Test - public void assertConvertFailed() { + void assertConvertFailed() { assertThrows(TracingStorageUnavailableException.class, () -> { DataSourceTracingStorageConverter converter = new DataSourceTracingStorageConverter(); doThrow(SQLException.class).when(dataSource).getConnection(); @@ -71,7 +71,7 @@ public void assertConvertFailed() { } @Test - public void assertStorageType() { + void assertStorageType() { TracingStorageConverter converter = TracingStorageConverterFactory.findConverter(HikariDataSource.class).orElse(null); assertNotNull(converter); assertThat(converter.storageType(), is(DataSource.class)); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java index 1bf7e064f7..781b3652fe 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java @@ -25,10 +25,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class RDBTracingListenerConfigurationTest { +class RDBTracingListenerConfigurationTest { @Test - public void assertCreateTracingListenerSuccess() throws TracingConfigurationException { + void assertCreateTracingListenerSuccess() throws TracingConfigurationException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:job_event_storage"); @@ -38,7 +38,7 @@ public void assertCreateTracingListenerSuccess() throws TracingConfigurationExce } @Test - public void assertCreateTracingListenerFailure() { + void assertCreateTracingListenerFailure() { assertThrows(TracingConfigurationException.class, () -> new RDBTracingListenerConfiguration().createTracingListener(new BasicDataSource())); } } diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerTest.java index 0a41349898..f16ecee1f5 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class RDBTracingListenerTest { +class RDBTracingListenerTest { private static final String JOB_NAME = "test_rdb_event_listener"; @@ -50,7 +50,7 @@ public final class RDBTracingListenerTest { private JobTracingEventBus jobTracingEventBus; @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:job_event_storage"); @@ -69,14 +69,14 @@ private void setRepository(final RDBTracingListener tracingListener) { } @Test - public void assertPostJobExecutionEvent() { + void assertPostJobExecutionEvent() { JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", JOB_NAME, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); jobTracingEventBus.post(jobExecutionEvent); verify(repository, atMost(1)).addJobExecutionEvent(jobExecutionEvent); } @Test - public void assertPostJobStatusTraceEvent() { + void assertPostJobStatusTraceEvent() { JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(JOB_NAME, "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "READY", "0", State.TASK_RUNNING, "message is empty."); jobTracingEventBus.post(jobStatusTraceEvent); verify(repository, atMost(1)).addJobStatusTraceEvent(jobStatusTraceEvent); diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/storage/RDBJobEventStorageTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/storage/RDBJobEventStorageTest.java index 5fc5c40848..9f1b09c64f 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/storage/RDBJobEventStorageTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/storage/RDBJobEventStorageTest.java @@ -36,14 +36,14 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class RDBJobEventStorageTest { +class RDBJobEventStorageTest { private RDBJobEventStorage storage; private BasicDataSource dataSource; @BeforeEach - public void setup() throws SQLException { + void setup() throws SQLException { dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:job_event_storage"); @@ -53,23 +53,23 @@ public void setup() throws SQLException { } @AfterEach - public void teardown() throws SQLException { + void teardown() throws SQLException { dataSource.close(); } @Test - public void assertAddJobExecutionEvent() { + void assertAddJobExecutionEvent() { assertTrue(storage.addJobExecutionEvent(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0))); } @Test - public void assertAddJobStatusTraceEvent() { + void assertAddJobStatusTraceEvent() { assertTrue(storage.addJobStatusTraceEvent( new JobStatusTraceEvent("test_job", "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "READY", "0", State.TASK_RUNNING, "message is empty."))); } @Test - public void assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState() { + void assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState() { JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent( "test_job", "fake_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_STAGING, "message is empty."); jobStatusTraceEvent.setOriginalTaskId("original_fake_failover_task_id"); @@ -79,7 +79,7 @@ public void assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState() { } @Test - public void assertAddJobStatusTraceEventWhenFailoverWithTaskFailedState() { + void assertAddJobStatusTraceEventWhenFailoverWithTaskFailedState() { JobStatusTraceEvent stagingJobStatusTraceEvent = new JobStatusTraceEvent( "test_job", "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, "FAILOVER", "0", State.TASK_STAGING, "message is empty."); stagingJobStatusTraceEvent.setOriginalTaskId("original_fake_failed_failover_task_id"); @@ -95,7 +95,7 @@ public void assertAddJobStatusTraceEventWhenFailoverWithTaskFailedState() { } @Test - public void assertUpdateJobExecutionEventWhenSuccess() { + void assertUpdateJobExecutionEventWhenSuccess() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); assertTrue(storage.addJobExecutionEvent(startEvent)); JobExecutionEvent successEvent = startEvent.executionSuccess(); @@ -103,7 +103,7 @@ public void assertUpdateJobExecutionEventWhenSuccess() { } @Test - public void assertUpdateJobExecutionEventWhenFailure() { + void assertUpdateJobExecutionEventWhenFailure() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); assertTrue(storage.addJobExecutionEvent(startEvent)); JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure"); @@ -113,7 +113,7 @@ public void assertUpdateJobExecutionEventWhenFailure() { } @Test - public void assertUpdateJobExecutionEventWhenSuccessAndConflict() { + void assertUpdateJobExecutionEventWhenSuccessAndConflict() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); JobExecutionEvent successEvent = startEvent.executionSuccess(); assertTrue(storage.addJobExecutionEvent(successEvent)); @@ -121,7 +121,7 @@ public void assertUpdateJobExecutionEventWhenSuccessAndConflict() { } @Test - public void assertUpdateJobExecutionEventWhenFailureAndConflict() { + void assertUpdateJobExecutionEventWhenFailureAndConflict() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); JobExecutionEvent failureEvent = startEvent.executionFailure("java.lang.RuntimeException: failure"); assertTrue(storage.addJobExecutionEvent(failureEvent)); @@ -130,7 +130,7 @@ public void assertUpdateJobExecutionEventWhenFailureAndConflict() { } @Test - public void assertUpdateJobExecutionEventWhenFailureAndMessageExceed() { + void assertUpdateJobExecutionEventWhenFailureAndMessageExceed() { JobExecutionEvent startEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0); assertTrue(storage.addJobExecutionEvent(startEvent)); StringBuilder failureMsg = new StringBuilder(); @@ -143,7 +143,7 @@ public void assertUpdateJobExecutionEventWhenFailureAndMessageExceed() { } @Test - public void assertFindJobExecutionEvent() { + void assertFindJobExecutionEvent() { storage.addJobExecutionEvent(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)); } } diff --git a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/yaml/YamlDataSourceConfigurationConverterTest.java b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/yaml/YamlDataSourceConfigurationConverterTest.java index 8113a08c08..9b0545cf06 100644 --- a/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/yaml/YamlDataSourceConfigurationConverterTest.java +++ b/elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/yaml/YamlDataSourceConfigurationConverterTest.java @@ -28,10 +28,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class YamlDataSourceConfigurationConverterTest { +class YamlDataSourceConfigurationConverterTest { @Test - public void assertConvertDataSourceConfiguration() { + void assertConvertDataSourceConfiguration() { DataSourceConfiguration dataSourceConfiguration = new DataSourceConfiguration("org.h2.Driver"); dataSourceConfiguration.getProps().put("foo", "bar"); YamlDataSourceConfigurationConverter converter = new YamlDataSourceConfigurationConverter(); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java index 47b990a437..b6eeb74f3d 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java @@ -28,12 +28,12 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ElasticJobExecutorServiceTest { +class ElasticJobExecutorServiceTest { private static boolean hasExecuted; @Test - public void assertCreateExecutorService() { + void assertCreateExecutorService() { ElasticJobExecutorService executorServiceObject = new ElasticJobExecutorService("executor-service-test", 1); assertThat(executorServiceObject.getActiveThreadCount(), is(0)); assertThat(executorServiceObject.getWorkQueueSize(), is(0)); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java index 6aa87e4856..c7856ef707 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ExecutorServiceReloadableTest.java @@ -35,13 +35,13 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class ExecutorServiceReloadableTest { +class ExecutorServiceReloadableTest { @Mock private ExecutorService mockExecutorService; @Test - public void assertInitialize() { + void assertInitialize() { ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable(); String jobExecutorServiceHandlerType = "SINGLE_THREAD"; JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).build(); @@ -55,7 +55,7 @@ public void assertInitialize() { } @Test - public void assertReload() { + void assertReload() { ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable(); setField(executorServiceReloadable, "jobExecutorServiceHandlerType", "mock"); setField(executorServiceReloadable, "executorService", mockExecutorService); @@ -69,7 +69,7 @@ public void assertReload() { } @Test - public void assertUnnecessaryToReload() { + void assertUnnecessaryToReload() { ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable(); JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).build(); executorServiceReloadable.init(jobConfig); @@ -81,7 +81,7 @@ public void assertUnnecessaryToReload() { } @Test - public void assertShutdown() { + void assertShutdown() { ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable(); setField(executorServiceReloadable, "executorService", mockExecutorService); executorServiceReloadable.close(); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/ShardingItemParametersTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/ShardingItemParametersTest.java index 040e44b06b..432efe2386 100755 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/ShardingItemParametersTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/ShardingItemParametersTest.java @@ -28,25 +28,25 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ShardingItemParametersTest { +class ShardingItemParametersTest { @Test - public void assertNewWhenPairFormatInvalid() { + void assertNewWhenPairFormatInvalid() { assertThrows(JobConfigurationException.class, () -> new ShardingItemParameters("xxx-xxx")); } @Test - public void assertNewWhenItemIsNotNumber() { + void assertNewWhenItemIsNotNumber() { assertThrows(JobConfigurationException.class, () -> new ShardingItemParameters("xxx=xxx")); } @Test - public void assertGetMapWhenIsEmpty() { + void assertGetMapWhenIsEmpty() { assertThat(new ShardingItemParameters("").getMap(), is(Collections.EMPTY_MAP)); } @Test - public void assertGetMap() { + void assertGetMap() { Map expected = new HashMap<>(3); expected.put(0, "A"); expected.put(1, "B"); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java index c65a15f749..c5f2f26fd0 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java @@ -29,10 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class TaskContextTest { +class TaskContextTest { @Test - public void assertNew() { + void assertNew() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0"); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); assertThat(actual.getMetaInfo().getShardingItems().get(0), is(0)); @@ -42,19 +42,19 @@ public void assertNew() { } @Test - public void assertNewWithoutSlaveId() { + void assertNewWithoutSlaveId() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY); assertThat(actual.getSlaveId(), is("unassigned-slave")); } @Test - public void assertGetMetaInfo() { + void assertGetMetaInfo() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0"); assertThat(actual.getMetaInfo().toString(), is("test_job@-@0")); } @Test - public void assertTaskContextFrom() { + void assertTaskContextFrom() { TaskContext actual = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); assertThat(actual.getId(), is(TaskNode.builder().build().getTaskNodeValue())); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); @@ -64,52 +64,52 @@ public void assertTaskContextFrom() { } @Test - public void assertMetaInfoFromWithMetaInfo() { + void assertMetaInfoFromWithMetaInfo() { MetaInfo actual = MetaInfo.from("test_job@-@1"); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getShardingItems().get(0), is(1)); } @Test - public void assertMetaInfoFromWithTaskId() { + void assertMetaInfoFromWithTaskId() { MetaInfo actual = MetaInfo.from("test_job@-@1@-@READY@-@unassigned-slave@-@0"); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getShardingItems().get(0), is(1)); } @Test - public void assertMetaInfoFromWithMetaInfoWithoutShardingItems() { + void assertMetaInfoFromWithMetaInfoWithoutShardingItems() { MetaInfo actual = MetaInfo.from("test_job@-@"); assertThat(actual.getJobName(), is("test_job")); assertTrue(actual.getShardingItems().isEmpty()); } @Test - public void assertMetaInfoFromWithTaskIdWithoutShardingItems() { + void assertMetaInfoFromWithTaskIdWithoutShardingItems() { MetaInfo actual = MetaInfo.from("test_job@-@@-@READY@-@unassigned-slave@-@0"); assertThat(actual.getJobName(), is("test_job")); assertTrue(actual.getShardingItems().isEmpty()); } @Test - public void assertGetIdForUnassignedSlave() { + void assertGetIdForUnassignedSlave() { assertThat(TaskContext.getIdForUnassignedSlave("test_job@-@0@-@READY@-@slave-S0@-@0"), is("test_job@-@0@-@READY@-@unassigned-slave@-@0")); } @Test - public void assertGetTaskName() { + void assertGetTaskName() { TaskContext actual = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); assertThat(actual.getTaskName(), is("test_job@-@0@-@READY@-@slave-S0")); } @Test - public void assertGetExecutorId() { + void assertGetExecutorId() { TaskContext actual = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); assertThat(actual.getExecutorId("app"), is("app@-@slave-S0")); } @Test - public void assertSetSlaveId() { + void assertSetSlaveId() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0"); assertThat(actual.getSlaveId(), is("slave-S0")); actual.setSlaveId("slave-S1"); @@ -117,7 +117,7 @@ public void assertSetSlaveId() { } @Test - public void assertSetIdle() { + void assertSetIdle() { TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0"); assertFalse(actual.isIdle()); actual.setIdle(true); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/HostExceptionTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/HostExceptionTest.java index fc91f356aa..db2d8b26a6 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/HostExceptionTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/HostExceptionTest.java @@ -24,10 +24,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class HostExceptionTest { +class HostExceptionTest { @Test - public void assertGetCause() { + void assertGetCause() { IOException cause = new IOException(); assertThat(new HostException(cause).getCause(), is(cause)); } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/IpUtilsTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/IpUtilsTest.java index d88adb03df..49fbe4a05a 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/IpUtilsTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/IpUtilsTest.java @@ -37,16 +37,16 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public final class IpUtilsTest { +class IpUtilsTest { @Test - public void assertGetIp() { + void assertGetIp() { assertNotNull(IpUtils.getIp()); } @Test @SneakyThrows - public void assertPreferredNetworkInterface() { + void assertPreferredNetworkInterface() { System.setProperty(IpUtils.PREFERRED_NETWORK_INTERFACE, "eth0"); Method declaredMethod = IpUtils.class.getDeclaredMethod("isPreferredNetworkInterface", NetworkInterface.class); declaredMethod.setAccessible(true); @@ -59,7 +59,7 @@ public void assertPreferredNetworkInterface() { @Test @SneakyThrows - public void assertPreferredNetworkAddress() { + void assertPreferredNetworkAddress() { Method declaredMethod = IpUtils.class.getDeclaredMethod("isPreferredAddress", InetAddress.class); declaredMethod.setAccessible(true); InetAddress inetAddress = mock(InetAddress.class); @@ -79,7 +79,7 @@ public void assertPreferredNetworkAddress() { @Test @SneakyThrows - public void assertGetFirstNetworkInterface() { + void assertGetFirstNetworkInterface() { InetAddress address1 = mock(Inet4Address.class); when(address1.isLoopbackAddress()).thenReturn(false); when(address1.isAnyLocalAddress()).thenReturn(false); @@ -114,7 +114,7 @@ public void assertGetFirstNetworkInterface() { @Test @SneakyThrows - public void assertGetHostName() { + void assertGetHostName() { assertNotNull(IpUtils.getHostName()); Field field = IpUtils.class.getDeclaredField("cachedHostName"); field.setAccessible(true); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/TimeServiceTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/TimeServiceTest.java index d48b5c87b9..bf08ba5e6b 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/TimeServiceTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/env/TimeServiceTest.java @@ -21,12 +21,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -public class TimeServiceTest { +class TimeServiceTest { private final TimeService timeService = new TimeService(); @Test - public void assertGetCurrentMillis() { + void assertGetCurrentMillis() { assertTrue(timeService.getCurrentMillis() <= System.currentTimeMillis()); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/ExceptionUtilsTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/ExceptionUtilsTest.java index d42f12baf1..2739b42350 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/ExceptionUtilsTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/ExceptionUtilsTest.java @@ -23,20 +23,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ExceptionUtilsTest { +class ExceptionUtilsTest { @Test - public void assertTransformWithError() { + void assertTransformWithError() { assertTrue(ExceptionUtils.transform(new Error("Error")).startsWith("java.lang.Error")); } @Test - public void assertTransformWithException() { + void assertTransformWithException() { assertTrue(ExceptionUtils.transform(new Exception("Exception")).startsWith("java.lang.Exception")); } @Test - public void assertTransformWithNull() { + void assertTransformWithNull() { assertThat(ExceptionUtils.transform(null), is("")); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobConfigurationExceptionTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobConfigurationExceptionTest.java index 0af136a9e3..4605f68929 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobConfigurationExceptionTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobConfigurationExceptionTest.java @@ -23,15 +23,15 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobConfigurationExceptionTest { +class JobConfigurationExceptionTest { @Test - public void assertGetMessage() { + void assertGetMessage() { assertThat(new JobConfigurationException("message is: '%s'", "test").getMessage(), is("message is: 'test'")); } @Test - public void assertGetCause() { + void assertGetCause() { assertThat(new JobConfigurationException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionEnvironmentExceptionTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionEnvironmentExceptionTest.java index 7b69ba07ce..fbbaf78cf6 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionEnvironmentExceptionTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionEnvironmentExceptionTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobExecutionEnvironmentExceptionTest { +class JobExecutionEnvironmentExceptionTest { @Test - public void assertGetMessage() { + void assertGetMessage() { assertThat(new JobExecutionEnvironmentException("message is: '%s'", "test").getMessage(), is("message is: 'test'")); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobStatisticExceptionTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobStatisticExceptionTest.java index 0b904b655e..27b26aef5b 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobStatisticExceptionTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobStatisticExceptionTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -public class JobStatisticExceptionTest { +class JobStatisticExceptionTest { @Test - public void assertGetCause() { + void assertGetCause() { assertThat(new JobStatisticException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobSystemExceptionTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobSystemExceptionTest.java index 5b83660c08..89c2c78a10 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobSystemExceptionTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/JobSystemExceptionTest.java @@ -23,22 +23,22 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobSystemExceptionTest { +class JobSystemExceptionTest { @Test - public void assertGetMessage() { + void assertGetMessage() { assertThat(new JobSystemException("message is: '%s'", "test").getMessage(), is("message is: 'test'")); } @Test - public void assertGetMessageCause() { + void assertGetMessageCause() { JobSystemException jobSystemException = new JobSystemException("message is: ", new RuntimeException()); assertThat(jobSystemException.getMessage(), is("message is: ")); assertThat(jobSystemException.getCause(), instanceOf(RuntimeException.class)); } @Test - public void assertGetCause() { + void assertGetCause() { assertThat(new JobSystemException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobInstanceTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobInstanceTest.java index 2bbc181d50..eaa2963193 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobInstanceTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobInstanceTest.java @@ -24,20 +24,20 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobInstanceTest { +class JobInstanceTest { @Test - public void assertGetJobInstanceId() { + void assertGetJobInstanceId() { assertThat(new JobInstance("127.0.0.1@-@0").getJobInstanceId(), is("127.0.0.1@-@0")); } @Test - public void assertGetIp() { + void assertGetIp() { assertThat(new JobInstance().getServerIp(), is(IpUtils.getIp())); } @Test - public void assertYamlConvert() { + void assertYamlConvert() { JobInstance actual = YamlEngine.unmarshal(YamlEngine.marshal(new JobInstance("id", "labels")), JobInstance.class); assertThat(actual.getJobInstanceId(), is("id")); assertThat(actual.getServerIp(), is(IpUtils.getIp())); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobShardingStrategyFactoryTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobShardingStrategyFactoryTest.java index bbf9888d67..9db6376abc 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobShardingStrategyFactoryTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/JobShardingStrategyFactoryTest.java @@ -26,20 +26,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class JobShardingStrategyFactoryTest { +class JobShardingStrategyFactoryTest { @Test - public void assertGetDefaultStrategy() { + void assertGetDefaultStrategy() { assertThat(JobShardingStrategyFactory.getStrategy(null), instanceOf(AverageAllocationJobShardingStrategy.class)); } @Test - public void assertGetInvalidStrategy() { + void assertGetInvalidStrategy() { assertThrows(JobConfigurationException.class, () -> JobShardingStrategyFactory.getStrategy("INVALID")); } @Test - public void assertGetStrategy() { + void assertGetStrategy() { assertThat(JobShardingStrategyFactory.getStrategy("ODEVITY"), instanceOf(OdevitySortByNameJobShardingStrategy.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/AverageAllocationJobShardingStrategyTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/AverageAllocationJobShardingStrategyTest.java index e4b01e232d..b60a4f600e 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/AverageAllocationJobShardingStrategyTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/AverageAllocationJobShardingStrategyTest.java @@ -30,24 +30,24 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class AverageAllocationJobShardingStrategyTest { +class AverageAllocationJobShardingStrategyTest { private final JobShardingStrategy jobShardingStrategy = new AverageAllocationJobShardingStrategy(); @Test - public void shardingForZeroServer() { + void shardingForZeroServer() { assertThat(jobShardingStrategy.sharding(Collections.emptyList(), "test_job", 3), is(Collections.>emptyMap())); } @Test - public void shardingForOneServer() { + void shardingForOneServer() { Map> expected = new LinkedHashMap<>(1, 1); expected.put(new JobInstance("host0@-@0"), Arrays.asList(0, 1, 2)); assertThat(jobShardingStrategy.sharding(Collections.singletonList(new JobInstance("host0@-@0")), "test_job", 3), is(expected)); } @Test - public void shardingForServersMoreThanShardingCount() { + void shardingForServersMoreThanShardingCount() { Map> expected = new LinkedHashMap<>(3, 1); expected.put(new JobInstance("host0@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host1@-@0"), Collections.singletonList(1)); @@ -56,7 +56,7 @@ public void shardingForServersMoreThanShardingCount() { } @Test - public void shardingForServersLessThanShardingCountAliquot() { + void shardingForServersLessThanShardingCountAliquot() { Map> expected = new LinkedHashMap<>(3, 1); expected.put(new JobInstance("host0@-@0"), Arrays.asList(0, 1, 2)); expected.put(new JobInstance("host1@-@0"), Arrays.asList(3, 4, 5)); @@ -65,7 +65,7 @@ public void shardingForServersLessThanShardingCountAliquot() { } @Test - public void shardingForServersLessThanShardingCountAliquantFor8ShardingCountAnd3Servers() { + void shardingForServersLessThanShardingCountAliquantFor8ShardingCountAnd3Servers() { Map> expected = new LinkedHashMap<>(3, 1); expected.put(new JobInstance("host0@-@0"), Arrays.asList(0, 1, 6)); expected.put(new JobInstance("host1@-@0"), Arrays.asList(2, 3, 7)); @@ -74,7 +74,7 @@ public void shardingForServersLessThanShardingCountAliquantFor8ShardingCountAnd3 } @Test - public void shardingForServersLessThanShardingCountAliquantFor10ShardingCountAnd3Servers() { + void shardingForServersLessThanShardingCountAliquantFor10ShardingCountAnd3Servers() { Map> expected = new LinkedHashMap<>(3, 1); expected.put(new JobInstance("host0@-@0"), Arrays.asList(0, 1, 2, 9)); expected.put(new JobInstance("host1@-@0"), Arrays.asList(3, 4, 5)); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/OdevitySortByNameJobShardingStrategyTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/OdevitySortByNameJobShardingStrategyTest.java index 009078818a..dfe768ce69 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/OdevitySortByNameJobShardingStrategyTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/OdevitySortByNameJobShardingStrategyTest.java @@ -29,12 +29,12 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class OdevitySortByNameJobShardingStrategyTest { +class OdevitySortByNameJobShardingStrategyTest { private final OdevitySortByNameJobShardingStrategy odevitySortByNameJobShardingStrategy = new OdevitySortByNameJobShardingStrategy(); @Test - public void assertShardingByAsc() { + void assertShardingByAsc() { Map> expected = new HashMap<>(); expected.put(new JobInstance("host0@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host1@-@0"), Collections.singletonList(1)); @@ -43,7 +43,7 @@ public void assertShardingByAsc() { } @Test - public void assertShardingByDesc() { + void assertShardingByDesc() { Map> expected = new HashMap<>(); expected.put(new JobInstance("host2@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host1@-@0"), Collections.singletonList(1)); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RotateServerByNameJobShardingStrategyTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RotateServerByNameJobShardingStrategyTest.java index aa081a4537..4f159e6e75 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RotateServerByNameJobShardingStrategyTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RotateServerByNameJobShardingStrategyTest.java @@ -29,12 +29,12 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class RotateServerByNameJobShardingStrategyTest { +class RotateServerByNameJobShardingStrategyTest { private final RoundRobinByNameJobShardingStrategy rotateServerByNameJobShardingStrategy = new RoundRobinByNameJobShardingStrategy(); @Test - public void assertSharding1() { + void assertSharding1() { Map> expected = new HashMap<>(); expected.put(new JobInstance("host1@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host2@-@0"), Collections.singletonList(1)); @@ -43,7 +43,7 @@ public void assertSharding1() { } @Test - public void assertSharding2() { + void assertSharding2() { Map> expected = new HashMap<>(); expected.put(new JobInstance("host2@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host0@-@0"), Collections.singletonList(1)); @@ -52,7 +52,7 @@ public void assertSharding2() { } @Test - public void assertSharding3() { + void assertSharding3() { Map> expected = new HashMap<>(); expected.put(new JobInstance("host0@-@0"), Collections.singletonList(0)); expected.put(new JobInstance("host1@-@0"), Collections.singletonList(1)); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandlerFactoryTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandlerFactoryTest.java index b5f921c016..25758af9ec 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandlerFactoryTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/JobExecutorServiceHandlerFactoryTest.java @@ -26,20 +26,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class JobExecutorServiceHandlerFactoryTest { +class JobExecutorServiceHandlerFactoryTest { @Test - public void assertGetDefaultHandler() { + void assertGetDefaultHandler() { assertThat(JobExecutorServiceHandlerFactory.getHandler(""), instanceOf(CPUUsageJobExecutorServiceHandler.class)); } @Test - public void assertGetInvalidHandler() { + void assertGetInvalidHandler() { assertThrows(JobConfigurationException.class, () -> JobExecutorServiceHandlerFactory.getHandler("INVALID")); } @Test - public void assertGetHandler() { + void assertGetHandler() { assertThat(JobExecutorServiceHandlerFactory.getHandler("SINGLE_THREAD"), instanceOf(SingleThreadJobExecutorServiceHandler.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java index b2a3e9720c..6bea560a9f 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java @@ -23,10 +23,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class CPUUsageJobExecutorServiceHandlerTest { +class CPUUsageJobExecutorServiceHandlerTest { @Test - public void assertGetPoolSizeAndType() { + void assertGetPoolSizeAndType() { CPUUsageJobExecutorServiceHandler cpuUsageJobExecutorServiceHandler = (CPUUsageJobExecutorServiceHandler) JobExecutorServiceHandlerFactory.getHandler("CPU"); assertThat(cpuUsageJobExecutorServiceHandler.getPoolSize(), is(Runtime.getRuntime().availableProcessors() * 2)); assertThat(cpuUsageJobExecutorServiceHandler.getType(), is("CPU")); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java index f4b05ffc87..d0dd4ff31e 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java @@ -23,10 +23,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class SingleThreadJobExecutorServiceHandlerTest { +class SingleThreadJobExecutorServiceHandlerTest { @Test - public void assertGetPoolSizeAndType() { + void assertGetPoolSizeAndType() { SingleThreadJobExecutorServiceHandler singleThreadJobExecutorServiceHandler = (SingleThreadJobExecutorServiceHandler) JobExecutorServiceHandlerFactory.getHandler("SINGLE_THREAD"); assertThat(singleThreadJobExecutorServiceHandler.getPoolSize(), is(1)); assertThat(singleThreadJobExecutorServiceHandler.getType(), is("SINGLE_THREAD")); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/json/GsonFactoryTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/json/GsonFactoryTest.java index 51d83b2011..38b542a551 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/json/GsonFactoryTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/json/GsonFactoryTest.java @@ -30,15 +30,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class GsonFactoryTest { +class GsonFactoryTest { @Test - public void assertGetGson() { + void assertGetGson() { assertThat(GsonFactory.getGson(), is(GsonFactory.getGson())); } @Test - public void assertRegisterTypeAdapter() { + void assertRegisterTypeAdapter() { Gson beforeRegisterGson = GsonFactory.getGson(); GsonFactory.registerTypeAdapter(GsonFactoryTest.class, new TypeAdapter() { @@ -58,18 +58,18 @@ public void write(final JsonWriter out, final Object value) throws IOException { } @Test - public void assertGetJsonParser() { + void assertGetJsonParser() { assertThat(GsonFactory.getJsonParser(), is(GsonFactory.getJsonParser())); } @Test - public void assertParser() { + void assertParser() { String json = "{\"name\":\"test\"}"; assertThat(GsonFactory.getJsonParser().parse(json).getAsJsonObject().get("name").getAsString(), is("test")); } @Test - public void assertParserWithException() { + void assertParserWithException() { assertThrows(JsonParseException.class, () -> { String json = "{\"name\":\"test\""; assertThat(GsonFactory.getJsonParser().parse(json).getAsJsonObject().get("name").getAsString(), is("test")); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactoryTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactoryTest.java index 4e0333e0d7..669316cc8a 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactoryTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactoryTest.java @@ -25,15 +25,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ElasticJobListenerFactoryTest { +class ElasticJobListenerFactoryTest { @Test - public void assertCreateInvalidJobListener() { + void assertCreateInvalidJobListener() { assertThrows(JobConfigurationException.class, () -> ElasticJobListenerFactory.createListener("INVALID").orElseThrow(() -> new JobConfigurationException("Invalid elastic job listener!"))); } @Test - public void assertCreatJobListener() { + void assertCreatJobListener() { assertThat(ElasticJobListenerFactory.createListener("fooElasticJobListener").orElse(null), instanceOf(FooElasticJobListener.class)); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ShardingContextsTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ShardingContextsTest.java index 91375ad711..36139d5c17 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ShardingContextsTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/listener/ShardingContextsTest.java @@ -26,10 +26,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ShardingContextsTest { +class ShardingContextsTest { @Test - public void assertCreateShardingContext() { + void assertCreateShardingContext() { ShardingContexts shardingContexts = createShardingContexts(); ShardingContext actual = shardingContexts.createShardingContext(1); assertThat(actual.getJobName(), is(shardingContexts.getJobName())); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java index 4e8493abc0..87022c38f1 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class JobConfigurationPOJOTest { +class JobConfigurationPOJOTest { private static final String YAML = "cron: 0/1 * * * * ?\n" + "description: Job description\n" @@ -65,7 +65,7 @@ public final class JobConfigurationPOJOTest { + "staticSharding: false\n"; @Test - public void assertToJobConfiguration() { + void assertToJobConfiguration() { JobConfigurationPOJO pojo = new JobConfigurationPOJO(); pojo.setJobName("test_job"); pojo.setCron("0/1 * * * * ?"); @@ -103,7 +103,7 @@ public void assertToJobConfiguration() { } @Test - public void assertFromJobConfiguration() { + void assertFromJobConfiguration() { JobConfiguration jobConfiguration = JobConfiguration.newBuilder("test_job", 3) .cron("0/1 * * * * ?") .shardingItemParameters("0=A,1=B,2=C").jobParameter("param") @@ -131,7 +131,7 @@ public void assertFromJobConfiguration() { } @Test - public void assertMarshal() { + void assertMarshal() { JobConfigurationPOJO actual = new JobConfigurationPOJO(); actual.setJobName("test_job"); actual.setCron("0/1 * * * * ?"); @@ -148,7 +148,7 @@ public void assertMarshal() { } @Test - public void assertMarshalWithNullValue() { + void assertMarshalWithNullValue() { JobConfigurationPOJO actual = new JobConfigurationPOJO(); actual.setJobName("test_job"); actual.setCron("0/1 * * * * ?"); @@ -158,7 +158,7 @@ public void assertMarshalWithNullValue() { } @Test - public void assertUnmarshal() { + void assertUnmarshal() { JobConfigurationPOJO actual = YamlEngine.unmarshal(YAML, JobConfigurationPOJO.class); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getCron(), is("0/1 * * * * ?")); @@ -176,7 +176,7 @@ public void assertUnmarshal() { } @Test - public void assertUnmarshalWithNullValue() { + void assertUnmarshalWithNullValue() { JobConfigurationPOJO actual = YamlEngine.unmarshal(YAML_WITH_NULL, JobConfigurationPOJO.class); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getCron(), is("0/1 * * * * ?")); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/spi/ElasticJobServiceLoaderTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/spi/ElasticJobServiceLoaderTest.java index 350ce60876..e21af0f174 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/spi/ElasticJobServiceLoaderTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/spi/ElasticJobServiceLoaderTest.java @@ -28,43 +28,43 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -public final class ElasticJobServiceLoaderTest { +class ElasticJobServiceLoaderTest { @BeforeAll - public static void register() { + static void register() { ElasticJobServiceLoader.registerTypedService(TypedFooService.class); } @Test - public void assertGetCacheTypedService() { + void assertGetCacheTypedService() { assertThat(ElasticJobServiceLoader.getCachedTypedServiceInstance(TypedFooService.class, "typedFooServiceImpl").orElse(null), instanceOf(TypedFooService.class)); } @Test - public void assertNewTypedServiceInstance() { + void assertNewTypedServiceInstance() { assertThat(ElasticJobServiceLoader.getCachedTypedServiceInstance(TypedFooService.class, "typedFooServiceImpl").orElse(null), instanceOf(TypedFooService.class)); } @Test - public void assertGetCacheTypedServiceFailureWithUnRegisteredServiceInterface() { + void assertGetCacheTypedServiceFailureWithUnRegisteredServiceInterface() { Assertions.assertThrows(IllegalArgumentException.class, () -> ElasticJobServiceLoader.getCachedTypedServiceInstance( UnRegisteredTypedFooService.class, "unRegisteredTypedFooServiceImpl").orElseThrow(IllegalArgumentException::new)); } @Test - public void assertGetCacheTypedServiceFailureWithInvalidType() { + void assertGetCacheTypedServiceFailureWithInvalidType() { Assertions.assertThrows(IllegalArgumentException.class, () -> ElasticJobServiceLoader.getCachedTypedServiceInstance( TypedFooService.class, "INVALID").orElseThrow(IllegalArgumentException::new)); } @Test - public void assertNewTypedServiceInstanceFailureWithUnRegisteredServiceInterface() { + void assertNewTypedServiceInstanceFailureWithUnRegisteredServiceInterface() { Assertions.assertThrows(IllegalArgumentException.class, () -> ElasticJobServiceLoader .newTypedServiceInstance(UnRegisteredTypedFooService.class, "unRegisteredTypedFooServiceImpl", new Properties()).orElseThrow(IllegalArgumentException::new)); } @Test - public void assertNewTypedServiceInstanceFailureWithInvalidType() { + void assertNewTypedServiceInstanceFailureWithInvalidType() { Assertions.assertThrows(IllegalArgumentException.class, () -> ElasticJobServiceLoader.newTypedServiceInstance( TypedFooService.class, "INVALID", new Properties()).orElseThrow(IllegalArgumentException::new)); } diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRuleTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRuleTest.java index 5f7e0e3c9c..c1a732a074 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRuleTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRuleTest.java @@ -24,10 +24,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobPropertiesValidateRuleTest { +class JobPropertiesValidateRuleTest { @Test - public void assertValidateIsRequiredWithValidateError() { + void assertValidateIsRequiredWithValidateError() { try { JobPropertiesValidateRule.validateIsRequired(new Properties(), "key"); } catch (NullPointerException ex) { @@ -36,26 +36,26 @@ public void assertValidateIsRequiredWithValidateError() { } @Test - public void assertValidateIsRequiredWithNormal() { + void assertValidateIsRequiredWithNormal() { Properties properties = new Properties(); properties.setProperty("key", "value"); JobPropertiesValidateRule.validateIsRequired(properties, "key"); } @Test - public void assertValidateIsPositiveIntegerWithValueNoExist() { + void assertValidateIsPositiveIntegerWithValueNoExist() { JobPropertiesValidateRule.validateIsPositiveInteger(new Properties(), "key"); } @Test - public void assertValidateIsPositiveIntegerWithNormal() { + void assertValidateIsPositiveIntegerWithNormal() { Properties properties = new Properties(); properties.setProperty("key", "1"); JobPropertiesValidateRule.validateIsPositiveInteger(new Properties(), "key"); } @Test - public void assertValidateIsPositiveIntegerWithWrongString() { + void assertValidateIsPositiveIntegerWithWrongString() { Properties properties = new Properties(); properties.setProperty("key", "wrong_value"); try { @@ -66,7 +66,7 @@ public void assertValidateIsPositiveIntegerWithWrongString() { } @Test - public void assertValidateIsPositiveIntegerWithNegativeNumber() { + void assertValidateIsPositiveIntegerWithNegativeNumber() { Properties properties = new Properties(); properties.setProperty("key", "-1"); try { diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngineTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngineTest.java index 9bebfef178..1e830b65ad 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngineTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngineTest.java @@ -24,7 +24,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class YamlEngineTest { +class YamlEngineTest { private static final String YAML = "bar: bar\n" + "foo: foo\n" @@ -39,7 +39,7 @@ public final class YamlEngineTest { private static final String PREFIX2 = "nest.bar"; @Test - public void assertMarshal() { + void assertMarshal() { FooYamlConfiguration actual = new FooYamlConfiguration(); actual.setFoo("foo"); actual.setBar("bar"); @@ -51,14 +51,14 @@ public void assertMarshal() { } @Test - public void assertMarshalWithNullValue() { + void assertMarshalWithNullValue() { FooYamlConfiguration actual = new FooYamlConfiguration(); actual.setFoo("foo"); assertThat(YamlEngine.marshal(actual), is(YAML_WITH_NULL)); } @Test - public void assertUnmarshal() { + void assertUnmarshal() { FooYamlConfiguration actual = YamlEngine.unmarshal(YAML, FooYamlConfiguration.class); assertThat(actual.getFoo(), is("foo")); assertThat(actual.getBar(), is("bar")); @@ -67,7 +67,7 @@ public void assertUnmarshal() { } @Test - public void assertUnmarshalWithNullValue() { + void assertUnmarshalWithNullValue() { FooYamlConfiguration actual = YamlEngine.unmarshal(YAML_WITH_NULL, FooYamlConfiguration.class); assertThat(actual.getFoo(), is("foo")); assertNull(actual.getBar()); diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/config/YamlConfigurationConverterFactoryTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/config/YamlConfigurationConverterFactoryTest.java index 0de1734828..7d2a2f0946 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/config/YamlConfigurationConverterFactoryTest.java +++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/yaml/config/YamlConfigurationConverterFactoryTest.java @@ -21,14 +21,13 @@ import static org.junit.jupiter.api.Assertions.assertFalse; -public final class YamlConfigurationConverterFactoryTest { +class YamlConfigurationConverterFactoryTest { @Test - public void assertConverterNotFound() { + void assertConverterNotFound() { assertFalse(YamlConfigurationConverterFactory.findConverter(AClassWithoutCorrespondingConverter.class).isPresent()); } private static class AClassWithoutCorrespondingConverter { - } } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/main/java/org/apache/shardingsphere/elasticjob/reg/listener/ConnectionStateChangedEventListener.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/main/java/org/apache/shardingsphere/elasticjob/reg/listener/ConnectionStateChangedEventListener.java index dc268358c5..a29a10f3af 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/main/java/org/apache/shardingsphere/elasticjob/reg/listener/ConnectionStateChangedEventListener.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/main/java/org/apache/shardingsphere/elasticjob/reg/listener/ConnectionStateChangedEventListener.java @@ -30,7 +30,7 @@ enum State { RECONNECTED, - UNAVAILABLE, + UNAVAILABLE } /** diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/base/transaction/TransactionOperationTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/base/transaction/TransactionOperationTest.java index bf382a5366..a4d5ec50d7 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/base/transaction/TransactionOperationTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/base/transaction/TransactionOperationTest.java @@ -23,10 +23,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class TransactionOperationTest { +class TransactionOperationTest { @Test - public void assertOpAdd() { + void assertOpAdd() { TransactionOperation actual = TransactionOperation.opAdd("key", "value"); assertThat(actual.getType(), is(Type.ADD)); assertThat(actual.getKey(), is("key")); @@ -34,7 +34,7 @@ public void assertOpAdd() { } @Test - public void assertOpUpdate() { + void assertOpUpdate() { TransactionOperation actual = TransactionOperation.opUpdate("key", "value"); assertThat(actual.getType(), is(Type.UPDATE)); assertThat(actual.getKey(), is("key")); @@ -42,14 +42,14 @@ public void assertOpUpdate() { } @Test - public void assertOpDelete() { + void assertOpDelete() { TransactionOperation actual = TransactionOperation.opDelete("key"); assertThat(actual.getType(), is(Type.DELETE)); assertThat(actual.getKey(), is("key")); } @Test - public void assertOpCheckExists() { + void assertOpCheckExists() { TransactionOperation actual = TransactionOperation.opCheckExists("key"); assertThat(actual.getType(), is(Type.CHECK_EXISTS)); assertThat(actual.getKey(), is("key")); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/exception/RegExceptionHandlerTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/exception/RegExceptionHandlerTest.java index 01c0e1e575..0622e7c0b9 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/exception/RegExceptionHandlerTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-registry-center-api/src/test/java/org/apache/shardingsphere/elasticjob/reg/exception/RegExceptionHandlerTest.java @@ -22,22 +22,22 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public final class RegExceptionHandlerTest { +class RegExceptionHandlerTest { @Test @Disabled // TODO throw InterruptedException will cause zookeeper TestingServer break. Ignore first, fix it later. - public void assertHandleExceptionWithInterruptedException() { + void assertHandleExceptionWithInterruptedException() { RegExceptionHandler.handleException(new InterruptedException()); } @Test - public void assertHandleExceptionWithNull() { + void assertHandleExceptionWithNull() { RegExceptionHandler.handleException(null); } @Test - public void assertHandleExceptionWithOtherException() { + void assertHandleExceptionWithOtherException() { assertThrows(RegException.class, () -> RegExceptionHandler.handleException(new RuntimeException())); } } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperConfigurationTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperConfigurationTest.java index f02943e254..3320dde803 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperConfigurationTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperConfigurationTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ZookeeperConfigurationTest { +class ZookeeperConfigurationTest { @Test - public void assertNewZookeeperConfigurationForServerListsAndNamespace() { + void assertNewZookeeperConfigurationForServerListsAndNamespace() { ZookeeperConfiguration zkConfig = new ZookeeperConfiguration("localhost:2181", "myNamespace"); assertThat(zkConfig.getServerLists(), is("localhost:2181")); assertThat(zkConfig.getNamespace(), is("myNamespace")); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java index 5edb311d47..ec14a7a951 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class ZookeeperElectionServiceTest { +class ZookeeperElectionServiceTest { private static final String HOST_AND_PORT = "localhost:8899"; @@ -50,12 +50,12 @@ public class ZookeeperElectionServiceTest { private ElectionCandidate electionCandidate; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); } @Test - public void assertContend() throws Exception { + void assertContend() throws Exception { CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000)); client.start(); client.blockUntilConnected(); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java index bc8e215b14..ec43699cc4 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java @@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -public final class ZookeeperRegistryCenterExecuteInLeaderTest { +class ZookeeperRegistryCenterExecuteInLeaderTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterExecuteInLeaderTest.class.getName()); @@ -39,7 +39,7 @@ public final class ZookeeperRegistryCenterExecuteInLeaderTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); @@ -47,13 +47,13 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test @Timeout(value = 10000L, unit = TimeUnit.MILLISECONDS) - public void assertExecuteInLeader() throws InterruptedException { + void assertExecuteInLeader() throws InterruptedException { final int threads = 10; CountDownLatch countDownLatch = new CountDownLatch(threads); SerialOnlyExecutionCallback serialOnlyExecutionCallback = new SerialOnlyExecutionCallback(countDownLatch, Thread.currentThread()); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java index d4f4fe7167..c86f4396f8 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ZookeeperRegistryCenterForAuthTest { +class ZookeeperRegistryCenterForAuthTest { private static final String NAME_SPACE = ZookeeperRegistryCenterForAuthTest.class.getName(); @@ -40,7 +40,7 @@ public final class ZookeeperRegistryCenterForAuthTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); ZOOKEEPER_CONFIGURATION.setDigest("digest:password"); ZOOKEEPER_CONFIGURATION.setSessionTimeoutMilliseconds(5000); @@ -51,12 +51,12 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test - public void assertInitWithDigestSuccess() throws Exception { + void assertInitWithDigestSuccess() throws Exception { CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(EmbedTestingServer.getConnectionString()) .retryPolicy(new RetryOneTime(2000)) @@ -67,7 +67,7 @@ public void assertInitWithDigestSuccess() throws Exception { } @Test - public void assertInitWithDigestFailure() { + void assertInitWithDigestFailure() { assertThrows(NoAuthException.class, () -> { CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000)); client.start(); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterInitFailureTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterInitFailureTest.java index dc59f3ad97..e32e51a966 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterInitFailureTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterInitFailureTest.java @@ -22,10 +22,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ZookeeperRegistryCenterInitFailureTest { +class ZookeeperRegistryCenterInitFailureTest { @Test - public void assertInitFailure() { + void assertInitFailure() { assertThrows(RegException.class, () -> { ZookeeperRegistryCenter zkRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("localhost:1", ZookeeperRegistryCenterInitFailureTest.class.getName())); zkRegCenter.init(); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterListenerTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterListenerTest.java index a5e84a63fb..1b1657b417 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterListenerTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterListenerTest.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class ZookeeperRegistryCenterListenerTest { +class ZookeeperRegistryCenterListenerTest { @Mock private Map caches; @@ -64,14 +64,14 @@ public class ZookeeperRegistryCenterListenerTest { private final String jobPath = "/test_job"; @BeforeEach - public void setUp() { + void setUp() { regCenter = new ZookeeperRegistryCenter(null); ZookeeperRegistryCenterTestUtil.setFieldValue(regCenter, "caches", caches); ZookeeperRegistryCenterTestUtil.setFieldValue(regCenter, "client", client); } @Test - public void testAddConnectionStateChangedEventListener() { + void testAddConnectionStateChangedEventListener() { when(client.getConnectionStateListenable()).thenReturn(connStateListenable); regCenter.addConnectionStateChangedEventListener(jobPath, null); verify(client.getConnectionStateListenable()).addListener(any()); @@ -79,7 +79,7 @@ public void testAddConnectionStateChangedEventListener() { } @Test - public void testWatch() { + void testWatch() { when(caches.get(jobPath + "/")).thenReturn(cache); when(cache.listenable()).thenReturn(dataListenable); regCenter.watch(jobPath, null, null); @@ -88,7 +88,7 @@ public void testWatch() { } @Test - public void testRemoveDataListenersNonCache() { + void testRemoveDataListenersNonCache() { when(cache.listenable()).thenReturn(dataListenable); regCenter.removeDataListeners(jobPath); verify(cache.listenable(), never()).removeListener(any()); @@ -96,7 +96,7 @@ public void testRemoveDataListenersNonCache() { } @Test - public void testRemoveDataListenersHasCache() { + void testRemoveDataListenersHasCache() { when(caches.get(jobPath + "/")).thenReturn(cache); when(cache.listenable()).thenReturn(dataListenable); List list = new ArrayList<>(); @@ -109,7 +109,7 @@ public void testRemoveDataListenersHasCache() { } @Test - public void testRemoveDataListenersHasCacheEmptyListeners() { + void testRemoveDataListenersHasCacheEmptyListeners() { when(caches.get(jobPath + "/")).thenReturn(cache); when(cache.listenable()).thenReturn(dataListenable); regCenter.removeDataListeners(jobPath); @@ -118,7 +118,7 @@ public void testRemoveDataListenersHasCacheEmptyListeners() { } @Test - public void testRemoveConnStateListener() { + void testRemoveConnStateListener() { when(client.getConnectionStateListenable()).thenReturn(connStateListenable); List list = new ArrayList<>(); list.add(null); @@ -131,7 +131,7 @@ public void testRemoveConnStateListener() { } @Test - public void testRemoveConnStateListenerEmptyListeners() { + void testRemoveConnStateListenerEmptyListeners() { when(client.getConnectionStateListenable()).thenReturn(connStateListenable); regCenter.removeConnStateListener(jobPath); assertNull(getConnStateListeners().get(jobPath)); @@ -140,13 +140,11 @@ public void testRemoveConnStateListenerEmptyListeners() { @SuppressWarnings("unchecked") private Map> getConnStateListeners() { - return (Map>) ZookeeperRegistryCenterTestUtil - .getFieldValue(regCenter, "connStateListeners"); + return (Map>) ZookeeperRegistryCenterTestUtil.getFieldValue(regCenter, "connStateListeners"); } @SuppressWarnings("unchecked") private Map> getDataListeners() { - return (Map>) ZookeeperRegistryCenterTestUtil - .getFieldValue(regCenter, "dataListeners"); + return (Map>) ZookeeperRegistryCenterTestUtil.getFieldValue(regCenter, "dataListeners"); } } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java index 119335b6f0..d5fc1fe656 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ZookeeperRegistryCenterMiscellaneousTest { +class ZookeeperRegistryCenterMiscellaneousTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterMiscellaneousTest.class.getName()); @@ -36,7 +36,7 @@ public final class ZookeeperRegistryCenterMiscellaneousTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); @@ -45,23 +45,23 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test - public void assertGetRawClient() { + void assertGetRawClient() { assertThat(zkRegCenter.getRawClient(), instanceOf(CuratorFramework.class)); assertThat(((CuratorFramework) zkRegCenter.getRawClient()).getNamespace(), is(ZookeeperRegistryCenterMiscellaneousTest.class.getName())); } @Test - public void assertGetRawCache() { + void assertGetRawCache() { assertThat(zkRegCenter.getRawCache("/test"), instanceOf(CuratorCache.class)); } @Test - public void assertGetZkConfig() { + void assertGetZkConfig() { ZookeeperRegistryCenter zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); assertThat(zkRegCenter.getZkConfig(), is(ZOOKEEPER_CONFIGURATION)); } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java index 10da179f00..5736390517 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java @@ -35,14 +35,14 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ZookeeperRegistryCenterModifyTest { +class ZookeeperRegistryCenterModifyTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterModifyTest.class.getName()); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); @@ -51,12 +51,12 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test - public void assertPersist() { + void assertPersist() { zkRegCenter.persist("/test", "test_update"); zkRegCenter.persist("/persist/new", "new_value"); assertThat(zkRegCenter.get("/test"), is("test_update")); @@ -64,14 +64,14 @@ public void assertPersist() { } @Test - public void assertUpdate() { + void assertUpdate() { zkRegCenter.persist("/update", "before_update"); zkRegCenter.update("/update", "after_update"); assertThat(zkRegCenter.getDirectly("/update"), is("after_update")); } @Test - public void assertPersistEphemeral() throws Exception { + void assertPersistEphemeral() throws Exception { zkRegCenter.persist("/persist", "persist_value"); zkRegCenter.persistEphemeral("/ephemeral", "ephemeral_value"); assertThat(zkRegCenter.get("/persist"), is("persist_value")); @@ -86,7 +86,7 @@ public void assertPersistEphemeral() throws Exception { } @Test - public void assertPersistSequential() throws Exception { + void assertPersistSequential() throws Exception { assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential")); assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential")); CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000)); @@ -103,7 +103,7 @@ public void assertPersistSequential() throws Exception { } @Test - public void assertPersistEphemeralSequential() throws Exception { + void assertPersistEphemeralSequential() throws Exception { zkRegCenter.persistEphemeralSequential("/sequential/test_ephemeral_sequential"); zkRegCenter.persistEphemeralSequential("/sequential/test_ephemeral_sequential"); CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000)); @@ -121,7 +121,7 @@ public void assertPersistEphemeralSequential() throws Exception { } @Test - public void assertRemove() { + void assertRemove() { zkRegCenter.remove("/test"); assertFalse(zkRegCenter.isExisted("/test")); } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java index 3b22d66051..7a54c80851 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class ZookeeperRegistryCenterQueryWithCacheTest { +class ZookeeperRegistryCenterQueryWithCacheTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterQueryWithCacheTest.class.getName()); @@ -35,7 +35,7 @@ public final class ZookeeperRegistryCenterQueryWithCacheTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); @@ -45,17 +45,17 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test - public void assertGetWithoutValue() { + void assertGetWithoutValue() { assertNull(zkRegCenter.get("/test/null")); } @Test - public void assertGetFromCache() { + void assertGetFromCache() { assertThat(zkRegCenter.get("/test"), is("test")); assertThat(zkRegCenter.get("/test/deep/nested"), is("deepNested")); } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java index 94e630d291..c15e81dd26 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java @@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ZookeeperRegistryCenterQueryWithoutCacheTest { +class ZookeeperRegistryCenterQueryWithoutCacheTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterQueryWithoutCacheTest.class.getName()); @@ -40,7 +40,7 @@ public final class ZookeeperRegistryCenterQueryWithoutCacheTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); @@ -50,18 +50,18 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test - public void assertGetFromServer() { + void assertGetFromServer() { assertThat(zkRegCenter.get("/test"), is("test")); assertThat(zkRegCenter.get("/test/deep/nested"), is("deepNested")); } @Test - public void assertGetChildrenKeys() { + void assertGetChildrenKeys() { assertThat(zkRegCenter.getChildrenKeys("/test"), is(Arrays.asList("deep", "child"))); assertThat(zkRegCenter.getChildrenKeys("/test/deep"), is(Collections.singletonList("nested"))); assertThat(zkRegCenter.getChildrenKeys("/test/child"), is(Collections.emptyList())); @@ -69,7 +69,7 @@ public void assertGetChildrenKeys() { } @Test - public void assertGetNumChildren() { + void assertGetNumChildren() { assertThat(zkRegCenter.getNumChildren("/test"), is(2)); assertThat(zkRegCenter.getNumChildren("/test/deep"), is(1)); assertThat(zkRegCenter.getNumChildren("/test/child"), is(0)); @@ -77,14 +77,14 @@ public void assertGetNumChildren() { } @Test - public void assertIsExisted() { + void assertIsExisted() { assertTrue(zkRegCenter.isExisted("/test")); assertTrue(zkRegCenter.isExisted("/test/deep/nested")); assertFalse(zkRegCenter.isExisted("/notExisted")); } @Test - public void assertGetRegistryCenterTime() { + void assertGetRegistryCenterTime() { long regCenterTime = zkRegCenter.getRegistryCenterTime("/_systemTime/current"); assertTrue(regCenterTime <= System.currentTimeMillis()); long updatedRegCenterTime = zkRegCenter.getRegistryCenterTime("/_systemTime/current"); @@ -92,7 +92,7 @@ public void assertGetRegistryCenterTime() { } @Test - public void assertGetWithoutNode() { + void assertGetWithoutNode() { assertNull(zkRegCenter.get("/notExisted")); } } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java index 4f5c08a730..6ff7882c12 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; -public final class ZookeeperRegistryCenterTransactionTest { +class ZookeeperRegistryCenterTransactionTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterTransactionTest.class.getName()); @@ -40,7 +40,7 @@ public final class ZookeeperRegistryCenterTransactionTest { private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); @@ -48,12 +48,12 @@ public static void setUp() { } @BeforeEach - public void setup() { + void setup() { ZookeeperRegistryCenterTestUtil.persist(zkRegCenter); } @Test - public void assertExecuteInTransactionSucceeded() throws Exception { + void assertExecuteInTransactionSucceeded() throws Exception { List operations = new ArrayList<>(3); operations.add(TransactionOperation.opCheckExists("/test")); operations.add(TransactionOperation.opCheckExists("/test/child")); @@ -64,7 +64,7 @@ public void assertExecuteInTransactionSucceeded() throws Exception { } @Test - public void assertExecuteInTransactionFailed() throws Exception { + void assertExecuteInTransactionFailed() throws Exception { List operations = new ArrayList<>(3); operations.add(TransactionOperation.opAdd("/test/shouldnotexists", "")); operations.add(TransactionOperation.opCheckExists("/test/notexists")); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java index f6a0eeaf07..8720358229 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java @@ -35,14 +35,14 @@ import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; -public final class ZookeeperRegistryCenterWatchTest { +class ZookeeperRegistryCenterWatchTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), ZookeeperRegistryCenterWatchTest.class.getName()); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void setUp() { + static void setUp() { EmbedTestingServer.start(); zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); @@ -51,13 +51,13 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + static void tearDown() { zkRegCenter.close(); } @Test @Timeout(value = 10000L, unit = TimeUnit.MILLISECONDS) - public void assertWatchWithoutExecutor() throws InterruptedException { + void assertWatchWithoutExecutor() throws InterruptedException { CountDownLatch waitingForCountDownValue = new CountDownLatch(1); String key = "/test-watch-without-executor"; zkRegCenter.addCacheData(key); @@ -76,7 +76,7 @@ public void assertWatchWithoutExecutor() throws InterruptedException { @Test @Timeout(value = 10000L, unit = TimeUnit.MILLISECONDS) - public void assertWatchWithExecutor() throws InterruptedException { + void assertWatchWithExecutor() throws InterruptedException { CountDownLatch waitingForCountDownValue = new CountDownLatch(1); String key = "/test-watch-with-executor"; zkRegCenter.addCacheData(key); diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/exception/ZookeeperCuratorIgnoredExceptionProviderTest.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/exception/ZookeeperCuratorIgnoredExceptionProviderTest.java index 70109d83e0..a953548540 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/exception/ZookeeperCuratorIgnoredExceptionProviderTest.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/exception/ZookeeperCuratorIgnoredExceptionProviderTest.java @@ -28,10 +28,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ZookeeperCuratorIgnoredExceptionProviderTest { +class ZookeeperCuratorIgnoredExceptionProviderTest { @Test - public void assertIgnoredException() { + void assertIgnoredException() { List> expected = Arrays.asList(ConnectionLossException.class, NoNodeException.class, NodeExistsException.class); assertThat(new ZookeeperCuratorIgnoredExceptionProvider().getIgnoredExceptions(), is(expected)); } diff --git a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/util/ZookeeperRegistryCenterTestUtil.java b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/util/ZookeeperRegistryCenterTestUtil.java index e9f8da443b..dc16f0dd99 100644 --- a/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/util/ZookeeperRegistryCenterTestUtil.java +++ b/elasticjob-infra/elasticjob-registry-center/elasticjob-regitry-center-provider/elasticjob-registry-center-zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/util/ZookeeperRegistryCenterTestUtil.java @@ -25,7 +25,7 @@ import java.lang.reflect.Field; @NoArgsConstructor(access = AccessLevel.PRIVATE) -public class ZookeeperRegistryCenterTestUtil { +public final class ZookeeperRegistryCenterTestUtil { /** * Persist the data to registry center. diff --git a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/annotation/ParamSource.java b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/annotation/ParamSource.java index 0eff5f0be5..6a32a59aeb 100644 --- a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/annotation/ParamSource.java +++ b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/annotation/ParamSource.java @@ -46,5 +46,5 @@ public enum ParamSource { /** * Unknown source. */ - UNKNOWN, + UNKNOWN } diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexPathMatcherTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexPathMatcherTest.java index 6770959ca9..5126e3df52 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexPathMatcherTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexPathMatcherTest.java @@ -29,10 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class RegexPathMatcherTest { +class RegexPathMatcherTest { @Test - public void assertCaptureTemplate() { + void assertCaptureTemplate() { PathMatcher pathMatcher = new RegexPathMatcher(); Map variables = pathMatcher.captureVariables("/app/{jobName}/disable/{until}/done", "/app/myJob/disable/20201231/done?name=some_name&value=some_value"); assertFalse(variables.isEmpty()); @@ -43,20 +43,20 @@ public void assertCaptureTemplate() { } @Test - public void assertCapturePatternWithoutTemplate() { + void assertCapturePatternWithoutTemplate() { PathMatcher pathMatcher = new RegexPathMatcher(); Map variables = pathMatcher.captureVariables("/app", "/app"); assertTrue(variables.isEmpty()); } @Test - public void assertPathMatch() { + void assertPathMatch() { PathMatcher pathMatcher = new RegexPathMatcher(); assertTrue(pathMatcher.matches("/app/{jobName}", "/app/myJob")); } @Test - public void assertValidatePathPattern() { + void assertValidatePathPattern() { PathMatcher pathMatcher = new RegexPathMatcher(); assertTrue(pathMatcher.isValidPathPattern("/")); assertTrue(pathMatcher.isValidPathPattern("/app")); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexUrlPatternMapTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexUrlPatternMapTest.java index f124f4ab45..1a83142144 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexUrlPatternMapTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/RegexUrlPatternMapTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class RegexUrlPatternMapTest { +class RegexUrlPatternMapTest { @Test - public void assertRegexUrlPatternMap() { + void assertRegexUrlPatternMap() { RegexUrlPatternMap urlPatternMap = new RegexUrlPatternMap<>(); urlPatternMap.put("/app/{jobName}", 1); urlPatternMap.put("/app/list", 2); @@ -49,7 +49,7 @@ public void assertRegexUrlPatternMap() { } @Test - public void assertAmbiguous() { + void assertAmbiguous() { RegexUrlPatternMap urlPatternMap = new RegexUrlPatternMap<>(); urlPatternMap.put("/foo/{bar}/{fooName}/status", 10); urlPatternMap.put("/foo/{bar}/operate/{metrics}", 11); @@ -60,7 +60,7 @@ public void assertAmbiguous() { } @Test - public void assertDuplicate() { + void assertDuplicate() { assertThrows(IllegalArgumentException.class, () -> { RegexUrlPatternMap urlPatternMap = new RegexUrlPatternMap<>(); urlPatternMap.put("/app/{jobName}/enable", 0); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerFactoryTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerFactoryTest.java index 0376b03458..26cf3eb53e 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerFactoryTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerFactoryTest.java @@ -23,16 +23,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class RequestBodyDeserializerFactoryTest { +class RequestBodyDeserializerFactoryTest { @Test - public void assertGetJsonDefaultDeserializer() { + void assertGetJsonDefaultDeserializer() { RequestBodyDeserializer deserializer = RequestBodyDeserializerFactory.getRequestBodyDeserializer(HttpHeaderValues.APPLICATION_JSON.toString()); assertNotNull(deserializer); } @Test - public void assertDeserializerNotFound() { + void assertDeserializerNotFound() { assertThrows(RequestBodyDeserializerNotFoundException.class, () -> RequestBodyDeserializerFactory.getRequestBodyDeserializer("Unknown")); } } diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/filter/DefaultFilterChainTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/filter/DefaultFilterChainTest.java index d3dc3f022c..719937b9ef 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/filter/DefaultFilterChainTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/filter/DefaultFilterChainTest.java @@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class DefaultFilterChainTest { +class DefaultFilterChainTest { @Mock private ChannelHandlerContext ctx; @@ -58,12 +58,12 @@ public final class DefaultFilterChainTest { private HandleContext handleContext; @BeforeEach - public void setUp() { + void setUp() { handleContext = new HandleContext<>(httpRequest, httpResponse); } @Test - public void assertNoFilter() { + void assertNoFilter() { DefaultFilterChain filterChain = new DefaultFilterChain(Collections.emptyList(), ctx, handleContext); filterChain.next(httpRequest); verify(ctx, never()).writeAndFlush(httpResponse); @@ -73,7 +73,7 @@ public void assertNoFilter() { } @Test - public void assertWithSingleFilterPassed() { + void assertWithSingleFilterPassed() { Filter passableFilter = spy(new PassableFilter()); DefaultFilterChain filterChain = new DefaultFilterChain(Collections.singletonList(passableFilter), ctx, handleContext); filterChain.next(httpRequest); @@ -85,7 +85,7 @@ public void assertWithSingleFilterPassed() { } @Test - public void assertWithSingleFilterDoResponse() { + void assertWithSingleFilterDoResponse() { Filter impassableFilter = mock(Filter.class); DefaultFilterChain filterChain = new DefaultFilterChain(Collections.singletonList(impassableFilter), ctx, handleContext); filterChain.next(httpRequest); @@ -97,7 +97,7 @@ public void assertWithSingleFilterDoResponse() { } @Test - public void assertWithThreeFiltersPassed() { + void assertWithThreeFiltersPassed() { Filter firstFilter = spy(new PassableFilter()); Filter secondFilter = spy(new PassableFilter()); Filter thirdFilter = spy(new PassableFilter()); @@ -113,7 +113,7 @@ public void assertWithThreeFiltersPassed() { } @Test - public void assertWithThreeFiltersDoResponseByTheSecond() { + void assertWithThreeFiltersDoResponseByTheSecond() { Filter firstFilter = spy(new PassableFilter()); Filter secondFilter = mock(Filter.class); Filter thirdFilter = spy(new PassableFilter()); @@ -129,7 +129,7 @@ public void assertWithThreeFiltersDoResponseByTheSecond() { } @Test - public void assertInvokeFinishedFilterChainWithoutFilter() { + void assertInvokeFinishedFilterChainWithoutFilter() { assertThrows(IllegalStateException.class, () -> { DefaultFilterChain filterChain = new DefaultFilterChain(Collections.emptyList(), ctx, handleContext); filterChain.next(httpRequest); @@ -138,7 +138,7 @@ public void assertInvokeFinishedFilterChainWithoutFilter() { } @Test - public void assertInvokePassedThroughFilterChainWithTwoFilters() { + void assertInvokePassedThroughFilterChainWithTwoFilters() { assertThrows(IllegalStateException.class, () -> { Filter firstFilter = spy(new PassableFilter()); Filter secondFilter = spy(new PassableFilter()); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/FilterChainInboundHandlerTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/FilterChainInboundHandlerTest.java index f3f95c3dbc..67cc066545 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/FilterChainInboundHandlerTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/FilterChainInboundHandlerTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class FilterChainInboundHandlerTest { +class FilterChainInboundHandlerTest { @Mock private List filterInstances; @@ -47,20 +47,20 @@ public final class FilterChainInboundHandlerTest { private EmbeddedChannel channel; @BeforeEach - public void setUp() { + void setUp() { channel = new EmbeddedChannel(new FilterChainInboundHandler(filterInstances)); } @Test @SneakyThrows - public void assertNoFilter() { + void assertNoFilter() { when(filterInstances.isEmpty()).thenReturn(true); channel.writeOneInbound(handleContext); verify(handleContext, never()).getHttpRequest(); } @Test - public void assertFilterExists() { + void assertFilterExists() { when(filterInstances.isEmpty()).thenReturn(false); channel.writeOneInbound(handleContext); verify(handleContext, atLeastOnce()).getHttpRequest(); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandlerParameterDecoderTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandlerParameterDecoderTest.java index 7af51ce1ad..ed909a3e4a 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandlerParameterDecoderTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandlerParameterDecoderTest.java @@ -43,12 +43,12 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class HandlerParameterDecoderTest { +class HandlerParameterDecoderTest { private EmbeddedChannel channel; @BeforeEach - public void setUp() { + void setUp() { ContextInitializationInboundHandler contextInitializationInboundHandler = new ContextInitializationInboundHandler(); HttpRequestDispatcher httpRequestDispatcher = new HttpRequestDispatcher(Collections.singletonList(new DecoderTestController()), false); HandlerParameterDecoder handlerParameterDecoder = new HandlerParameterDecoder(); @@ -57,7 +57,7 @@ public void setUp() { } @Test - public void assertDecodeParameters() { + void assertDecodeParameters() { QueryStringEncoder queryStringEncoder = new QueryStringEncoder("/myApp/C"); queryStringEncoder.addParam("cron", "0 * * * * ?"); queryStringEncoder.addParam("integer", "30"); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HttpRequestDispatcherTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HttpRequestDispatcherTest.java index 185bcf1a3c..12027a5d89 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HttpRequestDispatcherTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HttpRequestDispatcherTest.java @@ -30,10 +30,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public final class HttpRequestDispatcherTest { +class HttpRequestDispatcherTest { @Test - public void assertDispatcherHandlerNotFound() { + void assertDispatcherHandlerNotFound() { assertThrows(HandlerNotFoundException.class, () -> { EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDispatcher(Lists.newArrayList(new JobController()), false)); FullHttpRequest fullHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/hello/myJob/myCron"); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTest.java index 253b013e80..bb6654a88f 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTest.java @@ -47,7 +47,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -public final class NettyRestfulServiceTest { +class NettyRestfulServiceTest { private static final long TESTCASE_TIMEOUT = 10000L; @@ -58,7 +58,7 @@ public final class NettyRestfulServiceTest { private static RestfulService restfulService; @BeforeAll - public static void init() { + static void init() { NettyRestfulServiceConfiguration configuration = new NettyRestfulServiceConfiguration(PORT); configuration.setHost(HOST); configuration.addControllerInstances(new JobController(), new IndexController()); @@ -70,7 +70,7 @@ public static void init() { @SneakyThrows @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertRequestWithParameters() { + void assertRequestWithParameters() { String cron = "0 * * * * ?"; String uri = String.format("/job/myGroup/myJob?cron=%s", URLEncoder.encode(cron, "UTF-8")); String description = "Descriptions about this job."; @@ -93,7 +93,7 @@ public void assertRequestWithParameters() { @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertCustomExceptionHandler() { + void assertCustomExceptionHandler() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/job/throw/IllegalState"); request.headers().set("Exception-Message", "An illegal state exception message."); HttpClient.request(HOST, PORT, request, httpResponse -> { @@ -104,7 +104,7 @@ public void assertCustomExceptionHandler() { @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertUsingDefaultExceptionHandler() { + void assertUsingDefaultExceptionHandler() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/job/throw/IllegalArgument"); request.headers().set("Exception-Message", "An illegal argument exception message."); HttpClient.request(HOST, PORT, request, httpResponse -> { @@ -115,42 +115,34 @@ public void assertUsingDefaultExceptionHandler() { @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertReturnStatusCode() { + void assertReturnStatusCode() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/job/code/204"); - HttpClient.request(HOST, PORT, request, httpResponse -> { - assertThat(httpResponse.status().code(), is(204)); - }, TESTCASE_TIMEOUT); + HttpClient.request(HOST, PORT, request, httpResponse -> assertThat(httpResponse.status().code(), is(204)), TESTCASE_TIMEOUT); } @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertHandlerNotFound() { + void assertHandlerNotFound() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/not/found"); - HttpClient.request(HOST, PORT, request, httpResponse -> { - assertThat(httpResponse.status().code(), is(404)); - }, TESTCASE_TIMEOUT); + HttpClient.request(HOST, PORT, request, httpResponse -> assertThat(httpResponse.status().code(), is(404)), TESTCASE_TIMEOUT); } @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertRequestIndexWithSlash() { + void assertRequestIndexWithSlash() { DefaultFullHttpRequest requestWithSlash = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); - HttpClient.request(HOST, PORT, requestWithSlash, httpResponse -> { - assertThat(httpResponse.status().code(), is(200)); - }, TESTCASE_TIMEOUT); + HttpClient.request(HOST, PORT, requestWithSlash, httpResponse -> assertThat(httpResponse.status().code(), is(200)), TESTCASE_TIMEOUT); } @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertRequestIndexWithoutSlash() { + void assertRequestIndexWithoutSlash() { DefaultFullHttpRequest requestWithoutSlash = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, ""); - HttpClient.request(HOST, PORT, requestWithoutSlash, httpResponse -> { - assertThat(httpResponse.status().code(), is(200)); - }, TESTCASE_TIMEOUT); + HttpClient.request(HOST, PORT, requestWithoutSlash, httpResponse -> assertThat(httpResponse.status().code(), is(200)), TESTCASE_TIMEOUT); } @AfterAll - public static void tearDown() { + static void tearDown() { if (null != restfulService) { restfulService.shutdown(); } diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashInsensitiveTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashInsensitiveTest.java index a0bf589597..a8f32f85b3 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashInsensitiveTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashInsensitiveTest.java @@ -25,14 +25,14 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public final class NettyRestfulServiceTrailingSlashInsensitiveTest { +class NettyRestfulServiceTrailingSlashInsensitiveTest { private static final String HOST = "localhost"; private static final int PORT = 18082; @Test - public void assertPathDuplicateWhenTrailingSlashInsensitive() { + void assertPathDuplicateWhenTrailingSlashInsensitive() { assertThrows(IllegalArgumentException.class, () -> { NettyRestfulServiceConfiguration configuration = new NettyRestfulServiceConfiguration(PORT); configuration.setHost(HOST); diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashSensitiveTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashSensitiveTest.java index 2146168e9c..46dd288d2f 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashSensitiveTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTrailingSlashSensitiveTest.java @@ -36,7 +36,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class NettyRestfulServiceTrailingSlashSensitiveTest { +class NettyRestfulServiceTrailingSlashSensitiveTest { private static final long TESTCASE_TIMEOUT = 10000L; @@ -47,7 +47,7 @@ public final class NettyRestfulServiceTrailingSlashSensitiveTest { private static RestfulService restfulService; @BeforeAll - public static void init() { + static void init() { NettyRestfulServiceConfiguration configuration = new NettyRestfulServiceConfiguration(PORT); configuration.setHost(HOST); configuration.setTrailingSlashSensitive(true); @@ -58,7 +58,7 @@ public static void init() { @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertWithoutTrailingSlash() { + void assertWithoutTrailingSlash() { DefaultFullHttpRequest requestWithSlash = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/trailing/slash"); HttpClient.request(HOST, PORT, requestWithSlash, httpResponse -> { assertThat(httpResponse.status().code(), is(200)); @@ -70,7 +70,7 @@ public void assertWithoutTrailingSlash() { @Test @Timeout(value = TESTCASE_TIMEOUT, unit = TimeUnit.MILLISECONDS) - public void assertWithTrailingSlash() { + void assertWithTrailingSlash() { DefaultFullHttpRequest requestWithoutSlash = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/trailing/slash/"); HttpClient.request(HOST, PORT, requestWithoutSlash, httpResponse -> { assertThat(httpResponse.status().code(), is(200)); @@ -81,7 +81,7 @@ public void assertWithTrailingSlash() { } @AfterAll - public static void tearDown() { + static void tearDown() { if (null != restfulService) { restfulService.shutdown(); } diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerFactoryTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerFactoryTest.java index b32934535b..69d263144d 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerFactoryTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerFactoryTest.java @@ -23,16 +23,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class ResponseBodySerializerFactoryTest { +class ResponseBodySerializerFactoryTest { @Test - public void assertGetJsonDefaultSerializer() { + void assertGetJsonDefaultSerializer() { ResponseBodySerializer serializer = ResponseBodySerializerFactory.getResponseBodySerializer(HttpHeaderValues.APPLICATION_JSON.toString()); assertNotNull(serializer); } @Test - public void assertSerializerNotFound() { + void assertSerializerNotFound() { assertThrows(ResponseBodySerializerNotFoundException.class, () -> ResponseBodySerializerFactory.getResponseBodySerializer("Unknown")); } } diff --git a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/wrapper/QueryParameterMapTest.java b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/wrapper/QueryParameterMapTest.java index a50a3a1182..a5523b19c0 100644 --- a/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/wrapper/QueryParameterMapTest.java +++ b/elasticjob-infra/elasticjob-restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/wrapper/QueryParameterMapTest.java @@ -30,10 +30,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; -public final class QueryParameterMapTest { +class QueryParameterMapTest { @Test - public void assertGetFirst() { + void assertGetFirst() { QueryParameterMap queryParameterMap = new QueryParameterMap(); queryParameterMap.add("name", "foo"); assertThat(queryParameterMap.getFirst("name"), is("foo")); @@ -41,7 +41,7 @@ public void assertGetFirst() { } @Test - public void assertConvertToSingleValueMap() { + void assertConvertToSingleValueMap() { Map> queries = new LinkedHashMap<>(1 << 2); queries.put("foo", new LinkedList<>(Arrays.asList("first_foo", "second_foo"))); queries.put("bar", new LinkedList<>(Arrays.asList("first_bar", "second_bar"))); @@ -52,7 +52,7 @@ public void assertConvertToSingleValueMap() { } @Test - public void assertGetEntrySet() { + void assertGetEntrySet() { QueryParameterMap queryParameterMap = new QueryParameterMap(); queryParameterMap.put("foo", new LinkedList<>(Arrays.asList("first_foo", "second_foo"))); queryParameterMap.put("bar", new LinkedList<>(Arrays.asList("first_bar", "second_bar"))); diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java index 20afc622c4..b3e410c7fb 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java +++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java @@ -53,7 +53,7 @@ public ReconcileService(final CoordinatorRegistryCenter regCenter, final String @Override protected void runOneIteration() { int reconcileIntervalMinutes = configService.load(true).getReconcileIntervalMinutes(); - if (reconcileIntervalMinutes > 0 && (System.currentTimeMillis() - lastReconcileTime >= reconcileIntervalMinutes * 60 * 1000)) { + if (reconcileIntervalMinutes > 0 && System.currentTimeMillis() - lastReconcileTime >= (long) reconcileIntervalMinutes * 60 * 1000) { lastReconcileTime = System.currentTimeMillis(); if (!shardingService.isNeedSharding() && shardingService.hasShardingInfoInOfflineServers() && !(isStaticSharding() && hasShardingInfo())) { log.warn("Elastic Job: job status node has inconsistent value,start reconciling..."); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/impl/OneOffJobBootstrapTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/impl/OneOffJobBootstrapTest.java index fd93cf0c45..0ff75c46cb 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/impl/OneOffJobBootstrapTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/impl/OneOffJobBootstrapTest.java @@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class OneOffJobBootstrapTest { +class OneOffJobBootstrapTest { private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), OneOffJobBootstrapTest.class.getSimpleName()); @@ -49,29 +49,29 @@ public final class OneOffJobBootstrapTest { private ZookeeperRegistryCenter zkRegCenter; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); } @BeforeEach - public void setUp() { + void setUp() { zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); zkRegCenter.init(); } @AfterEach - public void teardown() { + void teardown() { zkRegCenter.close(); } @Test - public void assertConfigFailedWithCron() { + void assertConfigFailedWithCron() { assertThrows(IllegalArgumentException.class, () -> new OneOffJobBootstrap(zkRegCenter, (SimpleJob) shardingContext -> { }, JobConfiguration.newBuilder("test_one_off_job_execute_with_config_cron", SHARDING_TOTAL_COUNT).cron("0/5 * * * * ?").build())); } @Test - public void assertExecute() { + void assertExecute() { AtomicInteger counter = new AtomicInteger(0); final OneOffJobBootstrap oneOffJobBootstrap = new OneOffJobBootstrap(zkRegCenter, (SimpleJob) shardingContext -> counter.incrementAndGet(), JobConfiguration.newBuilder("test_one_off_job_execute", SHARDING_TOTAL_COUNT).build()); @@ -82,7 +82,7 @@ public void assertExecute() { } @Test - public void assertShutdown() throws SchedulerException { + void assertShutdown() throws SchedulerException { OneOffJobBootstrap oneOffJobBootstrap = new OneOffJobBootstrap(zkRegCenter, (SimpleJob) shardingContext -> { }, JobConfiguration.newBuilder("test_one_off_job_shutdown", SHARDING_TOTAL_COUNT).build()); oneOffJobBootstrap.shutdown(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/listener/DistributeOnceElasticJobListenerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/listener/DistributeOnceElasticJobListenerTest.java index e90776a581..04b047e48b 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/listener/DistributeOnceElasticJobListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/listener/DistributeOnceElasticJobListenerTest.java @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class DistributeOnceElasticJobListenerTest { +class DistributeOnceElasticJobListenerTest { @Mock private GuaranteeService guaranteeService; @@ -57,7 +57,7 @@ public final class DistributeOnceElasticJobListenerTest { private TestDistributeOnceElasticJobListener distributeOnceElasticJobListener; @BeforeEach - public void setUp() { + void setUp() { distributeOnceElasticJobListener = new TestDistributeOnceElasticJobListener(elasticJobListenerCaller); distributeOnceElasticJobListener.setGuaranteeService(guaranteeService); ReflectionUtils.setSuperclassFieldValue(distributeOnceElasticJobListener, "timeService", timeService); @@ -68,7 +68,7 @@ public void setUp() { } @Test - public void assertBeforeJobExecutedWhenIsAllStarted() { + void assertBeforeJobExecutedWhenIsAllStarted() { when(guaranteeService.isRegisterStartSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllStarted()).thenReturn(true); distributeOnceElasticJobListener.beforeJobExecuted(shardingContexts); @@ -77,7 +77,7 @@ public void assertBeforeJobExecutedWhenIsAllStarted() { } @Test - public void assertBeforeJobExecutedWhenIsNotAllStartedAndNotTimeout() { + void assertBeforeJobExecutedWhenIsNotAllStartedAndNotTimeout() { when(guaranteeService.isRegisterStartSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllStarted()).thenReturn(false); when(timeService.getCurrentMillis()).thenReturn(0L); @@ -87,7 +87,7 @@ public void assertBeforeJobExecutedWhenIsNotAllStartedAndNotTimeout() { } @Test - public void assertBeforeJobExecutedWhenIsNotAllStartedAndTimeout() { + void assertBeforeJobExecutedWhenIsNotAllStartedAndTimeout() { assertThrows(JobSystemException.class, () -> { when(guaranteeService.isRegisterStartSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllStarted()).thenReturn(false); @@ -99,7 +99,7 @@ public void assertBeforeJobExecutedWhenIsNotAllStartedAndTimeout() { } @Test - public void assertAfterJobExecutedWhenIsAllCompleted() { + void assertAfterJobExecutedWhenIsAllCompleted() { when(guaranteeService.isRegisterCompleteSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllCompleted()).thenReturn(true); distributeOnceElasticJobListener.afterJobExecuted(shardingContexts); @@ -108,7 +108,7 @@ public void assertAfterJobExecutedWhenIsAllCompleted() { } @Test - public void assertAfterJobExecutedWhenIsAllCompletedAndNotTimeout() { + void assertAfterJobExecutedWhenIsAllCompletedAndNotTimeout() { when(guaranteeService.isRegisterCompleteSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllCompleted()).thenReturn(false); when(timeService.getCurrentMillis()).thenReturn(0L); @@ -118,7 +118,7 @@ public void assertAfterJobExecutedWhenIsAllCompletedAndNotTimeout() { } @Test - public void assertAfterJobExecutedWhenIsAllCompletedAndTimeout() { + void assertAfterJobExecutedWhenIsAllCompletedAndTimeout() { assertThrows(JobSystemException.class, () -> { when(guaranteeService.isRegisterCompleteSuccess(Sets.newHashSet(0, 1))).thenReturn(true); when(guaranteeService.isAllCompleted()).thenReturn(false); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/registry/JobInstanceRegistryTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/registry/JobInstanceRegistryTest.java index 23a7bcec7d..881c14a7a3 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/registry/JobInstanceRegistryTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/registry/JobInstanceRegistryTest.java @@ -34,41 +34,37 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class JobInstanceRegistryTest { +class JobInstanceRegistryTest { @Mock private CoordinatorRegistryCenter regCenter; @Test - public void assertListenWithoutConfigPath() { - JobInstanceRegistry jobInstanceRegistry = new JobInstanceRegistry(regCenter, new JobInstance("id")); - jobInstanceRegistry.new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName", "")); + void assertListenWithoutConfigPath() { + new JobInstanceRegistry(regCenter, new JobInstance("id")).new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName", "")); verify(regCenter, times(0)).get("/jobName"); } @Test - public void assertListenLabelNotMatch() { - JobInstanceRegistry jobInstanceRegistry = new JobInstanceRegistry(regCenter, new JobInstance("id", "label1,label2")); + void assertListenLabelNotMatch() { String jobConfig = toYaml(JobConfiguration.newBuilder("jobName", 1).label("label").build()); - jobInstanceRegistry.new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); + new JobInstanceRegistry(regCenter, new JobInstance("id", "label1,label2")).new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); verify(regCenter, times(0)).get("/jobName"); } @Test - public void assertListenScheduleJob() { + void assertListenScheduleJob() { assertThrows(RuntimeException.class, () -> { - JobInstanceRegistry jobInstanceRegistry = new JobInstanceRegistry(regCenter, new JobInstance("id")); String jobConfig = toYaml(JobConfiguration.newBuilder("jobName", 1).cron("0/1 * * * * ?").label("label").build()); - jobInstanceRegistry.new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); + new JobInstanceRegistry(regCenter, new JobInstance("id")).new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); }); } @Test - public void assertListenOneOffJob() { + void assertListenOneOffJob() { assertThrows(RuntimeException.class, () -> { - JobInstanceRegistry jobInstanceRegistry = new JobInstanceRegistry(regCenter, new JobInstance("id", "label")); String jobConfig = toYaml(JobConfiguration.newBuilder("jobName", 1).label("label").build()); - jobInstanceRegistry.new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); + new JobInstanceRegistry(regCenter, new JobInstance("id", "label")).new JobInstanceRegistryListener().onChange(new DataChangedEvent(Type.ADDED, "/jobName/config", jobConfig)); }); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java index 0cf2fbf780..0a6aa35986 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java @@ -74,14 +74,14 @@ private JobBootstrap createJobBootstrap(final TestType type, final ElasticJob el } @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); ZOOKEEPER_CONFIG.setConnectionTimeoutMilliseconds(30000); REGISTRY_CENTER.init(); } @BeforeEach - public void setUp() { + void setUp() { if (jobBootstrap instanceof ScheduleJobBootstrap) { ((ScheduleJobBootstrap) jobBootstrap).schedule(); } else { @@ -90,7 +90,7 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { jobBootstrap.shutdown(); ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/OneOffDisabledJobIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/OneOffDisabledJobIntegrateTest.java index e131a4ffcb..220dde4cdb 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/OneOffDisabledJobIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/OneOffDisabledJobIntegrateTest.java @@ -20,9 +20,9 @@ import org.apache.shardingsphere.elasticjob.api.JobConfiguration; import org.junit.jupiter.api.Test; -public final class OneOffDisabledJobIntegrateTest extends DisabledJobIntegrateTest { +class OneOffDisabledJobIntegrateTest extends DisabledJobIntegrateTest { - public OneOffDisabledJobIntegrateTest() { + OneOffDisabledJobIntegrateTest() { super(TestType.ONE_OFF); } @@ -33,7 +33,7 @@ protected JobConfiguration getJobConfiguration(final String jobName) { } @Test - public void assertJobRunning() { + void assertJobRunning() { assertDisabledRegCenterInfo(); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/ScheduleDisabledJobIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/ScheduleDisabledJobIntegrateTest.java index 14974c1198..0b2a3e2cf8 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/ScheduleDisabledJobIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/disable/ScheduleDisabledJobIntegrateTest.java @@ -30,9 +30,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ScheduleDisabledJobIntegrateTest extends DisabledJobIntegrateTest { +class ScheduleDisabledJobIntegrateTest extends DisabledJobIntegrateTest { - public ScheduleDisabledJobIntegrateTest() { + ScheduleDisabledJobIntegrateTest() { super(TestType.SCHEDULE); } @@ -43,7 +43,7 @@ protected JobConfiguration getJobConfiguration(final String jobName) { } @Test - public void assertJobRunning() { + void assertJobRunning() { assertDisabledRegCenterInfo(); setJobEnable(); Awaitility.await().atMost(10L, TimeUnit.SECONDS).untilAsserted(() -> assertThat(((DetailedFooJob) getElasticJob()).isCompleted(), is(true))); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/EnabledJobIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/EnabledJobIntegrateTest.java index b220b2b38d..2698f08ed4 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/EnabledJobIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/EnabledJobIntegrateTest.java @@ -40,7 +40,7 @@ protected EnabledJobIntegrateTest(final TestType type, final ElasticJob elasticJ } @BeforeEach - public final void assertEnabledRegCenterInfo() { + void assertEnabledRegCenterInfo() { assertThat(JobRegistry.getInstance().getCurrentShardingTotalCount(getJobName()), is(3)); assertThat(JobRegistry.getInstance().getJobInstance(getJobName()).getServerIp(), is(IpUtils.getIp())); JobConfiguration jobConfig = YamlEngine.unmarshal(getREGISTRY_CENTER().get("/" + getJobName() + "/config"), JobConfigurationPOJO.class).toJobConfiguration(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/OneOffEnabledJobIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/OneOffEnabledJobIntegrateTest.java index 1809deea17..375812ead9 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/OneOffEnabledJobIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/OneOffEnabledJobIntegrateTest.java @@ -28,9 +28,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class OneOffEnabledJobIntegrateTest extends EnabledJobIntegrateTest { +class OneOffEnabledJobIntegrateTest extends EnabledJobIntegrateTest { - public OneOffEnabledJobIntegrateTest() { + OneOffEnabledJobIntegrateTest() { super(TestType.ONE_OFF, new DetailedFooJob()); } @@ -41,7 +41,7 @@ protected JobConfiguration getJobConfiguration(final String jobName) { } @Test - public void assertJobInit() { + void assertJobInit() { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(((DetailedFooJob) getElasticJob()).isCompleted(), is(true))); assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding")); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/ScheduleEnabledJobIntegrateTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/ScheduleEnabledJobIntegrateTest.java index 3d994336bd..26f26d4045 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/ScheduleEnabledJobIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/enable/ScheduleEnabledJobIntegrateTest.java @@ -28,9 +28,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ScheduleEnabledJobIntegrateTest extends EnabledJobIntegrateTest { +class ScheduleEnabledJobIntegrateTest extends EnabledJobIntegrateTest { - public ScheduleEnabledJobIntegrateTest() { + ScheduleEnabledJobIntegrateTest() { super(TestType.SCHEDULE, new DetailedFooJob()); } @@ -41,7 +41,7 @@ protected JobConfiguration getJobConfiguration(final String jobName) { } @Test - public void assertJobInit() { + void assertJobInit() { Awaitility.await().atMost(10L, TimeUnit.SECONDS).untilAsserted(() -> assertThat(((DetailedFooJob) getElasticJob()).isCompleted(), is(true))); assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding")); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/JobAnnotationBuilderTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/JobAnnotationBuilderTest.java index 221be372a0..acdabbf6d4 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/JobAnnotationBuilderTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/JobAnnotationBuilderTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class JobAnnotationBuilderTest { +class JobAnnotationBuilderTest { @Test - public void assertGenerateJobConfiguration() { + void assertGenerateJobConfiguration() { JobConfiguration jobConfiguration = JobAnnotationBuilder.generateJobConfiguration(AnnotationSimpleJob.class); assertThat(jobConfiguration.getJobName(), is("AnnotationSimpleJob")); assertThat(jobConfiguration.getShardingTotalCount(), is(3)); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/BaseAnnotationTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/BaseAnnotationTest.java index a09ebafbce..a3d878e000 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/BaseAnnotationTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/BaseAnnotationTest.java @@ -74,14 +74,14 @@ private JobBootstrap createJobBootstrap(final TestType type, final ElasticJob el } @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); ZOOKEEPER_CONFIG.setConnectionTimeoutMilliseconds(30000); REGISTRY_CENTER.init(); } @BeforeEach - public void setUp() { + void setUp() { if (jobBootstrap instanceof ScheduleJobBootstrap) { ((ScheduleJobBootstrap) jobBootstrap).schedule(); } else { @@ -90,7 +90,7 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { jobBootstrap.shutdown(); ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/OneOffEnabledJobTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/OneOffEnabledJobTest.java index 75a8615299..bd1ae65a87 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/OneOffEnabledJobTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/OneOffEnabledJobTest.java @@ -35,14 +35,14 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class OneOffEnabledJobTest extends BaseAnnotationTest { +class OneOffEnabledJobTest extends BaseAnnotationTest { - public OneOffEnabledJobTest() { + OneOffEnabledJobTest() { super(TestType.ONE_OFF, new AnnotationUnShardingJob()); } @BeforeEach - public void assertEnabledRegCenterInfo() { + void assertEnabledRegCenterInfo() { assertThat(JobRegistry.getInstance().getCurrentShardingTotalCount(getJobName()), is(1)); assertThat(JobRegistry.getInstance().getJobInstance(getJobName()).getServerIp(), is(IpUtils.getIp())); JobConfiguration jobConfig = YamlEngine.unmarshal(getREGISTRY_CENTER().get("/" + getJobName() + "/config"), JobConfigurationPOJO.class).toJobConfiguration(); @@ -56,7 +56,7 @@ public void assertEnabledRegCenterInfo() { } @Test - public void assertJobInit() { + void assertJobInit() { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(((AnnotationUnShardingJob) getElasticJob()).isCompleted(), is(true))); assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding")); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/ScheduleEnabledJobTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/ScheduleEnabledJobTest.java index cc4c4d3d66..82333eaafd 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/ScheduleEnabledJobTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/annotation/integrate/ScheduleEnabledJobTest.java @@ -35,14 +35,14 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ScheduleEnabledJobTest extends BaseAnnotationTest { +class ScheduleEnabledJobTest extends BaseAnnotationTest { - public ScheduleEnabledJobTest() { + ScheduleEnabledJobTest() { super(TestType.SCHEDULE, new AnnotationSimpleJob()); } @BeforeEach - public void assertEnabledRegCenterInfo() { + void assertEnabledRegCenterInfo() { assertThat(JobRegistry.getInstance().getCurrentShardingTotalCount(getJobName()), is(3)); assertThat(JobRegistry.getInstance().getJobInstance(getJobName()).getServerIp(), is(IpUtils.getIp())); JobConfiguration jobConfig = YamlEngine.unmarshal(getREGISTRY_CENTER().get("/" + getJobName() + "/config"), JobConfigurationPOJO.class).toJobConfiguration(); @@ -58,7 +58,7 @@ public void assertEnabledRegCenterInfo() { } @Test - public void assertJobInit() { + void assertJobInit() { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(((AnnotationSimpleJob) getElasticJob()).isCompleted(), is(true))); assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding")); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationNodeTest.java index 96bfdc0d6a..6bab8143d3 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationNodeTest.java @@ -21,12 +21,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ConfigurationNodeTest { +class ConfigurationNodeTest { private final ConfigurationNode configurationNode = new ConfigurationNode("test_job"); @Test - public void assertIsConfigPath() { + void assertIsConfigPath() { assertTrue(configurationNode.isConfigPath("/test_job/config")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java index 5ae1541aa7..51167d7eb0 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ConfigurationServiceTest { +class ConfigurationServiceTest { @Mock private JobNodeStorage jobNodeStorage; @@ -48,12 +48,12 @@ public final class ConfigurationServiceTest { private final ConfigurationService configService = new ConfigurationService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(configService, "jobNodeStorage", jobNodeStorage); } @Test - public void assertLoadDirectly() { + void assertLoadDirectly() { when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml()); JobConfiguration actual = configService.load(false); assertThat(actual.getJobName(), is("test_job")); @@ -62,7 +62,7 @@ public void assertLoadDirectly() { } @Test - public void assertLoadFromCache() { + void assertLoadFromCache() { when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml()); JobConfiguration actual = configService.load(true); assertThat(actual.getJobName(), is("test_job")); @@ -71,7 +71,7 @@ public void assertLoadFromCache() { } @Test - public void assertLoadFromCacheButNull() { + void assertLoadFromCacheButNull() { when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(null); when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml()); JobConfiguration actual = configService.load(true); @@ -81,7 +81,7 @@ public void assertLoadFromCacheButNull() { } @Test - public void assertSetUpJobConfigurationJobConfigurationForJobConflict() { + void assertSetUpJobConfigurationJobConfigurationForJobConflict() { assertThrows(JobConfigurationException.class, () -> { when(jobNodeStorage.isJobRootNodeExisted()).thenReturn(true); when(jobNodeStorage.getJobRootNodeData()).thenReturn("org.apache.shardingsphere.elasticjob.lite.api.script.api.ScriptJob"); @@ -95,14 +95,14 @@ public void assertSetUpJobConfigurationJobConfigurationForJobConflict() { } @Test - public void assertSetUpJobConfigurationNewJobConfiguration() { + void assertSetUpJobConfigurationNewJobConfiguration() { JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build(); assertThat(configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig), is(jobConfig)); verify(jobNodeStorage).replaceJobNode("config", YamlEngine.marshal(JobConfigurationPOJO.fromJobConfiguration(jobConfig))); } @Test - public void assertSetUpJobConfigurationExistedJobConfigurationAndOverwrite() { + void assertSetUpJobConfigurationExistedJobConfigurationAndOverwrite() { when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true); JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").overwrite(true).build(); assertThat(configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig), is(jobConfig)); @@ -110,7 +110,7 @@ public void assertSetUpJobConfigurationExistedJobConfigurationAndOverwrite() { } @Test - public void assertSetUpJobConfigurationExistedJobConfigurationAndNotOverwrite() { + void assertSetUpJobConfigurationExistedJobConfigurationAndNotOverwrite() { when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true); when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn( YamlEngine.marshal(JobConfigurationPOJO.fromJobConfiguration(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()))); @@ -120,13 +120,13 @@ public void assertSetUpJobConfigurationExistedJobConfigurationAndNotOverwrite() } @Test - public void assertIsMaxTimeDiffSecondsTolerableWithDefaultValue() throws JobExecutionEnvironmentException { + void assertIsMaxTimeDiffSecondsTolerableWithDefaultValue() throws JobExecutionEnvironmentException { when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml(-1)); configService.checkMaxTimeDiffSecondsTolerable(); } @Test - public void assertIsMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException { + void assertIsMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException { when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml()); when(jobNodeStorage.getRegistryCenterTime()).thenReturn(System.currentTimeMillis()); configService.checkMaxTimeDiffSecondsTolerable(); @@ -134,7 +134,7 @@ public void assertIsMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironment } @Test - public void assertIsNotMaxTimeDiffSecondsTolerable() { + void assertIsNotMaxTimeDiffSecondsTolerable() { assertThrows(JobExecutionEnvironmentException.class, () -> { when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml()); when(jobNodeStorage.getRegistryCenterTime()).thenReturn(0L); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java index 61a02bdf52..ee04859410 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java @@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class RescheduleListenerManagerTest { +class RescheduleListenerManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -51,36 +51,36 @@ public final class RescheduleListenerManagerTest { private final RescheduleListenerManager rescheduleListenerManager = new RescheduleListenerManager(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setSuperclassFieldValue(rescheduleListenerManager, "jobNodeStorage", jobNodeStorage); } @Test - public void assertStart() { + void assertStart() { rescheduleListenerManager.start(); verify(jobNodeStorage).addDataListener(ArgumentMatchers.any()); } @Test - public void assertCronSettingChangedJobListenerWhenIsNotCronPath() { + void assertCronSettingChangedJobListenerWhenIsNotCronPath() { rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/config/other", LiteYamlConstants.getJobYaml())); verify(jobScheduleController, times(0)).rescheduleJob(any(), any()); } @Test - public void assertCronSettingChangedJobListenerWhenIsCronPathButNotUpdate() { + void assertCronSettingChangedJobListenerWhenIsCronPathButNotUpdate() { rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(jobScheduleController, times(0)).rescheduleJob(any(), any()); } @Test - public void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateButCannotFindJob() { + void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateButCannotFindJob() { rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(jobScheduleController, times(0)).rescheduleJob(any(), any()); } @Test - public void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateAndFindJob() { + void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateAndFindJob() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/ElectionListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/ElectionListenerManagerTest.java index 390b2b0414..25f524fd23 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/ElectionListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/ElectionListenerManagerTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ElectionListenerManagerTest { +class ElectionListenerManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -59,7 +59,7 @@ public final class ElectionListenerManagerTest { private final ElectionListenerManager electionListenerManager = new ElectionListenerManager(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); ReflectionUtils.setSuperclassFieldValue(electionListenerManager, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(electionListenerManager, "leaderService", leaderService); @@ -67,37 +67,37 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { electionListenerManager.start(); verify(jobNodeStorage, times(2)).addDataListener(ArgumentMatchers.any()); } @Test - public void assertIsNotLeaderInstancePathAndServerPath() { + void assertIsNotLeaderInstancePathAndServerPath() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.DELETED, "/test_job/leader/election/other", "127.0.0.1")); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenAddLeaderInstancePath() { + void assertLeaderElectionWhenAddLeaderInstancePath() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/leader/election/instance", "127.0.0.1")); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenRemoveLeaderInstancePathWithoutAvailableServers() { + void assertLeaderElectionWhenRemoveLeaderInstancePathWithoutAvailableServers() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/leader/election/instance", "127.0.0.1")); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenRemoveLeaderInstancePathWithAvailableServerButJobInstanceIsShutdown() { + void assertLeaderElectionWhenRemoveLeaderInstancePathWithAvailableServerButJobInstanceIsShutdown() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/leader/election/instance", "127.0.0.1")); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenRemoveLeaderInstancePathWithAvailableServer() { + void assertLeaderElectionWhenRemoveLeaderInstancePathWithAvailableServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(serverService.isAvailableServer("127.0.0.1")).thenReturn(true); @@ -107,19 +107,19 @@ public void assertLeaderElectionWhenRemoveLeaderInstancePathWithAvailableServer( } @Test - public void assertLeaderElectionWhenServerDisableWithoutLeader() { + void assertLeaderElectionWhenServerDisableWithoutLeader() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/servers/127.0.0.1", ServerStatus.DISABLED.name())); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenServerEnableWithLeader() { + void assertLeaderElectionWhenServerEnableWithLeader() { electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/servers/127.0.0.1", "")); verify(leaderService, times(0)).electLeader(); } @Test - public void assertLeaderElectionWhenServerEnableWithoutLeader() { + void assertLeaderElectionWhenServerEnableWithoutLeader() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); electionListenerManager.new LeaderElectionJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/servers/127.0.0.1", "")); @@ -128,13 +128,13 @@ public void assertLeaderElectionWhenServerEnableWithoutLeader() { } @Test - public void assertLeaderAbdicationWhenFollowerDisable() { + void assertLeaderAbdicationWhenFollowerDisable() { electionListenerManager.new LeaderAbdicationJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/servers/127.0.0.1", ServerStatus.DISABLED.name())); verify(leaderService, times(0)).removeLeader(); } @Test - public void assertLeaderAbdicationWhenLeaderDisable() { + void assertLeaderAbdicationWhenLeaderDisable() { when(leaderService.isLeader()).thenReturn(true); electionListenerManager.new LeaderAbdicationJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/servers/127.0.0.1", ServerStatus.DISABLED.name())); verify(leaderService).removeLeader(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderNodeTest.java index 3158ce5f7c..9fd5b56eca 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderNodeTest.java @@ -22,17 +22,17 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class LeaderNodeTest { +class LeaderNodeTest { private final LeaderNode leaderNode = new LeaderNode("test_job"); @Test - public void assertIsLeaderInstancePath() { + void assertIsLeaderInstancePath() { assertTrue(leaderNode.isLeaderInstancePath("/test_job/leader/election/instance")); } @Test - public void assertIsNotLeaderInstancePath() { + void assertIsNotLeaderInstancePath() { assertFalse(leaderNode.isLeaderInstancePath("/test_job/leader/election/instance1")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderServiceTest.java index 8fe0bb3b8e..f00e72ac14 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/election/LeaderServiceTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class LeaderServiceTest { +class LeaderServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -57,7 +57,7 @@ public final class LeaderServiceTest { private LeaderService leaderService; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); leaderService = new LeaderService(null, "test_job"); ReflectionUtils.setFieldValue(leaderService, "jobNodeStorage", jobNodeStorage); @@ -65,13 +65,13 @@ public void setUp() { } @Test - public void assertElectLeader() { + void assertElectLeader() { leaderService.electLeader(); verify(jobNodeStorage).executeInLeader(eq("leader/election/latch"), ArgumentMatchers.any()); } @Test - public void assertIsLeaderUntilBlockWithLeader() { + void assertIsLeaderUntilBlockWithLeader() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(true); @@ -82,21 +82,21 @@ public void assertIsLeaderUntilBlockWithLeader() { } @Test - public void assertIsLeaderUntilBlockWithoutLeaderAndAvailableServers() { + void assertIsLeaderUntilBlockWithoutLeaderAndAvailableServers() { when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(false); assertFalse(leaderService.isLeaderUntilBlock()); verify(jobNodeStorage, times(0)).executeInLeader(eq("leader/election/latch"), ArgumentMatchers.any()); } @Test - public void assertIsLeaderUntilBlockWithoutLeaderWithAvailableServers() { + void assertIsLeaderUntilBlockWithoutLeaderWithAvailableServers() { when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(false, true); assertFalse(leaderService.isLeaderUntilBlock()); verify(jobNodeStorage, times(0)).executeInLeader(eq("leader/election/latch"), ArgumentMatchers.any()); } @Test - public void assertIsLeaderUntilBlockWhenHasLeader() { + void assertIsLeaderUntilBlockWhenHasLeader() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(false, true); @@ -109,7 +109,7 @@ public void assertIsLeaderUntilBlockWhenHasLeader() { } @Test - public void assertIsLeader() { + void assertIsLeader() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.getJobNodeData("leader/election/instance")).thenReturn("127.0.0.1@-@0"); @@ -118,26 +118,26 @@ public void assertIsLeader() { } @Test - public void assertHasLeader() { + void assertHasLeader() { when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(true); assertTrue(leaderService.hasLeader()); } @Test - public void assertRemoveLeader() { + void assertRemoveLeader() { leaderService.removeLeader(); verify(jobNodeStorage).removeJobNodeIfExisted("leader/election/instance"); } @Test - public void assertElectLeaderExecutionCallbackWithLeader() { + void assertElectLeaderExecutionCallbackWithLeader() { when(jobNodeStorage.isJobNodeExisted("leader/election/instance")).thenReturn(true); leaderService.new LeaderElectionExecutionCallback().execute(); verify(jobNodeStorage, times(0)).fillEphemeralJobNode("leader/election/instance", "127.0.0.1@-@0"); } @Test - public void assertElectLeaderExecutionCallbackWithoutLeader() { + void assertElectLeaderExecutionCallbackWithoutLeader() { leaderService.new LeaderElectionExecutionCallback().execute(); verify(jobNodeStorage).fillEphemeralJobNode("leader/election/instance", "127.0.0.1@-@0"); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java index c78e78df4d..db4acd39f9 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java @@ -51,7 +51,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class FailoverListenerManagerTest { +class FailoverListenerManagerTest { @Mock private JobNodeStorage jobNodeStorage; @@ -80,7 +80,7 @@ public final class FailoverListenerManagerTest { private final FailoverListenerManager failoverListenerManager = new FailoverListenerManager(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setSuperclassFieldValue(failoverListenerManager, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(failoverListenerManager, "configService", configService); ReflectionUtils.setFieldValue(failoverListenerManager, "shardingService", shardingService); @@ -91,19 +91,19 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { failoverListenerManager.start(); verify(jobNodeStorage, times(3)).addDataListener(ArgumentMatchers.any(DataChangedEventListener.class)); } @Test - public void assertJobCrashedJobListenerWhenFailoverDisabled() { + void assertJobCrashedJobListenerWhenFailoverDisabled() { failoverListenerManager.new JobCrashedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/instances/127.0.0.1@-@0", "")); verify(failoverService, times(0)).failoverIfNecessary(); } @Test - public void assertJobCrashedJobListenerWhenIsNotNodeRemoved() { + void assertJobCrashedJobListenerWhenIsNotNodeRemoved() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -113,7 +113,7 @@ public void assertJobCrashedJobListenerWhenIsNotNodeRemoved() { } @Test - public void assertJobCrashedJobListenerWhenIsNotInstancesPath() { + void assertJobCrashedJobListenerWhenIsNotInstancesPath() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -123,7 +123,7 @@ public void assertJobCrashedJobListenerWhenIsNotInstancesPath() { } @Test - public void assertJobCrashedJobListenerWhenIsSameInstance() { + void assertJobCrashedJobListenerWhenIsSameInstance() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -133,7 +133,7 @@ public void assertJobCrashedJobListenerWhenIsSameInstance() { } @Test - public void assertJobCrashedJobListenerWhenIsOtherInstanceCrashed() { + void assertJobCrashedJobListenerWhenIsOtherInstanceCrashed() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -148,7 +148,7 @@ public void assertJobCrashedJobListenerWhenIsOtherInstanceCrashed() { } @Test - public void assertJobCrashedJobListenerWhenIsOtherFailoverInstanceCrashed() { + void assertJobCrashedJobListenerWhenIsOtherFailoverInstanceCrashed() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -162,31 +162,31 @@ public void assertJobCrashedJobListenerWhenIsOtherFailoverInstanceCrashed() { } @Test - public void assertFailoverSettingsChangedJobListenerWhenIsNotFailoverPath() { + void assertFailoverSettingsChangedJobListenerWhenIsNotFailoverPath() { failoverListenerManager.new FailoverSettingsChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/other", LiteYamlConstants.getJobYaml())); verify(failoverService, times(0)).removeFailoverInfo(); } @Test - public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathButNotUpdate() { + void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathButNotUpdate() { failoverListenerManager.new FailoverSettingsChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/config", "")); verify(failoverService, times(0)).removeFailoverInfo(); } @Test - public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() { + void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() { failoverListenerManager.new FailoverSettingsChangedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(failoverService, times(0)).removeFailoverInfo(); } @Test - public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() { + void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() { failoverListenerManager.new FailoverSettingsChangedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYamlWithFailover(false))); verify(failoverService).removeFailoverInfo(); } @Test - public void assertLegacyCrashedRunningItemListenerWhenRunningItemsArePresent() { + void assertLegacyCrashedRunningItemListenerWhenRunningItemsArePresent() { JobInstance jobInstance = new JobInstance("127.0.0.1@-@1"); JobRegistry.getInstance().registerJob("test_job", mock(JobScheduleController.class)); JobRegistry.getInstance().addJobInstance("test_job", jobInstance); @@ -208,7 +208,7 @@ public void assertLegacyCrashedRunningItemListenerWhenRunningItemsArePresent() { } @Test - public void assertLegacyCrashedRunningItemListenerWhenJobInstanceAbsent() { + void assertLegacyCrashedRunningItemListenerWhenJobInstanceAbsent() { failoverListenerManager.new LegacyCrashedRunningItemListener().onChange(new DataChangedEvent(Type.ADDED, "", "")); verifyNoInteractions(instanceNode); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverNodeTest.java index 27ce6ff398..c2fde69823 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverNodeTest.java @@ -23,32 +23,32 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class FailoverNodeTest { +class FailoverNodeTest { private final FailoverNode failoverNode = new FailoverNode("test_job"); @Test - public void assertGetItemsNode() { + void assertGetItemsNode() { assertThat(FailoverNode.getItemsNode(0), is("leader/failover/items/0")); } @Test - public void assertGetExecutionFailoverNode() { + void assertGetExecutionFailoverNode() { assertThat(FailoverNode.getExecutionFailoverNode(0), is("sharding/0/failover")); } @Test - public void assertGetItemWhenNotExecutionFailoverPath() { + void assertGetItemWhenNotExecutionFailoverPath() { assertNull(failoverNode.getItemByExecutionFailoverPath("/test_job/sharding/0/completed")); } @Test - public void assertGetItemByExecutionFailoverPath() { + void assertGetItemByExecutionFailoverPath() { assertThat(failoverNode.getItemByExecutionFailoverPath("/test_job/sharding/0/failover"), is(0)); } @Test - public void assertGetProcessingFailoverNode() { + void assertGetProcessingFailoverNode() { assertThat(FailoverNode.getExecutingFailoverNode(0), is("sharding/0/failovering")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverServiceTest.java index 0ec86e8bbe..b204338ec6 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverServiceTest.java @@ -46,7 +46,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class FailoverServiceTest { +class FailoverServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -66,7 +66,7 @@ public final class FailoverServiceTest { private final FailoverService failoverService = new FailoverService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(failoverService, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(failoverService, "shardingService", shardingService); ReflectionUtils.setFieldValue(failoverService, "jobName", "test_job"); @@ -75,7 +75,7 @@ public void setUp() { } @Test - public void assertSetCrashedFailoverFlagWhenItemIsNotAssigned() { + void assertSetCrashedFailoverFlagWhenItemIsNotAssigned() { when(jobNodeStorage.isJobNodeExisted("sharding/0/failover")).thenReturn(true); failoverService.setCrashedFailoverFlag(0); verify(jobNodeStorage).isJobNodeExisted("sharding/0/failover"); @@ -83,7 +83,7 @@ public void assertSetCrashedFailoverFlagWhenItemIsNotAssigned() { } @Test - public void assertSetCrashedFailoverFlagWhenItemIsAssigned() { + void assertSetCrashedFailoverFlagWhenItemIsAssigned() { when(jobNodeStorage.isJobNodeExisted("sharding/0/failover")).thenReturn(false); failoverService.setCrashedFailoverFlag(0); verify(jobNodeStorage).isJobNodeExisted("sharding/0/failover"); @@ -91,13 +91,13 @@ public void assertSetCrashedFailoverFlagWhenItemIsAssigned() { } @Test - public void assertSetCrashedFailoverFlagDirectly() { + void assertSetCrashedFailoverFlagDirectly() { failoverService.setCrashedFailoverFlagDirectly(0); verify(jobNodeStorage).createJobNodeIfNeeded("leader/failover/items/0"); } @Test - public void assertFailoverIfUnnecessaryWhenItemsRootNodeNotExisted() { + void assertFailoverIfUnnecessaryWhenItemsRootNodeNotExisted() { when(jobNodeStorage.isJobNodeExisted("leader/failover/items")).thenReturn(false); failoverService.failoverIfNecessary(); verify(jobNodeStorage).isJobNodeExisted("leader/failover/items"); @@ -105,7 +105,7 @@ public void assertFailoverIfUnnecessaryWhenItemsRootNodeNotExisted() { } @Test - public void assertFailoverIfUnnecessaryWhenItemsRootNodeIsEmpty() { + void assertFailoverIfUnnecessaryWhenItemsRootNodeIsEmpty() { when(jobNodeStorage.isJobNodeExisted("leader/failover/items")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("leader/failover/items")).thenReturn(Collections.emptyList()); failoverService.failoverIfNecessary(); @@ -115,7 +115,7 @@ public void assertFailoverIfUnnecessaryWhenItemsRootNodeIsEmpty() { } @Test - public void assertFailoverIfUnnecessaryWhenServerIsNotReady() { + void assertFailoverIfUnnecessaryWhenServerIsNotReady() { JobRegistry.getInstance().setJobRunning("test_job", true); when(jobNodeStorage.isJobNodeExisted("leader/failover/items")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("leader/failover/items")).thenReturn(Arrays.asList("0", "1", "2")); @@ -126,7 +126,7 @@ public void assertFailoverIfUnnecessaryWhenServerIsNotReady() { } @Test - public void assertFailoverIfNecessary() { + void assertFailoverIfNecessary() { JobRegistry.getInstance().setJobRunning("test_job", false); when(jobNodeStorage.isJobNodeExisted("leader/failover/items")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("leader/failover/items")).thenReturn(Arrays.asList("0", "1", "2")); @@ -138,7 +138,7 @@ public void assertFailoverIfNecessary() { } @Test - public void assertFailoverLeaderExecutionCallbackIfNotNecessary() { + void assertFailoverLeaderExecutionCallbackIfNotNecessary() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); JobRegistry.getInstance().setJobRunning("test_job", false); @@ -150,7 +150,7 @@ public void assertFailoverLeaderExecutionCallbackIfNotNecessary() { } @Test - public void assertFailoverLeaderExecutionCallbackIfNecessary() { + void assertFailoverLeaderExecutionCallbackIfNecessary() { JobRegistry.getInstance().setJobRunning("test_job", false); when(jobNodeStorage.isJobNodeExisted("leader/failover/items")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("leader/failover/items")).thenReturn(Arrays.asList("0", "1", "2")); @@ -168,7 +168,7 @@ public void assertFailoverLeaderExecutionCallbackIfNecessary() { } @Test - public void assertGetFailoveringItems() { + void assertGetFailoveringItems() { JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.getJobNodeChildrenKeys("sharding")).thenReturn(Arrays.asList("0", "1", "2")); when(jobNodeStorage.isJobNodeExisted("sharding/0/failovering")).thenReturn(true); @@ -186,14 +186,14 @@ public void assertGetFailoveringItems() { } @Test - public void assertUpdateFailoverComplete() { + void assertUpdateFailoverComplete() { failoverService.updateFailoverComplete(Arrays.asList(0, 1)); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/0/failover"); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/1/failover"); } @Test - public void assertGetFailoverItems() { + void assertGetFailoverItems() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.getJobNodeChildrenKeys("sharding")).thenReturn(Arrays.asList("0", "1", "2")); @@ -212,13 +212,13 @@ public void assertGetFailoverItems() { } @Test - public void assertGetLocalFailoverItemsIfShutdown() { + void assertGetLocalFailoverItemsIfShutdown() { assertThat(failoverService.getLocalFailoverItems(), is(Collections.emptyList())); verify(jobNodeStorage, times(0)).getJobNodeChildrenKeys("sharding"); } @Test - public void assertGetLocalFailoverItems() { + void assertGetLocalFailoverItems() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.getJobNodeChildrenKeys("sharding")).thenReturn(Arrays.asList("0", "1", "2")); @@ -237,7 +237,7 @@ public void assertGetLocalFailoverItems() { } @Test - public void assertGetLocalTakeOffItems() { + void assertGetLocalTakeOffItems() { when(shardingService.getLocalShardingItems()).thenReturn(Arrays.asList(0, 1, 2)); when(jobNodeStorage.isJobNodeExisted("sharding/0/failover")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("sharding/1/failover")).thenReturn(true); @@ -250,7 +250,7 @@ public void assertGetLocalTakeOffItems() { } @Test - public void assertGetAllFailoveringItems() { + void assertGetAllFailoveringItems() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).build()); String jobInstanceId = "127.0.0.1@-@1"; when(jobNodeStorage.getJobNodeData("sharding/0/failovering")).thenReturn(jobInstanceId); @@ -262,13 +262,13 @@ public void assertGetAllFailoveringItems() { } @Test - public void assertClearFailoveringItem() { + void assertClearFailoveringItem() { failoverService.clearFailoveringItem(0); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/0/failovering"); } @Test - public void assertRemoveFailoverInfo() { + void assertRemoveFailoverInfo() { when(jobNodeStorage.getJobNodeChildrenKeys("sharding")).thenReturn(Arrays.asList("0", "1", "2")); failoverService.removeFailoverInfo(); verify(jobNodeStorage).getJobNodeChildrenKeys("sharding"); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeListenerManagerTest.java index 52591a5803..e5f8ea2585 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeListenerManagerTest.java @@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class GuaranteeListenerManagerTest { +class GuaranteeListenerManagerTest { @Mock private JobNodeStorage jobNodeStorage; @@ -51,49 +51,49 @@ public final class GuaranteeListenerManagerTest { private GuaranteeListenerManager guaranteeListenerManager; @BeforeEach - public void setUp() { + void setUp() { guaranteeListenerManager = new GuaranteeListenerManager(null, "test_job", Arrays.asList(elasticJobListener, distributeOnceElasticJobListener)); ReflectionUtils.setSuperclassFieldValue(guaranteeListenerManager, "jobNodeStorage", jobNodeStorage); } @Test - public void assertStart() { + void assertStart() { guaranteeListenerManager.start(); verify(jobNodeStorage, times(2)).addDataListener(any(DataChangedEventListener.class)); } @Test - public void assertStartedNodeRemovedJobListenerWhenIsNotRemoved() { + void assertStartedNodeRemovedJobListenerWhenIsNotRemoved() { guaranteeListenerManager.new StartedNodeRemovedJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.UPDATED, "/test_job/guarantee/started", "")); verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart(); } @Test - public void assertStartedNodeRemovedJobListenerWhenIsNotStartedNode() { + void assertStartedNodeRemovedJobListenerWhenIsNotStartedNode() { guaranteeListenerManager.new StartedNodeRemovedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/other_job/guarantee/started", "")); verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart(); } @Test - public void assertStartedNodeRemovedJobListenerWhenIsRemovedAndStartedNode() { + void assertStartedNodeRemovedJobListenerWhenIsRemovedAndStartedNode() { guaranteeListenerManager.new StartedNodeRemovedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/guarantee/started", "")); verify(distributeOnceElasticJobListener).notifyWaitingTaskStart(); } @Test - public void assertCompletedNodeRemovedJobListenerWhenIsNotRemoved() { + void assertCompletedNodeRemovedJobListenerWhenIsNotRemoved() { guaranteeListenerManager.new CompletedNodeRemovedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/guarantee/completed", "")); verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart(); } @Test - public void assertCompletedNodeRemovedJobListenerWhenIsNotCompletedNode() { + void assertCompletedNodeRemovedJobListenerWhenIsNotCompletedNode() { guaranteeListenerManager.new CompletedNodeRemovedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/other_job/guarantee/completed", "")); verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart(); } @Test - public void assertCompletedNodeRemovedJobListenerWhenIsRemovedAndCompletedNode() { + void assertCompletedNodeRemovedJobListenerWhenIsRemovedAndCompletedNode() { guaranteeListenerManager.new CompletedNodeRemovedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/guarantee/completed", "")); verify(distributeOnceElasticJobListener).notifyWaitingTaskComplete(); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNodeTest.java index bb45e46b60..aa260748a5 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNodeTest.java @@ -24,37 +24,37 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class GuaranteeNodeTest { +class GuaranteeNodeTest { private final GuaranteeNode guaranteeNode = new GuaranteeNode("test_job"); @Test - public void assertGetStartedNode() { + void assertGetStartedNode() { assertThat(GuaranteeNode.getStartedNode(1), is("guarantee/started/1")); } @Test - public void assertGetCompletedNode() { + void assertGetCompletedNode() { assertThat(GuaranteeNode.getCompletedNode(1), is("guarantee/completed/1")); } @Test - public void assertIsStartedRootNode() { + void assertIsStartedRootNode() { assertTrue(guaranteeNode.isStartedRootNode("/test_job/guarantee/started")); } @Test - public void assertIsNotStartedRootNode() { + void assertIsNotStartedRootNode() { assertFalse(guaranteeNode.isStartedRootNode("/otherJob/guarantee/started")); } @Test - public void assertIsCompletedRootNode() { + void assertIsCompletedRootNode() { assertTrue(guaranteeNode.isCompletedRootNode("/test_job/guarantee/completed")); } @Test - public void assertIsNotCompletedRootNode() { + void assertIsNotCompletedRootNode() { assertFalse(guaranteeNode.isCompletedRootNode("/otherJob/guarantee/completed")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeServiceTest.java index ca0b4b897f..33aa82743a 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeServiceTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class GuaranteeServiceTest { +class GuaranteeServiceTest { @Mock private JobNodeStorage jobNodeStorage; @@ -55,38 +55,38 @@ public final class GuaranteeServiceTest { private final GuaranteeService guaranteeService = new GuaranteeService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(guaranteeService, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(guaranteeService, "configService", configService); } @Test - public void assertRegisterStart() { + void assertRegisterStart() { guaranteeService.registerStart(Arrays.asList(0, 1)); verify(jobNodeStorage).createJobNodeIfNeeded("guarantee/started/0"); verify(jobNodeStorage).createJobNodeIfNeeded("guarantee/started/1"); } @Test - public void assertIsNotRegisterStartSuccess() { + void assertIsNotRegisterStartSuccess() { assertFalse(guaranteeService.isRegisterStartSuccess(Arrays.asList(0, 1))); } @Test - public void assertIsRegisterStartSuccess() { + void assertIsRegisterStartSuccess() { when(jobNodeStorage.isJobNodeExisted("guarantee/started/0")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("guarantee/started/1")).thenReturn(true); assertTrue(guaranteeService.isRegisterStartSuccess(Arrays.asList(0, 1))); } @Test - public void assertIsNotAllStartedWhenRootNodeIsNotExisted() { + void assertIsNotAllStartedWhenRootNodeIsNotExisted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(false); assertFalse(guaranteeService.isAllStarted()); } @Test - public void assertIsNotAllStarted() { + void assertIsNotAllStarted() { when(configService.load(false)).thenReturn( JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").setProperty("streaming.process", Boolean.TRUE.toString()).build()); when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); @@ -95,7 +95,7 @@ public void assertIsNotAllStarted() { } @Test - public void assertIsAllStarted() { + void assertIsAllStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1", "2")); @@ -103,44 +103,44 @@ public void assertIsAllStarted() { } @Test - public void assertClearAllStartedInfo() { + void assertClearAllStartedInfo() { guaranteeService.clearAllStartedInfo(); verify(jobNodeStorage).removeJobNodeIfExisted("guarantee/started"); } @Test - public void assertRegisterComplete() { + void assertRegisterComplete() { guaranteeService.registerComplete(Arrays.asList(0, 1)); verify(jobNodeStorage).createJobNodeIfNeeded("guarantee/completed/0"); verify(jobNodeStorage).createJobNodeIfNeeded("guarantee/completed/1"); } @Test - public void assertIsNotRegisterCompleteSuccess() { + void assertIsNotRegisterCompleteSuccess() { assertFalse(guaranteeService.isRegisterCompleteSuccess(Arrays.asList(0, 1))); } @Test - public void assertIsRegisterCompleteSuccess() { + void assertIsRegisterCompleteSuccess() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed/0")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("guarantee/completed/1")).thenReturn(true); assertTrue(guaranteeService.isRegisterCompleteSuccess(Arrays.asList(0, 1))); } @Test - public void assertIsNotAllCompletedWhenRootNodeIsNotExisted() { + void assertIsNotAllCompletedWhenRootNodeIsNotExisted() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(false); assertFalse(guaranteeService.isAllCompleted()); } @Test - public void assertIsNotAllCompleted() { + void assertIsNotAllCompleted() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(false); assertFalse(guaranteeService.isAllCompleted()); } @Test - public void assertIsAllCompleted() { + void assertIsAllCompleted() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(true); when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/completed")).thenReturn(Arrays.asList("0", "1", "2")); @@ -148,13 +148,13 @@ public void assertIsAllCompleted() { } @Test - public void assertClearAllCompletedInfo() { + void assertClearAllCompletedInfo() { guaranteeService.clearAllCompletedInfo(); verify(jobNodeStorage).removeJobNodeIfExisted("guarantee/completed"); } @Test - public void assertExecuteInLeaderForLastCompleted() { + void assertExecuteInLeaderForLastCompleted() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(true); when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/completed")).thenReturn(Arrays.asList("0", "1", "2")); @@ -163,14 +163,14 @@ public void assertExecuteInLeaderForLastCompleted() { } @Test - public void assertExecuteInLeaderForNotLastCompleted() { + void assertExecuteInLeaderForNotLastCompleted() { when(jobNodeStorage.isJobNodeExisted("guarantee/completed")).thenReturn(false); guaranteeService.new LeaderExecutionCallbackForLastCompleted(listener, shardingContexts).execute(); verify(listener, never()).doAfterJobExecutedAtLastCompleted(shardingContexts); } @Test - public void assertExecuteInLeaderForLastStarted() { + void assertExecuteInLeaderForLastStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1", "2")); @@ -179,7 +179,7 @@ public void assertExecuteInLeaderForLastStarted() { } @Test - public void assertExecuteInLeaderForNotLastStarted() { + void assertExecuteInLeaderForNotLastStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(false); guaranteeService.new LeaderExecutionCallbackForLastStarted(listener, shardingContexts).execute(); verify(listener, never()).doBeforeJobExecutedAtLastStarted(shardingContexts); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceNodeTest.java index 403016c983..14eac7dc9f 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceNodeTest.java @@ -27,48 +27,48 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class InstanceNodeTest { +class InstanceNodeTest { private static InstanceNode instanceNode; @BeforeAll - public static void setUp() { + static void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); instanceNode = new InstanceNode("test_job"); } @Test - public void assertGetInstanceFullPath() { + void assertGetInstanceFullPath() { assertThat(instanceNode.getInstanceFullPath(), is("/test_job/instances")); } @Test - public void assertIsInstancePath() { + void assertIsInstancePath() { assertTrue(instanceNode.isInstancePath("/test_job/instances/127.0.0.1@-@0")); } @Test - public void assertIsNotInstancePath() { + void assertIsNotInstancePath() { assertFalse(instanceNode.isInstancePath("/test_job/other/127.0.0.1@-@0")); } @Test - public void assertIsLocalInstancePath() { + void assertIsLocalInstancePath() { assertTrue(instanceNode.isLocalInstancePath("/test_job/instances/127.0.0.1@-@0")); } @Test - public void assertIsNotLocalInstancePath() { + void assertIsNotLocalInstancePath() { assertFalse(instanceNode.isLocalInstancePath("/test_job/instances/127.0.0.2@-@0")); } @Test - public void assertGetLocalInstancePath() { + void assertGetLocalInstancePath() { assertThat(instanceNode.getLocalInstancePath(), is("instances/127.0.0.1@-@0")); } @Test - public void assertGetInstancePath() { + void assertGetInstancePath() { assertThat(instanceNode.getInstancePath("127.0.0.1@-@0"), is("instances/127.0.0.1@-@0")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceServiceTest.java index 3ab2b42d66..3c811b6ddc 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/InstanceServiceTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class InstanceServiceTest { +class InstanceServiceTest { @Mock private JobNodeStorage jobNodeStorage; @@ -49,7 +49,7 @@ public final class InstanceServiceTest { private InstanceService instanceService; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); instanceService = new InstanceService(null, "test_job"); InstanceNode instanceNode = new InstanceNode("test_job"); @@ -59,19 +59,19 @@ public void setUp() { } @Test - public void assertPersistOnline() { + void assertPersistOnline() { instanceService.persistOnline(); verify(jobNodeStorage).fillEphemeralJobNode("instances/127.0.0.1@-@0", "jobInstanceId: 127.0.0.1@-@0\nserverIp: 127.0.0.1\n"); } @Test - public void assertRemoveInstance() { + void assertRemoveInstance() { instanceService.removeInstance(); verify(jobNodeStorage).removeJobNodeIfExisted("instances/127.0.0.1@-@0"); } @Test - public void assertGetAvailableJobInstances() { + void assertGetAvailableJobInstances() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("127.0.0.1@-@0", "127.0.0.2@-@0")); when(jobNodeStorage.getJobNodeData("instances/127.0.0.1@-@0")).thenReturn("jobInstanceId: 127.0.0.1@-@0\nlabels: labels\nserverIp: 127.0.0.1\n"); when(jobNodeStorage.getJobNodeData("instances/127.0.0.2@-@0")).thenReturn("jobInstanceId: 127.0.0.2@-@0\nlabels: labels\nserverIp: 127.0.0.2\n"); @@ -80,7 +80,7 @@ public void assertGetAvailableJobInstances() { } @Test - public void assertGetAvailableJobInstancesWhenInstanceRemoving() { + void assertGetAvailableJobInstancesWhenInstanceRemoving() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("127.0.0.1@-@0", "127.0.0.2@-@0")); when(jobNodeStorage.getJobNodeData("instances/127.0.0.1@-@0")).thenReturn("jobInstanceId: 127.0.0.1@-@0\nlabels: labels\nserverIp: 127.0.0.1\n"); when(serverService.isEnableServer("127.0.0.1")).thenReturn(true); @@ -88,13 +88,13 @@ public void assertGetAvailableJobInstancesWhenInstanceRemoving() { } @Test - public void assertIsLocalJobInstanceExisted() { + void assertIsLocalJobInstanceExisted() { when(jobNodeStorage.isJobNodeExisted("instances/127.0.0.1@-@0")).thenReturn(true); assertTrue(instanceService.isLocalJobInstanceExisted()); } @Test - public void assertTriggerAllInstances() { + void assertTriggerAllInstances() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("127.0.0.1@-@0", "127.0.0.2@-@0")); instanceService.triggerAllInstances(); verify(jobNodeStorage).createJobNodeIfNeeded("trigger/127.0.0.1@-@0"); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/ShutdownListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/ShutdownListenerManagerTest.java index fec37fc1d3..4d17553c95 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/ShutdownListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/instance/ShutdownListenerManagerTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ShutdownListenerManagerTest { +class ShutdownListenerManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -59,7 +59,7 @@ public final class ShutdownListenerManagerTest { private ShutdownListenerManager shutdownListenerManager; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); shutdownListenerManager = new ShutdownListenerManager(null, "test_job"); ReflectionUtils.setFieldValue(shutdownListenerManager, "instanceService", instanceService); @@ -68,24 +68,24 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown("test_job"); } @Test - public void assertStart() { + void assertStart() { shutdownListenerManager.start(); verify(jobNodeStorage).addDataListener(ArgumentMatchers.any()); } @Test - public void assertIsShutdownAlready() { + void assertIsShutdownAlready() { shutdownListenerManager.new InstanceShutdownStatusJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/instances/127.0.0.1@-@0", "")); verify(schedulerFacade, times(0)).shutdownInstance(); } @Test - public void assertIsNotLocalInstancePath() { + void assertIsNotLocalInstancePath() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); shutdownListenerManager.new InstanceShutdownStatusJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/instances/127.0.0.2@-@0", "")); @@ -93,7 +93,7 @@ public void assertIsNotLocalInstancePath() { } @Test - public void assertUpdateLocalInstancePath() { + void assertUpdateLocalInstancePath() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); shutdownListenerManager.new InstanceShutdownStatusJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/instances/127.0.0.1@-@0", "")); @@ -101,7 +101,7 @@ public void assertUpdateLocalInstancePath() { } @Test - public void assertRemoveLocalInstancePathForPausedJob() { + void assertRemoveLocalInstancePathForPausedJob() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobScheduleController.isPaused()).thenReturn(true); @@ -110,7 +110,7 @@ public void assertRemoveLocalInstancePathForPausedJob() { } @Test - public void assertRemoveLocalInstancePathForReconnectedRegistryCenter() { + void assertRemoveLocalInstancePathForReconnectedRegistryCenter() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(instanceService.isLocalJobInstanceExisted()).thenReturn(true); @@ -119,7 +119,7 @@ public void assertRemoveLocalInstancePathForReconnectedRegistryCenter() { } @Test - public void assertRemoveLocalInstancePath() { + void assertRemoveLocalInstancePath() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); shutdownListenerManager.new InstanceShutdownStatusJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/instances/127.0.0.1@-@0", "")); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerManagerTest.java index 00386e42ad..a2deec2d5c 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerManagerTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class ListenerManagerTest { +class ListenerManagerTest { @Mock private JobNodeStorage jobNodeStorage; @@ -73,7 +73,7 @@ public final class ListenerManagerTest { private final ListenerManager listenerManager = new ListenerManager(null, "test_job", Collections.emptyList()); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(listenerManager, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(listenerManager, "electionListenerManager", electionListenerManager); ReflectionUtils.setFieldValue(listenerManager, "shardingListenerManager", shardingListenerManager); @@ -87,7 +87,7 @@ public void setUp() { } @Test - public void assertStartAllListeners() { + void assertStartAllListeners() { listenerManager.startAllListeners(); verify(electionListenerManager).start(); verify(shardingListenerManager).start(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerNotifierManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerNotifierManagerTest.java index 126b369033..8affd3481b 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerNotifierManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/ListenerNotifierManagerTest.java @@ -27,17 +27,17 @@ import static org.hamcrest.MatcherAssert.assertThat; @ExtendWith(MockitoExtension.class) -public class ListenerNotifierManagerTest { +class ListenerNotifierManagerTest { @Test - public void assertRegisterAndGetJobNotifyExecutor() { + void assertRegisterAndGetJobNotifyExecutor() { String jobName = "test_job"; ListenerNotifierManager.getInstance().registerJobNotifyExecutor(jobName); assertThat(ListenerNotifierManager.getInstance().getJobNotifyExecutor(jobName), notNullValue(Executor.class)); } @Test - public void assertRemoveAndShutDownJobNotifyExecutor() { + void assertRemoveAndShutDownJobNotifyExecutor() { String jobName = "test_job"; ListenerNotifierManager.getInstance().registerJobNotifyExecutor(jobName); ListenerNotifierManager.getInstance().removeJobNotifyExecutor(jobName); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/RegistryCenterConnectionStateListenerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/RegistryCenterConnectionStateListenerTest.java index df2d796297..65efcea0ea 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/RegistryCenterConnectionStateListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/RegistryCenterConnectionStateListenerTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class RegistryCenterConnectionStateListenerTest { +class RegistryCenterConnectionStateListenerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -63,7 +63,7 @@ public final class RegistryCenterConnectionStateListenerTest { private RegistryCenterConnectionStateListener regCenterConnectionStateListener; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); regCenterConnectionStateListener = new RegistryCenterConnectionStateListener(null, "test_job"); ReflectionUtils.setFieldValue(regCenterConnectionStateListener, "serverService", serverService); @@ -73,7 +73,7 @@ public void setUp() { } @Test - public void assertConnectionLostListenerWhenConnectionStateIsLost() { + void assertConnectionLostListenerWhenConnectionStateIsLost() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); regCenterConnectionStateListener.onStateChanged(null, State.UNAVAILABLE); @@ -82,14 +82,14 @@ public void assertConnectionLostListenerWhenConnectionStateIsLost() { } @Test - public void assertConnectionLostListenerWhenConnectionStateIsLostButIsShutdown() { + void assertConnectionLostListenerWhenConnectionStateIsLostButIsShutdown() { regCenterConnectionStateListener.onStateChanged(null, State.UNAVAILABLE); verify(jobScheduleController, times(0)).pauseJob(); verify(jobScheduleController, times(0)).resumeJob(); } @Test - public void assertConnectionLostListenerWhenConnectionStateIsReconnected() { + void assertConnectionLostListenerWhenConnectionStateIsReconnected() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(shardingService.getLocalShardingItems()).thenReturn(Arrays.asList(0, 1)); @@ -102,14 +102,14 @@ public void assertConnectionLostListenerWhenConnectionStateIsReconnected() { } @Test - public void assertConnectionLostListenerWhenConnectionStateIsReconnectedButIsShutdown() { + void assertConnectionLostListenerWhenConnectionStateIsReconnectedButIsShutdown() { regCenterConnectionStateListener.onStateChanged(null, State.RECONNECTED); verify(jobScheduleController, times(0)).pauseJob(); verify(jobScheduleController, times(0)).resumeJob(); } @Test - public void assertConnectionLostListenerWhenConnectionStateIsOther() { + void assertConnectionLostListenerWhenConnectionStateIsOther() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); regCenterConnectionStateListener.onStateChanged(null, State.CONNECTED); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java index 425b298161..16fb642e2c 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ReconcileServiceTest { +class ReconcileServiceTest { @Mock private ConfigurationService configService; @@ -50,7 +50,7 @@ public final class ReconcileServiceTest { private ReconcileService reconcileService; @BeforeEach - public void setup() { + void setup() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); reconcileService = new ReconcileService(regCenter, "test_job"); ReflectionUtils.setFieldValue(reconcileService, "lastReconcileTime", 1L); @@ -59,7 +59,7 @@ public void setup() { } @Test - public void assertReconcile() { + void assertReconcile() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").reconcileIntervalMinutes(1).build()); when(shardingService.isNeedSharding()).thenReturn(false); when(shardingService.hasShardingInfoInOfflineServers()).thenReturn(true); @@ -70,7 +70,7 @@ public void assertReconcile() { } @Test - public void assertReconcileWithStaticSharding() { + void assertReconcileWithStaticSharding() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").reconcileIntervalMinutes(1).staticSharding(true).build()); when(shardingService.isNeedSharding()).thenReturn(false); when(shardingService.hasShardingInfoInOfflineServers()).thenReturn(true); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobRegistryTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobRegistryTest.java index 804c367c08..df3bca64e4 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobRegistryTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobRegistryTest.java @@ -29,53 +29,53 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public final class JobRegistryTest { +class JobRegistryTest { @Test - public void assertRegisterJob() { + void assertRegisterJob() { JobScheduleController jobScheduleController = mock(JobScheduleController.class); JobRegistry.getInstance().registerJob("test_job_scheduler_for_add", jobScheduleController); assertThat(JobRegistry.getInstance().getJobScheduleController("test_job_scheduler_for_add"), is(jobScheduleController)); } @Test - public void assertGetJobInstance() { + void assertGetJobInstance() { JobRegistry.getInstance().addJobInstance("exist_job_instance", new JobInstance("127.0.0.1@-@0")); assertThat(JobRegistry.getInstance().getJobInstance("exist_job_instance"), is(new JobInstance("127.0.0.1@-@0"))); } @Test - public void assertGetRegCenter() { + void assertGetRegCenter() { CoordinatorRegistryCenter regCenter = mock(CoordinatorRegistryCenter.class); JobRegistry.getInstance().registerRegistryCenter("test_job_scheduler_for_add", regCenter); assertThat(JobRegistry.getInstance().getRegCenter("test_job_scheduler_for_add"), is(regCenter)); } @Test - public void assertIsJobRunningIfNull() { + void assertIsJobRunningIfNull() { assertFalse(JobRegistry.getInstance().isJobRunning("null_job_instance")); } @Test - public void assertIsJobRunningIfNotNull() { + void assertIsJobRunningIfNotNull() { JobRegistry.getInstance().setJobRunning("exist_job_instance", true); assertTrue(JobRegistry.getInstance().isJobRunning("exist_job_instance")); } @Test - public void assertGetCurrentShardingTotalCountIfNull() { + void assertGetCurrentShardingTotalCountIfNull() { assertThat(JobRegistry.getInstance().getCurrentShardingTotalCount("exist_job_instance"), is(0)); } @Test - public void assertGetCurrentShardingTotalCountIfNotNull() { + void assertGetCurrentShardingTotalCountIfNotNull() { JobRegistry.getInstance().setCurrentShardingTotalCount("exist_job_instance", 10); assertThat(JobRegistry.getInstance().getCurrentShardingTotalCount("exist_job_instance"), is(10)); ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null); } @Test - public void assertShutdown() { + void assertShutdown() { JobScheduleController jobScheduleController = mock(JobScheduleController.class); CoordinatorRegistryCenter regCenter = mock(CoordinatorRegistryCenter.class); JobRegistry.getInstance().registerRegistryCenter("test_job_for_shutdown", regCenter); @@ -86,12 +86,12 @@ public void assertShutdown() { } @Test - public void assertIsShutdownForJobSchedulerNull() { + void assertIsShutdownForJobSchedulerNull() { assertTrue(JobRegistry.getInstance().isShutdown("test_job_for_job_scheduler_null")); } @Test - public void assertIsShutdownForJobInstanceNull() { + void assertIsShutdownForJobInstanceNull() { JobScheduleController jobScheduleController = mock(JobScheduleController.class); CoordinatorRegistryCenter regCenter = mock(CoordinatorRegistryCenter.class); JobRegistry.getInstance().registerRegistryCenter("test_job_for_job_instance_null", regCenter); @@ -100,7 +100,7 @@ public void assertIsShutdownForJobInstanceNull() { } @Test - public void assertIsNotShutdown() { + void assertIsNotShutdown() { JobScheduleController jobScheduleController = mock(JobScheduleController.class); CoordinatorRegistryCenter regCenter = mock(CoordinatorRegistryCenter.class); JobRegistry.getInstance().registerRegistryCenter("test_job_for_job_not_shutdown", regCenter); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleControllerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleControllerTest.java index 5d690953db..92b0dfa0f5 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleControllerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduleControllerTest.java @@ -44,7 +44,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobScheduleControllerTest { +class JobScheduleControllerTest { @Mock private Scheduler scheduler; @@ -55,12 +55,12 @@ public final class JobScheduleControllerTest { private JobScheduleController jobScheduleController; @BeforeEach - public void setUp() { + void setUp() { jobScheduleController = new JobScheduleController(scheduler, jobDetail, "test_job_Trigger"); } @Test - public void assertIsPausedFailure() { + void assertIsPausedFailure() { assertThrows(JobSystemException.class, () -> { doThrow(SchedulerException.class).when(scheduler).getTriggerState(new TriggerKey("test_job_Trigger")); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); @@ -73,28 +73,28 @@ public void assertIsPausedFailure() { } @Test - public void assertIsPausedIfTriggerStateIsNormal() throws SchedulerException { + void assertIsPausedIfTriggerStateIsNormal() throws SchedulerException { when(scheduler.getTriggerState(new TriggerKey("test_job_Trigger"))).thenReturn(Trigger.TriggerState.NORMAL); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); assertFalse(jobScheduleController.isPaused()); } @Test - public void assertIsPausedIfTriggerStateIsPaused() throws SchedulerException { + void assertIsPausedIfTriggerStateIsPaused() throws SchedulerException { when(scheduler.getTriggerState(new TriggerKey("test_job_Trigger"))).thenReturn(Trigger.TriggerState.PAUSED); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); assertTrue(jobScheduleController.isPaused()); } @Test - public void assertIsPauseJobIfShutdown() throws SchedulerException { + void assertIsPauseJobIfShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(true); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); assertFalse(jobScheduleController.isPaused()); } @Test - public void assertPauseJobIfShutdown() throws SchedulerException { + void assertPauseJobIfShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(true); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.pauseJob(); @@ -102,7 +102,7 @@ public void assertPauseJobIfShutdown() throws SchedulerException { } @Test - public void assertPauseJobFailure() { + void assertPauseJobFailure() { assertThrows(JobSystemException.class, () -> { doThrow(SchedulerException.class).when(scheduler).pauseAll(); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); @@ -115,14 +115,14 @@ public void assertPauseJobFailure() { } @Test - public void assertPauseJobSuccess() throws SchedulerException { + void assertPauseJobSuccess() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.pauseJob(); verify(scheduler).pauseAll(); } @Test - public void assertResumeJobIfShutdown() throws SchedulerException { + void assertResumeJobIfShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(true); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.resumeJob(); @@ -130,7 +130,7 @@ public void assertResumeJobIfShutdown() throws SchedulerException { } @Test - public void assertResumeJobFailure() { + void assertResumeJobFailure() { assertThrows(JobSystemException.class, () -> { doThrow(SchedulerException.class).when(scheduler).resumeAll(); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); @@ -143,14 +143,14 @@ public void assertResumeJobFailure() { } @Test - public void assertResumeJobSuccess() throws SchedulerException { + void assertResumeJobSuccess() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.resumeJob(); verify(scheduler).resumeAll(); } @Test - public void assertTriggerJobIfShutdown() throws SchedulerException { + void assertTriggerJobIfShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(true); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); ReflectionUtils.setFieldValue(jobScheduleController, "jobDetail", jobDetail); @@ -160,7 +160,7 @@ public void assertTriggerJobIfShutdown() throws SchedulerException { } @Test - public void assertTriggerJobFailure() { + void assertTriggerJobFailure() { assertThrows(JobSystemException.class, () -> { JobKey jobKey = new JobKey("test_job"); when(jobDetail.getKey()).thenReturn(jobKey); @@ -178,7 +178,7 @@ public void assertTriggerJobFailure() { } @Test - public void assertTriggerJobSuccess() throws SchedulerException { + void assertTriggerJobSuccess() throws SchedulerException { JobKey jobKey = new JobKey("test_job"); when(jobDetail.getKey()).thenReturn(jobKey); when(scheduler.checkExists(any(JobKey.class))).thenReturn(true); @@ -190,7 +190,7 @@ public void assertTriggerJobSuccess() throws SchedulerException { } @Test - public void assertTriggerOneOffJobSuccess() throws SchedulerException { + void assertTriggerOneOffJobSuccess() throws SchedulerException { JobKey jobKey = new JobKey("test_job"); when(jobDetail.getKey()).thenReturn(jobKey); when(scheduler.checkExists(jobDetail.getKey())).thenReturn(false); @@ -203,7 +203,7 @@ public void assertTriggerOneOffJobSuccess() throws SchedulerException { } @Test - public void assertShutdownJobIfShutdown() throws SchedulerException { + void assertShutdownJobIfShutdown() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); when(scheduler.isShutdown()).thenReturn(true); jobScheduleController.shutdown(); @@ -211,7 +211,7 @@ public void assertShutdownJobIfShutdown() throws SchedulerException { } @Test - public void assertShutdownFailure() { + void assertShutdownFailure() { assertThrows(JobSystemException.class, () -> { doThrow(SchedulerException.class).when(scheduler).shutdown(false); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); @@ -224,14 +224,14 @@ public void assertShutdownFailure() { } @Test - public void assertShutdownSuccess() throws SchedulerException { + void assertShutdownSuccess() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.shutdown(); verify(scheduler).shutdown(false); } @Test - public void assertRescheduleJobIfShutdown() throws SchedulerException { + void assertRescheduleJobIfShutdown() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); when(scheduler.isShutdown()).thenReturn(true); jobScheduleController.rescheduleJob("0/1 * * * * ?", null); @@ -239,7 +239,7 @@ public void assertRescheduleJobIfShutdown() throws SchedulerException { } @Test - public void assertRescheduleJobFailure() { + void assertRescheduleJobFailure() { assertThrows(JobSystemException.class, () -> { when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new CronTriggerImpl()); doThrow(SchedulerException.class).when(scheduler).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), any()); @@ -253,7 +253,7 @@ public void assertRescheduleJobFailure() { } @Test - public void assertRescheduleJobSuccess() throws SchedulerException { + void assertRescheduleJobSuccess() throws SchedulerException { when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new CronTriggerImpl()); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.rescheduleJob("0/1 * * * * ?", null); @@ -261,14 +261,14 @@ public void assertRescheduleJobSuccess() throws SchedulerException { } @Test - public void assertRescheduleJobWhenTriggerIsNull() throws SchedulerException { + void assertRescheduleJobWhenTriggerIsNull() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.rescheduleJob("0/1 * * * * ?", null); verify(scheduler, times(0)).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), any()); } @Test - public void assertRescheduleJobIfShutdownForOneOffJob() throws SchedulerException { + void assertRescheduleJobIfShutdownForOneOffJob() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); when(scheduler.isShutdown()).thenReturn(true); jobScheduleController.rescheduleJob(); @@ -276,7 +276,7 @@ public void assertRescheduleJobIfShutdownForOneOffJob() throws SchedulerExceptio } @Test - public void assertRescheduleJobFailureForOneOffJob() { + void assertRescheduleJobFailureForOneOffJob() { assertThrows(JobSystemException.class, () -> { when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new SimpleTriggerImpl()); doThrow(SchedulerException.class).when(scheduler).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), any()); @@ -290,7 +290,7 @@ public void assertRescheduleJobFailureForOneOffJob() { } @Test - public void assertRescheduleJobSuccessForOneOffJob() throws SchedulerException { + void assertRescheduleJobSuccessForOneOffJob() throws SchedulerException { when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new SimpleTriggerImpl()); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.rescheduleJob(); @@ -298,7 +298,7 @@ public void assertRescheduleJobSuccessForOneOffJob() throws SchedulerException { } @Test - public void assertRescheduleJobWhenTriggerIsNullForOneOffJob() throws SchedulerException { + void assertRescheduleJobWhenTriggerIsNullForOneOffJob() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.rescheduleJob(); verify(scheduler, times(0)).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), any()); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobTriggerListenerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobTriggerListenerTest.java index db1ead14fa..36ee33a689 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobTriggerListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobTriggerListenerTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobTriggerListenerTest { +class JobTriggerListenerTest { @Mock private ExecutionService executionService; @@ -50,23 +50,23 @@ public final class JobTriggerListenerTest { private JobTriggerListener jobTriggerListener; @BeforeEach - public void setUp() { + void setUp() { jobTriggerListener = new JobTriggerListener(executionService, shardingService); } @Test - public void assertGetName() { + void assertGetName() { assertThat(jobTriggerListener.getName(), is("JobTriggerListener")); } @Test - public void assertTriggerMisfiredWhenPreviousFireTimeIsNull() { + void assertTriggerMisfiredWhenPreviousFireTimeIsNull() { jobTriggerListener.triggerMisfired(trigger); verify(executionService, times(0)).setMisfire(Collections.singletonList(0)); } @Test - public void assertTriggerMisfiredWhenPreviousFireTimeIsNotNull() { + void assertTriggerMisfiredWhenPreviousFireTimeIsNotNull() { when(shardingService.getLocalShardingItems()).thenReturn(Collections.singletonList(0)); when(trigger.getPreviousFireTime()).thenReturn(new Date()); jobTriggerListener.triggerMisfired(trigger); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java index 8d8a1dc68d..5ac6645d49 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java @@ -46,7 +46,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class LiteJobFacadeTest { +class LiteJobFacadeTest { @Mock private ConfigurationService configService; @@ -74,7 +74,7 @@ public final class LiteJobFacadeTest { private StringBuilder orderResult; @BeforeEach - public void setUp() { + void setUp() { orderResult = new StringBuilder(); TestElasticJobListener l1 = new TestElasticJobListener(caller, "l1", 2, orderResult); TestElasticJobListener l2 = new TestElasticJobListener(caller, "l2", 1, orderResult); @@ -88,41 +88,41 @@ public void setUp() { } @Test - public void assertLoad() { + void assertLoad() { JobConfiguration expected = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build(); when(configService.load(true)).thenReturn(expected); assertThat(liteJobFacade.loadJobConfiguration(true), is(expected)); } @Test - public void assertCheckMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException { + void assertCheckMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException { liteJobFacade.checkJobExecutionEnvironment(); verify(configService).checkMaxTimeDiffSecondsTolerable(); } @Test - public void assertFailoverIfUnnecessary() { + void assertFailoverIfUnnecessary() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build()); liteJobFacade.failoverIfNecessary(); verify(failoverService, times(0)).failoverIfNecessary(); } @Test - public void assertFailoverIfNecessary() { + void assertFailoverIfNecessary() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).monitorExecution(true).build()); liteJobFacade.failoverIfNecessary(); verify(failoverService).failoverIfNecessary(); } @Test - public void assertRegisterJobBegin() { + void assertRegisterJobBegin() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); liteJobFacade.registerJobBegin(shardingContexts); verify(executionService).registerJobBegin(shardingContexts); } @Test - public void assertRegisterJobCompletedWhenFailoverDisabled() { + void assertRegisterJobCompletedWhenFailoverDisabled() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build()); liteJobFacade.registerJobCompleted(shardingContexts); @@ -131,7 +131,7 @@ public void assertRegisterJobCompletedWhenFailoverDisabled() { } @Test - public void assertRegisterJobCompletedWhenFailoverEnabled() { + void assertRegisterJobCompletedWhenFailoverEnabled() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).monitorExecution(true).build()); liteJobFacade.registerJobCompleted(shardingContexts); @@ -140,7 +140,7 @@ public void assertRegisterJobCompletedWhenFailoverEnabled() { } @Test - public void assertGetShardingContextWhenIsFailoverEnableAndFailover() { + void assertGetShardingContextWhenIsFailoverEnableAndFailover() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).monitorExecution(true).build()); when(failoverService.getLocalFailoverItems()).thenReturn(Collections.singletonList(1)); @@ -150,7 +150,7 @@ public void assertGetShardingContextWhenIsFailoverEnableAndFailover() { } @Test - public void assertGetShardingContextWhenIsFailoverEnableAndNotFailover() { + void assertGetShardingContextWhenIsFailoverEnableAndNotFailover() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).monitorExecution(true).build()); when(failoverService.getLocalFailoverItems()).thenReturn(Collections.emptyList()); @@ -162,7 +162,7 @@ public void assertGetShardingContextWhenIsFailoverEnableAndNotFailover() { } @Test - public void assertGetShardingContextWhenIsFailoverDisable() { + void assertGetShardingContextWhenIsFailoverDisable() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build()); when(shardingService.getLocalShardingItems()).thenReturn(Arrays.asList(0, 1)); @@ -172,7 +172,7 @@ public void assertGetShardingContextWhenIsFailoverDisable() { } @Test - public void assertGetShardingContextWhenHasDisabledItems() { + void assertGetShardingContextWhenHasDisabledItems() { ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap()); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build()); when(shardingService.getLocalShardingItems()).thenReturn(Lists.newArrayList(0, 1)); @@ -183,39 +183,39 @@ public void assertGetShardingContextWhenHasDisabledItems() { } @Test - public void assertMisfireIfRunning() { + void assertMisfireIfRunning() { when(executionService.misfireIfHasRunningItems(Arrays.asList(0, 1))).thenReturn(true); assertThat(liteJobFacade.misfireIfRunning(Arrays.asList(0, 1)), is(true)); } @Test - public void assertClearMisfire() { + void assertClearMisfire() { liteJobFacade.clearMisfire(Arrays.asList(0, 1)); verify(executionService).clearMisfire(Arrays.asList(0, 1)); } @Test - public void assertIsNeedSharding() { + void assertIsNeedSharding() { when(shardingService.isNeedSharding()).thenReturn(true); assertThat(liteJobFacade.isNeedSharding(), is(true)); } @Test - public void assertBeforeJobExecuted() { + void assertBeforeJobExecuted() { liteJobFacade.beforeJobExecuted(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap())); verify(caller, times(2)).before(); assertThat(orderResult.toString(), is("l2l1")); } @Test - public void assertAfterJobExecuted() { + void assertAfterJobExecuted() { liteJobFacade.afterJobExecuted(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap())); verify(caller, times(2)).after(); assertThat(orderResult.toString(), is("l2l1")); } @Test - public void assertPostJobExecutionEvent() { + void assertPostJobExecutionEvent() { liteJobFacade.postJobExecutionEvent(null); verify(jobTracingEventBus).post(null); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/SchedulerFacadeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/SchedulerFacadeTest.java index 1609fa9bca..8ab368ac3c 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/SchedulerFacadeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/SchedulerFacadeTest.java @@ -33,7 +33,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class SchedulerFacadeTest { +class SchedulerFacadeTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -50,7 +50,7 @@ public final class SchedulerFacadeTest { private SchedulerFacade schedulerFacade; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); schedulerFacade = new SchedulerFacade(null, "test_job"); ReflectionUtils.setFieldValue(schedulerFacade, "leaderService", leaderService); @@ -58,7 +58,7 @@ public void setUp() { } @Test - public void assertShutdownInstanceIfNotLeaderAndReconcileServiceIsNotRunning() { + void assertShutdownInstanceIfNotLeaderAndReconcileServiceIsNotRunning() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); schedulerFacade.shutdownInstance(); @@ -67,7 +67,7 @@ public void assertShutdownInstanceIfNotLeaderAndReconcileServiceIsNotRunning() { } @Test - public void assertShutdownInstanceIfLeaderAndReconcileServiceIsRunning() { + void assertShutdownInstanceIfLeaderAndReconcileServiceIsRunning() { when(leaderService.isLeader()).thenReturn(true); JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerNodeTest.java index 2613122f56..1f6ca05d20 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerNodeTest.java @@ -27,37 +27,37 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class ServerNodeTest { +class ServerNodeTest { private final ServerNode serverNode = new ServerNode("test_job"); @BeforeAll - public static void setUp() { + static void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); } @Test - public void assertIsServerPath() { + void assertIsServerPath() { assertTrue(serverNode.isServerPath("/test_job/servers/127.0.0.1")); } @Test - public void assertIsNotServerPath() { + void assertIsNotServerPath() { assertFalse(serverNode.isServerPath("/test_job/servers/255.255.255.256")); } @Test - public void assertIsLocalServerPath() { + void assertIsLocalServerPath() { assertTrue(serverNode.isLocalServerPath("/test_job/servers/127.0.0.1")); } @Test - public void assertIsNotLocalServerPath() { + void assertIsNotLocalServerPath() { assertFalse(serverNode.isLocalServerPath("/test_job/servers/127.0.0.2")); } @Test - public void assertGetServerNode() { + void assertGetServerNode() { assertThat(serverNode.getServerNode("127.0.0.1"), is("servers/127.0.0.1")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerServiceTest.java index d775045c6a..9884d74f2a 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerServiceTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ServerServiceTest { +class ServerServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -53,7 +53,7 @@ public final class ServerServiceTest { private ServerService serverService; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0", null, "127.0.0.1")); serverService = new ServerService(null, "test_job"); ServerNode serverNode = new ServerNode("test_job"); @@ -62,14 +62,14 @@ public void setUp() { } @Test - public void assertPersistOnlineForInstanceShutdown() { + void assertPersistOnlineForInstanceShutdown() { JobRegistry.getInstance().shutdown("test_job"); serverService.persistOnline(false); verify(jobNodeStorage, times(0)).fillJobNode("servers/127.0.0.1", ServerStatus.DISABLED.name()); } @Test - public void assertPersistOnlineForDisabledServer() { + void assertPersistOnlineForDisabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); serverService.persistOnline(false); @@ -78,7 +78,7 @@ public void assertPersistOnlineForDisabledServer() { } @Test - public void assertPersistOnlineForEnabledServer() { + void assertPersistOnlineForEnabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); serverService.persistOnline(true); @@ -87,7 +87,7 @@ public void assertPersistOnlineForEnabledServer() { } @Test - public void assertHasAvailableServers() { + void assertHasAvailableServers() { when(jobNodeStorage.getJobNodeChildrenKeys("servers")).thenReturn(Arrays.asList("127.0.0.1", "127.0.0.2", "127.0.0.3")); when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn(ServerStatus.DISABLED.name()); when(jobNodeStorage.getJobNodeData("servers/127.0.0.2")).thenReturn(ServerStatus.ENABLED.name()); @@ -97,7 +97,7 @@ public void assertHasAvailableServers() { } @Test - public void assertHasNotAvailableServers() { + void assertHasNotAvailableServers() { when(jobNodeStorage.getJobNodeChildrenKeys("servers")).thenReturn(Arrays.asList("127.0.0.1", "127.0.0.2")); when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn(ServerStatus.DISABLED.name()); when(jobNodeStorage.getJobNodeData("servers/127.0.0.2")).thenReturn(ServerStatus.DISABLED.name()); @@ -105,39 +105,39 @@ public void assertHasNotAvailableServers() { } @Test - public void assertIsNotAvailableServerWhenDisabled() { + void assertIsNotAvailableServerWhenDisabled() { when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn(ServerStatus.DISABLED.name()); assertFalse(serverService.isAvailableServer("127.0.0.1")); } @Test - public void assertIsNotAvailableServerWithoutOnlineInstances() { + void assertIsNotAvailableServerWithoutOnlineInstances() { when(jobNodeStorage.getJobNodeChildrenKeys("instances")).thenReturn(Collections.singletonList("127.0.0.2@-@0")); when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn(ServerStatus.ENABLED.name()); assertFalse(serverService.isAvailableServer("127.0.0.1")); } @Test - public void assertIsAvailableServer() { + void assertIsAvailableServer() { when(jobNodeStorage.getJobNodeChildrenKeys("instances")).thenReturn(Collections.singletonList("127.0.0.1@-@0")); when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn(ServerStatus.ENABLED.name()); assertTrue(serverService.isAvailableServer("127.0.0.1")); } @Test - public void assertIsNotEnableServer() { + void assertIsNotEnableServer() { when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn("", ServerStatus.DISABLED.name()); assertFalse(serverService.isEnableServer("127.0.0.1")); } @Test - public void assertIsEnableServer() { + void assertIsEnableServer() { when(jobNodeStorage.getJobNodeData("servers/127.0.0.1")).thenReturn("", ServerStatus.ENABLED.name()); assertTrue(serverService.isEnableServer("127.0.0.1")); } @Test - public void assertServerNodeAbsent() { + void assertServerNodeAbsent() { assertFalse(serverService.isEnableServer("127.0.0.1")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/DefaultJobClassNameProviderTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/DefaultJobClassNameProviderTest.java index 55b9560a9e..856bbde327 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/DefaultJobClassNameProviderTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/DefaultJobClassNameProviderTest.java @@ -26,10 +26,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class DefaultJobClassNameProviderTest { +class DefaultJobClassNameProviderTest { @Test - public void assertGetOrdinaryClassJobName() { + void assertGetOrdinaryClassJobName() { JobClassNameProvider jobClassNameProvider = new DefaultJobClassNameProvider(); String result = jobClassNameProvider.getJobClassName(new DetailedFooJob()); assertThat(result, is("org.apache.shardingsphere.elasticjob.lite.fixture.job.DetailedFooJob")); @@ -38,7 +38,7 @@ public void assertGetOrdinaryClassJobName() { // TODO OpenJDK 21 breaks this unit test. @Test @DisabledForJreRange(min = JRE.JAVA_21, max = JRE.OTHER) - public void assertGetLambdaJobName() { + void assertGetLambdaJobName() { JobClassNameProvider jobClassNameProvider = new DefaultJobClassNameProvider(); FooJob lambdaFooJob = shardingContext -> { }; diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/JobClassNameProviderFactoryTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/JobClassNameProviderFactoryTest.java index 34f52ae760..065fa6917d 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/JobClassNameProviderFactoryTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/JobClassNameProviderFactoryTest.java @@ -22,10 +22,10 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobClassNameProviderFactoryTest { +class JobClassNameProviderFactoryTest { @Test - public void assertGetDefaultStrategy() { + void assertGetDefaultStrategy() { assertThat(JobClassNameProviderFactory.getProvider(), instanceOf(DefaultJobClassNameProvider.class)); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java index 1243e3967d..4670b369e2 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class SetUpFacadeTest { +class SetUpFacadeTest { @Mock private LeaderService leaderService; @@ -61,7 +61,7 @@ public final class SetUpFacadeTest { private SetUpFacade setUpFacade; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); setUpFacade = new SetUpFacade(regCenter, "test_job", Collections.emptyList()); ReflectionUtils.setFieldValue(setUpFacade, "leaderService", leaderService); @@ -72,7 +72,7 @@ public void setUp() { } @Test - public void assertRegisterStartUpInfo() { + void assertRegisterStartUpInfo() { setUpFacade.registerStartUpInfo(true); verify(listenerManager).startAllListeners(); verify(leaderService).electLeader(); @@ -80,7 +80,7 @@ public void assertRegisterStartUpInfo() { } @Test - public void assertTearDown() { + void assertTearDown() { when(reconcileService.isRunning()).thenReturn(true); setUpFacade.tearDown(); verify(reconcileService).stopAsync(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextServiceTest.java index 637729706b..e01d8046b5 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextServiceTest.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ExecutionContextServiceTest { +class ExecutionContextServiceTest { @Mock private JobNodeStorage jobNodeStorage; @@ -53,14 +53,14 @@ public final class ExecutionContextServiceTest { private final ExecutionContextService executionContextService = new ExecutionContextService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(executionContextService, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(executionContextService, "configService", configService); JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); } @Test - public void assertGetShardingContextWhenNotAssignShardingItem() { + void assertGetShardingContextWhenNotAssignShardingItem() { when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3) .cron("0/1 * * * * ?").setProperty("streaming.process", Boolean.TRUE.toString()).monitorExecution(false).build()); ShardingContexts shardingContexts = executionContextService.getJobShardingContext(Collections.emptyList()); @@ -69,7 +69,7 @@ public void assertGetShardingContextWhenNotAssignShardingItem() { } @Test - public void assertGetShardingContextWhenAssignShardingItems() { + void assertGetShardingContextWhenAssignShardingItems() { when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3) .cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").setProperty("streaming.process", Boolean.TRUE.toString()).monitorExecution(false).build()); Map map = new HashMap<>(3); @@ -80,7 +80,7 @@ public void assertGetShardingContextWhenAssignShardingItems() { } @Test - public void assertGetShardingContextWhenHasRunningItems() { + void assertGetShardingContextWhenHasRunningItems() { when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3) .cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").setProperty("streaming.process", Boolean.TRUE.toString()).monitorExecution(true).build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionServiceTest.java index edde6c7f2e..20e42e249c 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionServiceTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ExecutionServiceTest { +class ExecutionServiceTest { @Mock private JobNodeStorage jobNodeStorage; @@ -58,18 +58,18 @@ public final class ExecutionServiceTest { private final ExecutionService executionService = new ExecutionService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(executionService, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(executionService, "configService", configService); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown("test_job"); } @Test - public void assertRegisterJobBeginWithoutMonitorExecution() { + void assertRegisterJobBeginWithoutMonitorExecution() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(false).build()); executionService.registerJobBegin(getShardingContext()); verify(jobNodeStorage, times(0)).fillEphemeralJobNode(any(), any()); @@ -77,7 +77,7 @@ public void assertRegisterJobBeginWithoutMonitorExecution() { } @Test - public void assertRegisterJobBeginWithMonitorExecution() { + void assertRegisterJobBeginWithMonitorExecution() { String jobInstanceId = "127.0.0.1@-@1"; JobRegistry.getInstance().addJobInstance("test_job", new JobInstance(jobInstanceId)); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); @@ -89,7 +89,7 @@ public void assertRegisterJobBeginWithMonitorExecution() { } @Test - public void assertRegisterJobBeginWithFailoverEnabled() { + void assertRegisterJobBeginWithFailoverEnabled() { String jobInstanceId = "127.0.0.1@-@1"; JobRegistry.getInstance().addJobInstance("test_job", new JobInstance(jobInstanceId)); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(true).build()); @@ -101,7 +101,7 @@ public void assertRegisterJobBeginWithFailoverEnabled() { } @Test - public void assertRegisterJobCompletedWithoutMonitorExecution() { + void assertRegisterJobCompletedWithoutMonitorExecution() { JobRegistry.getInstance().setJobRunning("test_job", true); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(false).build()); executionService.registerJobCompleted(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap())); @@ -111,7 +111,7 @@ public void assertRegisterJobCompletedWithoutMonitorExecution() { } @Test - public void assertRegisterJobCompletedWithMonitorExecution() { + void assertRegisterJobCompletedWithMonitorExecution() { JobRegistry.getInstance().setJobRunning("test_job", true); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); executionService.registerJobCompleted(getShardingContext()); @@ -122,7 +122,7 @@ public void assertRegisterJobCompletedWithMonitorExecution() { } @Test - public void assertClearAllRunningInfo() { + void assertClearAllRunningInfo() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(false).build()); executionService.clearAllRunningInfo(); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/0/running"); @@ -131,20 +131,20 @@ public void assertClearAllRunningInfo() { } @Test - public void assertClearRunningInfo() { + void assertClearRunningInfo() { executionService.clearRunningInfo(Arrays.asList(0, 1)); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/0/running"); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/1/running"); } @Test - public void assertNotHaveRunningItemsWithoutMonitorExecution() { + void assertNotHaveRunningItemsWithoutMonitorExecution() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(false).build()); assertFalse(executionService.hasRunningItems(Arrays.asList(0, 1, 2))); } @Test - public void assertHasRunningItemsWithMonitorExecution() { + void assertHasRunningItemsWithMonitorExecution() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(true); @@ -152,7 +152,7 @@ public void assertHasRunningItemsWithMonitorExecution() { } @Test - public void assertNotHaveRunningItems() { + void assertNotHaveRunningItems() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(false); @@ -161,7 +161,7 @@ public void assertNotHaveRunningItems() { } @Test - public void assertHasRunningItemsForAll() { + void assertHasRunningItemsForAll() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(true); @@ -169,7 +169,7 @@ public void assertHasRunningItemsForAll() { } @Test - public void assertNotHaveRunningItemsForAll() { + void assertNotHaveRunningItemsForAll() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(false); @@ -178,7 +178,7 @@ public void assertNotHaveRunningItemsForAll() { } @Test - public void assertGetAllRunningItems() { + void assertGetAllRunningItems() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).build()); String jobInstanceId = "127.0.0.1@-@1"; when(jobNodeStorage.getJobNodeData("sharding/0/running")).thenReturn(jobInstanceId); @@ -190,7 +190,7 @@ public void assertGetAllRunningItems() { } @Test - public void assertMisfireIfNotRunning() { + void assertMisfireIfNotRunning() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(false); @@ -199,7 +199,7 @@ public void assertMisfireIfNotRunning() { } @Test - public void assertMisfireIfRunning() { + void assertMisfireIfRunning() { when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").monitorExecution(true).build()); when(jobNodeStorage.isJobNodeExisted("sharding/0/running")).thenReturn(false); when(jobNodeStorage.isJobNodeExisted("sharding/1/running")).thenReturn(true); @@ -207,7 +207,7 @@ public void assertMisfireIfRunning() { } @Test - public void assertSetMisfire() { + void assertSetMisfire() { executionService.setMisfire(Arrays.asList(0, 1, 2)); verify(jobNodeStorage).createJobNodeIfNeeded("sharding/0/misfire"); verify(jobNodeStorage).createJobNodeIfNeeded("sharding/1/misfire"); @@ -215,7 +215,7 @@ public void assertSetMisfire() { } @Test - public void assertGetMisfiredJobItems() { + void assertGetMisfiredJobItems() { when(jobNodeStorage.isJobNodeExisted("sharding/0/misfire")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("sharding/1/misfire")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("sharding/2/misfire")).thenReturn(false); @@ -223,7 +223,7 @@ public void assertGetMisfiredJobItems() { } @Test - public void assertClearMisfire() { + void assertClearMisfire() { executionService.clearMisfire(Arrays.asList(0, 1, 2)); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/0/misfire"); verify(jobNodeStorage).removeJobNodeIfExisted("sharding/1/misfire"); @@ -231,7 +231,7 @@ public void assertClearMisfire() { } @Test - public void assertGetDisabledItems() { + void assertGetDisabledItems() { when(jobNodeStorage.isJobNodeExisted("sharding/0/disabled")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("sharding/1/disabled")).thenReturn(true); when(jobNodeStorage.isJobNodeExisted("sharding/2/disabled")).thenReturn(false); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java index 1b5b6388a6..6f5bf035b8 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class MonitorExecutionListenerManagerTest { +class MonitorExecutionListenerManagerTest { @Mock private JobNodeStorage jobNodeStorage; @@ -43,31 +43,31 @@ public final class MonitorExecutionListenerManagerTest { private final MonitorExecutionListenerManager monitorExecutionListenerManager = new MonitorExecutionListenerManager(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setSuperclassFieldValue(monitorExecutionListenerManager, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(monitorExecutionListenerManager, "executionService", executionService); } @Test - public void assertMonitorExecutionSettingsChangedJobListenerWhenIsNotFailoverPath() { + void assertMonitorExecutionSettingsChangedJobListenerWhenIsNotFailoverPath() { monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/other", LiteYamlConstants.getJobYaml())); verify(executionService, times(0)).clearAllRunningInfo(); } @Test - public void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathButNotUpdate() { + void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathButNotUpdate() { monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/config", "")); verify(executionService, times(0)).clearAllRunningInfo(); } @Test - public void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() { + void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() { monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(executionService, times(0)).clearAllRunningInfo(); } @Test - public void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() { + void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() { DataChangedEvent event = new DataChangedEvent(Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYamlWithMonitorExecution(false)); monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().onChange(event); verify(executionService).clearAllRunningInfo(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java index 5ea835479f..6485aa912f 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ShardingListenerManagerTest { +class ShardingListenerManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -62,7 +62,7 @@ public final class ShardingListenerManagerTest { private ShardingListenerManager shardingListenerManager; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); shardingListenerManager = new ShardingListenerManager(null, "test_job"); ReflectionUtils.setSuperclassFieldValue(shardingListenerManager, "jobNodeStorage", jobNodeStorage); @@ -71,25 +71,25 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { shardingListenerManager.start(); verify(jobNodeStorage, times(2)).addDataListener(any(DataChangedEventListener.class)); } @Test - public void assertShardingTotalCountChangedJobListenerWhenIsNotConfigPath() { + void assertShardingTotalCountChangedJobListenerWhenIsNotConfigPath() { shardingListenerManager.new ShardingTotalCountChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/config/other", "")); verify(shardingService, times(0)).setReshardingFlag(); } @Test - public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathButCurrentShardingTotalCountIsZero() { + void assertShardingTotalCountChangedJobListenerWhenIsConfigPathButCurrentShardingTotalCountIsZero() { shardingListenerManager.new ShardingTotalCountChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(shardingService, times(0)).setReshardingFlag(); } @Test - public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsEqualToNewShardingTotalCount() { + void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsEqualToNewShardingTotalCount() { JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 3); shardingListenerManager.new ShardingTotalCountChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(shardingService, times(0)).setReshardingFlag(); @@ -97,7 +97,7 @@ public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrent } @Test - public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsNotEqualToNewShardingTotalCount() { + void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsNotEqualToNewShardingTotalCount() { JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 5); shardingListenerManager.new ShardingTotalCountChangedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/config", LiteYamlConstants.getJobYaml())); verify(shardingService).setReshardingFlag(); @@ -105,25 +105,25 @@ public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrent } @Test - public void assertListenServersChangedJobListenerWhenIsNotServerStatusPath() { + void assertListenServersChangedJobListenerWhenIsNotServerStatusPath() { shardingListenerManager.new ListenServersChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/servers/127.0.0.1/other", "")); verify(shardingService, times(0)).setReshardingFlag(); } @Test - public void assertListenServersChangedJobListenerWhenIsServerStatusPathButUpdate() { + void assertListenServersChangedJobListenerWhenIsServerStatusPathButUpdate() { shardingListenerManager.new ListenServersChangedJobListener().onChange(new DataChangedEvent(Type.UPDATED, "/test_job/servers/127.0.0.1/status", "")); verify(shardingService, times(0)).setReshardingFlag(); } @Test - public void assertListenServersChangedJobListenerWhenIsInstanceChangeButJobInstanceIsShutdown() { + void assertListenServersChangedJobListenerWhenIsInstanceChangeButJobInstanceIsShutdown() { shardingListenerManager.new ListenServersChangedJobListener().onChange(new DataChangedEvent(Type.ADDED, "/test_job/instances/xxx", "")); verify(shardingService, times(0)).setReshardingFlag(); } @Test - public void assertListenServersChangedJobListenerWhenIsInstanceChange() { + void assertListenServersChangedJobListenerWhenIsInstanceChange() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).build()); @@ -133,7 +133,7 @@ public void assertListenServersChangedJobListenerWhenIsInstanceChange() { } @Test - public void assertListenServersChangedJobListenerWhenIsServerChange() { + void assertListenServersChangedJobListenerWhenIsServerChange() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).build()); @@ -143,7 +143,7 @@ public void assertListenServersChangedJobListenerWhenIsServerChange() { } @Test - public void assertListenServersChangedJobListenerWhenIsStaticSharding() { + void assertListenServersChangedJobListenerWhenIsStaticSharding() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).staticSharding(true).build()); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingNodeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingNodeTest.java index f8354560d9..eedd44ff3d 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingNodeTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingNodeTest.java @@ -23,27 +23,27 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class ShardingNodeTest { +class ShardingNodeTest { private final ShardingNode shardingNode = new ShardingNode("test_job"); @Test - public void assertGetRunningNode() { + void assertGetRunningNode() { assertThat(ShardingNode.getRunningNode(0), is("sharding/0/running")); } @Test - public void assertGetMisfireNode() { + void assertGetMisfireNode() { assertThat(ShardingNode.getMisfireNode(0), is("sharding/0/misfire")); } @Test - public void assertGetItemWhenNotRunningItemPath() { + void assertGetItemWhenNotRunningItemPath() { assertNull(shardingNode.getItemByRunningItemPath("/test_job/sharding/0/completed")); } @Test - public void assertGetItemByRunningItemPath() { + void assertGetItemByRunningItemPath() { assertThat(shardingNode.getItemByRunningItemPath("/test_job/sharding/0/running"), is(0)); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingServiceTest.java index b3e12b3456..8128d82700 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingServiceTest.java @@ -50,7 +50,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ShardingServiceTest { +class ShardingServiceTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -79,7 +79,7 @@ public final class ShardingServiceTest { private final ShardingService shardingService = new ShardingService(null, "test_job"); @BeforeEach - public void setUp() { + void setUp() { ReflectionUtils.setFieldValue(shardingService, "jobNodeStorage", jobNodeStorage); ReflectionUtils.setFieldValue(shardingService, "leaderService", leaderService); ReflectionUtils.setFieldValue(shardingService, "configService", configService); @@ -90,40 +90,40 @@ public void setUp() { } @Test - public void assertSetReshardingFlagOnLeader() { + void assertSetReshardingFlagOnLeader() { when(leaderService.isLeaderUntilBlock()).thenReturn(true); shardingService.setReshardingFlag(); verify(jobNodeStorage).createJobNodeIfNeeded("leader/sharding/necessary"); } @Test - public void assertSetReshardingFlagOnNonLeader() { + void assertSetReshardingFlagOnNonLeader() { when(leaderService.isLeaderUntilBlock()).thenReturn(false); shardingService.setReshardingFlag(); verify(jobNodeStorage, times(0)).createJobNodeIfNeeded("leader/sharding/necessary"); } @Test - public void assertIsNeedSharding() { + void assertIsNeedSharding() { when(jobNodeStorage.isJobNodeExisted("leader/sharding/necessary")).thenReturn(true); assertTrue(shardingService.isNeedSharding()); } @Test - public void assertShardingWhenUnnecessary() { + void assertShardingWhenUnnecessary() { shardingService.shardingIfNecessary(); verify(jobNodeStorage, times(0)).fillEphemeralJobNode(ShardingNode.PROCESSING, ""); } @Test - public void assertShardingWithoutAvailableJobInstances() { + void assertShardingWithoutAvailableJobInstances() { when(jobNodeStorage.isJobNodeExisted("leader/sharding/necessary")).thenReturn(true); shardingService.shardingIfNecessary(); verify(jobNodeStorage, times(0)).fillEphemeralJobNode(ShardingNode.PROCESSING, ""); } @Test - public void assertShardingWhenIsNotLeader() { + void assertShardingWhenIsNotLeader() { when(jobNodeStorage.isJobNodeExisted("leader/sharding/necessary")).thenReturn(true, false); when(instanceService.getAvailableJobInstances()).thenReturn(Collections.singletonList(new JobInstance("127.0.0.1@-@0"))); when(leaderService.isLeaderUntilBlock()).thenReturn(false); @@ -133,7 +133,7 @@ public void assertShardingWhenIsNotLeader() { } @Test - public void assertShardingNecessaryWhenMonitorExecutionEnabledAndIncreaseShardingTotalCount() { + void assertShardingNecessaryWhenMonitorExecutionEnabledAndIncreaseShardingTotalCount() { when(instanceService.getAvailableJobInstances()).thenReturn(Collections.singletonList(new JobInstance("127.0.0.1@-@0"))); when(jobNodeStorage.isJobNodeExisted("leader/sharding/necessary")).thenReturn(true); when(leaderService.isLeaderUntilBlock()).thenReturn(true); @@ -153,7 +153,7 @@ public void assertShardingNecessaryWhenMonitorExecutionEnabledAndIncreaseShardin } @Test - public void assertShardingNecessaryWhenMonitorExecutionDisabledAndDecreaseShardingTotalCount() { + void assertShardingNecessaryWhenMonitorExecutionDisabledAndDecreaseShardingTotalCount() { when(instanceService.getAvailableJobInstances()).thenReturn(Collections.singletonList(new JobInstance("127.0.0.1@-@0"))); when(jobNodeStorage.isJobNodeExisted("leader/sharding/necessary")).thenReturn(true); when(leaderService.isLeaderUntilBlock()).thenReturn(true); @@ -173,13 +173,13 @@ public void assertShardingNecessaryWhenMonitorExecutionDisabledAndDecreaseShardi } @Test - public void assertGetShardingItemsWithNotAvailableServer() { + void assertGetShardingItemsWithNotAvailableServer() { when(jobNodeStorage.getJobNodeData("instances/127.0.0.1@-@0")).thenReturn("jobInstanceId: 127.0.0.1@-@0\nserverIp: 127.0.0.1\n"); assertThat(shardingService.getShardingItems("127.0.0.1@-@0"), is(Collections.emptyList())); } @Test - public void assertGetShardingItemsWithAvailableServer() { + void assertGetShardingItemsWithAvailableServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(serverService.isAvailableServer("127.0.0.1")).thenReturn(true); @@ -193,12 +193,12 @@ public void assertGetShardingItemsWithAvailableServer() { } @Test - public void assertGetLocalShardingItemsWithInstanceShutdown() { + void assertGetLocalShardingItemsWithInstanceShutdown() { assertThat(shardingService.getLocalShardingItems(), is(Collections.emptyList())); } @Test - public void assertGetLocalShardingItemsWithDisabledServer() { + void assertGetLocalShardingItemsWithDisabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); assertThat(shardingService.getLocalShardingItems(), is(Collections.emptyList())); @@ -206,7 +206,7 @@ public void assertGetLocalShardingItemsWithDisabledServer() { } @Test - public void assertGetLocalShardingItemsWithEnabledServer() { + void assertGetLocalShardingItemsWithEnabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(serverService.isAvailableServer("127.0.0.1")).thenReturn(true); @@ -220,7 +220,7 @@ public void assertGetLocalShardingItemsWithEnabledServer() { } @Test - public void assertHasShardingInfoInOfflineServers() { + void assertHasShardingInfoInOfflineServers() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("host0@-@0", "host0@-@1")); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(0))).thenReturn("host0@-@0"); @@ -230,7 +230,7 @@ public void assertHasShardingInfoInOfflineServers() { } @Test - public void assertHasNotShardingInfoInOfflineServers() { + void assertHasNotShardingInfoInOfflineServers() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("host0@-@0", "host0@-@1")); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(0))).thenReturn("host0@-@0"); @@ -240,12 +240,12 @@ public void assertHasNotShardingInfoInOfflineServers() { } @Test - public void assertGetCrashedShardingItemsWithNotEnableServer() { + void assertGetCrashedShardingItemsWithNotEnableServer() { assertThat(shardingService.getCrashedShardingItems("127.0.0.1@-@0"), is(Collections.emptyList())); } @Test - public void assertGetCrashedShardingItemsWithEnabledServer() { + void assertGetCrashedShardingItemsWithEnabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(serverService.isEnableServer("127.0.0.1")).thenReturn(true); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/BaseSnapshotServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/BaseSnapshotServiceTest.java index 874ef80dd0..a0dda8cf0c 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/BaseSnapshotServiceTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/BaseSnapshotServiceTest.java @@ -54,20 +54,20 @@ public BaseSnapshotServiceTest(final ElasticJob elasticJob) { } @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); ZOOKEEPER_CONFIG.setConnectionTimeoutMilliseconds(30000); REG_CENTER.init(); } @BeforeEach - public final void setUp() { + void setUp() { REG_CENTER.init(); bootstrap.schedule(); } @AfterEach - public final void tearDown() { + void tearDown() { bootstrap.shutdown(); ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null); } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceDisableTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceDisableTest.java index 551988fc36..6f3ea3b677 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceDisableTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceDisableTest.java @@ -28,19 +28,19 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class SnapshotServiceDisableTest extends BaseSnapshotServiceTest { +class SnapshotServiceDisableTest extends BaseSnapshotServiceTest { - public SnapshotServiceDisableTest() { + SnapshotServiceDisableTest() { super(new DetailedFooJob()); } @Test - public void assertMonitorWithDumpCommand() { + void assertMonitorWithDumpCommand() { assertThrows(IOException.class, () -> SocketUtils.sendCommand(SnapshotService.DUMP_COMMAND, DUMP_PORT - 1)); } @Test - public void assertPortInvalid() { + void assertPortInvalid() { assertThrows(IllegalArgumentException.class, () -> { SnapshotService snapshotService = new SnapshotService(getREG_CENTER(), -1); snapshotService.listen(); @@ -49,7 +49,7 @@ public void assertPortInvalid() { @Test @SneakyThrows - public void assertListenException() { + void assertListenException() { ServerSocket serverSocket = new ServerSocket(9898); SnapshotService snapshotService = new SnapshotService(getREG_CENTER(), 9898); snapshotService.listen(); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceEnableTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceEnableTest.java index fc0035d788..33fdbf4a00 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceEnableTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotServiceEnableTest.java @@ -27,35 +27,35 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public final class SnapshotServiceEnableTest extends BaseSnapshotServiceTest { +class SnapshotServiceEnableTest extends BaseSnapshotServiceTest { - public SnapshotServiceEnableTest() { + SnapshotServiceEnableTest() { super(new DetailedFooJob()); } @BeforeEach - public void listenMonitor() { + void listenMonitor() { getSnapshotService().listen(); } @AfterEach - public void closeMonitor() { + void closeMonitor() { getSnapshotService().close(); } @Test - public void assertMonitorWithCommand() throws IOException { + void assertMonitorWithCommand() throws IOException { assertNotNull(SocketUtils.sendCommand(SnapshotService.DUMP_COMMAND + getJobName(), DUMP_PORT)); assertEquals(SocketUtils.sendCommand("unknown_command", DUMP_PORT), ""); } @Test - public void assertDumpJobDirectly() { + void assertDumpJobDirectly() { assertNotNull(getSnapshotService().dumpJobDirectly(getJobName())); } @Test - public void assertDumpJob() throws IOException { + void assertDumpJob() throws IOException { assertNotNull(SnapshotService.dumpJob("127.0.0.1", DUMP_PORT, getJobName())); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodePathTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodePathTest.java index fa2c17073b..07f7535cd5 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodePathTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodePathTest.java @@ -22,37 +22,37 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobNodePathTest { +class JobNodePathTest { private final JobNodePath jobNodePath = new JobNodePath("test_job"); @Test - public void assertGetFullPath() { + void assertGetFullPath() { assertThat(jobNodePath.getFullPath("node"), is("/test_job/node")); } @Test - public void assertGetServerNodePath() { + void assertGetServerNodePath() { assertThat(jobNodePath.getServerNodePath(), is("/test_job/servers")); } @Test - public void assertGetServerNodePathForServerIp() { + void assertGetServerNodePathForServerIp() { assertThat(jobNodePath.getServerNodePath("ip0"), is("/test_job/servers/ip0")); } @Test - public void assertGetShardingNodePath() { + void assertGetShardingNodePath() { assertThat(jobNodePath.getShardingNodePath(), is("/test_job/sharding")); } @Test - public void assertGetShardingNodePathWihItemAndNode() { + void assertGetShardingNodePathWihItemAndNode() { assertThat(jobNodePath.getShardingNodePath("0", "running"), is("/test_job/sharding/0/running")); } @Test - public void assertGetLeaderIpNodePath() { + void assertGetLeaderIpNodePath() { assertThat(jobNodePath.getLeaderHostNodePath(), is("/test_job/leader/election/instance")); } } diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodeStorageTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodeStorageTest.java index 839a120f13..8383bc3af6 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodeStorageTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/storage/JobNodeStorageTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobNodeStorageTest { +class JobNodeStorageTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -55,41 +55,41 @@ public final class JobNodeStorageTest { private JobNodeStorage jobNodeStorage; @BeforeEach - public void setUp() { + void setUp() { jobNodeStorage = new JobNodeStorage(regCenter, "test_job"); ReflectionUtils.setFieldValue(jobNodeStorage, "regCenter", regCenter); } @Test - public void assertIsJobNodeExisted() { + void assertIsJobNodeExisted() { when(regCenter.isExisted("/test_job/config")).thenReturn(true); assertTrue(jobNodeStorage.isJobNodeExisted("config")); verify(regCenter).isExisted("/test_job/config"); } @Test - public void assertGetJobNodeData() { + void assertGetJobNodeData() { when(regCenter.get("/test_job/config/cron")).thenReturn("0/1 * * * * ?"); assertThat(jobNodeStorage.getJobNodeData("config/cron"), is("0/1 * * * * ?")); verify(regCenter).get("/test_job/config/cron"); } @Test - public void assertGetJobNodeDataDirectly() { + void assertGetJobNodeDataDirectly() { when(regCenter.getDirectly("/test_job/config/cron")).thenReturn("0/1 * * * * ?"); assertThat(jobNodeStorage.getJobNodeDataDirectly("config/cron"), is("0/1 * * * * ?")); verify(regCenter).getDirectly("/test_job/config/cron"); } @Test - public void assertGetJobNodeChildrenKeys() { + void assertGetJobNodeChildrenKeys() { when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("host0", "host1")); assertThat(jobNodeStorage.getJobNodeChildrenKeys("servers"), is(Arrays.asList("host0", "host1"))); verify(regCenter).getChildrenKeys("/test_job/servers"); } @Test - public void assertCreateJobNodeIfNeeded() { + void assertCreateJobNodeIfNeeded() { when(regCenter.isExisted("/test_job")).thenReturn(true); when(regCenter.isExisted("/test_job/config")).thenReturn(false); jobNodeStorage.createJobNodeIfNeeded("config"); @@ -99,7 +99,7 @@ public void assertCreateJobNodeIfNeeded() { } @Test - public void assertCreateJobNodeIfRootJobNodeIsNotExist() { + void assertCreateJobNodeIfRootJobNodeIsNotExist() { when(regCenter.isExisted("/test_job")).thenReturn(false); jobNodeStorage.createJobNodeIfNeeded("config"); verify(regCenter).isExisted("/test_job"); @@ -108,7 +108,7 @@ public void assertCreateJobNodeIfRootJobNodeIsNotExist() { } @Test - public void assertCreateJobNodeIfNotNeeded() { + void assertCreateJobNodeIfNotNeeded() { when(regCenter.isExisted("/test_job")).thenReturn(true); when(regCenter.isExisted("/test_job/config")).thenReturn(true); jobNodeStorage.createJobNodeIfNeeded("config"); @@ -118,7 +118,7 @@ public void assertCreateJobNodeIfNotNeeded() { } @Test - public void assertRemoveJobNodeIfNeeded() { + void assertRemoveJobNodeIfNeeded() { when(regCenter.isExisted("/test_job/config")).thenReturn(true); jobNodeStorage.removeJobNodeIfExisted("config"); verify(regCenter).isExisted("/test_job/config"); @@ -126,7 +126,7 @@ public void assertRemoveJobNodeIfNeeded() { } @Test - public void assertRemoveJobNodeIfNotNeeded() { + void assertRemoveJobNodeIfNotNeeded() { when(regCenter.isExisted("/test_job/config")).thenReturn(false); jobNodeStorage.removeJobNodeIfExisted("config"); verify(regCenter).isExisted("/test_job/config"); @@ -134,37 +134,37 @@ public void assertRemoveJobNodeIfNotNeeded() { } @Test - public void assertFillJobNode() { + void assertFillJobNode() { jobNodeStorage.fillJobNode("config/cron", "0/1 * * * * ?"); verify(regCenter).persist("/test_job/config/cron", "0/1 * * * * ?"); } @Test - public void assertFillEphemeralJobNode() { + void assertFillEphemeralJobNode() { jobNodeStorage.fillEphemeralJobNode("config/cron", "0/1 * * * * ?"); verify(regCenter).persistEphemeral("/test_job/config/cron", "0/1 * * * * ?"); } @Test - public void assertUpdateJobNode() { + void assertUpdateJobNode() { jobNodeStorage.updateJobNode("config/cron", "0/1 * * * * ?"); verify(regCenter).update("/test_job/config/cron", "0/1 * * * * ?"); } @Test - public void assertReplaceJobNode() { + void assertReplaceJobNode() { jobNodeStorage.replaceJobNode("config/cron", "0/1 * * * * ?"); verify(regCenter).persist("/test_job/config/cron", "0/1 * * * * ?"); } @Test - public void assertExecuteInTransactionSuccess() throws Exception { + void assertExecuteInTransactionSuccess() throws Exception { jobNodeStorage.executeInTransaction(Collections.singletonList(TransactionOperation.opAdd("/test_transaction", ""))); verify(regCenter).executeInTransaction(any(List.class)); } @Test - public void assertExecuteInTransactionFailure() { + void assertExecuteInTransactionFailure() { assertThrows(RegException.class, () -> { doThrow(RuntimeException.class).when(regCenter).executeInTransaction(any(List.class)); jobNodeStorage.executeInTransaction(Collections.singletonList(TransactionOperation.opAdd("/test_transaction", ""))); @@ -172,14 +172,14 @@ public void assertExecuteInTransactionFailure() { } @Test - public void assertAddConnectionStateListener() { + void assertAddConnectionStateListener() { ConnectionStateChangedEventListener listener = mock(ConnectionStateChangedEventListener.class); jobNodeStorage.addConnectionStateListener(listener); verify(regCenter).addConnectionStateChangedEventListener("/test_job", listener); } @Test - public void assertAddDataListener() { + void assertAddDataListener() { DataChangedEventListener listener = mock(DataChangedEventListener.class); String jobName = "test_job"; ListenerNotifierManager.getInstance().registerJobNotifyExecutor(jobName); @@ -189,7 +189,7 @@ public void assertAddDataListener() { } @Test - public void assertGetRegistryCenterTime() { + void assertGetRegistryCenterTime() { when(regCenter.getRegistryCenterTime("/test_job/systemTime/current")).thenReturn(0L); assertThat(jobNodeStorage.getRegistryCenterTime(), is(0L)); verify(regCenter).getRegistryCenterTime("/test_job/systemTime/current"); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/trigger/TriggerListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/trigger/TriggerListenerManagerTest.java index ec3bf90130..fc2769f53b 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/trigger/TriggerListenerManagerTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/trigger/TriggerListenerManagerTest.java @@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class TriggerListenerManagerTest { +class TriggerListenerManagerTest { @Mock private CoordinatorRegistryCenter regCenter; @@ -52,7 +52,7 @@ public final class TriggerListenerManagerTest { private TriggerListenerManager triggerListenerManager; @BeforeEach - public void setUp() { + void setUp() { JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0")); triggerListenerManager = new TriggerListenerManager(null, "test_job"); ReflectionUtils.setFieldValue(triggerListenerManager, "triggerService", triggerService); @@ -60,32 +60,32 @@ public void setUp() { } @Test - public void assertStart() { + void assertStart() { triggerListenerManager.start(); verify(jobNodeStorage).addDataListener(ArgumentMatchers.any()); } @Test - public void assertNotTriggerWhenIsNotLocalInstancePath() { + void assertNotTriggerWhenIsNotLocalInstancePath() { triggerListenerManager.new JobTriggerStatusJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/trigger/127.0.0.2@-@0", "")); verify(triggerService, times(0)).removeTriggerFlag(); } @Test - public void assertNotTriggerWhenIsNotCreate() { + void assertNotTriggerWhenIsNotCreate() { triggerListenerManager.new JobTriggerStatusJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.UPDATED, "/test_job/trigger/127.0.0.1@-@0", "")); verify(triggerService, times(0)).removeTriggerFlag(); } @Test - public void assertTriggerWhenJobScheduleControllerIsNull() { + void assertTriggerWhenJobScheduleControllerIsNull() { triggerListenerManager.new JobTriggerStatusJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/trigger/127.0.0.1@-@0", "")); verify(triggerService).removeTriggerFlag(); verify(jobScheduleController, times(0)).triggerJob(); } @Test - public void assertTriggerWhenJobIsRunning() { + void assertTriggerWhenJobIsRunning() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); JobRegistry.getInstance().setJobRunning("test_job", true); @@ -97,7 +97,7 @@ public void assertTriggerWhenJobIsRunning() { } @Test - public void assertTriggerWhenJobIsNotRunning() { + void assertTriggerWhenJobIsNotRunning() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); triggerListenerManager.new JobTriggerStatusJobListener().onChange(new DataChangedEvent(DataChangedEvent.Type.ADDED, "/test_job/trigger/127.0.0.1@-@0", "")); diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtilsTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtilsTest.java index 42b494bc11..cc20f40761 100644 --- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtilsTest.java +++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtilsTest.java @@ -25,16 +25,16 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class SensitiveInfoUtilsTest { +class SensitiveInfoUtilsTest { @Test - public void assertFilterContentWithoutIp() { + void assertFilterContentWithoutIp() { List actual = Arrays.asList("/simpleElasticDemoJob/servers", "/simpleElasticDemoJob/leader"); assertThat(SensitiveInfoUtils.filterSensitiveIps(actual), is(actual)); } @Test - public void assertFilterContentWithSensitiveIp() { + void assertFilterContentWithSensitiveIp() { List actual = Arrays.asList("/simpleElasticDemoJob/servers/127.0.0.1", "/simpleElasticDemoJob/servers/192.168.0.1/hostName | 192.168.0.1", "/simpleElasticDemoJob/servers/192.168.0.11", "/simpleElasticDemoJob/servers/192.168.0.111"); List expected = Arrays.asList("/simpleElasticDemoJob/servers/ip1", "/simpleElasticDemoJob/servers/ip2/hostName | ip2", diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java index 9a587e5449..500a5112f8 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java @@ -40,7 +40,7 @@ public abstract class AbstractEmbedZookeeperBaseTest { private static final Object INIT_LOCK = new Object(); @BeforeAll - public static void setUp() { + static void setUp() { startEmbedTestingServer(); } diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/api/JobAPIFactoryTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/api/JobAPIFactoryTest.java index f80089be91..8b45d0d486 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/api/JobAPIFactoryTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/api/JobAPIFactoryTest.java @@ -23,35 +23,35 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -public final class JobAPIFactoryTest extends AbstractEmbedZookeeperBaseTest { +class JobAPIFactoryTest extends AbstractEmbedZookeeperBaseTest { @Test - public void assertCreateJobConfigAPI() { + void assertCreateJobConfigAPI() { assertThat(JobAPIFactory.createJobConfigurationAPI(getConnectionString(), "namespace", null), instanceOf(JobConfigurationAPI.class)); } @Test - public void assertCreateJobOperateAPI() { + void assertCreateJobOperateAPI() { assertThat(JobAPIFactory.createJobOperateAPI(getConnectionString(), "namespace", null), instanceOf(JobOperateAPI.class)); } @Test - public void assertCreateServerOperateAPI() { + void assertCreateServerOperateAPI() { assertThat(JobAPIFactory.createShardingOperateAPI(getConnectionString(), "namespace", null), instanceOf(ShardingOperateAPI.class)); } @Test - public void assertCreateJobStatisticsAPI() { + void assertCreateJobStatisticsAPI() { assertThat(JobAPIFactory.createJobStatisticsAPI(getConnectionString(), "namespace", null), instanceOf(JobStatisticsAPI.class)); } @Test - public void assertCreateServerStatisticsAPI() { + void assertCreateServerStatisticsAPI() { assertThat(JobAPIFactory.createServerStatisticsAPI(getConnectionString(), "namespace", null), instanceOf(ServerStatisticsAPI.class)); } @Test - public void assertCreateShardingStatisticsAPI() { + void assertCreateShardingStatisticsAPI() { assertThat(JobAPIFactory.createShardingStatisticsAPI(getConnectionString(), "namespace", null), instanceOf(ShardingStatisticsAPI.class)); } } diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/ShardingStatusTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/ShardingStatusTest.java index 3defc997b4..99dd3e909f 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/ShardingStatusTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/domain/ShardingStatusTest.java @@ -22,25 +22,25 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public final class ShardingStatusTest { +class ShardingStatusTest { @Test - public void assertGetShardingStatusWhenIsDisabled() { + void assertGetShardingStatusWhenIsDisabled() { assertThat(ShardingInfo.ShardingStatus.getShardingStatus(true, false, true), is(ShardingInfo.ShardingStatus.DISABLED)); } @Test - public void assertGetShardingStatusWhenIsRunning() { + void assertGetShardingStatusWhenIsRunning() { assertThat(ShardingInfo.ShardingStatus.getShardingStatus(false, true, false), is(ShardingInfo.ShardingStatus.RUNNING)); } @Test - public void assertGetShardingStatusWhenIsPending() { + void assertGetShardingStatusWhenIsPending() { assertThat(ShardingInfo.ShardingStatus.getShardingStatus(false, false, false), is(ShardingInfo.ShardingStatus.PENDING)); } @Test - public void assertGetShardingStatusWhenIsShardingError() { + void assertGetShardingStatusWhenIsShardingError() { assertThat(ShardingInfo.ShardingStatus.getShardingStatus(false, false, true), is(ShardingInfo.ShardingStatus.SHARDING_FLAG)); } } diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/JobOperateAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/JobOperateAPIImplTest.java index bbe1733957..379173e34d 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/JobOperateAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/JobOperateAPIImplTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobOperateAPIImplTest { +class JobOperateAPIImplTest { static final int DUMP_PORT = 9000; @@ -45,12 +45,12 @@ public final class JobOperateAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { jobOperateAPI = new JobOperateAPIImpl(regCenter); } @Test - public void assertTriggerWithJobName() { + void assertTriggerWithJobName() { when(regCenter.isExisted("/test_job")).thenReturn(true); when(regCenter.isExisted("/test_job/trigger/ip1@-@defaultInstance")).thenReturn(false); when(regCenter.isExisted("/test_job/trigger/ip2@-@defaultInstance")).thenReturn(false); @@ -62,13 +62,13 @@ public void assertTriggerWithJobName() { } @Test - public void assertDisableWithJobNameAndServerIp() { + void assertDisableWithJobNameAndServerIp() { jobOperateAPI.disable("test_job", "localhost"); verify(regCenter).persist("/test_job/servers/localhost", "DISABLED"); } @Test - public void assertDisableWithJobName() { + void assertDisableWithJobName() { when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); jobOperateAPI.disable("test_job", null); verify(regCenter).getChildrenKeys("/test_job/servers"); @@ -77,7 +77,7 @@ public void assertDisableWithJobName() { } @Test - public void assertDisableWithServerIp() { + void assertDisableWithServerIp() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job1", "test_job2")); when(regCenter.isExisted("/test_job1/servers/localhost")).thenReturn(true); when(regCenter.isExisted("/test_job2/servers/localhost")).thenReturn(true); @@ -88,13 +88,13 @@ public void assertDisableWithServerIp() { } @Test - public void assertEnableWithJobNameAndServerIp() { + void assertEnableWithJobNameAndServerIp() { jobOperateAPI.enable("test_job", "localhost"); verify(regCenter).persist("/test_job/servers/localhost", "ENABLED"); } @Test - public void assertEnableWithJobName() { + void assertEnableWithJobName() { when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); jobOperateAPI.enable("test_job", null); verify(regCenter).getChildrenKeys("/test_job/servers"); @@ -103,7 +103,7 @@ public void assertEnableWithJobName() { } @Test - public void assertEnableWithServerIp() { + void assertEnableWithServerIp() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job1", "test_job2")); when(regCenter.isExisted("/test_job1/servers/localhost")).thenReturn(true); when(regCenter.isExisted("/test_job2/servers/localhost")).thenReturn(true); @@ -114,7 +114,7 @@ public void assertEnableWithServerIp() { } @Test - public void assertShutdownWithJobNameAndServerIp() { + void assertShutdownWithJobNameAndServerIp() { when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Collections.singletonList("localhost@-@defaultInstance")); when(regCenter.get("/test_job/instances/localhost@-@defaultInstance")).thenReturn("jobInstanceId: localhost@-@defaultInstance\nserverIp: localhost\n"); jobOperateAPI.shutdown("test_job", "localhost"); @@ -122,7 +122,7 @@ public void assertShutdownWithJobNameAndServerIp() { } @Test - public void assertShutdownWithJobName() { + void assertShutdownWithJobName() { when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance")); jobOperateAPI.shutdown("test_job", null); verify(regCenter).getChildrenKeys("/test_job/instances"); @@ -130,7 +130,7 @@ public void assertShutdownWithJobName() { } @Test - public void assertShutdownWithServerIp() { + void assertShutdownWithServerIp() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job1", "test_job2")); when(regCenter.getChildrenKeys("/test_job1/instances")).thenReturn(Collections.singletonList("localhost@-@defaultInstance")); when(regCenter.getChildrenKeys("/test_job2/instances")).thenReturn(Collections.singletonList("localhost@-@defaultInstance")); @@ -143,14 +143,14 @@ public void assertShutdownWithServerIp() { } @Test - public void assertRemoveWithJobNameAndServerIp() { + void assertRemoveWithJobNameAndServerIp() { jobOperateAPI.remove("test_job", "ip1"); verify(regCenter).remove("/test_job/servers/ip1"); assertFalse(regCenter.isExisted("/test_job/servers/ip1")); } @Test - public void assertRemoveWithJobName() { + void assertRemoveWithJobName() { when(regCenter.isExisted("/test_job")).thenReturn(true); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); jobOperateAPI.remove("test_job", null); @@ -163,7 +163,7 @@ public void assertRemoveWithJobName() { } @Test - public void assertRemoveWithServerIp() { + void assertRemoveWithServerIp() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job1", "test_job2")); jobOperateAPI.remove(null, "ip1"); assertFalse(regCenter.isExisted("/test_job1/servers/ip1")); diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/ShardingOperateAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/ShardingOperateAPIImplTest.java index 53ef7d293f..a516b9fcac 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/ShardingOperateAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/operate/ShardingOperateAPIImplTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public final class ShardingOperateAPIImplTest { +class ShardingOperateAPIImplTest { private ShardingOperateAPI shardingOperateAPI; @@ -36,18 +36,18 @@ public final class ShardingOperateAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { shardingOperateAPI = new ShardingOperateAPIImpl(regCenter); } @Test - public void assertDisableSharding() { + void assertDisableSharding() { shardingOperateAPI.disable("test_job", "0"); verify(regCenter).persist("/test_job/sharding/0/disabled", ""); } @Test - public void assertEnableSharding() { + void assertEnableSharding() { shardingOperateAPI.enable("test_job", "0"); verify(regCenter).remove("/test_job/sharding/0/disabled"); } diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactoryTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactoryTest.java index c4a4b10536..223a7cba7e 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactoryTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactoryTest.java @@ -29,24 +29,24 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNull; -public final class RegistryCenterFactoryTest extends AbstractEmbedZookeeperBaseTest { +class RegistryCenterFactoryTest extends AbstractEmbedZookeeperBaseTest { @Test - public void assertCreateCoordinatorRegistryCenterWithoutDigest() throws ReflectiveOperationException { + void assertCreateCoordinatorRegistryCenterWithoutDigest() throws ReflectiveOperationException { ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "namespace", null)); assertThat(zkConfig.getNamespace(), is("namespace")); assertNull(zkConfig.getDigest()); } @Test - public void assertCreateCoordinatorRegistryCenterWithDigest() throws ReflectiveOperationException { + void assertCreateCoordinatorRegistryCenterWithDigest() throws ReflectiveOperationException { ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "namespace", "digest")); assertThat(zkConfig.getNamespace(), is("namespace")); assertThat(zkConfig.getDigest(), is("digest")); } @Test - public void assertCreateCoordinatorRegistryCenterFromCache() throws ReflectiveOperationException { + void assertCreateCoordinatorRegistryCenterFromCache() throws ReflectiveOperationException { RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "otherNamespace", null); ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "otherNamespace", null)); assertThat(zkConfig.getNamespace(), is("otherNamespace")); diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobConfigurationAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobConfigurationAPIImplTest.java index 704d490a09..65367010a8 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobConfigurationAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobConfigurationAPIImplTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobConfigurationAPIImplTest { +class JobConfigurationAPIImplTest { private JobConfigurationAPI jobConfigAPI; @@ -47,12 +47,12 @@ public final class JobConfigurationAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { jobConfigAPI = new JobConfigurationAPIImpl(regCenter); } @Test - public void assertGetJobConfigNull() { + void assertGetJobConfigNull() { when(regCenter.get("/test_job/config")).thenReturn(null); JobConfigurationPOJO actual = jobConfigAPI.getJobConfiguration("test_job"); assertNull(actual); @@ -60,7 +60,7 @@ public void assertGetJobConfigNull() { } @Test - public void assertGetDataflowJobConfig() { + void assertGetDataflowJobConfig() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getDataflowJobYaml()); JobConfigurationPOJO actual = jobConfigAPI.getJobConfiguration("test_job"); assertJobConfig(actual); @@ -69,7 +69,7 @@ public void assertGetDataflowJobConfig() { } @Test - public void assertGetScriptJobConfig() { + void assertGetScriptJobConfig() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getScriptJobYaml()); JobConfigurationPOJO actual = jobConfigAPI.getJobConfiguration("test_job"); assertJobConfig(actual); @@ -93,7 +93,7 @@ private void assertJobConfig(final JobConfigurationPOJO pojo) { } @Test - public void assertUpdateJobConfig() { + void assertUpdateJobConfig() { JobConfigurationPOJO jobConfiguration = new JobConfigurationPOJO(); jobConfiguration.setJobName("test_job"); jobConfiguration.setCron("0/1 * * * * ?"); @@ -111,7 +111,7 @@ public void assertUpdateJobConfig() { } @Test - public void assertUpdateJobConfigIfJobNameIsEmpty() { + void assertUpdateJobConfigIfJobNameIsEmpty() { assertThrows(IllegalArgumentException.class, () -> { JobConfigurationPOJO jobConfiguration = new JobConfigurationPOJO(); jobConfiguration.setJobName(""); @@ -120,7 +120,7 @@ public void assertUpdateJobConfigIfJobNameIsEmpty() { } @Test - public void assertUpdateJobConfigIfCronIsEmpty() { + void assertUpdateJobConfigIfCronIsEmpty() { assertThrows(IllegalArgumentException.class, () -> { JobConfigurationPOJO jobConfiguration = new JobConfigurationPOJO(); jobConfiguration.setJobName("test_job"); @@ -130,7 +130,7 @@ public void assertUpdateJobConfigIfCronIsEmpty() { } @Test - public void assertUpdateJobConfigIfShardingTotalCountLessThanOne() { + void assertUpdateJobConfigIfShardingTotalCountLessThanOne() { assertThrows(IllegalArgumentException.class, () -> { JobConfigurationPOJO jobConfiguration = new JobConfigurationPOJO(); jobConfiguration.setJobName("test_job"); @@ -141,7 +141,7 @@ public void assertUpdateJobConfigIfShardingTotalCountLessThanOne() { } @Test - public void assertRemoveJobConfiguration() { + void assertRemoveJobConfiguration() { jobConfigAPI.removeJobConfiguration("test_job"); verify(regCenter).remove("/test_job"); } diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java index c5814ba569..f2aa7cb123 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java @@ -35,7 +35,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class JobStatisticsAPIImplTest { +class JobStatisticsAPIImplTest { private JobStatisticsAPI jobStatisticsAPI; @@ -44,18 +44,18 @@ public final class JobStatisticsAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { jobStatisticsAPI = new JobStatisticsAPIImpl(regCenter); } @Test - public void assertGetJobsTotalCount() { + void assertGetJobsTotalCount() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); assertThat(jobStatisticsAPI.getJobsTotalCount(), is(2)); } @Test - public void assertGetOKJobBriefInfo() { + void assertGetOKJobBriefInfo() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc")); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance")); @@ -74,7 +74,7 @@ public void assertGetOKJobBriefInfo() { } @Test - public void assertGetOKJobBriefInfoWithPartialDisabledServer() { + void assertGetOKJobBriefInfoWithPartialDisabledServer() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc")); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED"); @@ -87,7 +87,7 @@ public void assertGetOKJobBriefInfoWithPartialDisabledServer() { } @Test - public void assertGetDisabledJobBriefInfo() { + void assertGetDisabledJobBriefInfo() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc")); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED"); @@ -98,7 +98,7 @@ public void assertGetDisabledJobBriefInfo() { } @Test - public void assertGetShardingErrorJobBriefInfo() { + void assertGetShardingErrorJobBriefInfo() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc")); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance")); @@ -111,20 +111,20 @@ public void assertGetShardingErrorJobBriefInfo() { } @Test - public void assertGetCrashedJobBriefInfo() { + void assertGetCrashedJobBriefInfo() { when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc")); JobBriefInfo jobBrief = jobStatisticsAPI.getJobBriefInfo("test_job"); assertThat(jobBrief.getStatus(), is(JobBriefInfo.JobStatus.CRASHED)); } @Test - public void assertGetAllJobsBriefInfoWithoutNamespace() { + void assertGetAllJobsBriefInfoWithoutNamespace() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); assertThat(jobStatisticsAPI.getAllJobsBriefInfo().size(), is(0)); } @Test - public void assertGetAllJobsBriefInfo() { + void assertGetAllJobsBriefInfo() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.get("/test_job_1/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_1", "desc1")); when(regCenter.get("/test_job_2/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_2", "desc2")); @@ -151,7 +151,7 @@ public void assertGetAllJobsBriefInfo() { } @Test - public void assertGetJobsBriefInfoByIp() { + void assertGetJobsBriefInfoByIp() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2", "test_job_3")); when(regCenter.isExisted("/test_job_1/servers/ip1")).thenReturn(true); when(regCenter.isExisted("/test_job_2/servers/ip1")).thenReturn(true); diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImplTest.java index f56c2b6226..fdbddc3e5f 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImplTest.java @@ -35,7 +35,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ServerStatisticsAPIImplTest { +class ServerStatisticsAPIImplTest { private ServerStatisticsAPI serverStatisticsAPI; @@ -43,12 +43,12 @@ public final class ServerStatisticsAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { serverStatisticsAPI = new ServerStatisticsAPIImpl(regCenter); } @Test - public void assertGetJobsTotalCount() { + void assertGetJobsTotalCount() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.getChildrenKeys("/test_job_1/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job_2/servers")).thenReturn(Arrays.asList("ip2", "ip3")); @@ -56,7 +56,7 @@ public void assertGetJobsTotalCount() { } @Test - public void assertGetAllServersBriefInfo() { + void assertGetAllServersBriefInfo() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job1", "test_job2")); when(regCenter.getChildrenKeys("/test_job1/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job2/servers")).thenReturn(Arrays.asList("ip1", "ip2")); diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ShardingStatisticsAPIImplTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ShardingStatisticsAPIImplTest.java index 7577e4d432..7388011c50 100644 --- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ShardingStatisticsAPIImplTest.java +++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ShardingStatisticsAPIImplTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public final class ShardingStatisticsAPIImplTest { +class ShardingStatisticsAPIImplTest { private ShardingStatisticsAPI shardingStatisticsAPI; @@ -43,12 +43,12 @@ public final class ShardingStatisticsAPIImplTest { private CoordinatorRegistryCenter regCenter; @BeforeEach - public void setUp() { + void setUp() { shardingStatisticsAPI = new ShardingStatisticsAPIImpl(regCenter); } @Test - public void assertGetShardingInfo() { + void assertGetShardingInfo() { when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Arrays.asList("0", "1", "2", "3")); when(regCenter.get("/test_job/sharding/0/instance")).thenReturn("ip1@-@1234"); when(regCenter.get("/test_job/sharding/1/instance")).thenReturn("ip2@-@2341"); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobConfigurationPropertiesTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobConfigurationPropertiesTest.java index 0d037cdaf9..a886f0ea2e 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobConfigurationPropertiesTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobConfigurationPropertiesTest.java @@ -17,18 +17,19 @@ package org.apache.shardingsphere.elasticjob.lite.spring.boot.job; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.util.Collections; import org.apache.shardingsphere.elasticjob.api.ElasticJob; import org.apache.shardingsphere.elasticjob.api.JobConfiguration; import org.junit.jupiter.api.Test; -public final class ElasticJobConfigurationPropertiesTest { +import java.util.Collections; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +class ElasticJobConfigurationPropertiesTest { @Test - public void assertToJobConfiguration() { + void assertToJobConfiguration() { ElasticJobConfigurationProperties properties = new ElasticJobConfigurationProperties(); properties.setElasticJobClass(ElasticJob.class); properties.setElasticJobType("jobType"); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootScannerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootScannerTest.java index 50b62e8d90..6eceee06dd 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootScannerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootScannerTest.java @@ -39,19 +39,19 @@ @SpringBootTest @ActiveProfiles("elasticjob") @ElasticJobScan(basePackages = "org.apache.shardingsphere.elasticjob.lite.spring.boot.job.fixture.job.impl") -public class ElasticJobSpringBootScannerTest { +class ElasticJobSpringBootScannerTest { @Autowired private ApplicationContext applicationContext; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); AnnotationCustomJob.reset(); } @Test - public void assertDefaultBeanNameWithTypeJob() { + void assertDefaultBeanNameWithTypeJob() { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(AnnotationCustomJob.isCompleted(), is(true))); assertTrue(AnnotationCustomJob.isCompleted()); assertNotNull(applicationContext); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java index 27f78cb91c..1c6a51f731 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java @@ -59,18 +59,18 @@ @SpringBootTest @SpringBootApplication @ActiveProfiles("elasticjob") -public class ElasticJobSpringBootTest { +class ElasticJobSpringBootTest { @Autowired private ApplicationContext applicationContext; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); } @Test - public void assertZookeeperProperties() { + void assertZookeeperProperties() { assertNotNull(applicationContext); ZookeeperProperties actual = applicationContext.getBean(ZookeeperProperties.class); assertThat(actual.getServerLists(), is(EmbedTestingServer.getConnectionString())); @@ -78,7 +78,7 @@ public void assertZookeeperProperties() { } @Test - public void assertRegistryCenterCreation() { + void assertRegistryCenterCreation() { assertNotNull(applicationContext); ZookeeperRegistryCenter zookeeperRegistryCenter = applicationContext.getBean(ZookeeperRegistryCenter.class); assertNotNull(zookeeperRegistryCenter); @@ -87,7 +87,7 @@ public void assertRegistryCenterCreation() { } @Test - public void assertTracingConfigurationCreation() throws SQLException { + void assertTracingConfigurationCreation() throws SQLException { assertNotNull(applicationContext); TracingConfiguration tracingConfig = applicationContext.getBean(TracingConfiguration.class); assertNotNull(tracingConfig); @@ -98,7 +98,7 @@ public void assertTracingConfigurationCreation() throws SQLException { } @Test - public void assertTracingProperties() { + void assertTracingProperties() { assertNotNull(applicationContext); TracingProperties tracingProperties = applicationContext.getBean(TracingProperties.class); assertNotNull(tracingProperties); @@ -109,7 +109,7 @@ public void assertTracingProperties() { } @Test - public void assertElasticJobProperties() { + void assertElasticJobProperties() { assertNotNull(applicationContext); ElasticJobProperties elasticJobProperties = applicationContext.getBean(ElasticJobProperties.class); assertNotNull(elasticJobProperties); @@ -135,7 +135,7 @@ public void assertElasticJobProperties() { } @Test - public void assertJobScheduleCreation() { + void assertJobScheduleCreation() { Awaitility.await().atLeast(100L, TimeUnit.MILLISECONDS).atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> { assertNotNull(applicationContext); Map elasticJobBeans = applicationContext.getBeansOfType(ElasticJob.class); @@ -146,7 +146,7 @@ public void assertJobScheduleCreation() { } @Test - public void assertOneOffJobBootstrapBeanName() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + void assertOneOffJobBootstrapBeanName() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { assertNotNull(applicationContext); OneOffJobBootstrap customTestJobBootstrap = applicationContext.getBean("customTestJobBean", OneOffJobBootstrap.class); @@ -166,14 +166,14 @@ public void assertOneOffJobBootstrapBeanName() throws NoSuchFieldException, Secu } @Test - public void assertDefaultBeanNameWithClassJob() { + void assertDefaultBeanNameWithClassJob() { assertNotNull(applicationContext); assertNotNull(applicationContext.getBean("defaultBeanNameClassJobScheduleJobBootstrap", ScheduleJobBootstrap.class)); } @Test - public void assertDefaultBeanNameWithTypeJob() { + void assertDefaultBeanNameWithTypeJob() { assertNotNull(applicationContext); assertNotNull(applicationContext.getBean("defaultBeanNameTypeJobScheduleJobBootstrap", ScheduleJobBootstrap.class)); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperPropertiesTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperPropertiesTest.java index 05d1f22324..08740cd844 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperPropertiesTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperPropertiesTest.java @@ -17,16 +17,16 @@ package org.apache.shardingsphere.elasticjob.lite.spring.boot.reg; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration; import org.junit.jupiter.api.Test; -public final class ZookeeperPropertiesTest { +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +class ZookeeperPropertiesTest { @Test - public void assertToZookeeperConfiguration() { + void assertToZookeeperConfiguration() { ZookeeperProperties properties = new ZookeeperProperties(); properties.setServerLists("localhost:18181"); properties.setNamespace("test"); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/snapshot/ElasticJobSnapshotServiceConfigurationTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/snapshot/ElasticJobSnapshotServiceConfigurationTest.java index 4220468167..1d267b5c19 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/snapshot/ElasticJobSnapshotServiceConfigurationTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/snapshot/ElasticJobSnapshotServiceConfigurationTest.java @@ -32,18 +32,18 @@ @SpringBootTest @SpringBootApplication @ActiveProfiles("snapshot") -public class ElasticJobSnapshotServiceConfigurationTest { +class ElasticJobSnapshotServiceConfigurationTest { @Autowired private ApplicationContext applicationContext; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); } @Test - public void assertSnapshotServiceConfiguration() { + void assertSnapshotServiceConfiguration() { assertNotNull(applicationContext); assertNotNull(applicationContext.getBean(SnapshotService.class)); } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java index 489eb368d8..98c32dd087 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java @@ -38,18 +38,18 @@ @SpringBootTest @SpringBootApplication @ActiveProfiles("tracing") -public class TracingConfigurationTest { +class TracingConfigurationTest { @Autowired private ApplicationContext applicationContext; @BeforeAll - public static void init() { + static void init() { EmbedTestingServer.start(); } @Test - public void assertNotRDBConfiguration() { + void assertNotRDBConfiguration() { assertNotNull(applicationContext); assertFalse(applicationContext.containsBean("tracingDataSource")); ObjectProvider provider = applicationContext.getBeanProvider(ResolvableType.forClassWithGenerics(TracingConfiguration.class, DataSource.class)); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/setup/JobClassNameProviderFactoryTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/setup/JobClassNameProviderFactoryTest.java index 315be983cc..4ba75a964d 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/setup/JobClassNameProviderFactoryTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/setup/JobClassNameProviderFactoryTest.java @@ -17,16 +17,16 @@ package org.apache.shardingsphere.elasticjob.lite.spring.core.setup; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.MatcherAssert.assertThat; - import org.apache.shardingsphere.elasticjob.lite.internal.setup.JobClassNameProviderFactory; import org.junit.jupiter.api.Test; -public final class JobClassNameProviderFactoryTest { +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class JobClassNameProviderFactoryTest { @Test - public void assertGetStrategy() { + void assertGetStrategy() { assertThat(JobClassNameProviderFactory.getProvider(), instanceOf(SpringProxyJobClassNameProvider.class)); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/AopTargetUtilsTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/AopTargetUtilsTest.java index 8477180208..68b411779a 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/AopTargetUtilsTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/AopTargetUtilsTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public final class AopTargetUtilsTest { +class AopTargetUtilsTest { @Test - public void assertJdkDynamicProxyForGetTarget() { + void assertJdkDynamicProxyForGetTarget() { ElasticJob target = new TargetJob(); ProxyFactory pf = new ProxyFactory(target); pf.addInterface(ElasticJob.class); @@ -40,7 +40,7 @@ public void assertJdkDynamicProxyForGetTarget() { } @Test - public void assertCglibProxyForGetTarget() { + void assertCglibProxyForGetTarget() { ElasticJob target = new TargetJob(); ProxyFactory pf = new ProxyFactory(target); pf.setProxyTargetClass(true); @@ -50,7 +50,7 @@ public void assertCglibProxyForGetTarget() { } @Test - public void assertNoneProxyForGetTarget() { + void assertNoneProxyForGetTarget() { ElasticJob proxy = new TargetJob(); assertFalse(AopUtils.isAopProxy(proxy)); assertThat(AopTargetUtils.getTarget(proxy), is(proxy)); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/TargetJob.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/TargetJob.java index 9db5749936..d563b10463 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/TargetJob.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/core/util/TargetJob.java @@ -28,6 +28,5 @@ public class TargetJob implements ElasticJob { * @param shardingContext shardingContext */ public void execute(final ShardingContext shardingContext) { - } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractJobSpringIntegrateTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractJobSpringIntegrateTest.java index c463002d6c..a4d4cc0e59 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractJobSpringIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractJobSpringIntegrateTest.java @@ -47,19 +47,19 @@ public abstract class AbstractJobSpringIntegrateTest extends AbstractZookeeperJU @BeforeEach @AfterEach - public void reset() { + void reset() { FooSimpleElasticJob.reset(); DataflowElasticJob.reset(); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(simpleJobName); JobRegistry.getInstance().shutdown(throughputDataflowJobName); } @Test - public void assertSpringJobBean() { + void assertSpringJobBean() { assertSimpleElasticJobBean(); assertThroughputDataflowElasticJobBean(); } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractOneOffJobSpringIntegrateTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractOneOffJobSpringIntegrateTest.java index d56c06c1ed..048a6d0399 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractOneOffJobSpringIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/AbstractOneOffJobSpringIntegrateTest.java @@ -52,19 +52,19 @@ public abstract class AbstractOneOffJobSpringIntegrateTest extends AbstractZooke @BeforeEach @AfterEach - public void reset() { + void reset() { FooSimpleElasticJob.reset(); DataflowElasticJob.reset(); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(simpleJobName); JobRegistry.getInstance().shutdown(throughputDataflowJobName); } @Test - public void assertSpringJobBean() { + void assertSpringJobBean() { assertSimpleElasticJobBean(); assertThroughputDataflowElasticJobBean(); } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithEventTraceRdbTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithEventTraceRdbTest.java index eb8e67c505..5736f9bd05 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithEventTraceRdbTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithEventTraceRdbTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withEventTraceRdb.xml") -public final class JobSpringNamespaceWithEventTraceRdbTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithEventTraceRdbTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithEventTraceRdbTest() { + JobSpringNamespaceWithEventTraceRdbTest() { super("simpleElasticJob_namespace_event_trace_rdb", "dataflowElasticJob_namespace_event_trace_rdb"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithJobHandlerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithJobHandlerTest.java index 27a405ab0c..a6337d6684 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithJobHandlerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithJobHandlerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withJobHandler.xml") -public final class JobSpringNamespaceWithJobHandlerTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithJobHandlerTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithJobHandlerTest() { + JobSpringNamespaceWithJobHandlerTest() { super("simpleElasticJob_namespace_job_handler", "dataflowElasticJob_namespace_job_handler"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndCglibTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndCglibTest.java index a0069afaf1..79268621b3 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndCglibTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndCglibTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withListenerAndCglib.xml") -public final class JobSpringNamespaceWithListenerAndCglibTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithListenerAndCglibTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithListenerAndCglibTest() { + JobSpringNamespaceWithListenerAndCglibTest() { super("simpleElasticJob_namespace_listener_cglib", "dataflowElasticJob_namespace_listener_cglib"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java index 37dc9440b2..6d56e8c7d1 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withListenerAndJdkDynamicProxy.xml") -public final class JobSpringNamespaceWithListenerAndJdkDynamicProxyTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithListenerAndJdkDynamicProxyTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithListenerAndJdkDynamicProxyTest() { + JobSpringNamespaceWithListenerAndJdkDynamicProxyTest() { super("simpleElasticJob_namespace_listener_jdk_proxy", "dataflowElasticJob_namespace_listener_jdk_proxy"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerTest.java index 304b8c6902..d1cf6cb007 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithListenerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withListener.xml") -public final class JobSpringNamespaceWithListenerTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithListenerTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithListenerTest() { + JobSpringNamespaceWithListenerTest() { super("simpleElasticJob_namespace_listener", "dataflowElasticJob_namespace_listener"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithRefTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithRefTest.java index 3966032ed5..60f42adce4 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithRefTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithRefTest.java @@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ContextConfiguration(locations = "classpath:META-INF/job/withJobRef.xml") -public final class JobSpringNamespaceWithRefTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class JobSpringNamespaceWithRefTest extends AbstractZookeeperJUnitJupiterSpringContextTests { private final String simpleJobName = "simpleElasticJob_job_ref"; @@ -44,17 +44,17 @@ public final class JobSpringNamespaceWithRefTest extends AbstractZookeeperJUnitJ @BeforeEach @AfterEach - public void reset() { + void reset() { RefFooSimpleElasticJob.reset(); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(simpleJobName); } @Test - public void assertSpringJobBean() { + void assertSpringJobBean() { assertSimpleElasticJobBean(); } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithTypeTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithTypeTest.java index a868c3c329..6e6a9bfcd2 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithTypeTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithTypeTest.java @@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ContextConfiguration(locations = "classpath:META-INF/job/withJobType.xml") -public final class JobSpringNamespaceWithTypeTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class JobSpringNamespaceWithTypeTest extends AbstractZookeeperJUnitJupiterSpringContextTests { private final String scriptJobName = "scriptElasticJob_job_type"; @@ -46,13 +46,13 @@ public final class JobSpringNamespaceWithTypeTest extends AbstractZookeeperJUnit private Scheduler scheduler; @AfterEach - public void tearDown() { + void tearDown() { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(scheduler.getCurrentlyExecutingJobs().isEmpty(), is(true))); JobRegistry.getInstance().getJobScheduleController(scriptJobName).shutdown(); } @Test - public void jobScriptWithJobTypeTest() throws SchedulerException { + void jobScriptWithJobTypeTest() throws SchedulerException { Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(regCenter.isExisted("/" + scriptJobName + "/sharding"), is(true))); scheduler = (Scheduler) ReflectionTestUtils.getField(JobRegistry.getInstance().getJobScheduleController(scriptJobName), "scheduler"); assertTrue(scheduler.isStarted()); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithoutListenerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithoutListenerTest.java index 5a61986242..7bea1a7f1a 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithoutListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/JobSpringNamespaceWithoutListenerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/withoutListener.xml") -public final class JobSpringNamespaceWithoutListenerTest extends AbstractJobSpringIntegrateTest { +class JobSpringNamespaceWithoutListenerTest extends AbstractJobSpringIntegrateTest { - public JobSpringNamespaceWithoutListenerTest() { + JobSpringNamespaceWithoutListenerTest() { super("simpleElasticJob_namespace", "dataflowElasticJob_namespace"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithEventTraceRdbTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithEventTraceRdbTest.java index d562f9fdcd..8ca6c8bc24 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithEventTraceRdbTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithEventTraceRdbTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithEventTraceRdb.xml") -public final class OneOffJobSpringNamespaceWithEventTraceRdbTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithEventTraceRdbTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithEventTraceRdbTest() { + OneOffJobSpringNamespaceWithEventTraceRdbTest() { super("oneOffSimpleElasticJob_namespace_event_trace_rdb", "oneOffDataflowElasticJob_namespace_event_trace_rdb"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithJobHandlerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithJobHandlerTest.java index d8b64defa7..6bc59585b5 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithJobHandlerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithJobHandlerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithJobHandler.xml") -public final class OneOffJobSpringNamespaceWithJobHandlerTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithJobHandlerTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithJobHandlerTest() { + OneOffJobSpringNamespaceWithJobHandlerTest() { super("oneOffSimpleElasticJob_namespace_job_handler", "oneOffDataflowElasticJob_namespace_job_handler"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndCglibTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndCglibTest.java index f876c452c7..d2cdbb655d 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndCglibTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndCglibTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithListenerAndCglib.xml") -public final class OneOffJobSpringNamespaceWithListenerAndCglibTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithListenerAndCglibTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithListenerAndCglibTest() { + OneOffJobSpringNamespaceWithListenerAndCglibTest() { super("simpleElasticJob_namespace_listener_cglib", "dataflowElasticJob_namespace_listener_cglib"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java index fb83aa8bf4..783e0d3769 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithListenerAndJdkDynamicProxy.xml") -public final class OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest() { + OneOffJobSpringNamespaceWithListenerAndJdkDynamicProxyTest() { super("simpleElasticJob_namespace_listener_jdk_proxy", "dataflowElasticJob_namespace_listener_jdk_proxy"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerTest.java index 43ba1dfe83..d5c792dc7a 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithListenerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithListener.xml") -public final class OneOffJobSpringNamespaceWithListenerTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithListenerTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithListenerTest() { + OneOffJobSpringNamespaceWithListenerTest() { super("simpleElasticJob_namespace_listener", "dataflowElasticJob_namespace_listener"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithRefTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithRefTest.java index 5c9119b085..c678eb7173 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithRefTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithRefTest.java @@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithJobRef.xml") -public final class OneOffJobSpringNamespaceWithRefTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class OneOffJobSpringNamespaceWithRefTest extends AbstractZookeeperJUnitJupiterSpringContextTests { private final String oneOffSimpleJobName = "oneOffSimpleElasticJobRef"; @@ -49,17 +49,17 @@ public final class OneOffJobSpringNamespaceWithRefTest extends AbstractZookeeper @BeforeEach @AfterEach - public void reset() { + void reset() { RefFooSimpleElasticJob.reset(); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(oneOffSimpleJobName); } @Test - public void assertSpringJobBean() { + void assertSpringJobBean() { OneOffJobBootstrap bootstrap = applicationContext.getBean(oneOffSimpleJobName, OneOffJobBootstrap.class); bootstrap.execute(); assertOneOffSimpleElasticJobBean(); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java index 80b4dfca89..4078ae4e5f 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java @@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithJobType.xml") -public final class OneOffJobSpringNamespaceWithTypeTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class OneOffJobSpringNamespaceWithTypeTest extends AbstractZookeeperJUnitJupiterSpringContextTests { private final String scriptJobName = "oneOffScriptElasticJob_job_type"; @@ -44,12 +44,12 @@ public final class OneOffJobSpringNamespaceWithTypeTest extends AbstractZookeepe private CoordinatorRegistryCenter regCenter; @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(scriptJobName); } @Test - public void jobScriptWithJobTypeTest() { + void jobScriptWithJobTypeTest() { OneOffJobBootstrap bootstrap = applicationContext.getBean(scriptJobName, OneOffJobBootstrap.class); bootstrap.execute(); Awaitility.await().atLeast(100L, TimeUnit.MILLISECONDS).atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertTrue(regCenter.isExisted("/" + scriptJobName + "/sharding"))); diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithoutListenerTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithoutListenerTest.java index 22fc966687..63a5063daa 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithoutListenerTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/OneOffJobSpringNamespaceWithoutListenerTest.java @@ -20,9 +20,9 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = "classpath:META-INF/job/oneOffWithoutListener.xml") -public final class OneOffJobSpringNamespaceWithoutListenerTest extends AbstractOneOffJobSpringIntegrateTest { +class OneOffJobSpringNamespaceWithoutListenerTest extends AbstractOneOffJobSpringIntegrateTest { - public OneOffJobSpringNamespaceWithoutListenerTest() { + OneOffJobSpringNamespaceWithoutListenerTest() { super("oneOffSimpleElasticJob", "oneOffDataflowElasticJob"); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/scanner/AbstractJobSpringIntegrateTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/scanner/AbstractJobSpringIntegrateTest.java index cb430c0097..a25ed76a3f 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/scanner/AbstractJobSpringIntegrateTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/scanner/AbstractJobSpringIntegrateTest.java @@ -44,17 +44,17 @@ public abstract class AbstractJobSpringIntegrateTest extends AbstractZookeeperJU @BeforeEach @AfterEach - public void reset() { + void reset() { AnnotationSimpleJob.reset(); } @AfterEach - public void tearDown() { + void tearDown() { JobRegistry.getInstance().shutdown(simpleJobName); } @Test - public void assertSpringJobBean() { + void assertSpringJobBean() { assertSimpleElasticJobBean(); } @@ -63,5 +63,4 @@ private void assertSimpleElasticJobBean() { assertTrue(AnnotationSimpleJob.isCompleted()); assertTrue(regCenter.isExisted("/" + simpleJobName + "/sharding")); } - } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceDisableTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceDisableTest.java index 3f8943f1ec..e8cac52388 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceDisableTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceDisableTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @ContextConfiguration(locations = "classpath:META-INF/snapshot/snapshotDisabled.xml") -public final class SnapshotSpringNamespaceDisableTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class SnapshotSpringNamespaceDisableTest extends AbstractZookeeperJUnitJupiterSpringContextTests { @Test - public void assertSnapshotDisable() { + void assertSnapshotDisable() { assertThrows(IOException.class, () -> SocketUtils.sendCommand(SnapshotService.DUMP_COMMAND, 9998)); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceEnableTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceEnableTest.java index a1c94756ed..4c1bd1e954 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceEnableTest.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/snapshot/SnapshotSpringNamespaceEnableTest.java @@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; @ContextConfiguration(locations = "classpath:META-INF/snapshot/snapshotEnabled.xml") -public final class SnapshotSpringNamespaceEnableTest extends AbstractZookeeperJUnitJupiterSpringContextTests { +class SnapshotSpringNamespaceEnableTest extends AbstractZookeeperJUnitJupiterSpringContextTests { @Test - public void assertSnapshotEnable() throws IOException { + void assertSnapshotEnable() throws IOException { assertNull(SocketUtils.sendCommand("unknown_command", 9988)); } } diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/test/AbstractZookeeperJUnitJupiterSpringContextTests.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/test/AbstractZookeeperJUnitJupiterSpringContextTests.java index 108415a2ae..d78924878d 100644 --- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/test/AbstractZookeeperJUnitJupiterSpringContextTests.java +++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/test/AbstractZookeeperJUnitJupiterSpringContextTests.java @@ -28,8 +28,6 @@ * @see org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests */ @ExtendWith(SpringExtension.class) -@TestExecutionListeners(listeners = {EmbedZookeeperTestExecutionListener.class}, - inheritListeners = false, - mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS) +@TestExecutionListeners(listeners = EmbedZookeeperTestExecutionListener.class, inheritListeners = false, mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS) public abstract class AbstractZookeeperJUnitJupiterSpringContextTests { } diff --git a/pom.xml b/pom.xml index ddaa658283..ac37770234 100644 --- a/pom.xml +++ b/pom.xml @@ -103,7 +103,7 @@ 0.15 2.22.1 - 3.1.0 + 3.2.1 3.0.2 3.20.0 4.3.0 @@ -624,7 +624,7 @@ maven-checkstyle-plugin ${maven-checkstyle-plugin.version} - src/resources/checkstyle_ci.xml + src/resources/checkstyle.xml true diff --git a/src/resources/checkstyle.xml b/src/resources/checkstyle.xml index 00242136f7..7ee07e534f 100644 --- a/src/resources/checkstyle.xml +++ b/src/resources/checkstyle.xml @@ -17,244 +17,297 @@ --> - - - - + + + + + + - + - + + + + + + - - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - + + + + - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/resources/checkstyle_ci.xml b/src/resources/checkstyle_ci.xml deleted file mode 100644 index 326987419b..0000000000 --- a/src/resources/checkstyle_ci.xml +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -