-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored SentinelGrpcServerInterceptorTest #101
Refactored SentinelGrpcServerInterceptorTest #101
Conversation
Codecov Report
@@ Coverage Diff @@
## master #101 +/- ##
============================================
- Coverage 45.98% 45.84% -0.14%
+ Complexity 557 556 -1
============================================
Files 113 114 +1
Lines 3806 3813 +7
Branches 530 531 +1
============================================
- Hits 1750 1748 -2
- Misses 1846 1854 +8
- Partials 210 211 +1
Continue to review full report at Codecov.
|
GrpcTestServer() { | ||
} | ||
|
||
void prepare(int port) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the name start
may be more appropriate.
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove unused imports.
@@ -43,8 +39,8 @@ | |||
|
|||
private final String resourceName = "com.alibaba.sentinel.examples.FooService/anotherHello"; | |||
private final int threshold = 4; | |||
private final GrpcTestServer extractedSentinelGrpcServerInterceptorTest = new GrpcTestServer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is too long, just grpcTestServer
is okay.
…t' into feature/refactored-sentinel-grpc-server-interceptor-test # Conflicts: # sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/GrpcTestServer.java
} | ||
ServerBuilder<?> serverBuild = ServerBuilder.forPort(port) | ||
.addService(new FooServiceImpl()); | ||
if(shouldintercept) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat your code with Alibaba P3C Plugin and obey the rules in Alibaba Java Coding Guidelines (naming, indent, format, etc.). For example:
if (shouldIntercept) {
serverBuilder.intercept(new SentinelGrpcServerInterceptor());
}
Hi @sczyh30 , reformatted the code. |
Nice, thanks for your contribution! |
- Added a GrpcTestServer to abstract common server logic - Refactor with new added `GrpcTestServer`
Performed extract class operation for SentinelGrpcServerInterceptorTest. Extracted fields: server. Extracted Methods: prepareServer, stopServer.