pandaapo commented on code in PR #4480:
URL: https://github.com/apache/eventmesh/pull/4480#discussion_r1352312742
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java:
##########
@@ -171,35 +167,31 @@ public Package dispatcher(Package request, long timeout)
throws Exception {
Package response = super.io(request, timeout);
switch (request.getHeader().getCommand()) {
case HELLO_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HELLO_RESPONSE);
+ Assertions.assertEquals(Command.HELLO_RESPONSE,
response.getHeader().getCommand());
break;
case HEARTBEAT_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HEARTBEAT_RESPONSE);
+ Assertions.assertEquals(Command.HEARTBEAT_RESPONSE,
response.getHeader().getCommand());
break;
case LISTEN_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.LISTEN_RESPONSE);
+ Assertions.assertEquals(Command.LISTEN_RESPONSE,
response.getHeader().getCommand());
break;
case CLIENT_GOODBYE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.CLIENT_GOODBYE_RESPONSE);
+ Assertions.assertEquals(Command.CLIENT_GOODBYE_RESPONSE,
response.getHeader().getCommand());
break;
case SUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.SUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.SUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case UNSUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.UNSUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.UNSUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case SYS_LOG_TO_LOGSERVER:
- Assertions.assertNull(response);
- break;
case TRACE_LOG_TO_LOGSERVER:
Assertions.assertNull(response);
break;
default:
break;
}
- if (response != null) {
- assert response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
- }
+ assert response == null || response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
Review Comment:
Actually, since this is a unit testing module, using Junit assertions
directly is the better choice. After all, the `assert` keyword is not enabled
by default for assertion checking in Java runtime.
--
其实,既然这是个单元测试模块,直接使用Junit的断言是最好的。毕竟`assert`关键字在java执行时默认不开启断言检查。
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java:
##########
@@ -171,35 +167,31 @@ public Package dispatcher(Package request, long timeout)
throws Exception {
Package response = super.io(request, timeout);
switch (request.getHeader().getCommand()) {
case HELLO_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HELLO_RESPONSE);
+ Assertions.assertEquals(Command.HELLO_RESPONSE,
response.getHeader().getCommand());
break;
case HEARTBEAT_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HEARTBEAT_RESPONSE);
+ Assertions.assertEquals(Command.HEARTBEAT_RESPONSE,
response.getHeader().getCommand());
break;
case LISTEN_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.LISTEN_RESPONSE);
+ Assertions.assertEquals(Command.LISTEN_RESPONSE,
response.getHeader().getCommand());
break;
case CLIENT_GOODBYE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.CLIENT_GOODBYE_RESPONSE);
+ Assertions.assertEquals(Command.CLIENT_GOODBYE_RESPONSE,
response.getHeader().getCommand());
break;
case SUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.SUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.SUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case UNSUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.UNSUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.UNSUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case SYS_LOG_TO_LOGSERVER:
- Assertions.assertNull(response);
- break;
case TRACE_LOG_TO_LOGSERVER:
Assertions.assertNull(response);
break;
default:
break;
}
- if (response != null) {
- assert response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
- }
+ assert response == null || response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
Review Comment:
Actually, since this is a unit testing module, using Junit assertions
directly is the better choice. After all, the `assert` keyword is not enabled
by default for assertion checking in Java runtime.
--
其实,既然这是个单元测试模块,直接使用Junit的断言是最好的。毕竟`assert`关键字在java执行时默认不开启断言检查。
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java:
##########
@@ -171,35 +167,31 @@ public Package dispatcher(Package request, long timeout)
throws Exception {
Package response = super.io(request, timeout);
switch (request.getHeader().getCommand()) {
case HELLO_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HELLO_RESPONSE);
+ Assertions.assertEquals(Command.HELLO_RESPONSE,
response.getHeader().getCommand());
break;
case HEARTBEAT_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.HEARTBEAT_RESPONSE);
+ Assertions.assertEquals(Command.HEARTBEAT_RESPONSE,
response.getHeader().getCommand());
break;
case LISTEN_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.LISTEN_RESPONSE);
+ Assertions.assertEquals(Command.LISTEN_RESPONSE,
response.getHeader().getCommand());
break;
case CLIENT_GOODBYE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.CLIENT_GOODBYE_RESPONSE);
+ Assertions.assertEquals(Command.CLIENT_GOODBYE_RESPONSE,
response.getHeader().getCommand());
break;
case SUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.SUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.SUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case UNSUBSCRIBE_REQUEST:
- Assertions.assertEquals(response.getHeader().getCommand(),
Command.UNSUBSCRIBE_RESPONSE);
+ Assertions.assertEquals(Command.UNSUBSCRIBE_RESPONSE,
response.getHeader().getCommand());
break;
case SYS_LOG_TO_LOGSERVER:
- Assertions.assertNull(response);
- break;
case TRACE_LOG_TO_LOGSERVER:
Assertions.assertNull(response);
break;
default:
break;
}
- if (response != null) {
- assert response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
- }
+ assert response == null || response.getHeader().getCode() ==
OPStatus.SUCCESS.getCode();
Review Comment:
Actually, since this is a unit testing module, using Junit assertions
directly is the better choice. After all, the `assert` keyword is not enabled
by default for assertion checking in Java runtime.
---
其实,既然这是个单元测试模块,直接使用Junit的断言是最好的。毕竟`assert`关键字在java执行时默认不开启断言检查。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]