mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-08 03:49:56 +08:00
调整下行集成测试
This commit is contained in:
@@ -12,6 +12,7 @@ import sanbing.jcpp.app.dal.config.ibatis.enums.GunOptStatusEnum;
|
|||||||
import sanbing.jcpp.app.dal.config.ibatis.enums.GunRunStatusEnum;
|
import sanbing.jcpp.app.dal.config.ibatis.enums.GunRunStatusEnum;
|
||||||
import sanbing.jcpp.app.dal.config.ibatis.enums.OwnerTypeEnum;
|
import sanbing.jcpp.app.dal.config.ibatis.enums.OwnerTypeEnum;
|
||||||
import sanbing.jcpp.app.dal.entity.Gun;
|
import sanbing.jcpp.app.dal.entity.Gun;
|
||||||
|
import sanbing.jcpp.app.dal.entity.Pile;
|
||||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -37,9 +38,13 @@ class GunMapperIT extends AbstractTestBase {
|
|||||||
UUID.fromString("3f3a61e9-de55-4177-9b4e-3a1d8c529890"),
|
UUID.fromString("3f3a61e9-de55-4177-9b4e-3a1d8c529890"),
|
||||||
UUID.fromString("cf1a8970-5aa9-4636-a76e-d6bcf98b4a07")
|
UUID.fromString("cf1a8970-5aa9-4636-a76e-d6bcf98b4a07")
|
||||||
};
|
};
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
GunMapper gunMapper;
|
GunMapper gunMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PileMapper pileMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void curdTest() {
|
void curdTest() {
|
||||||
gunMapper.delete(Wrappers.lambdaQuery());
|
gunMapper.delete(Wrappers.lambdaQuery());
|
||||||
@@ -47,13 +52,16 @@ class GunMapperIT extends AbstractTestBase {
|
|||||||
for (int i = 0; i < NORMAL_PILE_ID.length; i++) {
|
for (int i = 0; i < NORMAL_PILE_ID.length; i++) {
|
||||||
UUID pileId = NORMAL_PILE_ID[i];
|
UUID pileId = NORMAL_PILE_ID[i];
|
||||||
UUID gunId = NORMAL_GUN_ID[i];
|
UUID gunId = NORMAL_GUN_ID[i];
|
||||||
|
|
||||||
|
Pile pile = pileMapper.selectById(pileId);
|
||||||
|
|
||||||
Gun gun = Gun.builder()
|
Gun gun = Gun.builder()
|
||||||
.id(gunId)
|
.id(gunId)
|
||||||
.createdTime(LocalDateTime.now())
|
.createdTime(LocalDateTime.now())
|
||||||
.additionalInfo(JacksonUtil.newObjectNode())
|
.additionalInfo(JacksonUtil.newObjectNode())
|
||||||
.gunNo("01")
|
.gunNo("02")
|
||||||
.gunName("三丙的1号枪")
|
.gunName(pile.getPileName() + "的2号枪")
|
||||||
.gunCode("20231212000001-" + (i + 1))
|
.gunCode(pile.getPileCode() + "-02")
|
||||||
.stationId(NORMAL_STATION_ID)
|
.stationId(NORMAL_STATION_ID)
|
||||||
.pileId(pileId)
|
.pileId(pileId)
|
||||||
.ownerId(NORMAL_USER_ID)
|
.ownerId(NORMAL_USER_ID)
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
|
|||||||
binaryHandlerConfig.getLengthFieldOffset(), binaryHandlerConfig.getLengthFieldLength(),
|
binaryHandlerConfig.getLengthFieldOffset(), binaryHandlerConfig.getLengthFieldLength(),
|
||||||
binaryHandlerConfig.getLengthAdjustment(), binaryHandlerConfig.getInitialBytesToStrip());
|
binaryHandlerConfig.getLengthAdjustment(), binaryHandlerConfig.getInitialBytesToStrip());
|
||||||
|
|
||||||
|
|
||||||
group = new NioEventLoopGroup();
|
group = new NioEventLoopGroup();
|
||||||
Bootstrap b = new Bootstrap();
|
Bootstrap b = new Bootstrap();
|
||||||
b.group(group)
|
b.group(group)
|
||||||
@@ -80,7 +79,6 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
|
|||||||
.addLast(new SimpleChannelInboundHandler<>() {
|
.addLast(new SimpleChannelInboundHandler<>() {
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
|
||||||
log.info("接收到下行报文:{}", msg);
|
log.info("接收到下行报文:{}", msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -105,14 +103,19 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
|
|||||||
// 先发送一段登录
|
// 先发送一段登录
|
||||||
channel.writeAndFlush(Unpooled.wrappedBuffer(HexUtil.decodeHex("6822001900012023121200001001011047562e393572313300898604d11722d0348606024E87"))).sync();
|
channel.writeAndFlush(Unpooled.wrappedBuffer(HexUtil.decodeHex("6822001900012023121200001001011047562e393572313300898604d11722d0348606024E87"))).sync();
|
||||||
|
|
||||||
// 停一会等注册完成 todo 也可以读下行消息判断是否登录成功
|
// 一直检查等待会话注册完成
|
||||||
Thread.sleep(1000);
|
UUID sessionId;
|
||||||
|
while (true) {
|
||||||
|
if (sessionRegistryProvider.getSessionCache().asMap().values().stream().findFirst().isPresent()) {
|
||||||
|
ProtocolSession protocolSession = sessionRegistryProvider.getSessionCache().asMap().values().stream().findFirst().get();
|
||||||
|
sessionId = protocolSession.getId();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
UUID messageId = UUID.randomUUID();
|
UUID messageId = UUID.randomUUID();
|
||||||
ProtocolSession protocolSession = sessionRegistryProvider.getSessionCache().asMap().values().stream().findFirst().get();
|
|
||||||
UUID sessionId = protocolSession.getId();
|
|
||||||
UUID requestId = UUID.randomUUID();
|
UUID requestId = UUID.randomUUID();
|
||||||
|
|
||||||
// 创建 DownlinkRestMessage 实例
|
// 创建 DownlinkRestMessage 实例
|
||||||
String pileCode = "20231212000010";
|
String pileCode = "20231212000010";
|
||||||
DownlinkRestMessage downlinkMsg = DownlinkRestMessage.newBuilder()
|
DownlinkRestMessage downlinkMsg = DownlinkRestMessage.newBuilder()
|
||||||
|
|||||||
Reference in New Issue
Block a user