You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by he...@apache.org on 2023/07/05 10:01:06 UTC
[shenyu] branch master updated: [ISSUE #4671] ShenYu e2e refactor to pass checkstyle check. (#4799)
This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 2f5d366c3 [ISSUE #4671] ShenYu e2e refactor to pass checkstyle check. (#4799)
2f5d366c3 is described below
commit 2f5d366c323771711a342bdd0bcd95f4d462724d
Author: DamonXue <Da...@gmail.com>
AuthorDate: Wed Jul 5 18:00:59 2023 +0800
[ISSUE #4671] ShenYu e2e refactor to pass checkstyle check. (#4799)
* client, engine and common complete.
* 11.
* check style complete.
* check style complete + 1.
* check style complete.
* check style complete + 2.
* check style complete + 1.
* resolve groovy module conflict.
* checkstyle +1.
* dependency change.
* dependency change +1.
---
shenyu-e2e/pom.xml | 16 +
.../e2e/testcase/divide/DividePluginCases.java | 30 +-
.../e2e/testcase/divide/DividePluginTest.java | 23 +-
.../testcase/springcloud/DataSynApolloTest.java | 2 +-
.../e2e/testcase/springcloud/DataSynHttpTest.java | 2 +-
.../e2e/testcase/springcloud/DataSynNacosTest.java | 2 +-
.../testcase/springcloud/DataSynZookeeperTest.java | 2 +-
.../springcloud/SpringCloudPluginCases.java | 35 +-
.../springcloud/SpringCloudPluginTest.java | 60 ++--
.../shenyu/e2e/client/ExternalServiceClient.java | 2 +-
.../shenyu/e2e/client/admin/AdminClient.java | 138 +++----
.../shenyu/e2e/client/gateway/GatewayClient.java | 55 ++-
.../org/apache/shenyu/e2e/matcher/RuleMatcher.java | 9 +-
.../apache/shenyu/e2e/matcher/SelectorMatcher.java | 18 +-
.../shenyu/e2e/client/admin/AdminClientTest.java | 18 +-
.../shenyu/e2e/annotation/ExternalService.java | 5 +
.../org/apache/shenyu/e2e/common/IdGenerator.java | 10 +-
.../org/apache/shenyu/e2e/common/IdManagers.java | 73 +++-
.../org/apache/shenyu/e2e/common/NameUtils.java | 8 +-
.../shenyu/e2e/common/RequestLogConsumer.java | 10 +-
.../org/apache/shenyu/e2e/common/TableView.java | 21 +-
.../org/apache/shenyu/e2e/model/MatchMode.java | 10 +-
.../java/org/apache/shenyu/e2e/model/Plugin.java | 26 +-
.../org/apache/shenyu/e2e/model/ResourcesData.java | 35 +-
.../org/apache/shenyu/e2e/model/SelectorType.java | 10 +-
.../org/apache/shenyu/e2e/model/ShenYuResult.java | 23 +-
.../apache/shenyu/e2e/model/data/Condition.java | 20 +-
.../org/apache/shenyu/e2e/model/data/MetaData.java | 53 ++-
.../apache/shenyu/e2e/model/data/PluginData.java | 20 +-
.../shenyu/e2e/model/data/QueryCondition.java | 18 +-
.../apache/shenyu/e2e/model/data/ResourceData.java | 14 +-
.../shenyu/e2e/model/data/RuleCacheData.java | 67 ++--
.../org/apache/shenyu/e2e/model/data/RuleData.java | 43 ++-
.../shenyu/e2e/model/data/RuleQueryCondition.java | 90 +++--
.../shenyu/e2e/model/data/SearchCondition.java | 43 ++-
.../shenyu/e2e/model/data/SelectorCacheData.java | 61 +++-
.../apache/shenyu/e2e/model/data/SelectorData.java | 59 +--
.../e2e/model/data/SelectorQueryCondition.java | 22 +-
.../shenyu/e2e/model/handle/DivideRuleHandle.java | 114 +++---
.../shenyu/e2e/model/handle/DivideUpstream.java | 119 +++---
.../apache/shenyu/e2e/model/handle/RuleHandle.java | 2 +-
.../e2e/model/handle/SpringCloudRuleHandle.java | 26 +-
.../apache/shenyu/e2e/model/handle/Upstreams.java | 22 +-
.../shenyu/e2e/model/response/FakeResourceDTO.java | 6 +-
.../shenyu/e2e/model/response/LoginInfo.java | 9 +-
.../shenyu/e2e/model/response/MetaDataDTO.java | 278 ++++++++++----
.../e2e/model/response/PaginatedResources.java | 6 +-
.../shenyu/e2e/model/response/Pagination.java | 12 +-
.../shenyu/e2e/model/response/PluginDTO.java | 16 +-
.../shenyu/e2e/model/response/ResourceDTO.java | 16 +
.../apache/shenyu/e2e/model/response/RuleDTO.java | 150 +++++---
.../e2e/model/response/SearchedResources.java | 12 +-
.../shenyu/e2e/model/response/SelectorDTO.java | 183 +++++++---
.../shenyu/e2e/template/ResourceDataTemplate.java | 42 ++-
.../apache/shenyu/e2e/common/TableViewTest.java | 22 +-
.../apache/shenyu/e2e/engine/ShenYuExtension.java | 18 +-
.../shenyu/e2e/engine/ShenYuExtensionContext.java | 43 ++-
.../shenyu/e2e/engine/ShenYuLogExtension.java | 11 +-
.../e2e/engine/annotation/ShenYuScenario.java | 5 +-
.../engine/annotation/ShenYuScenarioParameter.java | 3 +-
.../shenyu/e2e/engine/annotation/ShenYuTest.java | 40 ++-
.../shenyu/e2e/engine/annotation/ShenYuValue.java | 4 +
.../e2e/engine/config/ShenYuEngineConfigure.java | 400 +++++++++++----------
.../{DataSynHandler.java => DataSyncHandler.java} | 56 +--
.../ShenYuScenarioInvocationContextProvider.java | 10 +-
.../scenario/ShenYuScenarioParameterResolver.java | 7 +-
.../engine/scenario/ShenYuScenarioProvider.java | 4 +
.../engine/scenario/ShenYuScenarioSupplier.java | 30 +-
.../e2e/engine/scenario/function/Checker.java | 9 +-
.../e2e/engine/scenario/function/Deleter.java | 8 +-
.../e2e/engine/scenario/function/HttpChecker.java | 8 +
.../e2e/engine/scenario/function/HttpCheckers.java | 24 +-
.../e2e/engine/scenario/function/HttpVerifier.java | 2 -
.../e2e/engine/scenario/function/HttpWaiting.java | 9 +-
.../e2e/engine/scenario/function/Verifier.java | 8 +-
.../engine/scenario/function/WaitForHelper.java | 40 ++-
.../e2e/engine/scenario/function/Waiting.java | 9 +-
.../scenario/specification/AfterEachSpec.java | 19 +-
.../scenario/specification/BeforeEachSpec.java | 29 +-
.../engine/scenario/specification/CaseSpec.java | 8 +
.../scenario/specification/ScenarioSpec.java | 20 +-
.../specification/ScenarioSpecLogProxy.java | 8 +-
.../specification/ShenYuAfterEachSpec.java | 6 +-
.../specification/ShenYuBeforeEachSpec.java | 50 ++-
.../scenario/specification/ShenYuCaseSpec.java | 91 ++++-
.../scenario/specification/ShenYuScenarioSpec.java | 40 ++-
.../e2e/engine/service/DockerServiceCompose.java | 55 +--
.../e2e/engine/service/HostServiceCompose.java | 20 +-
.../shenyu/e2e/engine/service/NamingResolver.java | 35 +-
.../shenyu/e2e/engine/service/ServiceCompose.java | 23 +-
.../e2e/engine/service/WaitingForStrategies.java | 16 +-
.../engine/service/docker/DockerComposeFile.java | 27 +-
.../engine/service/docker/ShenYuLogConsumer.java | 2 +-
.../apache/shenyu/e2e/engine/ShenYuEngineTest.java | 29 +-
.../e2e/engine/function/WaitForHelperTest.java | 6 +-
95 files changed, 2277 insertions(+), 1143 deletions(-)
diff --git a/shenyu-e2e/pom.xml b/shenyu-e2e/pom.xml
index 9f85cf618..330280b39 100644
--- a/shenyu-e2e/pom.xml
+++ b/shenyu-e2e/pom.xml
@@ -105,11 +105,27 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginCases.java
index 066a25d1b..7ada273ea 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginCases.java
@@ -89,6 +89,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with uri path pattern.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithUriPathPattern() {
return ShenYuScenarioSpec.builder()
.name("single-divide uri path_pattern]")
@@ -123,6 +127,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with uri start with.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithUriStartWith() {
return ShenYuScenarioSpec.builder()
.name("single-divide uri starts_with]")
@@ -156,6 +164,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with end with.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithEndWith() {
return ShenYuScenarioSpec.builder()
.name("single-divide uri ends_with]")
@@ -191,6 +203,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with method get.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithMethodGet() {
return ShenYuScenarioSpec.builder()
.name("single-divide method GET")
@@ -231,6 +247,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with method post.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithMethodPost() {
return ShenYuScenarioSpec.builder()
.name("single-divide method POST")
@@ -271,6 +291,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with method put.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithMethodPut() {
return ShenYuScenarioSpec.builder()
.name("single-divide method PUT")
@@ -311,6 +335,10 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.build();
}
+ /**
+ * test divide with method delete.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec testDivideWithMethodDelete() {
return ShenYuScenarioSpec.builder()
.name("single-divide method DELETE")
@@ -350,4 +378,4 @@ public class DividePluginCases implements ShenYuScenarioProvider {
.afterEachSpec(ShenYuAfterEachSpec.DEFAULT)
.build();
}
-}
\ No newline at end of file
+}
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginTest.java
index f2301d828..dd3b2c23c 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/divide/DividePluginTest.java
@@ -48,7 +48,7 @@ import java.util.List;
baseUrl = "http://{hostname:localhost}:9095",
parameters = {
@Parameter(key = "username", value = "admin"),
- @Parameter(key = "password", value = "123456"),
+ @Parameter(key = "password", value = "123456")
}
),
@ServiceConfigure(
@@ -61,16 +61,16 @@ import java.util.List;
dockerComposeFile = "classpath:./docker-compose.{storage:h2}.yml"
)
public class DividePluginTest {
- List<String> selectorIds = Lists.newArrayList();
+ private List<String> selectorIds = Lists.newArrayList();
@BeforeAll
- static void setup(AdminClient client) {
+ static void setup(final AdminClient client) {
client.login();
client.deleteAllSelectors();
}
@BeforeEach
- void before(AdminClient client, GatewayClient gateway, BeforeEachSpec spec) {
+ void before(final AdminClient client, final GatewayClient gateway, final BeforeEachSpec spec) {
spec.getChecker().check(gateway);
ResourcesData resources = spec.getResources();
@@ -87,20 +87,21 @@ public class DividePluginTest {
spec.getWaiting().waitFor(gateway);
}
- @ShenYuScenario(provider = org.apache.shenyu.e2e.testcase.divide.DividePluginCases.class)
- void testDivide(GatewayClient gateway, CaseSpec spec) {
- spec.getVerifiers().forEach(verifier -> verifier.verify(gateway.getHttpRequesterSupplier().get()));
- }
-
@AfterEach
- void before(AdminClient client, GatewayClient gateway, AfterEachSpec spec) {
+ void after(final AdminClient client, final GatewayClient gateway, final AfterEachSpec spec) {
spec.getDeleter().delete(client, selectorIds);
spec.getPostChecker().check(gateway);
selectorIds = Lists.newArrayList();
}
+ @ShenYuScenario(provider = org.apache.shenyu.e2e.testcase.divide.DividePluginCases.class)
+ void testDivide(final GatewayClient gateway, final CaseSpec spec) {
+ spec.getVerifiers().forEach(verifier -> verifier.verify(gateway.getHttpRequesterSupplier().get()));
+ }
+
@AfterAll
- static void teardown(AdminClient client) {
+ static void teardown(final AdminClient client) {
client.deleteAllSelectors();
}
+
}
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynApolloTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynApolloTest.java
index 22267264b..1c6cbc0ce 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynApolloTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynApolloTest.java
@@ -62,7 +62,7 @@ import java.util.List;
public class DataSynApolloTest {
@Test
- void testDataSyn(AdminClient adminClient, GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
+ void testDataSyn(final AdminClient adminClient, final GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
adminClient.login();
Thread.sleep(10000);
List<MetaData> metaDataCacheList = gatewayClient.getMetaDataCache();
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynHttpTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynHttpTest.java
index 295e8db20..403caaf40 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynHttpTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynHttpTest.java
@@ -62,7 +62,7 @@ import java.util.List;
public class DataSynHttpTest {
@Test
- void testDataSyn(AdminClient adminClient, GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
+ void testDataSyn(final AdminClient adminClient, final GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
adminClient.login();
Thread.sleep(10000);
List<MetaData> metaDataCacheList = gatewayClient.getMetaDataCache();
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynNacosTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynNacosTest.java
index fb5b90639..f6a44e2d5 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynNacosTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynNacosTest.java
@@ -63,7 +63,7 @@ import java.util.List;
public class DataSynNacosTest {
@Test
- void testDataSyn(AdminClient adminClient, GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
+ void testDataSyn(final AdminClient adminClient, final GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
adminClient.login();
Thread.sleep(10000);
List<MetaData> metaDataCacheList = gatewayClient.getMetaDataCache();
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynZookeeperTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynZookeeperTest.java
index 7bd5d4ebf..6a7dbb294 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynZookeeperTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/DataSynZookeeperTest.java
@@ -62,7 +62,7 @@ import java.util.List;
public class DataSynZookeeperTest {
@Test
- void testDataSyn(AdminClient adminClient, GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
+ void testDataSyn(final AdminClient adminClient, final GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
adminClient.login();
Thread.sleep(10000);
List<MetaData> metaDataCacheList = gatewayClient.getMetaDataCache();
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginCases.java
index 63e4ca763..23a1e8e5d 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginCases.java
@@ -47,12 +47,12 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
private static final String TEST = "/springboot/test";
- private static final ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper MAPPER = new ObjectMapper();
- static List<DivideUpstream> divideUpstreams = Lists.newArrayList();
+ private static final List<DivideUpstream> DIVIDE_UPSTREAMS = Lists.newArrayList();
static {
- divideUpstreams.add(DivideUpstream.builder().protocol("http://")
+ DIVIDE_UPSTREAMS.add(DivideUpstream.builder().protocol("http://")
.upstreamUrl("springcloud:8884").status(true).timestamp(System.currentTimeMillis()).weight(50).warmup(10).build());
}
@@ -80,7 +80,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.EQUAL, TEST))
.build(),
@@ -97,7 +97,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
ShenYuCaseSpec.builder()
.addExists(TEST)
.addNotExists("/springcloud/te")
- .addNotExists( "/put")
+ .addNotExists("/put")
.addNotExists("/get")
.build()
)
@@ -114,7 +114,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.PATH_PATTERN, TEST + "/**"))
.build(),
@@ -151,7 +151,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, TEST))
.build(),
@@ -187,7 +187,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.ENDS_WITH, "/test"))
.build(),
@@ -220,7 +220,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "GET"),
@@ -263,7 +263,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "POST"),
@@ -306,7 +306,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "PUT"),
@@ -349,7 +349,7 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
newSelectorBuilder("selector", Plugin.SPRING_CLOUD)
.handle(SpringCloudSelectorHandle.builder().serviceId("springCloud-test")
.gray(true)
- .divideUpstreams(divideUpstreams)
+ .divideUpstreams(DIVIDE_UPSTREAMS)
.build())
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "DELETE"),
@@ -382,9 +382,14 @@ public class SpringCloudPluginCases implements ShenYuScenarioProvider {
.afterEachSpec(ShenYuAfterEachSpec.DEFAULT)
.build();
}
-
- public static void verifierUri(String handle) throws JsonProcessingException {
- SpringCloudSelectorHandle springCloudSelectorHandle = mapper.readValue(handle, SpringCloudSelectorHandle.class);
+
+ /**
+ * verifier uri.
+ * @param handle handle
+ * @throws JsonProcessingException JsonProcessingException
+ */
+ public static void verifierUri(final String handle) throws JsonProcessingException {
+ SpringCloudSelectorHandle springCloudSelectorHandle = MAPPER.readValue(handle, SpringCloudSelectorHandle.class);
Assertions.assertEquals("springCloud-test", springCloudSelectorHandle.getServiceId());
Assertions.assertEquals(false, springCloudSelectorHandle.getGray());
DivideUpstream divideUpstream = springCloudSelectorHandle.getDivideUpstreams().get(0);
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginTest.java
index 1660b2d16..a57e87b61 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-spring-cloud/src/test/java/org/apache/shenyu/e2e/testcase/springcloud/SpringCloudPluginTest.java
@@ -63,21 +63,13 @@ import java.util.List;
@ShenYuTest.ServiceConfigure(
serviceName = "gateway",
port = 9195,
- baseUrl = "http://{hostname:localhost}:9195",
- type = ShenYuEngineConfigure.ServiceType.SHENYU_GATEWAY,
- parameters = {
- @ShenYuTest.Parameter(key = "application", value = "spring.cloud.discovery.enabled:true,eureka.client.enabled:true"),
- @ShenYuTest.Parameter(key = "dataSyn", value = "gateway_websocket")
- }
- )
- },
- dockerComposeFile = "classpath:./docker-compose.mysql.yml"
-)
+ baseUrl = "http://{hostname:localhost}:9195", type = ShenYuEngineConfigure.ServiceType.SHENYU_GATEWAY, parameters = {@ShenYuTest.Parameter(key = "application", value = "spring.cloud.discovery.enabled:true,eureka.client.enabled:true"), @ShenYuTest.Parameter(key = "dataSyn", value = "gateway_websocket")})}, dockerComposeFile = "classpath:./docker-compose.mysql.yml")
public class SpringCloudPluginTest {
- List<String> selectorIds = Lists.newArrayList();
-
+
+ private List<String> selectorIds = Lists.newArrayList();
+
@BeforeAll
- static void setup(AdminClient adminClient, GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
+ static void setup(final AdminClient adminClient, final GatewayClient gatewayClient) throws InterruptedException, JsonProcessingException {
adminClient.login();
Thread.sleep(10000);
List<SelectorDTO> selectorDTOList = adminClient.listAllSelectors();
@@ -86,13 +78,13 @@ public class SpringCloudPluginTest {
Assertions.assertEquals(2, selectorDTOList.size());
Assertions.assertEquals(13, metaDataDTOList.size());
Assertions.assertEquals(14, ruleDTOList.size());
-
- for (SelectorDTO selectorDTO :selectorDTOList) {
- if (selectorDTO.getHandle() != null && selectorDTO.getHandle() != "") {
+
+ for (SelectorDTO selectorDTO : selectorDTOList) {
+ if (selectorDTO.getHandle() != null && !"".equals(selectorDTO.getHandle())) {
SpringCloudPluginCases.verifierUri(selectorDTO.getHandle());
}
}
-
+
List<MetaData> metaDataCacheList = gatewayClient.getMetaDataCache();
List<SelectorCacheData> selectorCacheList = gatewayClient.getSelectorCache();
List<RuleCacheData> ruleCacheList = gatewayClient.getRuleCache();
@@ -101,16 +93,16 @@ public class SpringCloudPluginTest {
Assertions.assertEquals(14, ruleCacheList.size());
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
- formData.add("id","8");
- formData.add("name","springCloud");
- formData.add("enabled","true");
- formData.add("role","Proxy");
- formData.add("sort","200");
+ formData.add("id", "8");
+ formData.add("name", "springCloud");
+ formData.add("enabled", "true");
+ formData.add("role", "Proxy");
+ formData.add("sort", "200");
adminClient.startPlugin("8", formData);
String id = "";
- for (int i = 0; i < selectorDTOList.size(); i++) {
- if (selectorDTOList.get(i).getHandle() != "") {
- id = selectorDTOList.get(i).getId();
+ for (SelectorDTO selectorDTO : selectorDTOList) {
+ if (!"".equals(selectorDTO.getHandle())) {
+ id = selectorDTO.getId();
}
}
adminClient.deleteSelectors(id);
@@ -119,7 +111,7 @@ public class SpringCloudPluginTest {
}
@BeforeEach
- void before(AdminClient client, GatewayClient gateway, BeforeEachSpec spec) {
+ void before(final AdminClient client, final GatewayClient gateway, final BeforeEachSpec spec) {
spec.getChecker().check(gateway);
ResourcesData resources = spec.getResources();
@@ -137,26 +129,26 @@ public class SpringCloudPluginTest {
}
@ShenYuScenario(provider = SpringCloudPluginCases.class)
- void testSpringCloud(GatewayClient gateway, CaseSpec spec) {
+ void testSpringCloud(final GatewayClient gateway, final CaseSpec spec) {
spec.getVerifiers().forEach(verifier -> verifier.verify(gateway.getHttpRequesterSupplier().get()));
}
@AfterEach
- void before(AdminClient client, GatewayClient gateway, AfterEachSpec spec) {
+ void after(final AdminClient client, final GatewayClient gateway, final AfterEachSpec spec) {
spec.getDeleter().delete(client, selectorIds);
spec.getPostChecker().check(gateway);
selectorIds = Lists.newArrayList();
}
@AfterAll
- static void teardown(AdminClient client) {
+ static void teardown(final AdminClient client) {
client.deleteAllSelectors();
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
- formData.add("id","8");
- formData.add("name","springCloud");
- formData.add("enabled","false");
- formData.add("role","Proxy");
- formData.add("sort","200");
+ formData.add("id", "8");
+ formData.add("name", "springCloud");
+ formData.add("enabled", "false");
+ formData.add("role", "Proxy");
+ formData.add("sort", "200");
client.startPlugin("8", formData);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/ExternalServiceClient.java b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/ExternalServiceClient.java
index a293e197d..0fbc4d480 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/ExternalServiceClient.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/ExternalServiceClient.java
@@ -28,7 +28,7 @@ public class ExternalServiceClient {
private final Properties properties;
- public ExternalServiceClient(String url, Properties properties) {
+ public ExternalServiceClient(final String url, final Properties properties) {
this.url = url;
this.properties = properties;
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/admin/AdminClient.java b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/admin/AdminClient.java
index a4e0b5043..acbff7a5d 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/admin/AdminClient.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/admin/AdminClient.java
@@ -70,6 +70,21 @@ import static org.apache.shenyu.e2e.model.data.SearchCondition.QUERY_ALL;
public class AdminClient {
private static final Logger log = LoggerFactory.getLogger(AdminClient.class);
+
+ private static final TypeReference<PaginatedResources<PluginDTO>> PAGINATED_PLUGINS_TYPE_REFERENCE = new TypeReference<PaginatedResources<PluginDTO>>() {
+ };
+
+ private static final TypeReference<SearchedResources<SelectorDTO>> SEARCHED_SELECTORS_TYPE_REFERENCE = new TypeReference<SearchedResources<SelectorDTO>>() {
+ };
+
+ private static final TypeReference<SearchedResources<RuleDTO>> SEARCHED_RULES_TYPE_REFERENCE = new TypeReference<SearchedResources<RuleDTO>>() {
+ };
+
+ private static final TypeReference<SearchedResources<FakeResourceDTO>> FAKE_VALUE_TYPE = new TypeReference<SearchedResources<FakeResourceDTO>>() {
+ };
+
+ private static final TypeReference<List<MetaDataDTO>> SEARCHED_METADATAS_TYPE_REFERENCE = new TypeReference<List<MetaDataDTO>>() {
+ };
private final MultiValueMap<String, String> basicAuth = new HttpHeaders();
@@ -83,21 +98,7 @@ public class AdminClient {
private final ImmutableMap<String, String> loginInfo;
- private static final TypeReference<PaginatedResources<PluginDTO>> PAGINATED_PLUGINS_TYPE_REFERENCE = new TypeReference<PaginatedResources<PluginDTO>>() {
- };
- private static final TypeReference<SearchedResources<SelectorDTO>> SEARCHED_SELECTORS_TYPE_REFERENCE = new TypeReference<SearchedResources<SelectorDTO>>() {
- };
-
- private static final TypeReference<SearchedResources<RuleDTO>> SEARCHED_RULES_TYPE_REFERENCE = new TypeReference<SearchedResources<RuleDTO>>() {
- };
-
- private static final TypeReference<SearchedResources<FakeResourceDTO>> FAKE_VALUE_TYPE = new TypeReference<SearchedResources<FakeResourceDTO>>() {
- };
-
- private static final TypeReference<List<MetaDataDTO>> SEARCHED_METADATAS_TYPE_REFERENCE = new TypeReference<List<MetaDataDTO>>() {
- };
-
- public AdminClient(String scenarioId, String baseURL, Properties properties) {
+ public AdminClient(final String scenarioId, final String baseURL, final Properties properties) {
Preconditions.checkArgument(properties.containsKey("username"), "Property username does not exist");
Preconditions.checkArgument(properties.containsKey("password"), "Property password does not exist");
@@ -151,8 +152,8 @@ public class AdminClient {
ShenYuResult rst = assertAndGet(response, "query success");
PaginatedResources<PluginDTO> pagination = Assertions.assertDoesNotThrow(
- () -> mapper.readValue(rst.getData().traverse(), PAGINATED_PLUGINS_TYPE_REFERENCE),
- "checking cast to PaginatedResources<T>"
+ () -> mapper.readValue(rst.getData().traverse(), PAGINATED_PLUGINS_TYPE_REFERENCE),
+ "checking cast to PaginatedResources<T>"
);
result.addAll(pagination.getDataList());
@@ -184,12 +185,16 @@ public class AdminClient {
.build();
return list("/rule/list/search", condition, SEARCHED_RULES_TYPE_REFERENCE, v -> v);
}
-
+
+ /**
+ * all meta data list.
+ * @return List
+ */
public List<MetaDataDTO> listAllMetaData() {
return getMetaDataList("/meta-data/findAll", SEARCHED_METADATAS_TYPE_REFERENCE, v -> v);
}
- private <T extends ResourceDTO, OUT> List<OUT> list(String uri, QueryCondition condition, TypeReference<SearchedResources<T>> valueType, Mapper<T, OUT> mapper) {
+ private <T extends ResourceDTO, OUT> List<OUT> list(final String uri, final QueryCondition condition, final TypeReference<SearchedResources<T>> valueType, final Mapper<T, OUT> mapper) {
List<OUT> result = Lists.newArrayList();
int curPage = 1;
@@ -206,7 +211,7 @@ public class AdminClient {
return result;
}
- private <T extends ResourceDTO, OUT> List<OUT> getMetaDataList(String uri, TypeReference<List<T>> valueType, Mapper<T, OUT> mapper) {
+ private <T extends ResourceDTO, OUT> List<OUT> getMetaDataList(final String uri, final TypeReference<List<T>> valueType, final Mapper<T, OUT> mapper) {
List<OUT> result = Lists.newArrayList();
List<T> resources = getSearch(uri, valueType);
resources.stream()
@@ -217,12 +222,11 @@ public class AdminClient {
/**
* Fetch the selectors by the given conditions.
- *
* @param keyword expected selectors included the word. return all if absent.
* @param plugins expected selectors under specified plugins. return all if absent.
* @return paginated info with list of {@link SelectorDTO}s
*/
- public SearchedResources<SelectorDTO> searchSelectors(String keyword, String... plugins) {
+ public SearchedResources<SelectorDTO> searchSelectors(final String keyword, final String... plugins) {
SelectorQueryCondition condition = SelectorQueryCondition.builder()
.keyword(keyword)
.plugins(plugins)
@@ -233,12 +237,13 @@ public class AdminClient {
/**
* Fetch the selectors by the given conditions.
- *
* @param keyword expected selectors included the word. return all if absent.
+ * @param page page.
+ * @param pageSize size.
* @param plugins expected selectors under specified plugins. return all if absent.
* @return paginated info with list of {@link SelectorDTO}s
*/
- public SearchedResources<SelectorDTO> searchSelectors(String keyword, int page, int pageSize, String... plugins) {
+ public SearchedResources<SelectorDTO> searchSelectors(final String keyword, final int page, final int pageSize, final String... plugins) {
SelectorQueryCondition condition = SelectorQueryCondition.builder()
.keyword(keyword)
.plugins(plugins)
@@ -254,7 +259,7 @@ public class AdminClient {
* @param selectors expected selectors under specified plugins. return all if absent.
* @return paginated info with list of {@link RuleDTO}s
*/
- public SearchedResources<RuleDTO> searchRules(String keyword, String... selectors) {
+ public SearchedResources<RuleDTO> searchRules(final String keyword, final String... selectors) {
RuleQueryCondition condition = RuleQueryCondition.builder()
.keyword(keyword)
.selectors(selectors)
@@ -263,37 +268,43 @@ public class AdminClient {
return search("/rule/list/search", condition, SEARCHED_RULES_TYPE_REFERENCE);
}
- private <T extends ResourceDTO> SearchedResources<T> search(String uri, QueryCondition condition, TypeReference<SearchedResources<T>> valueType) {
+ private <T extends ResourceDTO> SearchedResources<T> search(final String uri, final QueryCondition condition, final TypeReference<SearchedResources<T>> valueType) {
return search(uri, 1, 10, condition, valueType);
}
- private <T extends ResourceDTO> SearchedResources<T> search(String uri, int pageNum, int pageSize, QueryCondition condition, TypeReference<SearchedResources<T>> valueType) {
+ private <T extends ResourceDTO> SearchedResources<T> search(final String uri, final int pageNum, final int pageSize,
+ final QueryCondition condition, final TypeReference<SearchedResources<T>> valueType) {
SearchCondition searchCondition = SearchCondition.builder()
- .pageNum(pageNum)
- .pageSize(pageSize)
- .condition(condition)
- .build();
+ .pageNum(pageNum)
+ .pageSize(pageSize)
+ .condition(condition)
+ .build();
HttpEntity<SearchCondition> entity = new HttpEntity<>(searchCondition, basicAuth);
ResponseEntity<ShenYuResult> response = template.postForEntity(baseURL + uri, entity, ShenYuResult.class);
ShenYuResult rst = assertAndGet(response, "query success");
-
+
return Assertions.assertDoesNotThrow(
- () -> mapper.readValue(rst.getData().traverse(), valueType),
- "checking cast to SearchedResources<T>"
+ () -> mapper.readValue(rst.getData().traverse(), valueType),
+ "checking cast to SearchedResources<T>"
);
}
- private <T extends ResourceDTO> List<T> getSearch(String uri, TypeReference<List<T>> valueType) {
+ private <T extends ResourceDTO> List<T> getSearch(final String uri, final TypeReference<List<T>> valueType) {
ResponseEntity<ShenYuResult> response = template.exchange(baseURL + uri, HttpMethod.GET, new HttpEntity<>(basicAuth), ShenYuResult.class);
ShenYuResult rst = assertAndGet(response, "query success");
return Assertions.assertDoesNotThrow(
- () -> mapper.readValue(rst.getData().traverse(), valueType),
- "checking cast to SearchedResources<T>"
+ () -> mapper.readValue(rst.getData().traverse(), valueType),
+ "checking cast to SearchedResources<T>"
);
}
-
- public SelectorDTO create(SelectorData selector) {
+
+ /**
+ * create selectorDTO.
+ * @param selector selector
+ * @return SelectorDTO
+ */
+ public SelectorDTO create(final SelectorData selector) {
SelectorDTO dto = create("/selector", selector);
Selectors.INSTANCE.put(selector.getName(), dto.getId());
return dto;
@@ -301,14 +312,17 @@ public class AdminClient {
/**
* Create Rule.
+ * @param rule rule
+ * @return RuleDTO
*/
- public RuleDTO create(RuleData rule) {
+ public RuleDTO create(final RuleData rule) {
RuleDTO dto = create("/rule", rule);
Rules.INSTANCE.put(rule.getName(), dto.getId());
return dto;
}
- private <T extends ResourceData, R extends ResourceDTO> R create(String uri, T data) {
+ @SuppressWarnings("unchecked")
+ private <T extends ResourceData, R extends ResourceDTO> R create(final String uri, final T data) {
log.info("trying to create resource({}) name: {}", data.getClass().getSimpleName(), data.getName());
data.setName(NameUtils.wrap(data.getName(), scenarioId));
@@ -322,7 +336,6 @@ public class AdminClient {
Assertions.assertEquals(200, rst.getCode(), "checking shenyu result code");
Assertions.assertEquals("create success", rst.getMessage(), "checking shenyu result message");
-
SearchedResources<?> searchedResources = null;
if (data instanceof SelectorData) {
searchedResources = searchSelectors(data.getName());
@@ -344,7 +357,7 @@ public class AdminClient {
*
* @param ids ID of selectors that needs to delete.
*/
- public void deleteSelectors(List<String> ids) {
+ public void deleteSelectors(final List<String> ids) {
delete("/selector/batch", ids);
}
@@ -353,7 +366,7 @@ public class AdminClient {
*
* @param ids ID of selectors that needs to delete.
*/
- public void deleteSelectors(String... ids) {
+ public void deleteSelectors(final String... ids) {
delete("/selector/batch", Lists.newArrayList(ids));
}
@@ -362,12 +375,12 @@ public class AdminClient {
*
* @param ids ID of rules that needs to delete.
*/
- public void deleteRules(String... ids) {
+ public void deleteRules(final String... ids) {
delete("/rule/batch", Lists.newArrayList(ids));
}
/**
- * Delete all selectors
+ * Delete all selectors.
*/
public void deleteAllSelectors() {
deleteAll("/selector/batch");
@@ -378,12 +391,12 @@ public class AdminClient {
*
* @param selectorId ID of selector
*/
- public void deleteAllRules(String selectorId) {
+ public void deleteAllRules(final String selectorId) {
List<String> ids = searchRules(null, selectorId).getList().stream().map(RuleDTO::getId).collect(Collectors.toList());
deleteRules(ids.toArray(new String[]{}));
}
- private void deleteAll(String uri) {
+ private void deleteAll(final String uri) {
Preconditions.checkArgument(uri.endsWith("/batch"), "uri[{}] must be end with '/batch'", uri);
String listAllResourcesUrl = uri.replace("/batch", "") + "/list/search";
@@ -394,7 +407,7 @@ public class AdminClient {
Assertions.assertEquals(0, result.size(), "resource list is empty after deleted");
}
- private void delete(String uri, List<String> ids) {
+ private void delete(final String uri, final List<String> ids) {
if (ids.isEmpty()) {
log.info("delete resources, effected size: 0, cause by: there is not resources in ShenYuAdmin");
return;
@@ -414,14 +427,14 @@ public class AdminClient {
* @param id of selector that needs to fetch
* @return {@link SelectorDTO}
*/
- public SelectorDTO getSelector(String id) {
+ public SelectorDTO getSelector(final String id) {
return getResource("/selector", id, SelectorDTO.class);
}
- private <T extends ResourceDTO> T getResource(String uri, String id, Class<T> valueType) {
+ private <T extends ResourceDTO> T getResource(final String uri, final String id, final Class<T> valueType) {
ResponseEntity<ShenYuResult> response = template.exchange(baseURL + uri + "/{id}", HttpMethod.GET, new HttpEntity<>(basicAuth), ShenYuResult.class, id);
Assertions.assertEquals(HttpStatus.OK, response.getStatusCode(), "checking http status");
-
+
ShenYuResult rst = response.getBody();
Assertions.assertNotNull(rst, "checking http response body");
@@ -429,13 +442,13 @@ public class AdminClient {
Assertions.assertTrue(rst.getMessage().contains("selector is not existed"), "checking shenyu result message");
return null;
}
-
+
Assertions.assertEquals("detail success", rst.getMessage(), "checking shenyu result message");
Assertions.assertEquals(200, rst.getCode(), "checking shenyu result code");
return Assertions.assertDoesNotThrow(() -> rst.toObject(valueType), "checking cast data to " + valueType.getSimpleName());
}
- private ShenYuResult assertAndGet(ResponseEntity<ShenYuResult> response, String message) {
+ private ShenYuResult assertAndGet(final ResponseEntity<ShenYuResult> response, final String message) {
Assertions.assertEquals(HttpStatus.OK, response.getStatusCode(), "checking http status");
ShenYuResult rst = response.getBody();
@@ -445,12 +458,17 @@ public class AdminClient {
return rst;
}
-
- public void startPlugin(String id, MultiValueMap<String, String> formData) {
+
+ /**
+ * start plugin.
+ * @param id id
+ * @param formData formData
+ */
+ public void startPlugin(final String id, final MultiValueMap<String, String> formData) {
putResource("/plugin", id, SelectorDTO.class, formData);
}
-
- private <T extends ResourceDTO> T putResource(String uri, String id, Class<T> valueType, MultiValueMap<String, String> formData) {
+
+ private <T extends ResourceDTO> T putResource(final String uri, final String id, final Class<T> valueType, final MultiValueMap<String, String> formData) {
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, basicAuth);
ResponseEntity<ShenYuResult> response = template.exchange(baseURL + uri + "/" + id, HttpMethod.PUT, requestEntity, ShenYuResult.class);
Assertions.assertEquals(HttpStatus.OK, response.getStatusCode(), "checking http status");
@@ -458,9 +476,9 @@ public class AdminClient {
Assertions.assertNotNull(rst, "checking http response body");
return Assertions.assertDoesNotThrow(() -> rst.toObject(valueType), "checking cast data to " + valueType.getSimpleName());
}
-
+
@FunctionalInterface
- interface Mapper<IN, OUT> extends Function<IN, OUT> {
+ interface Mapper<I, O> extends Function<I, O> {
}
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/gateway/GatewayClient.java b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/gateway/GatewayClient.java
index ff379bdec..87477fddf 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/gateway/GatewayClient.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/client/gateway/GatewayClient.java
@@ -50,17 +50,17 @@ public class GatewayClient {
private static final Logger log = LoggerFactory.getLogger(GatewayClient.class);
+ private static final RestTemplate TEMPLATE = new RestTemplateBuilder().build();
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
private final String scenarioId;
private final String baseUrl;
private final Properties properties;
- private static final RestTemplate template = new RestTemplateBuilder().build();
-
- private static final ObjectMapper mapper = new ObjectMapper();
-
- public GatewayClient(String scenarioId, String baseUrl, Properties properties) {
+ public GatewayClient(final String scenarioId, final String baseUrl, final Properties properties) {
this.scenarioId = scenarioId;
this.baseUrl = baseUrl;
this.properties = properties;
@@ -74,7 +74,11 @@ public class GatewayClient {
public String getBaseUrl() {
return baseUrl;
}
-
+
+ /**
+ * get http request specification.
+ * @return Supplier
+ */
public Supplier<RequestSpecification> getHttpRequesterSupplier() {
return () -> given().baseUri(getBaseUrl())
.filter((req, resp, ctx) -> {
@@ -96,44 +100,59 @@ public class GatewayClient {
})
.when();
}
-
+
+ /**
+ * get meta data cache.
+ * @return List List
+ * @throws JsonProcessingException JsonProcessingException
+ */
public List<MetaData> getMetaDataCache() throws JsonProcessingException {
- ResponseEntity<List> response = template.exchange(baseUrl + "/actuator/metadata", HttpMethod.GET, null, List.class);
+ ResponseEntity<List> response = TEMPLATE.exchange(baseUrl + "/actuator/metadata", HttpMethod.GET, null, List.class);
List body = response.getBody();
Map<String, MetaData> s = (Map<String, MetaData>) body.get(0);
List<MetaData> metaDataList = new ArrayList<>();
for (Map.Entry entry : s.entrySet()) {
- String json = mapper.writeValueAsString(entry.getValue());
- MetaData metaData = mapper.readValue(json, MetaData.class);
+ String json = MAPPER.writeValueAsString(entry.getValue());
+ MetaData metaData = MAPPER.readValue(json, MetaData.class);
metaDataList.add(metaData);
}
return metaDataList;
}
-
+
+ /**
+ * get selector cache.
+ * @return List List
+ * @throws JsonProcessingException JsonProcessingException
+ */
public List<SelectorCacheData> getSelectorCache() throws JsonProcessingException {
- ResponseEntity<List> response = template.exchange(baseUrl + "/actuator/selectorData", HttpMethod.GET, null, List.class);
+ ResponseEntity<List> response = TEMPLATE.exchange(baseUrl + "/actuator/selectorData", HttpMethod.GET, null, List.class);
List body = response.getBody();
Map<String, SelectorCacheData> s = (Map<String, SelectorCacheData>) body.get(0);
List<SelectorCacheData> selectorDataList = new ArrayList<>();
for (Map.Entry entry : s.entrySet()) {
List list = (List) entry.getValue();
- String json = mapper.writeValueAsString(list.get(0));
- SelectorCacheData selectorData = mapper.readValue(json, SelectorCacheData.class);
+ String json = MAPPER.writeValueAsString(list.get(0));
+ SelectorCacheData selectorData = MAPPER.readValue(json, SelectorCacheData.class);
selectorDataList.add(selectorData);
}
return selectorDataList;
}
-
+
+ /**
+ * get rule cache.
+ * @return List list
+ * @throws JsonProcessingException JsonProcessingException
+ */
public List<RuleCacheData> getRuleCache() throws JsonProcessingException {
- ResponseEntity<List> response = template.exchange(baseUrl + "/actuator/ruleData", HttpMethod.GET, null, List.class);
+ ResponseEntity<List> response = TEMPLATE.exchange(baseUrl + "/actuator/ruleData", HttpMethod.GET, null, List.class);
List body = response.getBody();
Map<String, RuleCacheData> s = (Map<String, RuleCacheData>) body.get(0);
List<RuleCacheData> ruleDataList = new ArrayList<>();
for (Map.Entry entry : s.entrySet()) {
List list = (List) entry.getValue();
for (int i = 0; i < list.size(); i++) {
- String json = mapper.writeValueAsString(list.get(i));
- RuleCacheData ruleData = mapper.readValue(json, RuleCacheData.class);
+ String json = MAPPER.writeValueAsString(list.get(i));
+ RuleCacheData ruleData = MAPPER.readValue(json, RuleCacheData.class);
ruleDataList.add(ruleData);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/RuleMatcher.java b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/RuleMatcher.java
index 02e0bcda9..601402811 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/RuleMatcher.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/RuleMatcher.java
@@ -43,18 +43,17 @@ public class RuleMatcher {
private final RuleData expected;
- public RuleMatcher(RuleData expected) {
+ public RuleMatcher(final RuleData expected) {
this.expected = expected;
}
/**
- *
- *
+ * match rule.
* @param actual actual
* @throws JsonProcessingException JsonProcessingException
* @throws JSONException JSONException
*/
- public void matches(RuleDTO actual) throws JsonProcessingException, JSONException {
+ public void matches(final RuleDTO actual) throws JsonProcessingException, JSONException {
String handle = actual.getHandle();
if (Objects.nonNull(expected.getHandle())) {
String expected = mapper.writer().writeValueAsString(this.expected.getHandle());
@@ -76,7 +75,7 @@ public class RuleMatcher {
assertThat(actual, hasProperty("dateUpdated", notNullValue()));
}
- public static RuleMatcher verify(RuleData expected) {
+ public static RuleMatcher verify(final RuleData expected) {
return new RuleMatcher(expected);
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/SelectorMatcher.java b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/SelectorMatcher.java
index 34af17bb3..f85aa5da4 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/SelectorMatcher.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/main/java/org/apache/shenyu/e2e/matcher/SelectorMatcher.java
@@ -37,15 +37,23 @@ import static org.hamcrest.Matchers.notNullValue;
/**
* Selector matcher.
*/
-public class SelectorMatcher {
+public final class SelectorMatcher {
+
private final ObjectMapper mapper = new ObjectMapper();
+
private final SelectorData expected;
- private SelectorMatcher(SelectorData expected) {
+ private SelectorMatcher(final SelectorData expected) {
this.expected = expected;
}
-
- public void matches(SelectorDTO actual) throws JsonProcessingException, JSONException {
+
+ /**
+ * match selector.
+ * @param actual actual
+ * @throws JsonProcessingException JsonProcessingException
+ * @throws JSONException JSONException
+ */
+ public void matches(final SelectorDTO actual) throws JsonProcessingException, JSONException {
String handle = actual.getHandle();
if (Objects.nonNull(expected.getHandle())) {
String expected = mapper.writer().writeValueAsString(this.expected.getHandle());
@@ -69,7 +77,7 @@ public class SelectorMatcher {
assertThat(actual, hasProperty("dateUpdated", notNullValue()));
}
- public static SelectorMatcher verify(SelectorData expected) {
+ public static SelectorMatcher verify(final SelectorData expected) {
return new SelectorMatcher(expected);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-client/src/test/java/org/apache/shenyu/e2e/client/admin/AdminClientTest.java b/shenyu-e2e/shenyu-e2e-client/src/test/java/org/apache/shenyu/e2e/client/admin/AdminClientTest.java
index ef0a25977..e83d842c0 100644
--- a/shenyu-e2e/shenyu-e2e-client/src/test/java/org/apache/shenyu/e2e/client/admin/AdminClientTest.java
+++ b/shenyu-e2e/shenyu-e2e-client/src/test/java/org/apache/shenyu/e2e/client/admin/AdminClientTest.java
@@ -62,20 +62,20 @@ public class AdminClientTest {
private static final Logger log = LoggerFactory.getLogger(AdminClientTest.class);
- static AdminClient client;
-
- static GenericContainer<?> container = new GenericContainer<>("shenyu/admin:latest")
+ private static AdminClient client;
+
+ private static final GenericContainer<?> CONTAINER = new GenericContainer<>("shenyu/admin:latest")
.withExposedPorts(9095)
.withLogConsumer(new Slf4jLogConsumer(log));
- SelectorDTO selector;
-
- RuleDTO rule;
+ private SelectorDTO selector;
+
+ private RuleDTO rule;
@BeforeAll
static void setup() {
- container.start();
- container.waitingFor(new HttpWaitStrategy()
+ CONTAINER.start();
+ CONTAINER.waitingFor(new HttpWaitStrategy()
.allowInsecure()
.forPort(9095)
.withMethod("GET")
@@ -88,7 +88,7 @@ public class AdminClientTest {
properties.put("username", "admin");
properties.put("password", "123456");
- client = new AdminClient("shenyu-e2e", "http://localhost:" + container.getMappedPort(9095), properties);
+ client = new AdminClient("shenyu-e2e", "http://localhost:" + CONTAINER.getMappedPort(9095), properties);
client.login();
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/annotation/ExternalService.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/annotation/ExternalService.java
index 05fc2db12..4d0e903c3 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/annotation/ExternalService.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/annotation/ExternalService.java
@@ -28,5 +28,10 @@ import java.lang.annotation.Target;
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExternalService {
+
+ /**
+ * service name.
+ * @return String
+ */
String serviceName() default "";
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdGenerator.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdGenerator.java
index 43ed5a489..89d8d519b 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdGenerator.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdGenerator.java
@@ -23,11 +23,19 @@ import java.time.LocalTime;
* Id Generator.
*/
public class IdGenerator {
-
+
+ /**
+ * generate scenario id.
+ * @return String id
+ */
public static String generateScenarioId() {
return Long.toHexString(LocalTime.now().toNanoOfDay());
}
+ /**
+ * generate test id.
+ * @return String id
+ */
public static String generateTestId() {
return Integer.toHexString(LocalTime.now().getNano());
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdManagers.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdManagers.java
index 202ee6892..6f1667a4c 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdManagers.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/IdManagers.java
@@ -36,21 +36,36 @@ public class IdManagers {
INSTANCE;
private BiMap<String, String> name2id;
- public void set(BiMap<String, String> name2id) {
+
+ /**
+ * set the name 2 id mapping BiMap.
+ * @param name2id name2id
+ */
+ public void set(final BiMap<String, String> name2id) {
this.name2id = name2id;
StringJoiner joiner = new StringJoiner(",");
- for (Map.Entry entry : name2id.entrySet()) {
- joiner.add(entry.getKey().toString());
+ for (Map.Entry<String, String> entry : name2id.entrySet()) {
+ joiner.add(entry.getKey());
}
log.info("plugin list: " + joiner);
}
- public String getIdByName(String name) {
+ /**
+ * get id by name.
+ * @param name name
+ * @return String
+ */
+ public String getIdByName(final String name) {
return this.name2id.get(name);
}
- public String getNameById(String id) {
+ /**
+ * get name by id.
+ * @param id id
+ * @return String
+ */
+ public String getNameById(final String id) {
return this.name2id.inverse().get(id);
}
}
@@ -58,17 +73,32 @@ public class IdManagers {
public enum Rules {
INSTANCE;
- private BiMap<String, String> name2id = HashBiMap.create();
-
- public void put(String name, String id) {
+ private final BiMap<String, String> name2id = HashBiMap.create();
+
+ /**
+ * put name and id into the biMap of the single instance.
+ * @param name name
+ * @param id id
+ */
+ public void put(final String name, final String id) {
name2id.put(name, id);
}
- public String getIdByName(String name) {
+ /**
+ * get id by name.
+ * @param name name
+ * @return String
+ */
+ public String getIdByName(final String name) {
return this.name2id.get(name);
}
- public String getNameById(String id) {
+ /**
+ * get name by id.
+ * @param id id
+ * @return String
+ */
+ public String getNameById(final String id) {
return this.name2id.inverse().get(id);
}
}
@@ -77,16 +107,31 @@ public class IdManagers {
INSTANCE;
private final BiMap<String, String> name2id = HashBiMap.create();
-
- public void put(String name, String id) {
+
+ /**
+ * put name and id into the biMap of the single instance.
+ * @param name name
+ * @param id id
+ */
+ public void put(final String name, final String id) {
name2id.put(name, id);
}
- public String getIdByName(String name) {
+ /**
+ * get id by name.
+ * @param name name
+ * @return String
+ */
+ public String getIdByName(final String name) {
return this.name2id.get(name);
}
- public String getNameById(String id) {
+ /**
+ * get name by id.
+ * @param id id
+ * @return String
+ */
+ public String getNameById(final String id) {
return this.name2id.inverse().get(id);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/NameUtils.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/NameUtils.java
index 1f4a9c113..e5b931618 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/NameUtils.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/NameUtils.java
@@ -22,7 +22,13 @@ package org.apache.shenyu.e2e.common;
*/
public class NameUtils {
- public static String wrap(String name, String scenarioId) {
+ /**
+ * wrap name and scenarioId to the format name.
+ * @param name name
+ * @param scenarioId scenarioId
+ * @return String
+ */
+ public static String wrap(final String name, final String scenarioId) {
return name + "-" + scenarioId + "-" + IdGenerator.generateTestId();
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/RequestLogConsumer.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/RequestLogConsumer.java
index b94ffa9dc..5c230c5a9 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/RequestLogConsumer.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/RequestLogConsumer.java
@@ -33,14 +33,20 @@ import java.util.Collections;
* Consume request log.
*/
public class RequestLogConsumer {
+
private static final OutputStream FAKE_STREAM = new OutputStream() {
@Override
- public void write(int b) throws IOException {
+ public void write(final int b) throws IOException {
}
};
- public static void print(Logger logger, FilterableRequestSpecification requestSpec) {
+ /**
+ * log request spec details.
+ * @param logger logger
+ * @param requestSpec requestSpec
+ */
+ public static void print(final Logger logger, final FilterableRequestSpecification requestSpec) {
String uri = UrlDecoder.urlDecode(
requestSpec.getURI(),
Charset.forName(requestSpec.getConfig().getEncoderConfig().defaultQueryParameterCharset()),
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/TableView.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/TableView.java
index 8ef0244d8..44e430d75 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/TableView.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/common/TableView.java
@@ -26,15 +26,15 @@ import java.util.List;
*/
public class TableView {
- private List<String[]> table = new ArrayList<>();
+ private final List<String[]> table = new ArrayList<>();
private final int sizeOfColumnsInRow;
private final String[] headers;
- private int[] maxContentLengthOfColumns;
+ private final int[] maxContentLengthOfColumns;
- public TableView(String... headers) {
+ public TableView(final String... headers) {
this.headers = headers;
this.sizeOfColumnsInRow = headers.length;
this.maxContentLengthOfColumns = new int[headers.length];
@@ -43,7 +43,12 @@ public class TableView {
}
}
- public TableView addRow(Object... row) {
+ /**
+ * add rows to table as columns.
+ * @param row row
+ * @return TableView
+ */
+ public TableView addRow(final Object... row) {
if (row.length > sizeOfColumnsInRow) {
throw new IllegalArgumentException(String.format("Expecting the size of row to be %d but was %s", sizeOfColumnsInRow, row.length));
}
@@ -55,6 +60,10 @@ public class TableView {
return this;
}
+ /**
+ * print table as string.
+ * @return String
+ */
public String printAsString() {
String[] template = new String[maxContentLengthOfColumns.length];
@@ -79,7 +88,7 @@ public class TableView {
return tableBuilder.toString().trim();
}
- private StringBuilder printHeaders(String[] headers, String[] template, StringBuilder separator) {
+ private StringBuilder printHeaders(final String[] headers, final String[] template, final StringBuilder separator) {
StringBuilder builder = new StringBuilder(separator);
for (int i = 0; i < headers.length; i++) {
builder.append("|").append(String.format(template[i], headers[i]));
@@ -88,7 +97,7 @@ public class TableView {
return builder;
}
- private StringBuilder printRow(String[] columns, String[] template, StringBuilder separator) {
+ private StringBuilder printRow(final String[] columns, final String[] template, final StringBuilder separator) {
StringBuilder rowBuilder = new StringBuilder();
for (int i = 0; i < columns.length; i++) {
rowBuilder.append("|").append(String.format(template[i], columns[i]));
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/MatchMode.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/MatchMode.java
index 7ab2bd85d..c54659de2 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/MatchMode.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/MatchMode.java
@@ -30,15 +30,23 @@ public enum MatchMode {
private final String id;
- MatchMode(int id) {
+ MatchMode(final int id) {
this.id = String.valueOf(id);
}
+ /**
+ * get id.
+ * @return String
+ */
@JsonValue
public String getId() {
return id;
}
+ /**
+ * get alias of match mode name.
+ * @return String
+ */
public String alias() {
return name().toLowerCase(Locale.ROOT);
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
index 54dd8ad21..a3e6513f2 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
@@ -70,31 +70,47 @@ public enum Plugin {
LOGGING_ALIYUN_SLS("loggingAliyunSls", 34),
LOGGING_TENCENT_CLS("loggingTencentCls", 36),
LOGGING_PULSAR("loggingPulsar", 35),
- LOGGING_CLICK_HOUSE("loggingClickHouse", 38),
- ;
+ LOGGING_CLICK_HOUSE("loggingClickHouse", 38);
+
private static final Logger log = LoggerFactory.getLogger(Plugin.class);
private final String id;
private final String alias;
- Plugin(String alias, int id) {
+ Plugin(final String alias, final int id) {
this.alias = alias;
this.id = String.valueOf(id);
}
+ /**
+ * id.
+ * @return String
+ */
@JsonValue
public String getId() {
return id;
}
+ /**
+ * get alias.
+ * @return String
+ */
public String getAlias() {
return alias;
}
+ /**
+ * alias 2 id map.
+ * @return Map<String, String> map.
+ */
public static Map<String, String> toMap() {
return Arrays.stream(Plugin.values()).collect(Collectors.toMap(Plugin::getAlias, Plugin::getId));
}
- public static void check(List<PluginDTO> plugins) {
+ /**
+ * check.
+ * @param plugins plugins
+ */
+ public static void check(final List<PluginDTO> plugins) {
StringBuilder builder = new StringBuilder();
Map<String, String> pluginMap = toMap();
AssertionError error = null;
@@ -115,7 +131,7 @@ public enum Plugin {
}
if (Objects.nonNull(error)) {
log.warn("please paste follow lines to org.apache.shenyu.e2e.client.admin.model.Plugin:{}", builder);
-// throw error; // TODO Don't throw it temporarily
+ // throw error; // TODO Don't throw it temporarily
}
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ResourcesData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ResourcesData.java
index 1356a286f..eaf7c2175 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ResourcesData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ResourcesData.java
@@ -27,18 +27,18 @@ import java.util.List;
/**
* ResourcesData.
*/
-public class ResourcesData {
+public final class ResourcesData {
private final List<Resource> resources;
- private ResourcesData(List<Resource> resources) {
+ private ResourcesData(final List<Resource> resources) {
this.resources = resources;
}
/**
* get resources.
*
- * @return
+ * @return List
*/
public List<Resource> getResources() {
return resources;
@@ -46,11 +46,15 @@ public class ResourcesData {
@Override
public String toString() {
- return "ResourcesData{" +
- "resources=" + resources +
- '}';
+ return "ResourcesData{"
+ + "resources=" + resources
+ + '}';
}
-
+
+ /**
+ * builder.
+ * @return ResourcesDataBuilder
+ */
public static ResourcesDataBuilder builder() {
return new ResourcesDataBuilder();
}
@@ -58,24 +62,33 @@ public class ResourcesData {
public static class ResourcesDataBuilder {
private final Builder<Resource> resources = ImmutableList.builder();
- public ResourcesDataBuilder add(SelectorData selector, RuleData... rules) {
+ /**
+ * add resource data.
+ * @param selector selector
+ * @param rules rules
+ * @return ResourcesDataBuilder
+ */
+ public ResourcesDataBuilder add(final SelectorData selector, final RuleData... rules) {
resources.add(new Resource(selector, ImmutableList.<RuleData>builder().add(rules).build()));
return this;
}
+ /**
+ * build.
+ * @return ResourcesData
+ */
public ResourcesData build() {
return new ResourcesData(resources.build());
}
}
-
- public static class Resource {
+ public static final class Resource {
private final SelectorData selector;
private final List<RuleData> rules;
- private Resource(SelectorData selector, List<RuleData> rules) {
+ private Resource(final SelectorData selector, final List<RuleData> rules) {
this.selector = selector;
this.rules = rules;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/SelectorType.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/SelectorType.java
index c53df07fa..08005607b 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/SelectorType.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/SelectorType.java
@@ -30,15 +30,23 @@ public enum SelectorType {
private final String id;
- SelectorType(int id) {
+ SelectorType(final int id) {
this.id = String.valueOf(id);
}
+ /**
+ * id.
+ * @return String
+ */
@JsonValue
public String getId() {
return id;
}
+ /**
+ * alias.
+ * @return String
+ */
public String alias() {
return name().toLowerCase(Locale.ROOT);
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ShenYuResult.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ShenYuResult.java
index 1458bbf34..81f478344 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ShenYuResult.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/ShenYuResult.java
@@ -26,6 +26,8 @@ import java.io.IOException;
* ShenYu result.
*/
public class ShenYuResult {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
private int code;
@@ -33,12 +35,17 @@ public class ShenYuResult {
private JsonNode data;
- private static final ObjectMapper mapper = new ObjectMapper();
-
- public <Data> Data toObject(Class<Data> type) throws IOException {
- return mapper.readValue(data.traverse(), type);
+ /**
+ * transform to data object.
+ * @param type type
+ * @param <DATA> target type
+ * @return Data
+ * @throws IOException IOException
+ */
+ public <DATA> DATA toObject(final Class<DATA> type) throws IOException {
+ return MAPPER.readValue(data.traverse(), type);
}
-
+
/**
* get code.
*
@@ -53,7 +60,7 @@ public class ShenYuResult {
*
* @param code code
*/
- public void setCode(int code) {
+ public void setCode(final int code) {
this.code = code;
}
@@ -71,7 +78,7 @@ public class ShenYuResult {
*
* @param message message
*/
- public void setMessage(String message) {
+ public void setMessage(final String message) {
this.message = message;
}
@@ -89,7 +96,7 @@ public class ShenYuResult {
*
* @param data data
*/
- public void setData(JsonNode data) {
+ public void setData(final JsonNode data) {
this.data = data;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/Condition.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/Condition.java
index 4bb873c88..2b2712130 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/Condition.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/Condition.java
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
/**
* The request condition.
*/
-public class Condition {
+public final class Condition {
@NotNull
private ParamType paramType;
@@ -68,7 +68,7 @@ public class Condition {
*
* @param alias alias
*/
- ParamType(String alias) {
+ ParamType(final String alias) {
this.alias = alias;
}
@@ -112,7 +112,7 @@ public class Condition {
*
* @param alias alias
*/
- Operator(String alias) {
+ Operator(final String alias) {
this.alias = alias;
}
@@ -153,7 +153,7 @@ public class Condition {
*
* @param paramType paramType
*/
- public void setParamType(ParamType paramType) {
+ public void setParamType(final @NotNull ParamType paramType) {
this.paramType = paramType;
}
@@ -162,7 +162,7 @@ public class Condition {
*
* @return paramType
*/
- public ParamType getParamType() {
+ public @NotNull ParamType getParamType() {
return paramType;
}
@@ -171,7 +171,7 @@ public class Condition {
*
* @param operator operator
*/
- public void setOperator(Operator operator) {
+ public void setOperator(final @NotNull Operator operator) {
this.operator = operator;
}
@@ -180,7 +180,7 @@ public class Condition {
*
* @return operator
*/
- public Operator getOperator() {
+ public @NotNull Operator getOperator() {
return operator;
}
@@ -189,7 +189,7 @@ public class Condition {
*
* @param paramName paramName
*/
- public void setParamName(String paramName) {
+ public void setParamName(final String paramName) {
this.paramName = paramName;
}
@@ -207,7 +207,7 @@ public class Condition {
*
* @param paramValue paramValue
*/
- public void setParamValue(String paramValue) {
+ public void setParamValue(final String paramValue) {
this.paramValue = paramValue;
}
@@ -284,7 +284,7 @@ public class Condition {
}
/**
- * build paramValue
+ * build paramValue.
*
* @param paramValue paramValue
* @return paramValue
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/MetaData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/MetaData.java
index b9d39da2a..537c5d6dd 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/MetaData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/MetaData.java
@@ -21,26 +21,59 @@ import org.apache.commons.lang3.StringUtils;
import java.util.Objects;
+/**
+ * meta data.
+ */
public class MetaData {
-
+
+ /**
+ * id.
+ */
private String id;
-
+
+ /**
+ * app name.
+ */
private String appName;
-
+
+ /**
+ * context path.
+ */
private String contextPath;
-
+
+ /**
+ * path.
+ */
private String path;
-
+
+ /**
+ * rpc type.
+ */
private String rpcType;
-
+
+ /**
+ * service name.
+ */
private String serviceName;
-
+
+ /**
+ * method name.
+ */
private String methodName;
-
+
+ /**
+ * parameter types.
+ */
private String parameterTypes;
-
+
+ /**
+ * rpc extends.
+ */
private String rpcExt;
-
+
+ /**
+ * enabled or not.
+ */
private Boolean enabled;
/**
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/PluginData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/PluginData.java
index 6118c5416..4107479d5 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/PluginData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/PluginData.java
@@ -24,12 +24,30 @@ import org.jetbrains.annotations.NotNull;
*/
public class PluginData {
+ /**
+ * id.
+ */
private String id;
+
+ /**
+ * name.
+ */
@NotNull
private String name;
+
+ /**
+ * config.
+ */
private String config;
+
+ /**
+ * role.
+ */
private String role;
- private boolean enabled;
+ /**
+ * enabled.
+ */
+ private Boolean enabled;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/QueryCondition.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/QueryCondition.java
index 439bd33ac..8ecfc528c 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/QueryCondition.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/QueryCondition.java
@@ -21,10 +21,22 @@ package org.apache.shenyu.e2e.model.data;
* the condition of query.
*/
public interface QueryCondition {
-
+
+ /**
+ * get excluded.
+ * @return String
+ */
String getExcluded();
-
+
+ /**
+ * get keyword.
+ * @return String
+ */
String getKeyword();
-
+
+ /**
+ * switch status.
+ * @return boolean
+ */
boolean isSwitchStatus();
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/ResourceData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/ResourceData.java
index d5be257a8..f9731cd60 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/ResourceData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/ResourceData.java
@@ -29,16 +29,28 @@ import java.io.IOException;
*/
public interface ResourceData {
+ /**
+ * gei id.
+ * @return String
+ */
String getId();
+ /**
+ * get name.
+ * @return String
+ */
String getName();
+ /**
+ * set resource name.
+ * @param name name
+ */
void setName(String name);
class IntToStringSerializer extends JsonSerializer<String> {
@Override
- public void serialize(String name, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final String name, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
String id = Selectors.INSTANCE.getIdByName(name);
jsonGenerator.writeString(id);
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleCacheData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleCacheData.java
index bd7aabe63..370ae399e 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleCacheData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleCacheData.java
@@ -26,33 +26,60 @@ import java.util.Objects;
* @since 2.0.0
*/
public class RuleCacheData {
-
+
+ /**
+ * id.
+ */
private String id;
-
+
+ /**
+ * name.
+ */
private String name;
-
+
+ /**
+ * plugin name.
+ */
private String pluginName;
-
+
+ /**
+ * selector id.
+ */
private String selectorId;
/**
- * match way(0 and 1 or).
+ * match way(0 or 1).
*/
private Integer matchMode;
-
+
+ /**
+ * sort.
+ */
private Integer sort;
-
+
+ /**
+ * enabled or not.
+ */
private Boolean enabled;
-
- private Boolean loged;
+
+ /**
+ * logged.
+ */
+ private Boolean logged;
/**
* handle message(different plugin have different handle to mark ,json style).
*/
private String handle;
-
+
+ /**
+ * condition data list.
+ */
private List<ConditionData> conditionDataList;
-
+
+ /**
+ * before condition list.
+ */
private List<ConditionData> beforeConditionDataList;
/**
@@ -79,7 +106,7 @@ public class RuleCacheData {
this.matchMode = builder.matchMode;
this.sort = builder.sort;
this.enabled = builder.enabled;
- this.loged = builder.loged;
+ this.logged = builder.loged;
this.handle = builder.handle;
this.conditionDataList = builder.conditionDataList;
this.beforeConditionDataList = builder.beforeConditionDataList;
@@ -240,18 +267,18 @@ public class RuleCacheData {
*
* @return loged
*/
- public Boolean getLoged() {
- return loged;
+ public Boolean getLogged() {
+ return logged;
}
/**
* set loged.
*
- * @param loged loged
+ * @param logged loged
* @return this
*/
- public RuleCacheData setLoged(final Boolean loged) {
- this.loged = loged;
+ public RuleCacheData setLogged(final Boolean logged) {
+ this.logged = logged;
return this;
}
@@ -347,7 +374,7 @@ public class RuleCacheData {
&& Objects.equals(matchMode, ruleCacheData.matchMode)
&& Objects.equals(sort, ruleCacheData.sort)
&& Objects.equals(enabled, ruleCacheData.enabled)
- && Objects.equals(loged, ruleCacheData.loged)
+ && Objects.equals(logged, ruleCacheData.logged)
&& Objects.equals(handle, ruleCacheData.handle)
&& Objects.equals(conditionDataList, ruleCacheData.conditionDataList)
&& Objects.equals(beforeConditionDataList, ruleCacheData.beforeConditionDataList)
@@ -356,7 +383,7 @@ public class RuleCacheData {
@Override
public int hashCode() {
- return Objects.hash(id, name, pluginName, selectorId, matchMode, sort, enabled, loged, handle, conditionDataList,
+ return Objects.hash(id, name, pluginName, selectorId, matchMode, sort, enabled, logged, handle, conditionDataList,
beforeConditionDataList, matchRestful);
}
@@ -382,7 +409,7 @@ public class RuleCacheData {
+ ", enabled="
+ enabled
+ ", loged="
- + loged
+ + logged
+ ", handle='"
+ handle
+ '\''
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleData.java
index 0a5e4cd09..7cf3c72cd 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleData.java
@@ -27,19 +27,34 @@ import java.util.List;
/**
* Rule data.
*/
-public class RuleData implements ResourceData {
+public final class RuleData implements ResourceData {
+ /**
+ * id.
+ */
private String id;
+ /**
+ * name.
+ */
private String name;
+ /**
+ * selector id.
+ */
private String selectorId;
@JsonProperty("loged")
private boolean logged;
+ /**
+ * match mode.
+ */
private MatchMode matchMode;
+ /**
+ * sort.
+ */
private int sort;
@JsonSerialize(using = RuleHandle.Serializer.class)
@@ -51,8 +66,14 @@ public class RuleData implements ResourceData {
@JsonProperty("ruleConditions")
private List<Condition> conditionList;
+ /**
+ * enabled or not.
+ */
private boolean enabled;
+ /**
+ * match restful or not.
+ */
private Boolean matchRestful;
/**
@@ -87,7 +108,7 @@ public class RuleData implements ResourceData {
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -107,7 +128,7 @@ public class RuleData implements ResourceData {
* @param name name
*/
@Override
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -126,7 +147,7 @@ public class RuleData implements ResourceData {
*
* @param selectorId selectorId
*/
- public void setSelectorId(String selectorId) {
+ public void setSelectorId(final String selectorId) {
this.selectorId = selectorId;
}
@@ -153,7 +174,7 @@ public class RuleData implements ResourceData {
*
* @param logged logged
*/
- public void setLogged(boolean logged) {
+ public void setLogged(final boolean logged) {
this.logged = logged;
}
@@ -162,7 +183,7 @@ public class RuleData implements ResourceData {
*
* @param matchMode matchMode
*/
- public void setMatchMode(MatchMode matchMode) {
+ public void setMatchMode(final MatchMode matchMode) {
this.matchMode = matchMode;
}
@@ -180,7 +201,7 @@ public class RuleData implements ResourceData {
*
* @param sort sort
*/
- public void setSort(int sort) {
+ public void setSort(final int sort) {
this.sort = sort;
}
@@ -198,7 +219,7 @@ public class RuleData implements ResourceData {
*
* @param handle handle
*/
- public void setHandle(RuleHandle handle) {
+ public void setHandle(final RuleHandle handle) {
this.handle = handle;
}
@@ -216,7 +237,7 @@ public class RuleData implements ResourceData {
*
* @param conditionList conditionList
*/
- public void conditionList(List<Condition> conditionList) {
+ public void conditionList(final List<Condition> conditionList) {
this.conditionList = conditionList;
}
@@ -234,7 +255,7 @@ public class RuleData implements ResourceData {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -252,7 +273,7 @@ public class RuleData implements ResourceData {
*
* @param matchRestful matchRestful
*/
- public void setMatchRestful(Boolean matchRestful) {
+ public void setMatchRestful(final Boolean matchRestful) {
this.matchRestful = matchRestful;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleQueryCondition.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleQueryCondition.java
index d4595d3d2..0491296d4 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleQueryCondition.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/RuleQueryCondition.java
@@ -21,37 +21,51 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Arrays;
+/**
+ * rule query condition.
+ */
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class RuleQueryCondition implements QueryCondition {
-
+public final class RuleQueryCondition implements QueryCondition {
+
+ /**
+ * excluded.
+ */
private String excluded;
-
+
+ /**
+ * keyword.
+ */
private String keyword;
-
+
+ /**
+ * selectors.
+ */
private String[] selectors;
-
+
+ /**
+ * status switch.
+ */
private boolean switchStatus;
-
+
/**
* builder constructor.
- *
* @param builder builder
*/
- private RuleQueryCondition (Builder builder) {
+ private RuleQueryCondition(final Builder builder) {
this.excluded = builder.excluded;
this.keyword = builder.keyword;
this.selectors = builder.selectors;
this.switchStatus = builder.switchStatus;
}
+
/**
* class builder.
- *
* @return Builder
*/
public static Builder builder() {
return new Builder();
}
-
+
/**
* get excluded.
*
@@ -60,16 +74,16 @@ public class RuleQueryCondition implements QueryCondition {
public String getExcluded() {
return excluded;
}
-
+
/**
* set excluded.
*
* @param excluded excluded
*/
- public void setExcluded(String excluded) {
+ public void setExcluded(final String excluded) {
this.excluded = excluded;
}
-
+
/**
* get keyword.
*
@@ -78,16 +92,16 @@ public class RuleQueryCondition implements QueryCondition {
public String getKeyword() {
return keyword;
}
-
+
/**
* set keyword.
*
* @param keyword keyword
*/
- public void setKeyword(String keyword) {
+ public void setKeyword(final String keyword) {
this.keyword = keyword;
}
-
+
/**
* get selectors.
*
@@ -96,16 +110,16 @@ public class RuleQueryCondition implements QueryCondition {
public String[] getSelectors() {
return selectors;
}
-
+
/**
* set selectors.
*
* @param selectors selectors
*/
- public void setSelectors(String[] selectors) {
+ public void setSelectors(final String[] selectors) {
this.selectors = selectors;
}
-
+
/**
* is switchStatus.
*
@@ -114,16 +128,16 @@ public class RuleQueryCondition implements QueryCondition {
public boolean isSwitchStatus() {
return switchStatus;
}
-
+
/**
* set switchStatus.
*
* @param switchStatus switchStatus
*/
- public void setSwitchStatus(boolean switchStatus) {
+ public void setSwitchStatus(final boolean switchStatus) {
this.switchStatus = switchStatus;
}
-
+
@Override
public String toString() {
return "RuleQueryCondition{"
@@ -139,27 +153,27 @@ public class RuleQueryCondition implements QueryCondition {
+ switchStatus
+ '}';
}
-
+
/**
* class builder.
*/
public static final class Builder {
-
+
private String excluded;
-
+
private String keyword;
-
+
private String[] selectors;
-
+
private boolean switchStatus;
-
+
/**
* no args constructor.
*/
private Builder() {
-
+
}
-
+
/**
* build new Object.
*
@@ -168,47 +182,47 @@ public class RuleQueryCondition implements QueryCondition {
public RuleQueryCondition build() {
return new RuleQueryCondition(this);
}
-
+
/**
* build excluded.
*
* @param excluded excluded
* @return this
*/
- public Builder excluded(String excluded) {
+ public Builder excluded(final String excluded) {
this.excluded = excluded;
return this;
}
-
+
/**
* build keyword.
*
* @param keyword keyword
* @return this
*/
- public Builder keyword(String keyword) {
+ public Builder keyword(final String keyword) {
this.keyword = keyword;
return this;
}
-
+
/**
* build selectors.
*
* @param selectors selectors
* @return this
*/
- public Builder selectors(String[] selectors) {
+ public Builder selectors(final String[] selectors) {
this.selectors = selectors;
return this;
}
-
+
/**
* build switchStatus.
*
* @param switchStatus switchStatus
* @return this
*/
- public Builder switchStatus(boolean switchStatus) {
+ public Builder switchStatus(final boolean switchStatus) {
this.switchStatus = switchStatus;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SearchCondition.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SearchCondition.java
index aa201bd53..5d6130ee5 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SearchCondition.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SearchCondition.java
@@ -24,15 +24,15 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
* The condition of searching.
*/
@JsonInclude(Include.NON_NULL)
-public class SearchCondition {
-
- public static QueryCondition QUERY_ALL = new QueryCondition() {
+public final class SearchCondition {
+ public static final QueryCondition QUERY_ALL = new QueryCondition() {
+
@Override
public String getExcluded() {
return null;
}
-
+
@Override
public String getKeyword() {
return null;
@@ -49,26 +49,25 @@ public class SearchCondition {
private int pageSize;
private QueryCondition condition;
-
- /**
- * class builder.
- *
- * @return Builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
+
/**
* builder constructor.
- *
* @param builder builder
*/
- private SearchCondition(Builder builder) {
+ private SearchCondition(final Builder builder) {
this.pageNum = builder.pageNum;
this.pageSize = builder.pageSize;
this.condition = builder.condition;
}
+
+ /**
+ * class builder.
+ *
+ * @return Builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
/**
* get pageNum.
@@ -84,7 +83,7 @@ public class SearchCondition {
*
* @param pageNum pageNum
*/
- public void setPageNum(int pageNum) {
+ public void setPageNum(final int pageNum) {
this.pageNum = pageNum;
}
@@ -102,7 +101,7 @@ public class SearchCondition {
*
* @param pageSize pageSize
*/
- public void setPageSize(int pageSize) {
+ public void setPageSize(final int pageSize) {
this.pageSize = pageSize;
}
@@ -120,7 +119,7 @@ public class SearchCondition {
*
* @param condition condition
*/
- public void setCondition(QueryCondition condition) {
+ public void setCondition(final QueryCondition condition) {
this.condition = condition;
}
@@ -168,7 +167,7 @@ public class SearchCondition {
* @param pageNum pageNum
* @return this
*/
- public Builder pageNum(int pageNum) {
+ public Builder pageNum(final int pageNum) {
this.pageNum = pageNum;
return this;
}
@@ -179,7 +178,7 @@ public class SearchCondition {
* @param pageSize pageSize
* @return this
*/
- public Builder pageSize(int pageSize) {
+ public Builder pageSize(final int pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -190,7 +189,7 @@ public class SearchCondition {
* @param condition condition
* @return this
*/
- public Builder condition(QueryCondition condition) {
+ public Builder condition(final QueryCondition condition) {
this.condition = condition;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorCacheData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorCacheData.java
index 30a6b619b..963300d2e 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorCacheData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorCacheData.java
@@ -22,51 +22,80 @@ import java.util.Objects;
/**
* SelectorData.
- *
* @since 2.0.0
*/
public class SelectorCacheData {
-
+
+ /**
+ * id.
+ */
private String id;
-
+
+ /**
+ * plugin id.
+ */
private String pluginId;
-
+
/**
* plugin name.
*/
private String pluginName;
-
+
+ /**
+ * select name.
+ */
private String name;
-
+
/**
* matchMode(0 and 1 or).
*/
private Integer matchMode;
-
+
/**
* type(false full,true custom).
*/
private Integer type;
-
+
+ /**
+ * sort.
+ */
private Integer sort;
-
+
+ /**
+ * enabled.
+ */
private Boolean enabled;
-
+
+ /**
+ * logged.
+ */
private Boolean logged;
-
+
+ /**
+ * continued.
+ */
private Boolean continued = Boolean.TRUE;
-
+
+ /**
+ * handle.
+ */
private String handle;
-
+
+ /**
+ * condition list.
+ */
private List<ConditionData> conditionList;
-
+
+ /**
+ * orginal condition list.
+ */
private List<ConditionData> beforeConditionList;
-
+
/**
* match restful api.
*/
private Boolean matchRestful;
-
+
/**
* no args constructor.
*/
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorData.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorData.java
index b8b4e31b8..5050200f0 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorData.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorData.java
@@ -35,8 +35,11 @@ import java.util.List;
/**
* selector data.
*/
-public class SelectorData implements ResourceData {
+public final class SelectorData implements ResourceData {
+ /**
+ * id.
+ */
private String id;
private String name;
@@ -109,7 +112,7 @@ public class SelectorData implements ResourceData {
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -129,7 +132,7 @@ public class SelectorData implements ResourceData {
* @param name name
*/
@Override
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -147,7 +150,7 @@ public class SelectorData implements ResourceData {
*
* @param plugin plugin
*/
- public void plugin(Plugin plugin) {
+ public void plugin(final Plugin plugin) {
this.plugin = plugin;
}
@@ -165,7 +168,7 @@ public class SelectorData implements ResourceData {
*
* @param type type
*/
- public void setType(SelectorType type) {
+ public void setType(final SelectorType type) {
this.type = type;
}
@@ -183,7 +186,7 @@ public class SelectorData implements ResourceData {
*
* @param matchMode matchMode
*/
- public void setMatchMode(MatchMode matchMode) {
+ public void setMatchMode(final MatchMode matchMode) {
this.matchMode = matchMode;
}
@@ -201,7 +204,7 @@ public class SelectorData implements ResourceData {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -219,7 +222,7 @@ public class SelectorData implements ResourceData {
*
* @param logged logged
*/
- public void setLogged(boolean logged) {
+ public void setLogged(final boolean logged) {
this.logged = logged;
}
@@ -237,7 +240,7 @@ public class SelectorData implements ResourceData {
*
* @param continued continued
*/
- public void setContinued(boolean continued) {
+ public void setContinued(final boolean continued) {
this.continued = continued;
}
@@ -255,7 +258,7 @@ public class SelectorData implements ResourceData {
*
* @param handle handle
*/
- public void handle(PluginHandle handle) {
+ public void handle(final PluginHandle handle) {
this.handle = handle;
}
@@ -273,7 +276,7 @@ public class SelectorData implements ResourceData {
*
* @param conditionList conditionList
*/
- public void conditionList(List<Condition> conditionList) {
+ public void conditionList(final List<Condition> conditionList) {
this.conditionList = conditionList;
}
@@ -291,7 +294,7 @@ public class SelectorData implements ResourceData {
*
* @param sort sort
*/
- public void setSort(int sort) {
+ public void setSort(final int sort) {
this.sort = sort;
}
@@ -309,16 +312,16 @@ public class SelectorData implements ResourceData {
*
* @param matchRestful matchRestful
*/
- public void setMatchRestful(boolean matchRestful) {
+ public void setMatchRestful(final boolean matchRestful) {
this.matchRestful = matchRestful;
}
static class PluginHandleSerializer extends JsonSerializer<PluginHandle> {
- private static final ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper MAPPER = new ObjectMapper();
@Override
- public void serialize(PluginHandle pluginHandle, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
- String content = mapper.writer().writeValueAsString(pluginHandle);
+ public void serialize(final PluginHandle pluginHandle, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
+ String content = MAPPER.writer().writeValueAsString(pluginHandle);
jsonGenerator.writeString(Strings.nullToEmpty(content));
}
}
@@ -378,7 +381,7 @@ public class SelectorData implements ResourceData {
* @param id id
* @return this
*/
- public SelectorDataBuilder id(String id) {
+ public SelectorDataBuilder id(final String id) {
this.id = id;
return this;
}
@@ -389,7 +392,7 @@ public class SelectorData implements ResourceData {
* @param name name
* @return this
*/
- public SelectorDataBuilder name(String name) {
+ public SelectorDataBuilder name(final String name) {
this.name = name;
return this;
}
@@ -400,7 +403,7 @@ public class SelectorData implements ResourceData {
* @param plugin plugin
* @return this
*/
- public SelectorDataBuilder plugin(Plugin plugin) {
+ public SelectorDataBuilder plugin(final Plugin plugin) {
this.plugin = plugin;
return this;
}
@@ -411,7 +414,7 @@ public class SelectorData implements ResourceData {
* @param type type
* @return this
*/
- public SelectorDataBuilder type(SelectorType type) {
+ public SelectorDataBuilder type(final SelectorType type) {
this.type = type;
return this;
}
@@ -422,7 +425,7 @@ public class SelectorData implements ResourceData {
* @param matchMode matchMode
* @return this
*/
- public SelectorDataBuilder matchMode(MatchMode matchMode) {
+ public SelectorDataBuilder matchMode(final MatchMode matchMode) {
this.matchMode = matchMode;
return this;
}
@@ -433,7 +436,7 @@ public class SelectorData implements ResourceData {
* @param enabled enabled
* @return this
*/
- public SelectorDataBuilder enabled(boolean enabled) {
+ public SelectorDataBuilder enabled(final boolean enabled) {
this.enabled = enabled;
return this;
}
@@ -444,7 +447,7 @@ public class SelectorData implements ResourceData {
* @param logged logged
* @return this
*/
- public SelectorDataBuilder logged(boolean logged) {
+ public SelectorDataBuilder logged(final boolean logged) {
this.logged = logged;
return this;
}
@@ -455,7 +458,7 @@ public class SelectorData implements ResourceData {
* @param continued continued
* @return this
*/
- public SelectorDataBuilder continued(boolean continued) {
+ public SelectorDataBuilder continued(final boolean continued) {
this.continued = continued;
return this;
}
@@ -466,7 +469,7 @@ public class SelectorData implements ResourceData {
* @param handle handle
* @return this
*/
- public SelectorDataBuilder handle(PluginHandle handle) {
+ public SelectorDataBuilder handle(final PluginHandle handle) {
this.handle = handle;
return this;
}
@@ -477,7 +480,7 @@ public class SelectorData implements ResourceData {
* @param conditionList conditionList
* @return this
*/
- public SelectorDataBuilder conditionList(List<Condition> conditionList) {
+ public SelectorDataBuilder conditionList(final List<Condition> conditionList) {
this.conditionList = conditionList;
return this;
}
@@ -488,7 +491,7 @@ public class SelectorData implements ResourceData {
* @param sort sort
* @return this
*/
- public SelectorDataBuilder sort(int sort) {
+ public SelectorDataBuilder sort(final int sort) {
this.sort = sort;
return this;
}
@@ -499,7 +502,7 @@ public class SelectorData implements ResourceData {
* @param matchRestful matchRestful
* @return this
*/
- public SelectorDataBuilder matchRestful(boolean matchRestful) {
+ public SelectorDataBuilder matchRestful(final boolean matchRestful) {
this.matchRestful = matchRestful;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorQueryCondition.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorQueryCondition.java
index 450a21171..a575f07cd 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorQueryCondition.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/data/SelectorQueryCondition.java
@@ -26,7 +26,7 @@ import java.util.Arrays;
* Selector query condition.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class SelectorQueryCondition implements QueryCondition {
+public final class SelectorQueryCondition implements QueryCondition {
private String excluded;
@@ -42,11 +42,11 @@ public class SelectorQueryCondition implements QueryCondition {
*
* @param builder builder
*/
- private SelectorQueryCondition(Builder builder) {
+ private SelectorQueryCondition(final Builder builder) {
this.excluded = builder.excluded;
this.keyword = builder.keyword;
this.plugins = builder.plugins;
- this.switchStatus = builder.switchStatus;
+ this.switchStatus = builder.switchStatus;
}
/**
@@ -73,7 +73,7 @@ public class SelectorQueryCondition implements QueryCondition {
*
* @param excluded excluded
*/
- public void setExcluded(String excluded) {
+ public void setExcluded(final String excluded) {
this.excluded = excluded;
}
@@ -92,7 +92,7 @@ public class SelectorQueryCondition implements QueryCondition {
*
* @param keyword keyword
*/
- public void setKeyword(String keyword) {
+ public void setKeyword(final String keyword) {
this.keyword = keyword;
}
@@ -110,7 +110,7 @@ public class SelectorQueryCondition implements QueryCondition {
*
* @param plugins plugins
*/
- public void setPlugins(String[] plugins) {
+ public void setPlugins(final String[] plugins) {
this.plugins = plugins;
}
@@ -129,7 +129,7 @@ public class SelectorQueryCondition implements QueryCondition {
*
* @param switchStatus switchStatus
*/
- public void setSwitchStatus(boolean switchStatus) {
+ public void setSwitchStatus(final boolean switchStatus) {
this.switchStatus = switchStatus;
}
@@ -185,7 +185,7 @@ public class SelectorQueryCondition implements QueryCondition {
* @param excluded excluded
* @return this
*/
- public Builder excluded(String excluded) {
+ public Builder excluded(final String excluded) {
this.excluded = excluded;
return this;
}
@@ -196,7 +196,7 @@ public class SelectorQueryCondition implements QueryCondition {
* @param keyword keyword
* @return this
*/
- public Builder keyword(String keyword) {
+ public Builder keyword(final String keyword) {
this.keyword = keyword;
return this;
}
@@ -207,7 +207,7 @@ public class SelectorQueryCondition implements QueryCondition {
* @param plugins plugins
* @return this
*/
- public Builder plugins(String[] plugins) {
+ public Builder plugins(final String[] plugins) {
this.plugins = plugins;
return this;
}
@@ -218,7 +218,7 @@ public class SelectorQueryCondition implements QueryCondition {
* @param switchStatus switchStatus
* @return this
*/
- public Builder switchStatus(boolean switchStatus) {
+ public Builder switchStatus(final boolean switchStatus) {
this.switchStatus = switchStatus;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideRuleHandle.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideRuleHandle.java
index 543692ea4..20b161063 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideRuleHandle.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideRuleHandle.java
@@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.util.Converter;
/**
* Divide rule handle.
*/
-public class DivideRuleHandle implements RuleHandle {
+public final class DivideRuleHandle implements RuleHandle {
private String loadBalance;
@@ -42,32 +42,11 @@ public class DivideRuleHandle implements RuleHandle {
private long requestMaxSize;
- static class IntConverter implements Converter<Integer, String> {
- private static final JavaType _IN = SimpleType.constructUnsafe(int.class);
- private static final JavaType _OUT = ReferenceType.constructUnsafe(String.class);
-
- @Override
- public String convert(Integer integer) {
- return String.valueOf(integer);
- }
-
- @Override
- public JavaType getInputType(TypeFactory typeFactory) {
- return _IN;
- }
-
- @Override
- public JavaType getOutputType(TypeFactory typeFactory) {
- return _OUT;
- }
- }
-
/**
* builder constructor.
- *
* @param builder builder
*/
- private DivideRuleHandle(Builder builder) {
+ private DivideRuleHandle(final Builder builder) {
this.loadBalance = builder.loadBalance;
this.retryStrategy = builder.retryStrategy;
this.retry = builder.retry;
@@ -75,124 +54,133 @@ public class DivideRuleHandle implements RuleHandle {
this.headerMaxSize = builder.headerMaxSize;
this.requestMaxSize = builder.requestMaxSize;
}
-
+
/**
* class builder.
- *
* @return Builder
*/
public static Builder builder() {
return new Builder();
}
-
+
/**
* get loadBalance.
- *
* @return loadBalance
*/
public String getLoadBalance() {
return loadBalance;
}
-
+
/**
* set loadBalance.
- *
* @param loadBalance loadBalance
*/
- public void setLoadBalance(String loadBalance) {
+ public void setLoadBalance(final String loadBalance) {
this.loadBalance = loadBalance;
}
-
+
/**
* get retryStrategy.
- *
* @return retryStrategy
*/
public String getRetryStrategy() {
return retryStrategy;
}
-
+
/**
* set retryStrategy.
- *
* @param retryStrategy retryStrategy
*/
- public void setRetryStrategy(String retryStrategy) {
+ public void setRetryStrategy(final String retryStrategy) {
this.retryStrategy = retryStrategy;
}
-
+
/**
* get retry.
- *
* @return retry
*/
public int getRetry() {
return retry;
}
-
+
/**
* set retry.
- *
* @param retry retry
*/
- public void setRetry(int retry) {
+ public void setRetry(final int retry) {
this.retry = retry;
}
-
+
/**
* get timeout.
- *
* @return timeout
*/
public long getTimeout() {
return timeout;
}
-
+
/**
* set timeout.
- *
* @param timeout timeout
*/
- public void setTimeout(long timeout) {
+ public void setTimeout(final long timeout) {
this.timeout = timeout;
}
-
+
/**
* get headerMaxSize.
- *
* @return headerMaxSize
*/
public long getHeaderMaxSize() {
return headerMaxSize;
}
-
+
/**
* set headerMaxSize.
- *
- * @param headerMaxSize
+ * @param headerMaxSize headerMaxSize
*/
- public void setHeaderMaxSize(long headerMaxSize) {
+ public void setHeaderMaxSize(final long headerMaxSize) {
this.headerMaxSize = headerMaxSize;
}
-
+
/**
* get requestMaxSize.
- *
* @return requestMaxSize
*/
public long getRequestMaxSize() {
return requestMaxSize;
}
-
+
/**
* set requestMaxSize.
- *
* @param requestMaxSize requestMaxSize
*/
- public void setRequestMaxSize(long requestMaxSize) {
+ public void setRequestMaxSize(final long requestMaxSize) {
this.requestMaxSize = requestMaxSize;
}
-
+
+ static class IntConverter implements Converter<Integer, String> {
+
+ private static final JavaType IN = SimpleType.constructUnsafe(int.class);
+
+ private static final JavaType OUT = ReferenceType.constructUnsafe(String.class);
+
+ @Override
+ public String convert(final Integer integer) {
+ return String.valueOf(integer);
+ }
+
+ @Override
+ public JavaType getInputType(final TypeFactory typeFactory) {
+ return IN;
+ }
+
+ @Override
+ public JavaType getOutputType(final TypeFactory typeFactory) {
+ return OUT;
+ }
+ }
+
/**
* class builder.
*/
@@ -233,7 +221,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param loadBalance loadBalance
* @return this
*/
- public Builder loadBalance(String loadBalance) {
+ public Builder loadBalance(final String loadBalance) {
this.loadBalance = loadBalance;
return this;
}
@@ -244,7 +232,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param retryStrategy retryStrategy
* @return this
*/
- public Builder retryStrategy(String retryStrategy) {
+ public Builder retryStrategy(final String retryStrategy) {
this.retryStrategy = retryStrategy;
return this;
}
@@ -255,7 +243,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param retry retry
* @return this
*/
- public Builder retry(int retry) {
+ public Builder retry(final int retry) {
this.retry = retry;
return this;
}
@@ -266,7 +254,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param timeout timeout
* @return this
*/
- public Builder timeout(long timeout) {
+ public Builder timeout(final long timeout) {
this.timeout = timeout;
return this;
}
@@ -277,7 +265,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param headerMaxSize headerMaxSize
* @return this
*/
- public Builder headerMaxSize(long headerMaxSize) {
+ public Builder headerMaxSize(final long headerMaxSize) {
this.headerMaxSize = headerMaxSize;
return this;
}
@@ -288,7 +276,7 @@ public class DivideRuleHandle implements RuleHandle {
* @param requestMaxSize requestMaxSize
* @return this
*/
- public Builder requestMaxSize(long requestMaxSize) {
+ public Builder requestMaxSize(final long requestMaxSize) {
this.requestMaxSize = requestMaxSize;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideUpstream.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideUpstream.java
index 34538d50e..9eef26e8d 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideUpstream.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/DivideUpstream.java
@@ -51,16 +51,16 @@ public class DivideUpstream {
* warmup.
*/
private int warmup;
-
+
/**
* upstreamHost.
*/
private String upstreamHost;
-
+
private DivideUpstream() {
}
-
- public DivideUpstream(Builder builder) {
+
+ public DivideUpstream(final Builder builder) {
this.protocol = builder.protocol;
this.upstreamUrl = builder.upstreamUrl;
this.timestamp = builder.timestamp;
@@ -69,29 +69,31 @@ public class DivideUpstream {
this.status = builder.status;
this.upstreamHost = builder.upstreamHost;
}
-
+
+ /**
+ * builder.
+ * @return Builder
+ */
public static Builder builder() {
return new Builder();
}
-
+
/**
* get protocol.
- *
* @return protocol
*/
public String getProtocol() {
return protocol;
}
-
+
/**
* set protocol.
- *
* @param protocol protocol
*/
- public void setProtocol(String protocol) {
+ public void setProtocol(final String protocol) {
this.protocol = protocol;
}
-
+
/**
* get upstreamUrl.
*
@@ -100,19 +102,17 @@ public class DivideUpstream {
public String getUpstreamUrl() {
return upstreamUrl;
}
-
+
/**
* set upstreamUrl.
- *
* @param upstreamUrl upstreamUrl
*/
- public void setUpstreamUrl(String upstreamUrl) {
+ public void setUpstreamUrl(final String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
}
-
+
/**
* get timestamp.
- *
* @return timestamp
*/
public long getTimestamp() {
@@ -120,14 +120,13 @@ public class DivideUpstream {
}
/**
- * set timestamp
- *
+ * set timestamp.
* @param timestamp timestamp
*/
- public void setTimestamp(long timestamp) {
+ public void setTimestamp(final long timestamp) {
this.timestamp = timestamp;
}
-
+
/**
* get weight.
*
@@ -142,10 +141,10 @@ public class DivideUpstream {
*
* @param weight weight
*/
- public void setWeight(int weight) {
+ public void setWeight(final int weight) {
this.weight = weight;
}
-
+
/**
* get warmup.
*
@@ -160,10 +159,10 @@ public class DivideUpstream {
*
* @param warmup warmup
*/
- public void setWarmup(int warmup) {
+ public void setWarmup(final int warmup) {
this.warmup = warmup;
}
-
+
/**
* is status.
*
@@ -172,29 +171,36 @@ public class DivideUpstream {
public boolean isStatus() {
return status;
}
-
+
/**
* set status.
- *
* @param status status
*/
- public void setStatus(boolean status) {
+ public void setStatus(final boolean status) {
this.status = status;
}
-
+
+ /**
+ * get host of a upstream.
+ * @return String
+ */
public String getUpstreamHost() {
return upstreamHost;
}
-
- public void setUpstreamHost(String upstreamHost) {
+
+ /**
+ * set host of a upstream.
+ * @param upstreamHost upstreamHost
+ */
+ public void setUpstreamHost(final String upstreamHost) {
this.upstreamHost = upstreamHost;
}
-
+
/**
* class builder.
*/
public static final class Builder {
-
+
/**
* this is http protocol.
*/
@@ -219,88 +225,95 @@ public class DivideUpstream {
* warmup.
*/
private int warmup;
-
+
private boolean status;
-
+
/**
* upstreamHost.
*/
private String upstreamHost;
-
+
public Builder() {
}
-
+
+ /**
+ * build.
+ * @return DivideUpstream
+ */
public DivideUpstream build() {
return new DivideUpstream(this);
}
-
+
/**
* build protocol.
- *
* @param protocol protocol
* @return this
*/
- public Builder protocol(String protocol) {
+ public Builder protocol(final String protocol) {
this.protocol = protocol;
return this;
}
-
+
/**
* build upstreamUrl.
*
* @param upstreamUrl upstreamUrl
* @return this
*/
- public Builder upstreamUrl(String upstreamUrl) {
+ public Builder upstreamUrl(final String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
return this;
}
-
+
/**
* build timestamp.
*
* @param timestamp timestamp
* @return this
*/
- public Builder timestamp(long timestamp) {
+ public Builder timestamp(final long timestamp) {
this.timestamp = timestamp;
return this;
}
-
+
/**
* build weight.
*
* @param weight weight
* @return this
*/
- public Builder weight(int weight) {
+ public Builder weight(final int weight) {
this.weight = weight;
return this;
}
-
+
/**
* build warmup.
*
* @param warmup warmup
* @return this
*/
- public Builder warmup(int warmup) {
+ public Builder warmup(final int warmup) {
this.warmup = warmup;
return this;
}
-
+
/**
- * build status
- *
+ * build status.
* @param status status
* @return this
*/
- public Builder status(boolean status) {
+ public Builder status(final boolean status) {
this.status = status;
return this;
}
-
- public Builder upstreamHost(String upstreamHost) {
+
+ /**
+ * set host of a upstream builder.
+ * @param upstreamHost upstreamHost
+ * @return Builder
+ */
+ public Builder upstreamHost(final String upstreamHost) {
this.upstreamHost = upstreamHost;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/RuleHandle.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/RuleHandle.java
index 940be1e1c..7027344a6 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/RuleHandle.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/RuleHandle.java
@@ -30,7 +30,7 @@ public interface RuleHandle {
private final ObjectMapper mapper = new ObjectMapper();
@Override
- public void serialize(RuleHandle ruleHandle, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final RuleHandle ruleHandle, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(mapper.writeValueAsString(ruleHandle));
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/SpringCloudRuleHandle.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/SpringCloudRuleHandle.java
index 0b433db7f..9844ddafd 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/SpringCloudRuleHandle.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/SpringCloudRuleHandle.java
@@ -34,12 +34,16 @@ public class SpringCloudRuleHandle implements RuleHandle {
public SpringCloudRuleHandle() {
}
- public SpringCloudRuleHandle(Builder builder) {
+ public SpringCloudRuleHandle(final Builder builder) {
this.loadBalance = builder.loadBalance;
this.path = builder.path;
this.timeout = builder.timeout;
}
-
+
+ /**
+ * builder.
+ * @return Builder
+ */
public static Builder builder() {
return new Builder();
}
@@ -58,7 +62,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
*
* @param loadBalance loadBalance
*/
- public void setLoadBalance(String loadBalance) {
+ public void setLoadBalance(final String loadBalance) {
this.loadBalance = loadBalance;
}
@@ -76,7 +80,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
*
* @param path path
*/
- public void setPath(String path) {
+ public void setPath(final String path) {
this.path = path;
}
@@ -94,7 +98,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
*
* @param timeout timeout
*/
- public void setTimeout(long timeout) {
+ public void setTimeout(final long timeout) {
this.timeout = timeout;
}
@@ -114,7 +118,11 @@ public class SpringCloudRuleHandle implements RuleHandle {
*/
private Builder() {
}
-
+
+ /**
+ * build.
+ * @return SpringCloudRuleHandle
+ */
public SpringCloudRuleHandle build() {
return new SpringCloudRuleHandle(this);
}
@@ -125,7 +133,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
* @param loadBalance loadBalance
* @return this
*/
- public Builder loadBalance(String loadBalance) {
+ public Builder loadBalance(final String loadBalance) {
this.loadBalance = loadBalance;
return this;
}
@@ -136,7 +144,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
* @param path path
* @return this
*/
- public Builder path(String path) {
+ public Builder path(final String path) {
this.path = path;
return this;
}
@@ -147,7 +155,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
* @param timeout timeout
* @return this
*/
- public Builder timeout(long timeout) {
+ public Builder timeout(final long timeout) {
this.timeout = timeout;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/Upstreams.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/Upstreams.java
index 69bc6db58..0d854f0ef 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/Upstreams.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/handle/Upstreams.java
@@ -36,7 +36,7 @@ public class Upstreams implements PluginHandle {
private List<Upstream> upstreams;
- Upstreams(List<Upstream> upstreams) {
+ Upstreams(final List<Upstream> upstreams) {
this.upstreams = upstreams;
}
@@ -61,7 +61,7 @@ public class Upstreams implements PluginHandle {
/**
* class upstream.
*/
- public static class Upstream {
+ public static final class Upstream {
private String upstreamUrl;
@@ -70,7 +70,7 @@ public class Upstreams implements PluginHandle {
*
* @param builder builder
*/
- private Upstream(Builder builder) {
+ private Upstream(final Builder builder) {
this.upstreamUrl = builder.upstreamUrl;
}
@@ -97,7 +97,7 @@ public class Upstreams implements PluginHandle {
*
* @param upstreamUrl upstreamUrl
*/
- public void setUpstreamUrl(String upstreamUrl) {
+ public void setUpstreamUrl(final String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
}
@@ -129,7 +129,7 @@ public class Upstreams implements PluginHandle {
* @param upstreamUrl upstreamUrl
* @return this
*/
- public Builder upstreamUrl(String upstreamUrl) {
+ public Builder upstreamUrl(final String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
return this;
}
@@ -141,19 +141,23 @@ public class Upstreams implements PluginHandle {
*/
public static final class Builder {
- private List<Upstream> upstreams = Lists.newArrayList();
+ private final List<Upstream> upstreams = Lists.newArrayList();
/**
* add upstream.
*
- * @param upstream
+ * @param upstream upstream
* @return this
*/
- public Builder add(Upstream upstream) {
+ public Builder add(final Upstream upstream) {
upstreams.add(upstream);
return this;
}
+ /**
+ * build.
+ * @return Upstreams
+ */
public Upstreams build() {
return new Upstreams(this.upstreams);
}
@@ -163,7 +167,7 @@ public class Upstreams implements PluginHandle {
private final ObjectMapper mapper = new ObjectMapper();
@Override
- public void serialize(Upstreams upstreams, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final Upstreams upstreams, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeRaw(mapper.writer().writeValueAsString(upstreams.upstreams));
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/FakeResourceDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/FakeResourceDTO.java
index c4cc8fcd9..375025949 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/FakeResourceDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/FakeResourceDTO.java
@@ -25,7 +25,7 @@ import java.util.Date;
* Fake resourceDTO.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public class FakeResourceDTO implements ResourceDTO{
+public class FakeResourceDTO implements ResourceDTO {
private String id;
@@ -56,7 +56,7 @@ public class FakeResourceDTO implements ResourceDTO{
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -75,7 +75,7 @@ public class FakeResourceDTO implements ResourceDTO{
*
* @param name name
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/LoginInfo.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/LoginInfo.java
index bc7a73227..a95b8b96a 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/LoginInfo.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/LoginInfo.java
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class LoginInfo {
+
@JsonAlias("userName")
private String username;
@@ -48,7 +49,7 @@ public class LoginInfo {
*
* @param username username
*/
- public void setUsername(String username) {
+ public void setUsername(final String username) {
this.username = username;
}
@@ -66,7 +67,7 @@ public class LoginInfo {
*
* @param token token
*/
- public void setToken(String token) {
+ public void setToken(final String token) {
this.token = token;
}
@@ -84,7 +85,7 @@ public class LoginInfo {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -102,7 +103,7 @@ public class LoginInfo {
*
* @param expiredTime expiredTime
*/
- public void setExpiredTime(long expiredTime) {
+ public void setExpiredTime(final long expiredTime) {
this.expiredTime = expiredTime;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/MetaDataDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/MetaDataDTO.java
index 0fcaeeb19..7b8b40590 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/MetaDataDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/MetaDataDTO.java
@@ -22,9 +22,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
- * MetaDataDTO
+ * MetaDataDTO.
*/
-public class MetaDataDTO implements ResourceDTO {
+public final class MetaDataDTO implements ResourceDTO {
/**
* appName.
@@ -79,7 +79,7 @@ public class MetaDataDTO implements ResourceDTO {
private MetaDataDTO() {
}
- private MetaDataDTO(Builder builder) {
+ private MetaDataDTO(final Builder builder) {
this.appName = builder.appName;
this.path = builder.path;
this.pathDesc = builder.pathDesc;
@@ -93,72 +93,140 @@ public class MetaDataDTO implements ResourceDTO {
this.dateUpdated = builder.dateUpdated;
this.enabled = builder.enabled;
}
-
+
+ /**
+ * builder.
+ * @return Builder
+ */
public static Builder builder() {
return new Builder();
}
-
+
+ /**
+ * get app name.
+ * @return String
+ */
public String getAppName() {
- return appName;
+ return this.appName;
}
-
- public void setAppName(String appName) {
+
+ /**
+ * app name.
+ * @param appName appName
+ */
+ public void setAppName(final String appName) {
this.appName = appName;
}
-
+
+ /**
+ * path.
+ * @return String
+ */
public String getPath() {
return path;
}
-
- public void setPath(String path) {
+
+ /**
+ * set path.
+ * @param path path
+ */
+ public void setPath(final String path) {
this.path = path;
}
-
+
+ /**
+ * path describe.
+ * @return String
+ */
public String getPathDesc() {
return pathDesc;
}
-
- public void setPathDesc(String pathDesc) {
+
+ /**
+ * path describe.
+ * @param pathDesc pathDesc
+ */
+ public void setPathDesc(final String pathDesc) {
this.pathDesc = pathDesc;
}
-
+
+ /**
+ * rpc type.
+ * @return String
+ */
public String getRpcType() {
return rpcType;
}
-
- public void setRpcType(String rpcType) {
+
+ /**
+ * rpc type.
+ * @param rpcType rpcType
+ */
+ public void setRpcType(final String rpcType) {
this.rpcType = rpcType;
}
-
+
+ /**
+ * service name.
+ * @return String
+ */
public String getServiceName() {
return serviceName;
}
-
- public void setServiceName(String serviceName) {
+
+ /**
+ * service name.
+ * @param serviceName serviceName
+ */
+ public void setServiceName(final String serviceName) {
this.serviceName = serviceName;
}
-
+
+ /**
+ * method name.
+ * @return String
+ */
public String getMethodName() {
return methodName;
}
-
- public void setMethodName(String methodName) {
+
+ /**
+ * method name.
+ * @param methodName methodName
+ */
+ public void setMethodName(final String methodName) {
this.methodName = methodName;
}
-
+
+ /**
+ * parameter types.
+ * @return String
+ */
public String getParameterTypes() {
return parameterTypes;
}
-
- public void setParameterTypes(String parameterTypes) {
+
+ /**
+ * parameter types.
+ * @param parameterTypes parameterTypes
+ */
+ public void setParameterTypes(final String parameterTypes) {
this.parameterTypes = parameterTypes;
}
-
+
+ /**
+ * rpc extends.
+ * @return String
+ */
public String getRpcExt() {
return rpcExt;
}
-
- public void setRpcExt(String rpcExt) {
+
+ /**
+ * rpc extends.
+ * @param rpcExt rpcExt
+ */
+ public void setRpcExt(final String rpcExt) {
this.rpcExt = rpcExt;
}
@@ -171,8 +239,12 @@ public class MetaDataDTO implements ResourceDTO {
public String getName() {
return null;
}
-
- public void setId(String id) {
+
+ /**
+ * id.
+ * @param id id
+ */
+ public void setId(final String id) {
this.id = id;
}
@@ -180,8 +252,12 @@ public class MetaDataDTO implements ResourceDTO {
public Date getDateCreated() {
return dateCreated;
}
-
- public void setDateCreated(Date dateCreated) {
+
+ /**
+ * create date.
+ * @param dateCreated dateCreated
+ */
+ public void setDateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
}
@@ -189,16 +265,28 @@ public class MetaDataDTO implements ResourceDTO {
public Date getDateUpdated() {
return dateUpdated;
}
-
- public void setDateUpdated(Date dateUpdated) {
+
+ /**
+ * update date.
+ * @param dateUpdated dateUpdated
+ */
+ public void setDateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
}
-
+
+ /**
+ * enabled.
+ * @return boolean
+ */
public boolean isEnabled() {
return enabled;
}
-
- public void setEnabled(boolean enabled) {
+
+ /**
+ * enabled.
+ * @param enabled enabled
+ */
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -256,67 +344,131 @@ public class MetaDataDTO implements ResourceDTO {
private Builder() {
}
-
+
+ /**
+ * build.
+ * @return MetaDataDTO
+ */
public MetaDataDTO build() {
return new MetaDataDTO(this);
}
-
- public Builder appName(String appName) {
+
+ /**
+ * app name.
+ * @param appName appName
+ * @return Builder
+ */
+ public Builder appName(final String appName) {
this.appName = appName;
return this;
}
-
- public Builder path(String path) {
+
+ /**
+ * path.
+ * @param path path
+ * @return Builder
+ */
+ public Builder path(final String path) {
this.path = path;
return this;
}
-
- public Builder pathDesc(String pathDesc) {
+
+ /**
+ * path describe.
+ * @param pathDesc pathDesc
+ * @return Builder
+ */
+ public Builder pathDesc(final String pathDesc) {
this.pathDesc = pathDesc;
return this;
}
-
- public Builder rpcType(String rpcType) {
+
+ /**
+ * rpc type.
+ * @param rpcType rpcType
+ * @return Builder
+ */
+ public Builder rpcType(final String rpcType) {
this.rpcType = rpcType;
return this;
}
-
- public Builder serviceName(String serviceName) {
+
+ /**
+ * service name.
+ * @param serviceName serviceName
+ * @return Builder
+ */
+ public Builder serviceName(final String serviceName) {
this.serviceName = serviceName;
return this;
}
-
- public Builder methodName(String methodName) {
+
+ /**
+ * method name.
+ * @param methodName methodName
+ * @return Builder
+ */
+ public Builder methodName(final String methodName) {
this.methodName = methodName;
return this;
}
-
- public Builder parameterTypes(String parameterTypes) {
+
+ /**
+ * parameter types.
+ * @param parameterTypes parameterTypes
+ * @return Builder
+ */
+ public Builder parameterTypes(final String parameterTypes) {
this.parameterTypes = parameterTypes;
return this;
}
-
- public Builder rpcExt(String rpcExt) {
+
+ /**
+ * rpc extends.
+ * @param rpcExt rpcExt
+ * @return Builder
+ */
+ public Builder rpcExt(final String rpcExt) {
this.rpcExt = rpcExt;
return this;
}
-
- public Builder id(String id) {
+
+ /**
+ * id.
+ * @param id id
+ * @return Builder
+ */
+ public Builder id(final String id) {
this.id = id;
return this;
}
-
- public Builder dateCreated(Date dateCreated) {
+
+ /**
+ * create date.
+ * @param dateCreated dateCreated
+ * @return Builder
+ */
+ public Builder dateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
return this;
}
-
- public Builder dateUpdated(Date dateUpdated) {
+
+ /**
+ * update date.
+ * @param dateUpdated dateUpdated
+ * @return Builder
+ */
+ public Builder dateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
return this;
}
-
- public Builder enabled(boolean enabled) {
+
+ /**
+ * enabled.
+ * @param enabled enabled
+ * @return Builder
+ */
+ public Builder enabled(final boolean enabled) {
this.enabled = enabled;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PaginatedResources.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PaginatedResources.java
index 74e2fa760..1a4aed9f0 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PaginatedResources.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PaginatedResources.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
* Paginated resources.
*
- * @param <T> <T>
+ * @param <T> resourceDTO
*/
public class PaginatedResources<T extends ResourceDTO> {
@@ -44,7 +44,7 @@ public class PaginatedResources<T extends ResourceDTO> {
*
* @param page page
*/
- public void setPage(Pagination page) {
+ public void setPage(final Pagination page) {
this.page = page;
}
@@ -62,7 +62,7 @@ public class PaginatedResources<T extends ResourceDTO> {
*
* @param dataList dataList
*/
- public void setDataList(List<T> dataList) {
+ public void setDataList(final List<T> dataList) {
this.dataList = dataList;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/Pagination.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/Pagination.java
index aa41c21bb..8f22ac77d 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/Pagination.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/Pagination.java
@@ -47,11 +47,11 @@ public class Pagination {
}
/**
- * set currentPage
+ * set currentPage.
*
* @param currentPage currentPage
*/
- public void setCurrentPage(int currentPage) {
+ public void setCurrentPage(final int currentPage) {
this.currentPage = currentPage;
}
@@ -69,12 +69,12 @@ public class Pagination {
*
* @param pageSize pageSize
*/
- public void setPageSize(int pageSize) {
+ public void setPageSize(final int pageSize) {
this.pageSize = pageSize;
}
/**
- * get totalSize
+ * get totalSizea.
*
* @return totalSize.
*/
@@ -87,7 +87,7 @@ public class Pagination {
*
* @param totalSize totalSize
*/
- public void setTotalSize(int totalSize) {
+ public void setTotalSize(final int totalSize) {
this.totalSize = totalSize;
}
@@ -105,7 +105,7 @@ public class Pagination {
*
* @param totalPage totalPage
*/
- public void setTotalPage(int totalPage) {
+ public void setTotalPage(final int totalPage) {
this.totalPage = totalPage;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PluginDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PluginDTO.java
index 72c9425dd..6a1af73e9 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PluginDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/PluginDTO.java
@@ -59,7 +59,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -78,7 +78,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param name name
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -96,7 +96,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param role role
*/
- public void setRole(String role) {
+ public void setRole(final String role) {
this.role = role;
}
@@ -114,7 +114,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param sort sort
*/
- public void setSort(int sort) {
+ public void setSort(final int sort) {
this.sort = sort;
}
@@ -132,7 +132,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -150,7 +150,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param config config
*/
- public void setConfig(String config) {
+ public void setConfig(final String config) {
this.config = config;
}
@@ -169,7 +169,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param dateCreated dateCreated
*/
- public void setDateCreated(Date dateCreated) {
+ public void setDateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
}
@@ -188,7 +188,7 @@ public class PluginDTO implements ResourceDTO {
*
* @param dateUpdated dateUpdated
*/
- public void setDateUpdated(Date dateUpdated) {
+ public void setDateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/ResourceDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/ResourceDTO.java
index 703a32d1a..dcfc02cd0 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/ResourceDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/ResourceDTO.java
@@ -24,12 +24,28 @@ import java.util.Date;
@JsonIgnoreProperties(ignoreUnknown = true)
public interface ResourceDTO {
+ /**
+ * get id.
+ * @return String
+ */
String getId();
+ /**
+ * get name.
+ * @return String
+ */
String getName();
+ /**
+ * get create date.
+ * @return Date
+ */
Date getDateCreated();
+ /**
+ * get update date.
+ * @return Date
+ */
Date getDateUpdated();
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/RuleDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/RuleDTO.java
index 995efd5c7..16889e4f2 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/RuleDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/RuleDTO.java
@@ -26,7 +26,7 @@ import java.util.Date;
/**
* RuleDTO.
*/
-public class RuleDTO implements ResourceDTO {
+public final class RuleDTO implements ResourceDTO {
private String id;
@@ -59,7 +59,7 @@ public class RuleDTO implements ResourceDTO {
}
- private RuleDTO(Builder builder) {
+ private RuleDTO(final Builder builder) {
this.id = builder.id;
this.name = builder.name;
this.selectorId = builder.selectorId;
@@ -73,7 +73,11 @@ public class RuleDTO implements ResourceDTO {
this.dateCreated = builder.dateCreated;
this.dateUpdated = builder.dateUpdated;
}
-
+
+ /**
+ * builder.
+ * @return Builder
+ */
public static Builder builder() {
return new Builder();
}
@@ -93,7 +97,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -112,7 +116,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param name name
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -130,7 +134,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param selectorId selectorId
*/
- public void setSelectorId(String selectorId) {
+ public void setSelectorId(final String selectorId) {
this.selectorId = selectorId;
}
@@ -148,7 +152,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param matchMode matchMode
*/
- public void setMatchMode(int matchMode) {
+ public void setMatchMode(final int matchMode) {
this.matchMode = matchMode;
}
@@ -166,7 +170,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param matchModeName matchModeName
*/
- public void setMatchModeName(String matchModeName) {
+ public void setMatchModeName(final String matchModeName) {
this.matchModeName = matchModeName;
}
@@ -184,14 +188,14 @@ public class RuleDTO implements ResourceDTO {
*
* @param sort sort
*/
- public void setSort(int sort) {
+ public void setSort(final int sort) {
this.sort = sort;
}
/**
* is logged.
*
- * @return
+ * @return boolean
*/
public boolean isLogged() {
return logged;
@@ -202,7 +206,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param logged logged
*/
- public void setLogged(boolean logged) {
+ public void setLogged(final boolean logged) {
this.logged = logged;
}
@@ -220,7 +224,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -238,7 +242,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param handle handle
*/
- public void setHandle(String handle) {
+ public void setHandle(final String handle) {
this.handle = handle;
}
@@ -256,7 +260,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param ruleConditions ruleConditions
*/
- public void setRuleConditions(JsonNode ruleConditions) {
+ public void setRuleConditions(final JsonNode ruleConditions) {
this.ruleConditions = ruleConditions;
}
@@ -275,7 +279,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param dateCreated dateCreated
*/
- public void setDateCreated(Date dateCreated) {
+ public void setDateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
}
@@ -294,7 +298,7 @@ public class RuleDTO implements ResourceDTO {
*
* @param dateUpdated dateUpdated
*/
- public void setDateUpdated(Date dateUpdated) {
+ public void setDateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
}
@@ -330,67 +334,131 @@ public class RuleDTO implements ResourceDTO {
private Builder() {
}
-
+
+ /**
+ * build.
+ * @return RuleDTO
+ */
public RuleDTO build() {
return new RuleDTO(this);
}
-
- public Builder id(String id) {
+
+ /**
+ * id.
+ * @param id id
+ * @return Builder
+ */
+ public Builder id(final String id) {
this.id = id;
return this;
}
-
- public Builder name(String name) {
+
+ /**
+ * name.
+ * @param name name
+ * @return Builder
+ */
+ public Builder name(final String name) {
this.name = name;
return this;
}
-
- public Builder selectorId(String selectorId) {
+
+ /**
+ * selector id.
+ * @param selectorId selectorId
+ * @return Builder
+ */
+ public Builder selectorId(final String selectorId) {
this.selectorId = selectorId;
return this;
}
-
- public Builder matchMode(int matchMode) {
+
+ /**
+ * match mode.
+ * @param matchMode matchMode
+ * @return Builder
+ */
+ public Builder matchMode(final int matchMode) {
this.matchMode = matchMode;
return this;
}
-
- public Builder matchModeName(String matchModeName) {
+
+ /**
+ * match mode name.
+ * @param matchModeName matchModeName
+ * @return Builder
+ */
+ public Builder matchModeName(final String matchModeName) {
this.matchModeName = matchModeName;
return this;
}
-
- public Builder sort(int sort) {
+
+ /**
+ * sort.
+ * @param sort sort
+ * @return Builder
+ */
+ public Builder sort(final int sort) {
this.sort = sort;
return this;
}
-
- public Builder logged(boolean logged) {
+
+ /**
+ * logged.
+ * @param logged logged
+ * @return Builder
+ */
+ public Builder logged(final boolean logged) {
this.logged = logged;
return this;
}
-
- public Builder enabled(boolean enabled) {
+
+ /**
+ * enabled.
+ * @param enabled enabled
+ * @return Builder
+ */
+ public Builder enabled(final boolean enabled) {
this.enabled = enabled;
return this;
}
-
- public Builder handle(String handle) {
+
+ /**
+ * handle.
+ * @param handle handle
+ * @return Builder
+ */
+ public Builder handle(final String handle) {
this.handle = handle;
return this;
}
-
- public Builder ruleConditions(JsonNode ruleConditions) {
+
+ /**
+ * rule conditions.
+ * @param ruleConditions ruleConditions
+ * @return Builder
+ */
+ public Builder ruleConditions(final JsonNode ruleConditions) {
this.ruleConditions = ruleConditions;
return this;
}
-
- public Builder dateCreated(Date dateCreated) {
+
+ /**
+ * create date.
+ * @param dateCreated dateCreated
+ * @return Builder
+ */
+ public Builder dateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
return this;
}
-
- public Builder dateUpdated(Date dateUpdated) {
+
+ /**
+ * update date.
+ * @param dateUpdated dateUpdated
+ * @return Builder
+ */
+ public Builder dateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SearchedResources.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SearchedResources.java
index 252b1cd3c..3532223eb 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SearchedResources.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SearchedResources.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
* Searched resources.
*
- * @param <T> <T>
+ * @param <T> resourceDTO
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchedResources<T extends ResourceDTO> {
@@ -53,7 +53,7 @@ public class SearchedResources<T extends ResourceDTO> {
*
* @param pageNum pageNum
*/
- public void setPageNum(int pageNum) {
+ public void setPageNum(final int pageNum) {
this.pageNum = pageNum;
}
@@ -71,7 +71,7 @@ public class SearchedResources<T extends ResourceDTO> {
*
* @param pageSize pageSize
*/
- public void setPageSize(int pageSize) {
+ public void setPageSize(final int pageSize) {
this.pageSize = pageSize;
}
@@ -89,7 +89,7 @@ public class SearchedResources<T extends ResourceDTO> {
*
* @param total total
*/
- public void setTotal(int total) {
+ public void setTotal(final int total) {
this.total = total;
}
@@ -107,7 +107,7 @@ public class SearchedResources<T extends ResourceDTO> {
*
* @param pages pages
*/
- public void setPages(int pages) {
+ public void setPages(final int pages) {
this.pages = pages;
}
@@ -125,7 +125,7 @@ public class SearchedResources<T extends ResourceDTO> {
*
* @param list list
*/
- public void setList(List<T> list) {
+ public void setList(final List<T> list) {
this.list = list;
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SelectorDTO.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SelectorDTO.java
index 956653fe6..9e0e1ed16 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SelectorDTO.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/response/SelectorDTO.java
@@ -27,7 +27,7 @@ import java.util.List;
/**
* SelectorDTO.
*/
-public class SelectorDTO implements ResourceDTO {
+public final class SelectorDTO implements ResourceDTO {
private String id;
@@ -67,7 +67,7 @@ public class SelectorDTO implements ResourceDTO {
}
- private SelectorDTO(Builder builder) {
+ private SelectorDTO(final Builder builder) {
this.id = builder.id;
this.pluginId = builder.pluginId;
this.name = builder.name;
@@ -84,7 +84,11 @@ public class SelectorDTO implements ResourceDTO {
this.dateCreated = builder.dateCreated;
this.dateUpdated = builder.dateUpdated;
}
-
+
+ /**
+ * builder.
+ * @return Builder
+ */
public static Builder builder() {
return new Builder();
}
@@ -104,7 +108,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param id id
*/
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -122,7 +126,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param pluginId pluginId
*/
- public void setPluginId(String pluginId) {
+ public void setPluginId(final String pluginId) {
this.pluginId = pluginId;
}
@@ -141,7 +145,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param name name
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -159,7 +163,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param matchMode matchMode
*/
- public void setMatchMode(int matchMode) {
+ public void setMatchMode(final int matchMode) {
this.matchMode = matchMode;
}
@@ -173,11 +177,11 @@ public class SelectorDTO implements ResourceDTO {
}
/**
- * set matchModeName
+ * set matchModeName.
*
* @param matchModeName matchModeName
*/
- public void setMatchModeName(String matchModeName) {
+ public void setMatchModeName(final String matchModeName) {
this.matchModeName = matchModeName;
}
@@ -195,7 +199,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param type type
*/
- public void setType(int type) {
+ public void setType(final int type) {
this.type = type;
}
@@ -213,7 +217,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param typeName typeName
*/
- public void setTypeName(String typeName) {
+ public void setTypeName(final String typeName) {
this.typeName = typeName;
}
@@ -231,7 +235,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param sort sort
*/
- public void setSort(int sort) {
+ public void setSort(final int sort) {
this.sort = sort;
}
@@ -249,7 +253,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param enabled enabled
*/
- public void setEnabled(boolean enabled) {
+ public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@@ -267,7 +271,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param logged logged
*/
- public void setLogged(boolean logged) {
+ public void setLogged(final boolean logged) {
this.logged = logged;
}
@@ -285,7 +289,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param continued continued
*/
- public void setContinued(boolean continued) {
+ public void setContinued(final boolean continued) {
this.continued = continued;
}
@@ -303,7 +307,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param handle handle
*/
- public void setHandle(String handle) {
+ public void setHandle(final String handle) {
this.handle = handle;
}
@@ -321,7 +325,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param conditionList conditionList
*/
- public void setConditionList(List<Condition> conditionList) {
+ public void setConditionList(final List<Condition> conditionList) {
this.conditionList = conditionList;
}
@@ -340,7 +344,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param dateCreated dateCreated
*/
- public void setDateCreated(Date dateCreated) {
+ public void setDateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
}
@@ -359,7 +363,7 @@ public class SelectorDTO implements ResourceDTO {
*
* @param dateUpdated dateUpdated
*/
- public void setDateUpdated(Date dateUpdated) {
+ public void setDateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
}
@@ -402,82 +406,161 @@ public class SelectorDTO implements ResourceDTO {
private Builder() {
}
-
+
+ /**
+ * build.
+ * @return SelectorDTO
+ */
public SelectorDTO build() {
return new SelectorDTO(this);
}
-
- public Builder id(String id) {
+
+ /**
+ * id.
+ * @param id id
+ * @return Builder
+ */
+ public Builder id(final String id) {
this.id = id;
return this;
}
-
- public Builder pluginId(String pluginId) {
+
+ /**
+ * plugin id.
+ * @param pluginId pluginId
+ * @return Builder
+ */
+ public Builder pluginId(final String pluginId) {
this.pluginId = pluginId;
return this;
}
-
- public Builder name(String name) {
+
+ /**
+ * name.
+ * @param name name
+ * @return Builder
+ */
+ public Builder name(final String name) {
this.name = name;
return this;
}
-
- public Builder matchMode(int matchMode) {
+
+ /**
+ * match mode.
+ * @param matchMode matchMode
+ * @return Builder
+ */
+ public Builder matchMode(final int matchMode) {
this.matchMode = matchMode;
return this;
}
-
- public Builder matchModeName(String matchModeName) {
+
+ /**
+ * match mode name.
+ * @param matchModeName matchModeName
+ * @return Builder
+ */
+ public Builder matchModeName(final String matchModeName) {
this.matchModeName = matchModeName;
return this;
}
-
- public Builder type(int type) {
+
+ /**
+ * type.
+ * @param type type
+ * @return Builder
+ */
+ public Builder type(final int type) {
this.type = type;
return this;
}
-
- public Builder typeName(String typeName) {
+
+ /**
+ * type name.
+ * @param typeName typeName
+ * @return Builder
+ */
+ public Builder typeName(final String typeName) {
this.typeName = typeName;
return this;
}
-
- public Builder sort(int sort) {
+
+ /**
+ * sort.
+ * @param sort sort
+ * @return Builder
+ */
+ public Builder sort(final int sort) {
this.sort = sort;
return this;
}
-
- public Builder enabled(boolean enabled) {
+
+ /**
+ * enabled.
+ * @param enabled enabled
+ * @return Builder
+ */
+ public Builder enabled(final boolean enabled) {
this.enabled = enabled;
return this;
}
-
- public Builder logged(boolean logged) {
+
+ /**
+ * logged.
+ * @param logged logged
+ * @return Builder
+ */
+ public Builder logged(final boolean logged) {
this.logged = logged;
return this;
}
-
- public Builder continued(boolean continued) {
+
+ /**
+ * continued.
+ * @param continued continued
+ * @return Builder
+ */
+ public Builder continued(final boolean continued) {
this.continued = continued;
return this;
}
-
- public Builder handle(String handle) {
+
+ /**
+ * handle.
+ * @param handle handle
+ * @return Builder
+ */
+ public Builder handle(final String handle) {
this.handle = handle;
return this;
}
-
- public Builder conditionList(List<Condition> conditionList) {
+
+ /**
+ * condition list.
+ * @param conditionList conditionList
+ * @return Builder
+ */
+ public Builder conditionList(final List<Condition> conditionList) {
this.conditionList = conditionList;
return this;
}
-
- public Builder dateCreated(Date dateCreated) {
+
+ /**
+ * create date.
+ * @param dateCreated dateCreated
+ * @return Builder
+ */
+ public Builder dateCreated(final Date dateCreated) {
this.dateCreated = dateCreated;
return this;
}
-
- public Builder dateUpdated(Date dateUpdated) {
+
+ /**
+ * update date.
+ * @param dateUpdated dateUpdated
+ * @return Builder
+ */
+ public Builder dateUpdated(final Date dateUpdated) {
this.dateUpdated = dateUpdated;
return this;
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/template/ResourceDataTemplate.java b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/template/ResourceDataTemplate.java
index c862eabaa..516f8efe2 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/template/ResourceDataTemplate.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/template/ResourceDataTemplate.java
@@ -45,7 +45,7 @@ public class ResourceDataTemplate {
* @param plugin plugin
* @return SelectorData.Builder
*/
- public static SelectorData.SelectorDataBuilder newSelectorBuilder(@NotNull String name, Plugin plugin) {
+ public static SelectorData.SelectorDataBuilder newSelectorBuilder(final @NotNull String name, final Plugin plugin) {
return SelectorData.builder()
.name(name)
.plugin(plugin)
@@ -64,11 +64,17 @@ public class ResourceDataTemplate {
* @param name name
* @return RuleData.Builder
*/
- public static RuleData.RuleDataBuilder newRuleBuilder(@Nonnull String name) {
+ public static RuleData.RuleDataBuilder newRuleBuilder(final @Nonnull String name) {
return newRuleBuilder(name, null);
}
- public static RuleData.RuleDataBuilder newRuleBuilder(@Nonnull String name, String selectorId) {
+ /**
+ * new rule builder.
+ * @param name name
+ * @param selectorId selectorId
+ * @return RuleData.RuleDataBuilder
+ */
+ public static RuleData.RuleDataBuilder newRuleBuilder(final @Nonnull String name, final String selectorId) {
return RuleData.builder()
.name(name)
.matchMode(MatchMode.AND)
@@ -103,11 +109,19 @@ public class ResourceDataTemplate {
* @param value value
* @return Condition
*/
- public static Condition newCondition(Condition.ParamType type, Condition.Operator opt, String value) {
+ public static Condition newCondition(final Condition.ParamType type, final Condition.Operator opt, final String value) {
return newCondition(type, opt, null, value);
}
- public static Condition newCondition(Condition.ParamType type, Condition.Operator opt, @Nullable String key, String value) {
+ /**
+ * new condition.
+ * @param type type
+ * @param opt opt
+ * @param key key
+ * @param value value
+ * @return Condition
+ */
+ public static Condition newCondition(final Condition.ParamType type, final Condition.Operator opt, final @Nullable String key, final String value) {
return Condition.builder()
.paramType(type)
.operator(opt)
@@ -116,7 +130,14 @@ public class ResourceDataTemplate {
.build();
}
- public static List<Condition> newConditions(Condition.ParamType type, Condition.Operator opt, String value) {
+ /**
+ * new conditions.
+ * @param type type
+ * @param opt opt
+ * @param value value
+ * @return List
+ */
+ public static List<Condition> newConditions(final Condition.ParamType type, final Condition.Operator opt, final String value) {
ArrayList<Condition> list = new ArrayList<>();
list.add(newCondition(type, opt, value));
return list;
@@ -128,13 +149,18 @@ public class ResourceDataTemplate {
* @param url url
* @return Upstream
*/
- public static Upstreams.Upstream newUpstream(String url) {
+ public static Upstreams.Upstream newUpstream(final String url) {
return Upstreams.Upstream.builder()
.upstreamUrl(url)
.build();
}
- public static Upstreams newUpstreamsBuilder(String url) {
+ /**
+ * new upstream builder.
+ * @param url url
+ * @return Upstreams
+ */
+ public static Upstreams newUpstreamsBuilder(final String url) {
return Upstreams.builder().add(newUpstream(url)).build();
}
}
diff --git a/shenyu-e2e/shenyu-e2e-common/src/test/java/org/apache/shenyu/e2e/common/TableViewTest.java b/shenyu-e2e/shenyu-e2e-common/src/test/java/org/apache/shenyu/e2e/common/TableViewTest.java
index bc3a6bcd7..0049ea944 100644
--- a/shenyu-e2e/shenyu-e2e-common/src/test/java/org/apache/shenyu/e2e/common/TableViewTest.java
+++ b/shenyu-e2e/shenyu-e2e-common/src/test/java/org/apache/shenyu/e2e/common/TableViewTest.java
@@ -35,17 +35,17 @@ public class TableViewTest {
tableView.addRow(1, new Cell("123"), 1d, Lists.newArrayList("a", "b"));
Assertions.assertThat(tableView.printAsString())
- .isEqualTo(Stream.<String>builder()
- .add("+----------+---------------------------------+----------+----------+")
- .add("| header 1 | header 2 | header 3 | header 4 |")
- .add("+----------+---------------------------------+----------+----------+")
- .add("| column 1 | column 2 | column 3 | column 4 |")
- .add("+----------+---------------------------------+----------+----------+")
- .add("| 1 | TableViewTest.Cell(content=123) | 1.0 | [a, b] |")
- .add("+----------+---------------------------------+----------+----------+")
- .build()
- .collect(Collectors.joining(System.lineSeparator()))
- );
+ .isEqualTo(Stream.<String>builder()
+ .add("+----------+---------------------------------+----------+----------+")
+ .add("| header 1 | header 2 | header 3 | header 4 |")
+ .add("+----------+---------------------------------+----------+----------+")
+ .add("| column 1 | column 2 | column 3 | column 4 |")
+ .add("+----------+---------------------------------+----------+----------+")
+ .add("| 1 | TableViewTest.Cell(content=123) | 1.0 | [a, b] |")
+ .add("+----------+---------------------------------+----------+----------+")
+ .build()
+ .collect(Collectors.joining(System.lineSeparator()))
+ );
}
@Test
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtension.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtension.java
index 8b63e3f0e..3266f649d 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtension.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtension.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.e2e.engine;
+import com.github.dockerjava.api.DockerClient;
import junit.framework.AssertionFailedError;
import org.apache.shenyu.e2e.annotation.ExternalService;
import org.apache.shenyu.e2e.annotation.ShenYuAdminClient;
@@ -52,7 +53,7 @@ public class ShenYuExtension implements BeforeAllCallback, ExecutionCondition, A
private static final String KEY_ENGINE_CONFIGURE = "_shenyu_engine_configure_";
@Override
- public void beforeAll(ExtensionContext extensionContext) throws Exception {
+ public void beforeAll(final ExtensionContext extensionContext) throws Exception {
Store store = extensionContext.getStore(NAMESPACE);
ShenYuEngineConfigure configure = store.get(KEY_ENGINE_CONFIGURE, ShenYuEngineConfigure.class);
@@ -63,7 +64,7 @@ public class ShenYuExtension implements BeforeAllCallback, ExecutionCondition, A
}
@Override
- public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
+ public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
Store store = context.getStore(NAMESPACE);
ShenYuEngineConfigure configure = store.get(KEY_ENGINE_CONFIGURE, ShenYuEngineConfigure.class);
if (Objects.isNull(configure)) {
@@ -84,7 +85,7 @@ public class ShenYuExtension implements BeforeAllCallback, ExecutionCondition, A
private boolean isDockerAvailable() {
try {
- DockerClientFactory.instance().client();
+ final DockerClient client = DockerClientFactory.instance().client();
return true;
} catch (Throwable ex) {
return false;
@@ -92,12 +93,12 @@ public class ShenYuExtension implements BeforeAllCallback, ExecutionCondition, A
}
@Override
- public boolean supportsParameter(ParameterContext parameter, ExtensionContext extensionContext) throws ParameterResolutionException {
+ public boolean supportsParameter(final ParameterContext parameter, final ExtensionContext extensionContext) throws ParameterResolutionException {
return AnnotationUtils.isAnnotated(parameter.getParameter().getType(), ShenYuInjectable.class);
}
@Override
- public Object resolveParameter(ParameterContext parameter, ExtensionContext extensionContext) throws ParameterResolutionException {
+ public Object resolveParameter(final ParameterContext parameter, final ExtensionContext extensionContext) throws ParameterResolutionException {
Store store = extensionContext.getStore(NAMESPACE);
ShenYuExtensionContext context = store.get(KEY_EXTENSION_CONTEXT, ShenYuExtensionContext.class);
@@ -108,20 +109,21 @@ public class ShenYuExtension implements BeforeAllCallback, ExecutionCondition, A
if (parameterType.isAnnotationPresent(ShenYuGatewayClient.class)) {
return context.getGatewayClient();
}
+ // TODO fixme.
ExternalService service = AnnotationUtils.findAnnotation(parameterType, ExternalService.class)
- .orElseThrow(() -> new AssertionFailedError("")); // fixme
+ .orElseThrow(() -> new AssertionFailedError(""));
return context.getExternalServiceClient(service.serviceName());
}
@Override
- public void afterAll(ExtensionContext extensionContext) throws Exception {
+ public void afterAll(final ExtensionContext extensionContext) throws Exception {
Store store = extensionContext.getStore(NAMESPACE);
ShenYuExtensionContext context = store.get(KEY_EXTENSION_CONTEXT, ShenYuExtensionContext.class);
Assertions.assertTrue(Objects.nonNull(context), "ShenYuExtensionContext is non-nullable");
context.cleanup();
}
- static ShenYuExtensionContext createExtensionContext(ShenYuEngineConfigure config) {
+ static ShenYuExtensionContext createExtensionContext(final ShenYuEngineConfigure config) {
return new ShenYuExtensionContext(config);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtensionContext.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtensionContext.java
index f52f299f0..7d5948730 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtensionContext.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuExtensionContext.java
@@ -31,6 +31,9 @@ import org.apache.shenyu.e2e.engine.service.ServiceCompose;
import java.util.Map;
import java.util.Objects;
+import static org.apache.shenyu.e2e.engine.config.ShenYuEngineConfigure.Mode.DOCKER;
+import static org.apache.shenyu.e2e.engine.config.ShenYuEngineConfigure.Mode.HOST;
+
/**
* Start the project using the corresponding method based on the selected configuration.
*/
@@ -46,26 +49,28 @@ public class ShenYuExtensionContext {
private Map<String, ExternalServiceClient> externalServiceClientMap;
- ShenYuExtensionContext(ShenYuEngineConfigure config) {
- switch (config.getMode()) {
- case HOST: {
- serviceCompose = new HostServiceCompose(config.getHostConfigure());
- break;
- }
- case DOCKER: {
- serviceCompose = new DockerServiceCompose(config.getDockerConfigure());
- break;
- }
- default:
- throw new AssertionFailedError("Mode [" + config.getMode() + "] is not supported yet");
+ ShenYuExtensionContext(final ShenYuEngineConfigure config) {
+ if (config.getMode() == HOST) {
+ serviceCompose = new HostServiceCompose(config.getHostConfigure());
+ } else if (config.getMode() == DOCKER) {
+ serviceCompose = new DockerServiceCompose(config.getDockerConfigure());
+ } else {
+ throw new AssertionFailedError("Mode [" + config.getMode() + "] is not supported yet");
}
this.scenarioId = IdGenerator.generateScenarioId();
}
+ /**
+ * start.
+ */
public void setup() {
serviceCompose.start();
}
+ /**
+ * get admin client.
+ * @return AdminClient
+ */
public AdminClient getAdminClient() {
if (Objects.isNull(adminClient)) {
adminClient = serviceCompose.newAdminClient(scenarioId);
@@ -73,6 +78,10 @@ public class ShenYuExtensionContext {
return adminClient;
}
+ /**
+ * get gateway client.
+ * @return GatewayClient
+ */
public GatewayClient getGatewayClient() {
if (Objects.isNull(gatewayClient)) {
gatewayClient = serviceCompose.newGatewayClient(scenarioId);
@@ -80,7 +89,12 @@ public class ShenYuExtensionContext {
return gatewayClient;
}
- public ExternalServiceClient getExternalServiceClient(String externalServiceName) {
+ /**
+ * get external service client.
+ * @param externalServiceName externalServiceName
+ * @return ExternalServiceClient
+ */
+ public ExternalServiceClient getExternalServiceClient(final String externalServiceName) {
if (Objects.isNull(externalServiceClientMap)) {
externalServiceClientMap = Maps.newHashMap();
}
@@ -92,6 +106,9 @@ public class ShenYuExtensionContext {
return client;
}
+ /**
+ * clean up.
+ */
public void cleanup() {
serviceCompose.stop();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuLogExtension.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuLogExtension.java
index aaa35e1d5..3567f6eb3 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuLogExtension.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/ShenYuLogExtension.java
@@ -28,32 +28,33 @@ import java.lang.reflect.Method;
* ShenYu log extension.
*/
public class ShenYuLogExtension implements InvocationInterceptor {
+
@Override
- public void interceptBeforeAllMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
+ public void interceptBeforeAllMethod(final Invocation<Void> invocation, final ReflectiveInvocationContext<Method> invocationContext, final ExtensionContext extensionContext) throws Throwable {
MDC.put("phase", "BeforeAll");
invocation.proceed();
}
@Override
- public void interceptBeforeEachMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
+ public void interceptBeforeEachMethod(final Invocation<Void> invocation, final ReflectiveInvocationContext<Method> invocationContext, final ExtensionContext extensionContext) throws Throwable {
MDC.put("phase", "BeforeEach");
invocation.proceed();
}
@Override
- public void interceptTestTemplateMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
+ public void interceptTestTemplateMethod(final Invocation<Void> invocation, final ReflectiveInvocationContext<Method> invocationContext, final ExtensionContext extensionContext) throws Throwable {
MDC.put("phase", "Verify");
invocation.proceed();
}
@Override
- public void interceptAfterEachMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
+ public void interceptAfterEachMethod(final Invocation<Void> invocation, final ReflectiveInvocationContext<Method> invocationContext, final ExtensionContext extensionContext) throws Throwable {
MDC.put("phase", "AfterEach");
invocation.proceed();
}
@Override
- public void interceptAfterAllMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
+ public void interceptAfterAllMethod(final Invocation<Void> invocation, final ReflectiveInvocationContext<Method> invocationContext, final ExtensionContext extensionContext) throws Throwable {
MDC.put("phase", "AfterAll");
invocation.proceed();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenario.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenario.java
index fcbafeeb9..e863043e2 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenario.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenario.java
@@ -17,7 +17,6 @@
package org.apache.shenyu.e2e.engine.annotation;
-
import org.apache.shenyu.e2e.engine.scenario.ShenYuScenarioInvocationContextProvider;
import org.apache.shenyu.e2e.engine.scenario.ShenYuScenarioProvider;
import org.junit.jupiter.api.TestTemplate;
@@ -36,6 +35,10 @@ import java.lang.annotation.Target;
@ExtendWith(ShenYuScenarioInvocationContextProvider.class)
public @interface ShenYuScenario {
+ /**
+ * scenario provider class.
+ * @return Class<? extends ShenYuScenarioProvider>
+ */
Class<? extends ShenYuScenarioProvider> provider();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenarioParameter.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenarioParameter.java
index 378bbad49..f1a2d0ef7 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenarioParameter.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuScenarioParameter.java
@@ -17,7 +17,6 @@
package org.apache.shenyu.e2e.engine.annotation;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -26,5 +25,5 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ShenYuScenarioParameter {
-
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuTest.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuTest.java
index 2ba7124d8..3e61f227d 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuTest.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuTest.java
@@ -30,29 +30,45 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-@Target({ElementType.TYPE})
+@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith({ShenYuExtension.class, ShenYuLogExtension.class})
@TestInstance(Lifecycle.PER_CLASS)
public @interface ShenYuTest {
/**
+ * <p>
* Indices whether the depended on services run under ShenYu e2e engine managed.
* </p>
+ * <p>
* Mode.DOCKER: under ShenYu e2e engine managed.
* </p>
+ * <p>
* Mode.HOST: ShenYu e2e engine unmanaged the services.
* </p>
*
- * {@see Mode}
+ * {@code Mode}
+ * @return Mode
*/
@ShenYuValue("{shenyu.e2e.mode}")
Mode mode() default Mode.DOCKER;
+ /**
+ * services configs.
+ * @return ServiceConfigure[]
+ */
ServiceConfigure[] services() default {};
+ /**
+ * share key.
+ * @return String
+ */
String sharedKey() default "global";
+ /**
+ * docker compose file.
+ * @return String
+ */
@ShenYuValue("{shenyu.e2e.docker-compose}")
String dockerComposeFile() default "docker-compose.yml";
@@ -62,39 +78,55 @@ public @interface ShenYuTest {
/**
* Indices the service's name.
+ * @return String service name.
*/
@ShenYuValue("{shenyu.e2e.services[].serviceName}")
String serviceName();
/**
+ * <p>
* Indices the HTTP schema to access to service.
* </p>
* That is available for {@link Mode#DOCKER}
+ * @return String schema
*/
@ShenYuValue("{shenyu.e2e.services[].schema}")
String schema() default "http";
/**
+ * <p>
* Indices the port of service.
* </p>
* That is available for {@link Mode#DOCKER}
+ * TODO to support multi ports for service
+ * @return int port
*/
@ShenYuValue("{shenyu.e2e.services[].port}")
- int port() default -1; // TODO to support multi ports for service
+ int port() default -1;
/**
+ * <p>
* Indices the baseUrl of service.
* </p>
* That is available for {@link Mode#HOST}
+ * @return String base url
*/
@ShenYuValue("{shenyu.e2e.services[].baseUrl}")
String baseUrl() default "";
-
+
+ /**
+ * <p>
+ * Indices the service type of service.
+ * </p>
+ * {@code ServiceType}
+ * @return ServiceType
+ */
@ShenYuValue("{shenyu.e2e.services[].type}")
ServiceType type() default ServiceType.SHENYU_ADMIN;
/**
* Indices more configures about connection.
+ * @return Parameter[]
*/
Parameter[] parameters() default {};
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuValue.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuValue.java
index b600c1db2..1511a35a2 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuValue.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/annotation/ShenYuValue.java
@@ -26,6 +26,10 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface ShenYuValue {
+ /**
+ * value.
+ * @return String
+ */
String value();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/config/ShenYuEngineConfigure.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/config/ShenYuEngineConfigure.java
index f6e94d7dc..788b0fa10 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/config/ShenYuEngineConfigure.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/config/ShenYuEngineConfigure.java
@@ -43,7 +43,7 @@ public class ShenYuEngineConfigure {
private static final Pattern EXTRACTOR_PATTERN = Pattern.compile("\\{(.*?)\\}");
- private static final ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper MAPPER = new ObjectMapper();
private Mode mode;
@@ -51,10 +51,18 @@ public class ShenYuEngineConfigure {
private DockerConfigure dockerConfigure;
+ /**
+ * is run on host mode.
+ * @return boolean
+ */
public boolean isRunOnHost() {
return Mode.HOST == mode;
}
+ /**
+ * is run on docker mode.
+ * @return boolean
+ */
public boolean isRunOnDocker() {
return Mode.DOCKER == mode;
}
@@ -85,11 +93,164 @@ public class ShenYuEngineConfigure {
public DockerConfigure getDockerConfigure() {
return dockerConfigure;
}
-
+
+ /**
+ * get engine configure from annotation.
+ * @param annotation annotation
+ * @return ShenYuEngineConfigure
+ */
+ public static ShenYuEngineConfigure fromAnnotation(final ShenYuTest annotation) {
+ final ShenYuTest annotationProxy = newShenYuTestProxy(annotation);
+
+ ServiceConfigure[] services = annotationProxy.services();
+ ServiceConfigure[] serviceProxies = new ServiceConfigure[services.length];
+ for (int i = 0; i < services.length; i++) {
+ serviceProxies[i] = newServiceConfigureProxy(i, services[i]);
+ }
+
+ ShenYuEngineConfigure configure = new ShenYuEngineConfigure();
+ configure.mode = annotationProxy.mode();
+ if (Mode.DOCKER == annotationProxy.mode()) {
+ configure.dockerConfigure = parseDockerServiceConfigures(
+ annotationProxy.dockerComposeFile(),
+ serviceProxies
+ );
+ } else {
+ configure.hostConfigure = parseHostServiceConfigures(serviceProxies);
+ }
+ return configure;
+ }
+
+ private static HostConfigure parseHostServiceConfigures(final ServiceConfigure[] serviceConfigures) {
+ HostServiceConfigure admin = null;
+ HostServiceConfigure gateway = null;
+ List<HostServiceConfigure> services = new ArrayList<>();
+ for (ServiceConfigure configure : serviceConfigures) {
+ switch (configure.type()) {
+ case SHENYU_ADMIN:
+ admin = parseHostServiceConfigure(configure);
+ break;
+ case SHENYU_GATEWAY:
+ gateway = parseHostServiceConfigure(configure);
+ break;
+ default:
+ services.add(parseHostServiceConfigure(configure));
+ }
+ }
+ return new HostConfigure(admin, gateway, services);
+ }
+
+ private static HostServiceConfigure parseHostServiceConfigure(final ServiceConfigure configure) {
+ Preconditions.checkNotNull(configure.serviceName(), "serviceName is non-nullable");
+ Preconditions.checkNotNull(configure.baseUrl(), "baseUrl is non-nullable in docker-compose mode");
+
+ return new HostServiceConfigure(configure.serviceName(), configure.baseUrl(), toProperties(configure.parameters()));
+ }
+
+ private static DockerConfigure parseDockerServiceConfigures(final String dockerComposeFile, final ServiceConfigure[] serviceConfigures) {
+ Preconditions.checkNotNull(Strings.emptyToNull(dockerComposeFile), "dockerComposeFile is required in docker-compose mode");
+
+ DockerServiceConfigure admin = null;
+ DockerServiceConfigure gateway = null;
+ List<DockerServiceConfigure> services = new ArrayList<>();
+ for (ServiceConfigure configure : serviceConfigures) {
+ switch (configure.type()) {
+ case SHENYU_ADMIN:
+ admin = parseDockerServiceConfigure(configure);
+ break;
+ case SHENYU_GATEWAY:
+ gateway = parseDockerServiceConfigure(configure);
+ break;
+ default:
+ services.add(parseDockerServiceConfigure(configure));
+ }
+ }
+ return new DockerConfigure(dockerComposeFile, admin, gateway, services);
+ }
+
+ private static DockerServiceConfigure parseDockerServiceConfigure(final ServiceConfigure configure) {
+ Preconditions.checkNotNull(configure.serviceName(), "serviceName is non-nullable");
+
+ return new DockerServiceConfigure(configure.schema(), configure.serviceName(), configure.port(), toProperties(configure.parameters()));
+ }
+
+ private static Properties toProperties(final Parameter[] parameters) {
+ Properties properties = new Properties();
+ Arrays.stream(parameters).forEach(p -> properties.put(p.key(), p.value()));
+ return properties;
+ }
+
+ private static ShenYuTest newShenYuTestProxy(final ShenYuTest shenYuTest) {
+ return (ShenYuTest) Proxy.newProxyInstance(
+ ShenYuTest.class.getClassLoader(),
+ new Class[]{ShenYuTest.class},
+ (proxy, method, args) -> {
+ if (method.isAnnotationPresent(ShenYuValue.class)) {
+ ShenYuValue annotation = method.getAnnotation(ShenYuValue.class);
+
+ String propertyKey = annotation.value();
+ propertyKey = propertyKey.substring(1, propertyKey.length() - 1);
+ String property = System.getProperty(propertyKey);
+ if (!Strings.isNullOrEmpty(property)) {
+ return MAPPER.readValue("\"" + property + "\"", method.getReturnType());
+ }
+ }
+ return normal(method.invoke(shenYuTest), method.getReturnType());
+ });
+ }
+
+ private static ServiceConfigure newServiceConfigureProxy(final int index, final ServiceConfigure serviceConfigure) {
+ return (ServiceConfigure) Proxy.newProxyInstance(
+ ServiceConfigure.class.getClassLoader(),
+ new Class[]{ServiceConfigure.class},
+ (proxy, method, args) -> {
+ if (method.isAnnotationPresent(ShenYuValue.class)) {
+ ShenYuValue annotation = method.getAnnotation(ShenYuValue.class);
+
+ String rawKey = annotation.value();
+ String propertyKey = rawKey.replace("[]", "[" + index + "]")
+ .substring(1, rawKey.length() - 1);
+
+ String property = System.getProperty(propertyKey);
+ if (!Strings.isNullOrEmpty(property)) {
+ return MAPPER.readValue("\"" + property + "\"", method.getReturnType());
+ }
+ }
+ return normal(method.invoke(serviceConfigure), method.getReturnType());
+ });
+ }
+
+ private static Object normal(final Object obj, final Class<?> returnType) {
+ if (String.class == returnType) {
+ String result = obj.toString();
+
+ Matcher matcher = EXTRACTOR_PATTERN.matcher(result);
+ while (matcher.find()) {
+ String pattern = matcher.group(1);
+ String key = pattern;
+ String val = "null";
+
+ if (pattern.contains(":")) {
+ String[] kv = pattern.split(":");
+ key = kv[0];
+ val = kv[1];
+ }
+
+ result = result.replace(matcher.group(0), System.getProperty(key, val));
+ }
+ return result;
+ }
+ return obj;
+ }
+
public enum Mode {
-
+
HOST, DOCKER;
+ /**
+ * value.
+ * @return String
+ */
@JsonValue
public String value() {
return name();
@@ -97,30 +258,28 @@ public class ShenYuEngineConfigure {
}
public enum ServiceType {
-
+
SHENYU_ADMIN,
-
+
SHENYU_GATEWAY,
-
+
EXTERNAL_SERVICE,
}
-
public static class HostConfigure {
-
+
private final HostServiceConfigure admin;
-
+
private final HostServiceConfigure gateway;
-
+
private final List<HostServiceConfigure> externalServices;
-
-
- public HostConfigure(HostServiceConfigure admin, HostServiceConfigure gateway, List<HostServiceConfigure> externalServices) {
+
+ public HostConfigure(final HostServiceConfigure admin, final HostServiceConfigure gateway, final List<HostServiceConfigure> externalServices) {
this.admin = admin;
this.gateway = gateway;
this.externalServices = externalServices;
}
-
+
/**
* get admin.
*
@@ -129,7 +288,7 @@ public class ShenYuEngineConfigure {
public HostServiceConfigure getAdmin() {
return admin;
}
-
+
/**
* get gateway.
*
@@ -138,7 +297,7 @@ public class ShenYuEngineConfigure {
public HostServiceConfigure getGateway() {
return gateway;
}
-
+
/**
* get externalServices.
*
@@ -147,21 +306,21 @@ public class ShenYuEngineConfigure {
public List<HostServiceConfigure> getExternalServices() {
return externalServices;
}
-
+
public static class HostServiceConfigure {
-
+
private final String serviceName;
-
+
private final String baseUrl;
-
+
private final Properties properties;
-
- public HostServiceConfigure(String serviceName, String baseUrl, Properties properties) {
+
+ public HostServiceConfigure(final String serviceName, final String baseUrl, final Properties properties) {
this.serviceName = serviceName;
this.baseUrl = baseUrl;
this.properties = properties;
}
-
+
/**
* get serviceName.
*
@@ -170,7 +329,7 @@ public class ShenYuEngineConfigure {
public String getServiceName() {
return serviceName;
}
-
+
/**
* get baseUrl.
*
@@ -179,7 +338,7 @@ public class ShenYuEngineConfigure {
public String getBaseUrl() {
return baseUrl;
}
-
+
/**
* get properties.
*
@@ -190,24 +349,24 @@ public class ShenYuEngineConfigure {
}
}
}
-
+
public static class DockerConfigure {
-
+
private final String dockerComposeFile;
-
+
private final DockerServiceConfigure admin;
-
+
private final DockerServiceConfigure gateway;
-
+
private final List<DockerServiceConfigure> externalServices;
-
- public DockerConfigure(String dockerComposeFile, DockerServiceConfigure admin, DockerServiceConfigure gateway, List<DockerServiceConfigure> externalServices) {
+
+ public DockerConfigure(final String dockerComposeFile, final DockerServiceConfigure admin, final DockerServiceConfigure gateway, final List<DockerServiceConfigure> externalServices) {
this.dockerComposeFile = dockerComposeFile;
this.admin = admin;
this.gateway = gateway;
this.externalServices = externalServices;
}
-
+
/**
* get dockerComposeFile.
*
@@ -216,7 +375,7 @@ public class ShenYuEngineConfigure {
public String getDockerComposeFile() {
return dockerComposeFile;
}
-
+
/**
* get admin.
*
@@ -225,7 +384,7 @@ public class ShenYuEngineConfigure {
public DockerServiceConfigure getAdmin() {
return admin;
}
-
+
/**
* get gateway.
*
@@ -234,33 +393,33 @@ public class ShenYuEngineConfigure {
public DockerServiceConfigure getGateway() {
return gateway;
}
-
+
/**
* get externalServices.
*
- * @return
+ * @return List
*/
public List<DockerServiceConfigure> getExternalServices() {
return externalServices;
}
-
+
public static class DockerServiceConfigure {
-
+
private final String schema;
-
+
private final String serviceName;
-
+
private final int port;
-
+
private final Properties properties;
-
- public DockerServiceConfigure(String schema, String serviceName, int port, Properties properties) {
+
+ public DockerServiceConfigure(final String schema, final String serviceName, final int port, final Properties properties) {
this.schema = schema;
this.serviceName = serviceName;
this.port = port;
this.properties = properties;
}
-
+
/**
* get schema.
*
@@ -269,7 +428,7 @@ public class ShenYuEngineConfigure {
public String getSchema() {
return schema;
}
-
+
/**
* get serviceName.
*
@@ -278,7 +437,7 @@ public class ShenYuEngineConfigure {
public String getServiceName() {
return serviceName;
}
-
+
/**
* get port.
*
@@ -287,7 +446,7 @@ public class ShenYuEngineConfigure {
public int getPort() {
return port;
}
-
+
/**
* get properties.
*
@@ -298,149 +457,4 @@ public class ShenYuEngineConfigure {
}
}
}
-
- public static ShenYuEngineConfigure fromAnnotation(ShenYuTest annotation) {
- final ShenYuTest annotationProxy = newShenYuTestProxy(annotation);
-
- ServiceConfigure[] services = annotationProxy.services();
- ServiceConfigure[] serviceProxies = new ServiceConfigure[services.length];
- for (int i = 0; i< services.length; i++) {
- serviceProxies[i] = newServiceConfigureProxy(i, services[i]);
- }
-
- ShenYuEngineConfigure configure = new ShenYuEngineConfigure();
- configure.mode = annotationProxy.mode();
- if (Mode.DOCKER == annotationProxy.mode()) {
- configure.dockerConfigure = parseDockerServiceConfigures(
- annotationProxy.dockerComposeFile(),
- serviceProxies
- );
- } else {
- configure.hostConfigure = parseHostServiceConfigures(serviceProxies);
- }
- return configure;
- }
-
- private static HostConfigure parseHostServiceConfigures(ServiceConfigure[] serviceConfigures) {
- HostServiceConfigure admin = null;
- HostServiceConfigure gateway = null;
- List<HostServiceConfigure> services = new ArrayList<>();
- for (ServiceConfigure configure : serviceConfigures) {
- switch (configure.type()) {
- case SHENYU_ADMIN:
- admin = parseHostServiceConfigure(configure);
- break;
- case SHENYU_GATEWAY:
- gateway = parseHostServiceConfigure(configure);
- break;
- default:
- services.add(parseHostServiceConfigure(configure));
- }
- }
- return new HostConfigure(admin, gateway, services);
- }
-
-
- private static HostServiceConfigure parseHostServiceConfigure(ServiceConfigure configure) {
- Preconditions.checkNotNull(configure.serviceName(), "serviceName is non-nullable");
- Preconditions.checkNotNull(configure.baseUrl(), "baseUrl is non-nullable in docker-compose mode");
-
- return new HostServiceConfigure(configure.serviceName(), configure.baseUrl(), toProperties(configure.parameters()));
- }
-
- private static DockerConfigure parseDockerServiceConfigures(String dockerComposeFile, ServiceConfigure[] serviceConfigures) {
- Preconditions.checkNotNull(Strings.emptyToNull(dockerComposeFile), "dockerComposeFile is required in docker-compose mode");
-
- DockerServiceConfigure admin = null;
- DockerServiceConfigure gateway = null;
- List<DockerServiceConfigure> services = new ArrayList<>();
- for (ServiceConfigure configure : serviceConfigures) {
- switch (configure.type()) {
- case SHENYU_ADMIN:
- admin = parseDockerServiceConfigure(configure);
- break;
- case SHENYU_GATEWAY:
- gateway = parseDockerServiceConfigure(configure);
- break;
- default:
- services.add(parseDockerServiceConfigure(configure));
- }
- }
- return new DockerConfigure(dockerComposeFile, admin, gateway, services);
- }
-
- private static DockerServiceConfigure parseDockerServiceConfigure(ServiceConfigure configure) {
- Preconditions.checkNotNull(configure.serviceName(), "serviceName is non-nullable");
-
- return new DockerServiceConfigure(configure.schema(), configure.serviceName(), configure.port(), toProperties(configure.parameters()));
- }
-
- private static Properties toProperties(Parameter[] parameters) {
- Properties properties = new Properties();
- Arrays.stream(parameters).forEach(p -> properties.put(p.key(), p.value()));
- return properties;
- }
-
- private static ShenYuTest newShenYuTestProxy(ShenYuTest shenYuTest) {
- return (ShenYuTest) Proxy.newProxyInstance(
- ShenYuTest.class.getClassLoader(),
- new Class[]{ShenYuTest.class},
- (proxy, method, args) -> {
- if (method.isAnnotationPresent(ShenYuValue.class)) {
- ShenYuValue annotation = method.getAnnotation(ShenYuValue.class);
-
- String propertyKey = annotation.value();
- propertyKey = propertyKey.substring(1, propertyKey.length() - 1);
- String property = System.getProperty(propertyKey);
- if (!Strings.isNullOrEmpty(property)) {
- return mapper.readValue("\"" + property + "\"", method.getReturnType());
- }
- }
- return normal(method.invoke(shenYuTest), method.getReturnType());
- });
- }
-
- private static ServiceConfigure newServiceConfigureProxy(final int index, ServiceConfigure serviceConfigure) {
- return (ServiceConfigure) Proxy.newProxyInstance(
- ServiceConfigure.class.getClassLoader(),
- new Class[]{ServiceConfigure.class},
- (proxy, method, args) -> {
- if (method.isAnnotationPresent(ShenYuValue.class)) {
- ShenYuValue annotation = method.getAnnotation(ShenYuValue.class);
-
- String rawKey = annotation.value();
- String propertyKey = rawKey.replace("[]", "[" + index + "]")
- .substring(1, rawKey.length() - 1);
-
- String property = System.getProperty(propertyKey);
- if (!Strings.isNullOrEmpty(property)) {
- return mapper.readValue("\"" + property + "\"", method.getReturnType());
- }
- }
- return normal(method.invoke(serviceConfigure), method.getReturnType());
- });
- }
-
- private static Object normal(Object obj, Class<?> returnType) {
- if (String.class == returnType) {
- String result = obj.toString();
-
- Matcher matcher = EXTRACTOR_PATTERN.matcher(result);
- while (matcher.find()) {
- String pattern = matcher.group(1);
- String key = pattern;
- String val = "null";
-
- if (pattern.contains(":")) {
- String[] kv = pattern.split(":");
- key = kv[0];
- val = kv[1];
- }
-
- result = result.replace(matcher.group(0), System.getProperty(key, val));
- }
- return result;
- }
- return obj;
- }
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSynHandler.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSyncHandler.java
similarity index 80%
rename from shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSynHandler.java
rename to shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSyncHandler.java
index 32d01fc05..003acb1a9 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSynHandler.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/handler/DataSyncHandler.java
@@ -23,37 +23,40 @@ import java.util.Map;
/**
* Gateway DataSyn Handler.
*/
-public class DataSynHandler {
-
- private static final Map<String, Map<String, Object>> DATA_SYN_MAP = new HashMap<>();
-
+public class DataSyncHandler {
+
+ private static final Map<String, Map<String, Object>> DATA_SYNC_MAP = new HashMap<>();
+
private static final Map<String, Object> ADMIN_WEBSOCKET_MAP = new HashMap<>();
-
+
private static final Map<String, Object> GATEWAY_WEBSOCKET_MAP = new HashMap<>();
-
+
private static final Map<String, Object> ZOOKEEPER_MAP = new HashMap<>();
-
+
private static final Map<String, Object> ADMIN_APOLLO_MAP = new HashMap<>();
-
+
private static final Map<String, Object> GATEWAY_APOLLO_MAP = new HashMap<>();
-
+
private static final Map<String, Object> ADMIN_HTTP_MAP = new HashMap<>();
-
+
private static final Map<String, Object> GATEWAY_HTTP_MAP = new HashMap<>();
-
+
private static final Map<String, Object> NACOS_MAP = new HashMap<>();
-
+
private static final Map<String, Object> ACM_MAP = new HashMap<>();
-
+
+ /**
+ * init data sync handler.
+ */
public static void init() {
- DATA_SYN_MAP.put("admin_websocket", ADMIN_WEBSOCKET_MAP);
- DATA_SYN_MAP.put("gateway_websocket", GATEWAY_WEBSOCKET_MAP);
- DATA_SYN_MAP.put("zookeeper", ZOOKEEPER_MAP);
- DATA_SYN_MAP.put("admin_apollo",ADMIN_APOLLO_MAP);
- DATA_SYN_MAP.put("gateway_apollo",GATEWAY_APOLLO_MAP);
- DATA_SYN_MAP.put("admin_http", ADMIN_HTTP_MAP);
- DATA_SYN_MAP.put("gateway_http", GATEWAY_HTTP_MAP);
- DATA_SYN_MAP.put("nacos", NACOS_MAP);
+ DATA_SYNC_MAP.put("admin_websocket", ADMIN_WEBSOCKET_MAP);
+ DATA_SYNC_MAP.put("gateway_websocket", GATEWAY_WEBSOCKET_MAP);
+ DATA_SYNC_MAP.put("zookeeper", ZOOKEEPER_MAP);
+ DATA_SYNC_MAP.put("admin_apollo", ADMIN_APOLLO_MAP);
+ DATA_SYNC_MAP.put("gateway_apollo", GATEWAY_APOLLO_MAP);
+ DATA_SYNC_MAP.put("admin_http", ADMIN_HTTP_MAP);
+ DATA_SYNC_MAP.put("gateway_http", GATEWAY_HTTP_MAP);
+ DATA_SYNC_MAP.put("nacos", NACOS_MAP);
ADMIN_WEBSOCKET_MAP.put("enabled", "true");
GATEWAY_WEBSOCKET_MAP.put("urls", "ws://admin:9095/websocket");
@@ -91,8 +94,13 @@ public class DataSynHandler {
GATEWAY_APOLLO_MAP.put("clusterName", "test");
GATEWAY_APOLLO_MAP.put("namespace", "application");
}
-
- public static Map<String, Object> getDataSynMap(String dataSyn) {
- return DATA_SYN_MAP.get(dataSyn);
+
+ /**
+ * get data sync map.
+ * @param dataSyn dataSyn
+ * @return Map
+ */
+ public static Map<String, Object> getDataSynMap(final String dataSyn) {
+ return DATA_SYNC_MAP.get(dataSyn);
}
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioInvocationContextProvider.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioInvocationContextProvider.java
index 90e67b884..e46e6f78d 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioInvocationContextProvider.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioInvocationContextProvider.java
@@ -37,7 +37,7 @@ import java.util.stream.Stream.Builder;
public class ShenYuScenarioInvocationContextProvider implements TestTemplateInvocationContextProvider {
@Override
- public boolean supportsTestTemplate(ExtensionContext context) {
+ public boolean supportsTestTemplate(final ExtensionContext context) {
final Method method = context.getRequiredTestMethod();
if (!method.isAnnotationPresent(ShenYuScenario.class)) {
return false;
@@ -53,7 +53,7 @@ public class ShenYuScenarioInvocationContextProvider implements TestTemplateInvo
}
@Override
- public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
+ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(final ExtensionContext context) {
Store store = getStore(context);
ShenYuScenarioSupplier supplier = store.get(ShenYuScenarioSupplier.class, ShenYuScenarioSupplier.class);
@@ -63,19 +63,19 @@ public class ShenYuScenarioInvocationContextProvider implements TestTemplateInvo
return builder.build();
}
- private static Store getStore(ExtensionContext context) {
+ private static Store getStore(final ExtensionContext context) {
return context.getStore(Namespace.create(ShenYuScenarioInvocationContextProvider.class, context.getRequiredTestMethod()));
}
private static class ShenYuTestTemplateInvocationContext implements TestTemplateInvocationContext {
private final ScenarioSpec scenarioSpec;
- public ShenYuTestTemplateInvocationContext(ScenarioSpec scenarioSpec) {
+ ShenYuTestTemplateInvocationContext(final ScenarioSpec scenarioSpec) {
this.scenarioSpec = new ScenarioSpecLogProxy(scenarioSpec);
}
@Override
- public String getDisplayName(int invocationIndex) {
+ public String getDisplayName(final int invocationIndex) {
return "#" + invocationIndex + " " + scenarioSpec.getName();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioParameterResolver.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioParameterResolver.java
index 3b2b9d3d4..be56aa200 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioParameterResolver.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioParameterResolver.java
@@ -29,18 +29,17 @@ public class ShenYuScenarioParameterResolver implements ParameterResolver {
private final ScenarioSpec scenarioSpec;
- public ShenYuScenarioParameterResolver(ScenarioSpec scenarioSpec) {
+ public ShenYuScenarioParameterResolver(final ScenarioSpec scenarioSpec) {
this.scenarioSpec = scenarioSpec;
}
-
@Override
- public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ public boolean supportsParameter(final ParameterContext parameterContext, final ExtensionContext extensionContext) throws ParameterResolutionException {
return AnnotationUtils.isAnnotated(parameterContext.getParameter().getType(), ShenYuScenarioParameter.class);
}
@Override
- public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ public Object resolveParameter(final ParameterContext parameterContext, final ExtensionContext extensionContext) throws ParameterResolutionException {
return scenarioSpec.getByType(parameterContext.getParameter().getType());
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioProvider.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioProvider.java
index 808c79564..bf00d54df 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioProvider.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioProvider.java
@@ -24,5 +24,9 @@ import java.util.List;
@FunctionalInterface
public interface ShenYuScenarioProvider {
+ /**
+ * get scenario specifications list.
+ * @return List
+ */
List<ScenarioSpec> get();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioSupplier.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioSupplier.java
index e44eece02..7e70b1034 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioSupplier.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/ShenYuScenarioSupplier.java
@@ -31,7 +31,7 @@ public class ShenYuScenarioSupplier implements Iterator<ScenarioSpec>, Supplier<
private int index = -1;
- ShenYuScenarioSupplier(List<ScenarioSpec> supplies) {
+ ShenYuScenarioSupplier(final List<ScenarioSpec> supplies) {
this.supplies = ImmutableList.<ScenarioSpec>builder().addAll(supplies).build();
}
@@ -41,14 +41,34 @@ public class ShenYuScenarioSupplier implements Iterator<ScenarioSpec>, Supplier<
return supplies.iterator();
}
+ /**
+ * size.
+ * @return int
+ */
public int size() {
return supplies.size();
}
- public ScenarioSpec get(int index) {
+ /**
+ * the index of spec.
+ * @param index index
+ * @return ScenarioSpec
+ */
+ public ScenarioSpec get(final int index) {
return supplies.get(index);
}
+ /**
+ * get a scenario spec.
+ * @return ScenarioSpec
+ */
+ public ScenarioSpec get() {
+ if (index < 0) {
+ throw new NoSuchElementException();
+ }
+ return get(index);
+ }
+
@Override
public boolean hasNext() {
index++;
@@ -60,10 +80,4 @@ public class ShenYuScenarioSupplier implements Iterator<ScenarioSpec>, Supplier<
return get();
}
- public ScenarioSpec get() {
- if (index < 0) {
- throw new NoSuchElementException();
- }
- return get(index);
- }
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Checker.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Checker.java
index 06cb0d03c..5bdcd36ea 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Checker.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Checker.java
@@ -22,9 +22,14 @@ import org.apache.shenyu.e2e.client.gateway.GatewayClient;
@FunctionalInterface
public interface Checker {
- void check(GatewayClient client);
-
Checker DEFAULT = supplier -> {
+
};
+ /**
+ * check client.
+ * @param client client
+ */
+ void check(GatewayClient client);
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Deleter.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Deleter.java
index 495952d65..67fd1c02e 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Deleter.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Deleter.java
@@ -24,7 +24,13 @@ import java.util.List;
@FunctionalInterface
public interface Deleter {
+ Deleter DEFAULT = AdminClient::deleteSelectors;
+
+ /**
+ * delete client.
+ * @param client client
+ * @param selectorIds selectorIds
+ */
void delete(AdminClient client, List<String> selectorIds);
- Deleter DEFAULT = AdminClient::deleteSelectors;
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpChecker.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpChecker.java
index 54b108537..777dfc1e9 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpChecker.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpChecker.java
@@ -29,10 +29,18 @@ import java.util.function.Supplier;
@FunctionalInterface
public interface HttpChecker extends Checker, HttpVerifier {
+ /**
+ * check client.
+ * @param client client client client
+ */
default void check(GatewayClient client) {
check(client.getHttpRequesterSupplier());
}
+ /**
+ * check request specification.
+ * @param supplier supplier
+ */
default void check(Supplier<RequestSpecification> supplier) {
try {
verify(supplier.get());
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpCheckers.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpCheckers.java
index ee6fba5c1..a5abfd95e 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpCheckers.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpCheckers.java
@@ -30,7 +30,12 @@ import static org.hamcrest.Matchers.nullValue;
*/
public class HttpCheckers {
- public static HttpChecker notExists(String endpoint) {
+ /**
+ * endpoint is not exist.
+ * @param endpoint endpoint
+ * @return HttpChecker
+ */
+ public static HttpChecker notExists(final String endpoint) {
return notExists(Method.GET, endpoint);
}
@@ -41,8 +46,8 @@ public class HttpCheckers {
* @param endpoint endpoint
* @return HttpChecker
*/
- public static HttpChecker notExists(Method method, String endpoint) {
- return (request) -> {
+ public static HttpChecker notExists(final Method method, final String endpoint) {
+ return request -> {
try {
request.request(method, endpoint)
.then()
@@ -55,8 +60,13 @@ public class HttpCheckers {
}
};
}
-
- public static HttpChecker exists(String endpoint) {
+
+ /**
+ * exist endpoint.
+ * @param endpoint endpoint
+ * @return HttpChecker
+ */
+ public static HttpChecker exists(final String endpoint) {
return exists(Method.GET, endpoint);
}
@@ -67,8 +77,8 @@ public class HttpCheckers {
* @param endpoint endpoint
* @return HttpChecker
*/
- public static HttpChecker exists(Method method, String endpoint) {
- return (request) -> {
+ public static HttpChecker exists(final Method method, final String endpoint) {
+ return request -> {
try {
request.request(method, endpoint)
.then()
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpVerifier.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpVerifier.java
index a24cf21bf..70e53d6f0 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpVerifier.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpVerifier.java
@@ -17,8 +17,6 @@
package org.apache.shenyu.e2e.engine.scenario.function;
-import org.apache.shenyu.e2e.engine.scenario.function.Verifier;
-
/**
* Http Verifier interface.
*/
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpWaiting.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpWaiting.java
index f94959ebe..24563330e 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpWaiting.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/HttpWaiting.java
@@ -19,7 +19,6 @@ package org.apache.shenyu.e2e.engine.scenario.function;
import io.restassured.specification.RequestSpecification;
import org.apache.shenyu.e2e.client.gateway.GatewayClient;
-import org.apache.shenyu.e2e.engine.scenario.function.Waiting;
import java.util.function.Supplier;
@@ -29,10 +28,18 @@ import java.util.function.Supplier;
@FunctionalInterface
public interface HttpWaiting extends Waiting {
+ /**
+ * wait for client.
+ * @param client client
+ */
default void waitFor(GatewayClient client) {
waitFor(client.getHttpRequesterSupplier());
}
+ /**
+ * wait for request specification.
+ * @param supplier supplier
+ */
void waitFor(Supplier<RequestSpecification> supplier);
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Verifier.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Verifier.java
index 38ac3ff7d..c817b734f 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Verifier.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Verifier.java
@@ -21,9 +21,13 @@ import io.restassured.specification.RequestSpecification;
public interface Verifier {
- void verify(RequestSpecification request);
-
Verifier DEFAULT = request -> {
};
+ /**
+ * verify request specificaion.
+ * @param request request
+ */
+ void verify(RequestSpecification request);
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/WaitForHelper.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/WaitForHelper.java
index 12c5eda12..9b9ba4956 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/WaitForHelper.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/WaitForHelper.java
@@ -45,13 +45,13 @@ public class WaitForHelper {
private static final Logger log = LoggerFactory.getLogger(WaitForHelper.class);
- private static final ExecutorService executor = MoreExecutors.getExitingExecutorService((ThreadPoolExecutor) Executors.newFixedThreadPool(1));
+ private static final ExecutorService EXECUTOR = MoreExecutors.getExitingExecutorService((ThreadPoolExecutor) Executors.newFixedThreadPool(1));
- public int retryTimes = 30;
+ private int retryTimes = 30;
- public Duration timeInRetry = Duration.ofSeconds(3);
+ private Duration timeInRetry = Duration.ofSeconds(3);
- public Duration timeout = Duration.ofMinutes(3);
+ private Duration timeout = Duration.ofMinutes(3);
public WaitForHelper() {
}
@@ -71,9 +71,9 @@ public class WaitForHelper {
* @param expected expected
* @throws TimeoutException TimeoutException
*/
- public void waitFor(Supplier<RequestSpecification> supplier, Method method, String endpoint, ResponseSpecification expected) throws TimeoutException {
+ public void waitFor(final Supplier<RequestSpecification> supplier, final Method method, final String endpoint, final ResponseSpecification expected) throws TimeoutException {
final Map<String, String> contextMap = MDC.getCopyOfContextMap();
- Future<?> future = executor.submit(() -> {
+ Future<?> future = EXECUTOR.submit(() -> {
MDC.setContextMap(contextMap);
for (int i = 0; i < retryTimes; i++) {
@@ -115,9 +115,9 @@ public class WaitForHelper {
* @param checker checker
* @throws TimeoutException TimeoutException
*/
- public void waitFor(Supplier<RequestSpecification> supplier, HttpChecker checker) throws TimeoutException {
+ public void waitFor(final Supplier<RequestSpecification> supplier, final HttpChecker checker) throws TimeoutException {
final Map<String, String> contextMap = MDC.getCopyOfContextMap();
- Future<?> future = executor.submit(() -> {
+ Future<?> future = EXECUTOR.submit(() -> {
MDC.setContextMap(contextMap);
for (int i = 0; i < retryTimes; i++) {
@@ -145,15 +145,33 @@ public class WaitForHelper {
}
}
- public static void waitForEffecting(Supplier<RequestSpecification> supplier, Method method, String endpoint, ResponseSpecification expected) {
+ /**
+ * wait for effecting.
+ * @param supplier supplier
+ * @param method method
+ * @param endpoint endpoint
+ * @param expected expected
+ */
+ public static void waitForEffecting(final Supplier<RequestSpecification> supplier, final Method method, final String endpoint, final ResponseSpecification expected) {
Assertions.assertDoesNotThrow(() -> new WaitForHelper().waitFor(supplier, method, endpoint, expected), "waiting for endpoint to take effect");
}
- public static void waitForEffecting(Supplier<RequestSpecification> supplier, String endpoint, ResponseSpecification expected) {
+ /**
+ * wait for effecting.
+ * @param supplier supplier
+ * @param endpoint endpoint
+ * @param expected expected
+ */
+ public static void waitForEffecting(final Supplier<RequestSpecification> supplier, final String endpoint, final ResponseSpecification expected) {
Assertions.assertDoesNotThrow(() -> new WaitForHelper().waitFor(supplier, Method.GET, endpoint, expected), "waiting for endpoint to take effect");
}
- public static void waitForEffecting(Supplier<RequestSpecification> supplier, HttpChecker checker) {
+ /**
+ * wait for effecting.
+ * @param supplier supplier
+ * @param checker checker
+ */
+ public static void waitForEffecting(final Supplier<RequestSpecification> supplier, final HttpChecker checker) {
Assertions.assertDoesNotThrow(() -> new WaitForHelper().waitFor(supplier, checker), "waiting for endpoint to take effect");
}
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Waiting.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Waiting.java
index 3ba553d3a..d227370ab 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Waiting.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/function/Waiting.java
@@ -22,8 +22,13 @@ import org.apache.shenyu.e2e.client.gateway.GatewayClient;
@FunctionalInterface
public interface Waiting {
- void waitFor(GatewayClient client);
-
Waiting DEFAULT = supplier -> {
};
+
+ /**
+ * wait for client.
+ * @param client client
+ */
+ void waitFor(GatewayClient client);
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/AfterEachSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/AfterEachSpec.java
index be05140eb..6b75b2fa6 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/AfterEachSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/AfterEachSpec.java
@@ -24,19 +24,28 @@ import org.apache.shenyu.e2e.engine.scenario.function.Deleter;
@ShenYuScenarioParameter
public interface AfterEachSpec {
- Deleter getDeleter();
-
- Checker getPostChecker();
-
AfterEachSpec DEFAULT = new AfterEachSpec() {
@Override
public Deleter getDeleter() {
return Deleter.DEFAULT;
}
-
+
@Override
public Checker getPostChecker() {
return Checker.DEFAULT;
}
};
+
+ /**
+ * get after each deleter.
+ * @return Deleter
+ */
+ Deleter getDeleter();
+
+ /**
+ * get after each post checker.
+ * @return Checker
+ */
+ Checker getPostChecker();
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/BeforeEachSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/BeforeEachSpec.java
index 0eb0cfdeb..60ec69e99 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/BeforeEachSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/BeforeEachSpec.java
@@ -25,26 +25,39 @@ import org.apache.shenyu.e2e.engine.scenario.function.Waiting;
@ShenYuScenarioParameter
public interface BeforeEachSpec {
- Checker getChecker();
-
- ResourcesData getResources();
-
- Waiting getWaiting();
-
BeforeEachSpec DEFAULT = new BeforeEachSpec() {
@Override
public Checker getChecker() {
return Checker.DEFAULT;
}
-
+
@Override
public ResourcesData getResources() {
return ResourcesData.builder().build();
}
-
+
@Override
public Waiting getWaiting() {
return Waiting.DEFAULT;
}
};
+
+ /**
+ * get before each spec checker.
+ * @return Checker
+ */
+ Checker getChecker();
+
+ /**
+ * get before each resource data.
+ * @return ResourcesData
+ */
+ ResourcesData getResources();
+
+ /**
+ * get before each waiting.
+ * @return Waiting
+ */
+ Waiting getWaiting();
+
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/CaseSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/CaseSpec.java
index 805484bfe..cb30193e5 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/CaseSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/CaseSpec.java
@@ -25,8 +25,16 @@ import java.util.List;
@ShenYuScenarioParameter
public interface CaseSpec {
+ /**
+ * get case spec name.
+ * @return String
+ */
String getName();
+ /**
+ * get case spec verifiers.
+ * @return List
+ */
List<Verifier> getVerifiers();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpec.java
index 667c76dde..2a0c5dd5a 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpec.java
@@ -24,14 +24,18 @@ import java.util.Objects;
@ShenYuScenarioParameter
public interface ScenarioSpec {
+ /**
+ * get scenario spec name.
+ * @return String
+ */
String getName();
/**
* Verify which type the class belongs to.
*
* @param type type
- * @return <T>
- * @param <T> <T>
+ * @param <T> <T>
+ * @return T
*/
default <T> T getByType(Class<T> type) {
if (type.isAssignableFrom(BeforeEachSpec.class)) {
@@ -52,9 +56,21 @@ public interface ScenarioSpec {
return null;
}
+ /**
+ * get before each spec.
+ * @return BeforeEachSpec
+ */
BeforeEachSpec getBeforeEachSpec();
+ /**
+ * get case spec.
+ * @return CaseSpec
+ */
CaseSpec getCaseSpec();
+ /**
+ * get after each spec.
+ * @return AfterEachSpec
+ */
AfterEachSpec getAfterEachSpec();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpecLogProxy.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpecLogProxy.java
index fb3010acb..0ed1488c4 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpecLogProxy.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ScenarioSpecLogProxy.java
@@ -30,14 +30,14 @@ public class ScenarioSpecLogProxy implements ScenarioSpec {
private final ScenarioSpec spec;
- public ScenarioSpecLogProxy(ScenarioSpec spec) {
+ public ScenarioSpecLogProxy(final ScenarioSpec spec) {
this.spec = spec;
}
@Override
public BeforeEachSpec getBeforeEachSpec() {
return new BeforeEachSpec() {
- final BeforeEachSpec spec = ScenarioSpecLogProxy.this.spec.getBeforeEachSpec();
+ private final BeforeEachSpec spec = ScenarioSpecLogProxy.this.spec.getBeforeEachSpec();
@Override
public Checker getChecker() {
@@ -62,7 +62,7 @@ public class ScenarioSpecLogProxy implements ScenarioSpec {
@Override
public CaseSpec getCaseSpec() {
return new CaseSpec() {
- final CaseSpec spec = ScenarioSpecLogProxy.this.spec.getCaseSpec();
+ private final CaseSpec spec = ScenarioSpecLogProxy.this.spec.getCaseSpec();
@Override
public String getName() {
@@ -80,7 +80,7 @@ public class ScenarioSpecLogProxy implements ScenarioSpec {
@Override
public AfterEachSpec getAfterEachSpec() {
return new AfterEachSpec() {
- final AfterEachSpec spec = ScenarioSpecLogProxy.this.spec.getAfterEachSpec();
+ private final AfterEachSpec spec = ScenarioSpecLogProxy.this.spec.getAfterEachSpec();
@Override
public Deleter getDeleter() {
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuAfterEachSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuAfterEachSpec.java
index ce5c1489d..41c38b019 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuAfterEachSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuAfterEachSpec.java
@@ -25,13 +25,13 @@ import org.apache.shenyu.e2e.engine.scenario.function.Deleter;
*/
public class ShenYuAfterEachSpec implements AfterEachSpec {
+ public static final ShenYuAfterEachSpec DEFAULT = new ShenYuAfterEachSpec(Deleter.DEFAULT, Checker.DEFAULT);
+
private final Deleter deleter;
private final Checker postChecker;
- public static final ShenYuAfterEachSpec DEFAULT = new ShenYuAfterEachSpec(Deleter.DEFAULT, Checker.DEFAULT);
-
- public ShenYuAfterEachSpec(Deleter deleter, Checker postChecker) {
+ public ShenYuAfterEachSpec(final Deleter deleter, final Checker postChecker) {
this.deleter = deleter;
this.postChecker = postChecker;
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuBeforeEachSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuBeforeEachSpec.java
index 5c49bd603..3c9f8aa86 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuBeforeEachSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuBeforeEachSpec.java
@@ -41,12 +41,16 @@ public class ShenYuBeforeEachSpec implements BeforeEachSpec {
private final Waiting waiting;
- ShenYuBeforeEachSpec(Checker checker, ResourcesData resources, Waiting waiting) {
+ ShenYuBeforeEachSpec(final Checker checker, final ResourcesData resources, final Waiting waiting) {
this.checker = checker;
this.resources = resources;
this.waiting = waiting;
}
-
+
+ /**
+ * builder.
+ * @return ShenYuBeforeEachSpecBuilder
+ */
public static ShenYuBeforeEachSpecBuilder builder() {
return new ShenYuBeforeEachSpecBuilder();
}
@@ -89,33 +93,65 @@ public class ShenYuBeforeEachSpec implements BeforeEachSpec {
private Waiting waiting = Waiting.DEFAULT;
- public ShenYuBeforeEachSpecBuilder checker(@NotNull Checker checker) {
+ /**
+ * builder set checker.
+ * @param checker checker
+ * @return ShenYuBeforeEachSpecBuilder
+ */
+ public ShenYuBeforeEachSpecBuilder checker(final @NotNull Checker checker) {
this.checker = checker;
return this;
}
- public ShenYuBeforeEachSpecBuilder addSelectorAndRule(SelectorData selector, RuleData... rules) {
+ /**
+ * builder add selector and rule.
+ * @param selector selector
+ * @param rules rules
+ * @return ShenYuBeforeEachSpecBuilder
+ */
+ public ShenYuBeforeEachSpecBuilder addSelectorAndRule(final SelectorData selector, final RuleData... rules) {
builder.add(selector, rules);
return this;
}
- public ShenYuBeforeEachSpecBuilder waiting(@NotNull Waiting waiting) {
+ /**
+ * builder set waiting.
+ * @param waiting waiting
+ * @return ShenYuBeforeEachSpecBuilder
+ */
+ public ShenYuBeforeEachSpecBuilder waiting(final @NotNull Waiting waiting) {
this.waiting = waiting;
return this;
}
- public ShenYuBeforeEachSpecBuilder waiting(Method method, String endpoint, ResponseSpecification expected) {
+ /**
+ * builder set waiting.
+ * @param method method
+ * @param endpoint endpoint
+ * @param expected expected
+ * @return ShenYuBeforeEachSpecBuilder
+ */
+ public ShenYuBeforeEachSpecBuilder waiting(final Method method, final String endpoint, final ResponseSpecification expected) {
this.waiting = (HttpWaiting) supplier -> WaitForHelper.waitForEffecting(supplier, method, endpoint, expected);
return this;
}
- public ShenYuBeforeEachSpecBuilder waiting(@NotNull Checker checker) {
+ /**
+ * builder set waiting with checker.
+ * @param checker checker
+ * @return ShenYuBeforeEachSpecBuilder
+ */
+ public ShenYuBeforeEachSpecBuilder waiting(final @NotNull Checker checker) {
this.waiting = (HttpWaiting) supplier -> {
WaitForHelper.waitForEffecting(supplier, (HttpChecker) checker);
};
return this;
}
+ /**
+ * builder build before each spec.
+ * @return ShenYuBeforeEachSpec
+ */
public ShenYuBeforeEachSpec build() {
return new ShenYuBeforeEachSpec(checker, builder.build(), waiting);
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuCaseSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuCaseSpec.java
index f390526b7..01471032b 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuCaseSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuCaseSpec.java
@@ -28,7 +28,6 @@ import java.util.List;
import static org.apache.shenyu.e2e.engine.scenario.function.HttpCheckers.exists;
import static org.apache.shenyu.e2e.engine.scenario.function.HttpCheckers.notExists;
-
/**
* ShenYu case specification.
*/
@@ -38,7 +37,7 @@ public class ShenYuCaseSpec implements CaseSpec {
private final List<Verifier> verifiers;
- public ShenYuCaseSpec(String name, List<Verifier> verifiers) {
+ public ShenYuCaseSpec(final String name, final List<Verifier> verifiers) {
this.name = name;
this.verifiers = verifiers;
}
@@ -62,12 +61,21 @@ public class ShenYuCaseSpec implements CaseSpec {
public List<Verifier> getVerifiers() {
return verifiers;
}
-
+
+ /**
+ * builder.
+ * @return ShenYuTestCaseSpecBuilder
+ */
public static ShenYuTestCaseSpecBuilder builder() {
return new ShenYuTestCaseSpecBuilder();
}
- public static ShenYuTestCaseSpecBuilder builder(String name) {
+ /**
+ * builder.
+ * @param name name
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public static ShenYuTestCaseSpecBuilder builder(final String name) {
return new ShenYuTestCaseSpecBuilder(name);
}
@@ -80,44 +88,95 @@ public class ShenYuCaseSpec implements CaseSpec {
public ShenYuTestCaseSpecBuilder() {
}
- public ShenYuTestCaseSpecBuilder(String name) {
+ public ShenYuTestCaseSpecBuilder(final String name) {
this.name = name;
}
-
- public ShenYuTestCaseSpecBuilder name(String name) {
+
+ /**
+ * builder set name.
+ * @param name name
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder name(final String name) {
this.name = name;
return this;
}
- public ShenYuTestCaseSpecBuilder add(Verifier verifier) {
+ /**
+ * builder add verifier.
+ * @param verifier verifier
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder add(final Verifier verifier) {
builder.add(verifier);
return this;
}
-
- public ShenYuTestCaseSpecBuilder addVerifier(String endpoint, Matcher<?> matcher, Matcher<?>... matchers) {
+
+ /**
+ * add verifier case spec.
+ * @param endpoint endpoint
+ * @param matcher matcher
+ * @param matchers matchers
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addVerifier(final String endpoint, final Matcher<?> matcher, final Matcher<?>... matchers) {
return addVerifier(Method.GET, endpoint, matcher, matchers);
}
- public ShenYuTestCaseSpecBuilder addVerifier(Method method, String endpoint, Matcher<?> matcher, Matcher<?>... matchers) {
+ /**
+ * add verifier case spec.
+ * @param method method
+ * @param endpoint endpoint
+ * @param matcher matcher
+ * @param matchers matchers
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addVerifier(final Method method, final String endpoint, final Matcher<?> matcher, final Matcher<?>... matchers) {
return add(supplier -> supplier.when().request(method, endpoint).then().assertThat().body(matcher, matchers));
}
- public ShenYuTestCaseSpecBuilder addExists(String endpoint) {
+ /**
+ * add exist endpoint case spec.
+ * @param endpoint endpoint
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addExists(final String endpoint) {
return addExists(Method.GET, endpoint);
}
- public ShenYuTestCaseSpecBuilder addExists(Method method, String endpoint) {
+ /**
+ * add exist method endpoint case spec.
+ * @param method method
+ * @param endpoint endpoint
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addExists(final Method method, final String endpoint) {
return add(exists(method, endpoint));
}
-
- public ShenYuTestCaseSpecBuilder addNotExists(String endpoint) {
+
+ /**
+ * add not exist endpoint case spec.
+ * @param endpoint endpoint
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addNotExists(final String endpoint) {
return addNotExists(Method.GET, endpoint);
}
- public ShenYuTestCaseSpecBuilder addNotExists(Method method, String endpoint) {
+ /**
+ * add not exists case spec.
+ * @param method method
+ * @param endpoint endpoint
+ * @return ShenYuTestCaseSpecBuilder
+ */
+ public ShenYuTestCaseSpecBuilder addNotExists(final Method method, final String endpoint) {
return add(notExists(method, endpoint));
}
+ /**
+ * build.
+ * @return ShenYuCaseSpec
+ */
public ShenYuCaseSpec build() {
return new ShenYuCaseSpec(name, builder.build());
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuScenarioSpec.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuScenarioSpec.java
index 00e77ae28..0981d7885 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuScenarioSpec.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/scenario/specification/ShenYuScenarioSpec.java
@@ -34,7 +34,7 @@ public class ShenYuScenarioSpec implements ScenarioSpec {
private final AfterEachSpec afterEachSpec;
- public ShenYuScenarioSpec(String name, BeforeEachSpec beforeEachSpec, CaseSpec caseSpec, AfterEachSpec afterEachSpec) {
+ public ShenYuScenarioSpec(final String name, final BeforeEachSpec beforeEachSpec, final CaseSpec caseSpec, final AfterEachSpec afterEachSpec) {
this.name = name;
this.beforeEachSpec = beforeEachSpec;
this.caseSpec = caseSpec;
@@ -80,7 +80,11 @@ public class ShenYuScenarioSpec implements ScenarioSpec {
public AfterEachSpec getAfterEachSpec() {
return afterEachSpec;
}
-
+
+ /**
+ * scenario specification builder.
+ * @return ShenYuScenarioSpecBuilder
+ */
public static ShenYuScenarioSpecBuilder builder() {
return new ShenYuScenarioSpecBuilder();
}
@@ -95,26 +99,50 @@ public class ShenYuScenarioSpec implements ScenarioSpec {
private CaseSpec caseSpec;
- public ShenYuScenarioSpecBuilder name(String name) {
+ /**
+ * name.
+ * @param name name
+ * @return ShenYuScenarioSpecBuilder
+ */
+ public ShenYuScenarioSpecBuilder name(final String name) {
this.name = name;
return this;
}
- public ShenYuScenarioSpecBuilder beforeEachSpec(BeforeEachSpec beforeEachSpec) {
+ /**
+ * before each spec.
+ * @param beforeEachSpec beforeEachSpec
+ * @return ShenYuScenarioSpecBuilder
+ */
+ public ShenYuScenarioSpecBuilder beforeEachSpec(final BeforeEachSpec beforeEachSpec) {
this.beforeEachSpec = beforeEachSpec;
return this;
}
- public ShenYuScenarioSpecBuilder caseSpec(CaseSpec caseSpec) {
+ /**
+ * case spec.
+ * @param caseSpec caseSpec
+ * @return ShenYuScenarioSpecBuilder
+ */
+ public ShenYuScenarioSpecBuilder caseSpec(final CaseSpec caseSpec) {
this.caseSpec = caseSpec;
return this;
}
- public ShenYuScenarioSpecBuilder afterEachSpec(AfterEachSpec afterEachSpec) {
+ /**
+ * after each spec.
+ * @param afterEachSpec afterEachSpec
+ * @return ShenYuScenarioSpecBuilder
+ */
+ public ShenYuScenarioSpecBuilder afterEachSpec(final AfterEachSpec afterEachSpec) {
this.afterEachSpec = afterEachSpec;
return this;
}
+ /**
+ * build.
+ * @return ShenYuScenarioSpec
+ */
public ShenYuScenarioSpec build() {
Assertions.assertNotNull(caseSpec, "CaseSpec is required.");
if (Strings.isNullOrEmpty(name)) {
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/DockerServiceCompose.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/DockerServiceCompose.java
index 1e824f3b6..ec84827ac 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/DockerServiceCompose.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/DockerServiceCompose.java
@@ -26,7 +26,7 @@ import org.apache.shenyu.e2e.client.gateway.GatewayClient;
import org.apache.shenyu.e2e.common.TableView;
import org.apache.shenyu.e2e.engine.config.ShenYuEngineConfigure.DockerConfigure;
import org.apache.shenyu.e2e.engine.config.ShenYuEngineConfigure.DockerConfigure.DockerServiceConfigure;
-import org.apache.shenyu.e2e.engine.handler.DataSynHandler;
+import org.apache.shenyu.e2e.engine.handler.DataSyncHandler;
import org.apache.shenyu.e2e.engine.service.docker.DockerComposeFile;
import org.apache.shenyu.e2e.engine.service.docker.ShenYuLogConsumer;
import org.slf4j.Logger;
@@ -36,12 +36,12 @@ import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.shaded.org.yaml.snakeyaml.DumperOptions;
import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -69,12 +69,12 @@ public class DockerServiceCompose implements ServiceCompose {
private List<DockerServiceConfigure> externalServiceConfigurations;
- public DockerServiceCompose(DockerConfigure configure) {
+ public DockerServiceCompose(final DockerConfigure configure) {
this.configure = configure;
this.adminConfigure = configure.getAdmin();
this.gatewayConfigure = configure.getGateway();
modifyGatewayConfiguration(this.gatewayConfigure);
- DataSynHandler.init();
+ DataSyncHandler.init();
chooseDataSyn(GATEWAY_YML_LOCATION, this.gatewayConfigure);
chooseDataSyn(ADMIN_YML_LOCATION, this.adminConfigure);
DockerComposeFile parsedDockerComposeFile = DockerComposeFile.parse(configure.getDockerComposeFile());
@@ -83,6 +83,10 @@ public class DockerServiceCompose implements ServiceCompose {
services.forEach(name -> container.withLogConsumer(name, new ShenYuLogConsumer(name)));
}
+ /**
+ * start.
+ */
+ @Override
public void start() {
exposedServices();
waitingForAvailable();
@@ -132,7 +136,7 @@ public class DockerServiceCompose implements ServiceCompose {
if (stateOpt.isPresent()) {
ContainerState state = stateOpt.get();
List<String> bindings = state.getPortBindings();
- for (String binding : bindings) {
+ for (final String binding : bindings) {
tableView.addRow(serviceConfigure.getServiceName(), binding.split(":"));
}
}
@@ -157,7 +161,7 @@ public class DockerServiceCompose implements ServiceCompose {
return getBaseUrlByService(gatewayConfigure);
}
- private String getBaseUrlByService(DockerServiceConfigure configure) {
+ private String getBaseUrlByService(final DockerServiceConfigure configure) {
return configure.getSchema() + "://"
+ container.getServiceHost(configure.getServiceName(), configure.getPort())
+ ":"
@@ -165,17 +169,17 @@ public class DockerServiceCompose implements ServiceCompose {
}
@Override
- public GatewayClient newGatewayClient(String scenarioId) {
+ public GatewayClient newGatewayClient(final String scenarioId) {
return new GatewayClient(scenarioId, getGatewayBaseUrl(), gatewayConfigure.getProperties());
}
@Override
- public AdminClient newAdminClient(String scenarioId) {
+ public AdminClient newAdminClient(final String scenarioId) {
return new AdminClient(scenarioId, getAdminBaseUrl(), adminConfigure.getProperties());
}
@Override
- public ExternalServiceClient newExternalServiceClient(String externalServiceName) {
+ public ExternalServiceClient newExternalServiceClient(final String externalServiceName) {
DockerServiceConfigure dockerServiceConfigure = configure.getExternalServices().stream()
.filter(e -> externalServiceName.equals(e.getServiceName()))
.findFirst()
@@ -184,6 +188,10 @@ public class DockerServiceCompose implements ServiceCompose {
return new ExternalServiceClient(url, dockerServiceConfigure.getProperties());
}
+ /**
+ * stop.
+ */
+ @Override
public void stop() {
container.stop();
}
@@ -193,17 +201,17 @@ public class DockerServiceCompose implements ServiceCompose {
*
* @param gatewayConfigure gatewayConfigure
*/
- private void modifyGatewayConfiguration(DockerServiceConfigure gatewayConfigure) {
+ private void modifyGatewayConfiguration(final DockerServiceConfigure gatewayConfigure) {
String value = gatewayConfigure.getProperties().getProperty("application");
if (Objects.isNull(value)) {
return;
}
- try (InputStream inputStream = new FileInputStream(GATEWAY_YML_LOCATION)) {
+ try (InputStream inputStream = Files.newInputStream(Paths.get(GATEWAY_YML_LOCATION))) {
Yaml yaml = new Yaml();
Map<String, Object> yamlData = yaml.load(inputStream);
String[] sonValues = value.split(",");
- for (String sonValue : sonValues) {
- String[] subModule = sonValue.split("\\:");
+ for (final String sonValue : sonValues) {
+ String[] subModule = sonValue.split(":");
String[] subModulePath = subModule[0].split("\\.");
@@ -215,15 +223,16 @@ public class DockerServiceCompose implements ServiceCompose {
options.setExplicitStart(true);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
yaml = new Yaml(options);
- try (OutputStream outputStream = new FileOutputStream(GATEWAY_YML_LOCATION)) {
+ try (OutputStream outputStream = Files.newOutputStream(Paths.get(GATEWAY_YML_LOCATION))) {
yaml.dump(yamlData, new OutputStreamWriter(outputStream));
}
} catch (IOException e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
- private void modifyYamlValue(Map<String, Object> yamlData, String[] subModulePath, String newValue) {
+ @SuppressWarnings("unchecked")
+ private void modifyYamlValue(final Map<String, Object> yamlData, final String[] subModulePath, final String newValue) {
if (subModulePath.length == 0) {
return;
}
@@ -245,14 +254,14 @@ public class DockerServiceCompose implements ServiceCompose {
* @param path path
* @param dockerServiceConfigure dockerServiceConfigure
*/
- private void chooseDataSyn(String path, DockerServiceConfigure dockerServiceConfigure) {
- String yamlFilePath = path;
- try (InputStream inputStream = new FileInputStream(yamlFilePath)) {
+ @SuppressWarnings("unchecked")
+ private void chooseDataSyn(final String path, final DockerServiceConfigure dockerServiceConfigure) {
+ try (InputStream inputStream = Files.newInputStream(Paths.get(path))) {
Yaml yaml = new Yaml();
Map<String, Object> yamlData = yaml.load(inputStream);
Map<String, Object> shenyuParameter = (Map<String, Object>) yamlData.get("shenyu");
Map<String, Object> parameter = (Map<String, Object>) shenyuParameter.get("sync");
- Map<String, Object> subParameters = DataSynHandler.getDataSynMap(dockerServiceConfigure.getProperties().getProperty("dataSyn"));
+ Map<String, Object> subParameters = DataSyncHandler.getDataSynMap(dockerServiceConfigure.getProperties().getProperty("dataSyn"));
String synMethod = "";
if (dockerServiceConfigure.getProperties().getProperty("dataSyn").contains("_")) {
synMethod = dockerServiceConfigure.getProperties().getProperty("dataSyn").split("_")[1];
@@ -267,12 +276,12 @@ public class DockerServiceCompose implements ServiceCompose {
options.setExplicitStart(true);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
yaml = new Yaml(options);
- try (OutputStream outputStream = new FileOutputStream(yamlFilePath)) {
+ try (OutputStream outputStream = Files.newOutputStream(Paths.get(path))) {
yaml.dump(yamlData, new OutputStreamWriter(outputStream));
log.info("YAML file modified successfully.");
}
} catch (IOException e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/HostServiceCompose.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/HostServiceCompose.java
index ff8b34633..939c84d17 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/HostServiceCompose.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/HostServiceCompose.java
@@ -33,9 +33,9 @@ import java.util.Objects;
*/
public class HostServiceCompose implements ServiceCompose {
- private HostConfigure configure;
+ private final HostConfigure configure;
- public HostServiceCompose(HostConfigure configure) {
+ public HostServiceCompose(final HostConfigure configure) {
this.configure = configure;
}
@@ -47,7 +47,11 @@ public class HostServiceCompose implements ServiceCompose {
public HostConfigure getConfigure() {
return configure;
}
-
+
+ /**
+ * start.
+ */
+ @Override
public void start() {
List<HostServiceConfigure> configures = Lists.newArrayList(configure.getExternalServices());
if (Objects.nonNull(configure.getAdmin())) {
@@ -60,19 +64,19 @@ public class HostServiceCompose implements ServiceCompose {
}
@Override
- public AdminClient newAdminClient(String scenarioId) {
+ public AdminClient newAdminClient(final String scenarioId) {
HostServiceConfigure adminConfigure = configure.getAdmin();
return new AdminClient(scenarioId, adminConfigure.getBaseUrl(), adminConfigure.getProperties());
}
@Override
- public GatewayClient newGatewayClient(String scenarioId) {
+ public GatewayClient newGatewayClient(final String scenarioId) {
HostServiceConfigure gatewayConfigure = configure.getGateway();
return new GatewayClient(scenarioId, gatewayConfigure.getBaseUrl(), gatewayConfigure.getProperties());
}
@Override
- public ExternalServiceClient newExternalServiceClient(String externalServiceName) {
+ public ExternalServiceClient newExternalServiceClient(final String externalServiceName) {
HostServiceConfigure serviceConfigure = configure.getExternalServices().stream()
.filter(e -> externalServiceName.equals(e.getServiceName()))
.findFirst()
@@ -80,6 +84,10 @@ public class HostServiceCompose implements ServiceCompose {
return new ExternalServiceClient(serviceConfigure.getBaseUrl(), serviceConfigure.getProperties());
}
+ /**
+ * stop.
+ */
+ @Override
public void stop() {
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/NamingResolver.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/NamingResolver.java
index b5a1e85dd..94d8608da 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/NamingResolver.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/NamingResolver.java
@@ -37,27 +37,37 @@ import java.util.stream.Collectors;
* Resolve name.
*/
public enum NamingResolver {
+
INSTANCE;
private static final Logger log = LoggerFactory.getLogger(NamingResolver.class);
private Map<String, String> namingMap;
- public void ofHostConfigure(List<HostServiceConfigure> serviceConfigures) {
+ /**
+ * resolve name of host configure.
+ * @param serviceConfigures serviceConfigures
+ */
+ public void ofHostConfigure(final List<HostServiceConfigure> serviceConfigures) {
namingMap = serviceConfigures.stream()
- .collect(Collectors.toMap(
- HostServiceConfigure::getServiceName,
- c -> getAddressFromBaseUrl(c.getBaseUrl())
- )
- );
+ .collect(Collectors.toMap(
+ HostServiceConfigure::getServiceName,
+ c -> getAddressFromBaseUrl(c.getBaseUrl())
+ )
+ );
}
- public void ofDockerConfigure(DockerComposeContainer<?> container) {
- final Map<String, String> _namingMap = Maps.newHashMap();
+ /**
+ * resolve name of docker configure.
+ * @param container container
+ */
+ public void ofDockerConfigure(final DockerComposeContainer<?> container) {
+ final Map<String, String> namingMap = Maps.newHashMap();
try {
Field field = container.getClass().getDeclaredField("serviceInstanceMap");
field.setAccessible(true);
Map<String, ?> serviceInstanceMap = (Map<String, ?>) field.get(container);
+ field.setAccessible(false);
serviceInstanceMap.keySet().forEach(e -> {
if (container.getContainerByServiceName(e).isPresent()) {
@@ -70,19 +80,18 @@ public enum NamingResolver {
.findFirst()
.ifPresent(net -> {
String ip = net.getValue().getIpAddress();
- Objects.requireNonNull(net.getValue().getAliases()).forEach(alias -> _namingMap.put(alias, ip));
+ Objects.requireNonNull(net.getValue().getAliases()).forEach(alias -> namingMap.put(alias, ip));
});
} else {
log.warn("service {} not exists", e);
}
});
- System.out.println(_namingMap);
} catch (NoSuchFieldException | IllegalAccessException ignore) {
}
- this.namingMap = ImmutableMap.<String, String>builder().putAll(_namingMap).build();
+ this.namingMap = ImmutableMap.<String, String>builder().putAll(namingMap).build();
}
- private static String getAddressFromBaseUrl(String baseUrl) {
+ private static String getAddressFromBaseUrl(final String baseUrl) {
String address = baseUrl.replaceFirst("http(s)*://", "");
if (address.contains("/")) {
int index = address.indexOf('/');
@@ -97,7 +106,7 @@ public enum NamingResolver {
* @param name represents serviceName, hostname, or domain.
* @return return resulted ip if resolved success. otherwise, return name.
*/
- public String resolve(String name) {
+ public String resolve(final String name) {
String rst = namingMap.get(name);
if (!Strings.isNullOrEmpty(rst)) {
log.info("resolved {} to {} by docker-compose", name, rst);
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/ServiceCompose.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/ServiceCompose.java
index a2e4daadf..64feb4b74 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/ServiceCompose.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/ServiceCompose.java
@@ -23,13 +23,34 @@ import org.apache.shenyu.e2e.client.gateway.GatewayClient;
public interface ServiceCompose {
+ /**
+ * service compose start.
+ */
void start();
+ /**
+ * new a scenario of admin client.
+ * @param scenarioId scenarioId
+ * @return AdminClient
+ */
AdminClient newAdminClient(String scenarioId);
+ /**
+ * new a scenario gateway client.
+ * @param scenarioId scenarioId
+ * @return GatewayClient
+ */
GatewayClient newGatewayClient(String scenarioId);
+ /**
+ * new an external service client with the extendServiceName.
+ * @param externalServiceName externalServiceName
+ * @return ExternalServiceClient
+ */
ExternalServiceClient newExternalServiceClient(String externalServiceName);
-
+
+ /**
+ * service compose stop.
+ */
void stop();
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/WaitingForStrategies.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/WaitingForStrategies.java
index c3630c7b8..d3d69f192 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/WaitingForStrategies.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/WaitingForStrategies.java
@@ -30,8 +30,13 @@ public class WaitingForStrategies {
private static final String GET = "GET";
private static final String ACTUATOR_HEALTH = "/actuator/health";
-
- public static WaitStrategy newAdminStrategy(int port) {
+
+ /**
+ * new a admin http wait strategy.
+ * @param port port
+ * @return WaitStrategy
+ */
+ public static WaitStrategy newAdminStrategy(final int port) {
return new HttpWaitStrategy()
.allowInsecure()
.forPort(port)
@@ -42,7 +47,12 @@ public class WaitingForStrategies {
.withStartupTimeout(Duration.ofMinutes(3));
}
- public static WaitStrategy newGatewayStrategy(int port) {
+ /**
+ * new a gateway http wait strategy.
+ * @param port port
+ * @return WaitStrategy
+ */
+ public static WaitStrategy newGatewayStrategy(final int port) {
return new HttpWaitStrategy()
.allowInsecure()
.forPort(port)
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/DockerComposeFile.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/DockerComposeFile.java
index ba0885f5a..d148c9d49 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/DockerComposeFile.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/DockerComposeFile.java
@@ -35,8 +35,12 @@ public class DockerComposeFile {
private final List<String> services;
-
private final File file;
+
+ DockerComposeFile(final List<String> services, final File file) {
+ this.services = services;
+ this.file = file;
+ }
/**
* get services.
@@ -55,20 +59,21 @@ public class DockerComposeFile {
public File getFile() {
return file;
}
-
- DockerComposeFile(List<String> services, File file) {
- this.services = services;
- this.file = file;
- }
- public static DockerComposeFile parse(String fileName) {
+ /**
+ * parse file to a docker compose file.
+ * @param fileName fileName
+ * @return DockerComposeFile
+ */
+ @SuppressWarnings("unchecked")
+ public static DockerComposeFile parse(final String fileName) {
final File file = Assertions.assertDoesNotThrow(
- () -> ResourceUtils.getFile(fileName),
- "docker-compose file '" + fileName + "' is not found"
+ () -> ResourceUtils.getFile(fileName),
+ "docker-compose file '" + fileName + "' is not found"
);
final InputStream compose = Assertions.assertDoesNotThrow(
- () -> new FileInputStream(file),
- "docker-compose file '" + fileName + "' is not found"
+ () -> new FileInputStream(file),
+ "docker-compose file '" + fileName + "' is not found"
);
final Yaml yaml = new Yaml(new LoaderOptions());
Map<String, Object> content = yaml.load(compose);
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/ShenYuLogConsumer.java b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/ShenYuLogConsumer.java
index ca8be49c4..cfbf3ab2c 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/ShenYuLogConsumer.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/main/java/org/apache/shenyu/e2e/engine/service/docker/ShenYuLogConsumer.java
@@ -28,7 +28,7 @@ public class ShenYuLogConsumer extends Slf4jLogConsumer {
private static final Logger log = LoggerFactory.getLogger("docker-compose");
- public ShenYuLogConsumer(String serviceName) {
+ public ShenYuLogConsumer(final String serviceName) {
super(log);
withPrefix("service_name:" + serviceName);
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/ShenYuEngineTest.java b/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/ShenYuEngineTest.java
index 51a2a8d3c..f1fe9382d 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/ShenYuEngineTest.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/ShenYuEngineTest.java
@@ -49,19 +49,21 @@ import java.time.Duration;
baseUrl = "http://localhost:19095",
parameters = {
@Parameter(key = "username", value = "admin"),
- @Parameter(key = "password", value = "123456"),
+ @Parameter(key = "password", value = "123456")
}
)
}
)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ShenYuEngineTest {
- private static DockerComposeContainer<?> compose = null;
+
+ private static final DockerComposeContainer<?> COMPOSE;
+
static {
- URL resource =ShenYuEngineTest.class.getResource("/docker-compose.yml");
- compose = new DockerComposeContainer<>("test", new File(resource.getPath()));
- compose.withExposedService("admin", 9095);
- compose.waitingFor("admin", new HttpWaitStrategy()
+ URL resource = ShenYuEngineTest.class.getResource("/docker-compose.yml");
+ COMPOSE = new DockerComposeContainer<>("test", new File(resource.getPath()));
+ COMPOSE.withExposedService("admin", 9095);
+ COMPOSE.waitingFor("admin", new HttpWaitStrategy()
.allowInsecure()
.forPort(9095)
.withMethod("GET")
@@ -70,22 +72,22 @@ public class ShenYuEngineTest {
.forResponsePredicate(body -> body.contains("username or password error"))
.withReadTimeout(Duration.ofMinutes(1))
.withStartupTimeout(Duration.ofMinutes(3)));
- compose.start();
+ COMPOSE.start();
}
@BeforeAll
- static void setup(AdminClient client) {
+ static void setup(final AdminClient client) {
client.login();
}
@Test
@Order(0)
- void testCreateSelector(AdminClient client) throws JsonProcessingException {
+ void testCreateSelector(final AdminClient client) throws JsonProcessingException {
}
@Test
- void testA(AdminClient client) {
+ void testA(final AdminClient client) {
SelectorQueryCondition condition = SelectorQueryCondition.builder()
.keyword("my-plugin-divide-4b519a373ae8-2b9b5c50")
.switchStatus(true)
@@ -95,18 +97,17 @@ public class ShenYuEngineTest {
}
@Test
- void testDeleteAllSelectors(AdminClient client) {
+ void testDeleteAllSelectors(final AdminClient client) {
client.deleteAllSelectors();
}
-
@Test
- void testListRules(AdminClient client) {
+ void testListRules(final AdminClient client) {
client.listAllRules().forEach(e -> client.deleteRules(e.getId()));
}
@AfterAll
static void teardown() {
- compose.close();
+ COMPOSE.close();
}
}
diff --git a/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/function/WaitForHelperTest.java b/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/function/WaitForHelperTest.java
index 4091e5ebe..10220adb5 100644
--- a/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/function/WaitForHelperTest.java
+++ b/shenyu-e2e/shenyu-e2e-engine/src/test/java/org/apache/shenyu/e2e/engine/function/WaitForHelperTest.java
@@ -44,13 +44,13 @@ public class WaitForHelperTest {
@Test
void testTimeout() {
- Assertions.assertThrows(TimeoutException.class, () -> {
+ Assertions.assertThrows(TimeoutException.class, () ->
new WaitForHelper(10, Duration.ofSeconds(1), Duration.ofMillis(500)).waitFor(
() -> given().baseUri("https://postman-echo.com").when(),
Method.GET,
"/delay/2",
new ResponseSpecBuilder().expectBody("delay", equalTo(2)).build()
- );
- });
+ )
+ );
}
}