You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/10 13:26:25 UTC
[shardingsphere-elasticjob-lite] branch master updated: Use static
import with CoreMatchers for test cases (#1024)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new b75de73 Use static import with CoreMatchers for test cases (#1024)
b75de73 is described below
commit b75de73bc89f52c279568966e6ba677f6da1b510
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Jul 10 21:26:17 2020 +0800
Use static import with CoreMatchers for test cases (#1024)
---
.../elasticjob/cloud/exception/JobConfigurationExceptionTest.java | 4 ++--
.../elasticjob/cloud/exception/JobSystemExceptionTest.java | 4 ++--
.../elasticjob/cloud/executor/JobExecutorFactoryTest.java | 8 ++++----
.../elasticjob/cloud/restful/RestfulExceptionTest.java | 4 ++--
.../elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java | 4 ++--
.../elasticjob/tracing/event/JobExecutionEventTest.java | 3 +--
6 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobConfigurationExceptionTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobConfigurationExceptionTest.java
index 02cdd9c..c54d11f 100755
--- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobConfigurationExceptionTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobConfigurationExceptionTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.elasticjob.cloud.exception;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -32,6 +32,6 @@ public final class JobConfigurationExceptionTest {
@Test
public void assertGetCause() {
- assertThat(new JobConfigurationException(new RuntimeException()).getCause(), CoreMatchers.instanceOf(RuntimeException.class));
+ assertThat(new JobConfigurationException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class));
}
}
diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobSystemExceptionTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobSystemExceptionTest.java
index 8196be8..22b2118 100755
--- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobSystemExceptionTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/exception/JobSystemExceptionTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.elasticjob.cloud.exception;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -32,6 +32,6 @@ public final class JobSystemExceptionTest {
@Test
public void assertGetCause() {
- assertThat(new JobSystemException(new RuntimeException()).getCause(), CoreMatchers.instanceOf(RuntimeException.class));
+ assertThat(new JobSystemException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class));
}
}
diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/JobExecutorFactoryTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/JobExecutorFactoryTest.java
index f4abde6..11ede02 100755
--- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/JobExecutorFactoryTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/JobExecutorFactoryTest.java
@@ -28,12 +28,12 @@ import org.apache.shardingsphere.elasticjob.cloud.fixture.handler.IgnoreJobExcep
import org.apache.shardingsphere.elasticjob.cloud.fixture.job.OtherJob;
import org.apache.shardingsphere.elasticjob.cloud.fixture.job.TestDataflowJob;
import org.apache.shardingsphere.elasticjob.cloud.fixture.job.TestSimpleJob;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@@ -47,19 +47,19 @@ public final class JobExecutorFactoryTest {
@Test
public void assertGetJobExecutorForScriptJob() {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("test.sh", IgnoreJobExceptionHandler.class));
- assertThat(JobExecutorFactory.getJobExecutor(null, jobFacade), CoreMatchers.instanceOf(ScriptJobExecutor.class));
+ assertThat(JobExecutorFactory.getJobExecutor(null, jobFacade), instanceOf(ScriptJobExecutor.class));
}
@Test
public void assertGetJobExecutorForSimpleJob() {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
- assertThat(JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade), CoreMatchers.instanceOf(SimpleJobExecutor.class));
+ assertThat(JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade), instanceOf(SimpleJobExecutor.class));
}
@Test
public void assertGetJobExecutorForDataflowJob() {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(false));
- assertThat(JobExecutorFactory.getJobExecutor(new TestDataflowJob(null), jobFacade), CoreMatchers.instanceOf(DataflowJobExecutor.class));
+ assertThat(JobExecutorFactory.getJobExecutor(new TestDataflowJob(null), jobFacade), instanceOf(DataflowJobExecutor.class));
}
@Test(expected = JobConfigurationException.class)
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulExceptionTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulExceptionTest.java
index d13fbe3..a6ba0c2 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulExceptionTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulExceptionTest.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.elasticjob.cloud.restful;
-import org.hamcrest.core.IsInstanceOf;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
public final class RestfulExceptionTest {
@Test
public void assertRestfulException() {
- assertThat(new RestfulException(new RuntimeException()).getCause(), IsInstanceOf.instanceOf(RuntimeException.class));
+ assertThat(new RestfulException(new RuntimeException()).getCause(), instanceOf(RuntimeException.class));
}
}
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 e5e2dad..7142552 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
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.env;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.shardingsphere.elasticjob.cloud.reg.zookeeper.ZookeeperConfiguration;
import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
-import org.hamcrest.core.IsInstanceOf;
import org.junit.Test;
import org.unitils.util.ReflectionUtils;
@@ -28,6 +27,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Properties;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
@@ -76,7 +76,7 @@ public final class BootstrapEnvironmentTest {
properties.setProperty(BootstrapEnvironment.EnvironmentArgument.EVENT_TRACE_RDB_PASSWORD.getKey(), "password");
ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", properties);
Optional<TracingConfiguration> tracingConfiguration = bootstrapEnvironment.getTracingConfiguration();
- tracingConfiguration.ifPresent(tracingConfiguration1 -> assertThat(tracingConfiguration1.getStorage(), IsInstanceOf.instanceOf(BasicDataSource.class)));
+ tracingConfiguration.ifPresent(tracingConfiguration1 -> assertThat(tracingConfiguration1.getStorage(), instanceOf(BasicDataSource.class)));
}
@Test
diff --git a/elasticjob-common/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java b/elasticjob-common/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java
index 3696941..1240643 100644
--- a/elasticjob-common/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java
+++ b/elasticjob-common/elasticjob-tracing/elasticjob-tracing-api/src/test/java/org/apache/shardingsphere/elasticjob/tracing/event/JobExecutionEventTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.tracing.event;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -33,7 +32,7 @@ public final class JobExecutionEventTest {
public 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(), CoreMatchers.is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER));
+ assertThat(actual.getSource(), is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER));
assertThat(actual.getShardingItem(), is(0));
assertNotNull(actual.getHostname());
assertNotNull(actual.getStartTime());