Search in sources :

Example 1 with GlobalLockQueryRequestProto

use of io.seata.serializer.protobuf.generated.GlobalLockQueryRequestProto in project seata by seata.

the class GlobalLockQueryRequestConvertor method convert2Proto.

@Override
public GlobalLockQueryRequestProto convert2Proto(GlobalLockQueryRequest globalLockQueryRequest) {
    final short typeCode = globalLockQueryRequest.getTypeCode();
    final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
    final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
    final String applicationData = globalLockQueryRequest.getApplicationData();
    final String lockKey = globalLockQueryRequest.getLockKey();
    BranchRegisterRequestProto branchRegisterRequestProto = BranchRegisterRequestProto.newBuilder().setAbstractTransactionRequest(abstractTransactionRequestProto).setApplicationData(applicationData == null ? "" : applicationData).setBranchType(BranchTypeProto.valueOf(globalLockQueryRequest.getBranchType().name())).setLockKey(lockKey == null ? "" : lockKey).setResourceId(globalLockQueryRequest.getResourceId()).setXid(globalLockQueryRequest.getXid()).build();
    GlobalLockQueryRequestProto result = GlobalLockQueryRequestProto.newBuilder().setBranchRegisterRequest(branchRegisterRequestProto).build();
    return result;
}
Also used : BranchRegisterRequestProto(io.seata.serializer.protobuf.generated.BranchRegisterRequestProto) GlobalLockQueryRequestProto(io.seata.serializer.protobuf.generated.GlobalLockQueryRequestProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto) AbstractTransactionRequestProto(io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)

Example 2 with GlobalLockQueryRequestProto

use of io.seata.serializer.protobuf.generated.GlobalLockQueryRequestProto in project seata by seata.

the class GlobalLockQueryRequestConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    GlobalLockQueryRequest globalLockQueryRequest = new GlobalLockQueryRequest();
    globalLockQueryRequest.setApplicationData("data");
    globalLockQueryRequest.setBranchType(BranchType.AT);
    globalLockQueryRequest.setLockKey("localKey");
    globalLockQueryRequest.setResourceId("resourceId");
    globalLockQueryRequest.setXid("xid");
    GlobalLockQueryRequestConvertor convertor = new GlobalLockQueryRequestConvertor();
    GlobalLockQueryRequestProto proto = convertor.convert2Proto(globalLockQueryRequest);
    GlobalLockQueryRequest real = convertor.convert2Model(proto);
    assertThat(real.getTypeCode()).isEqualTo(globalLockQueryRequest.getTypeCode());
    assertThat(real.getApplicationData()).isEqualTo(globalLockQueryRequest.getApplicationData());
    assertThat(real.getXid()).isEqualTo(globalLockQueryRequest.getXid());
    assertThat(real.getBranchType()).isEqualTo(globalLockQueryRequest.getBranchType());
    assertThat(real.getLockKey()).isEqualTo(globalLockQueryRequest.getLockKey());
    assertThat(real.getResourceId()).isEqualTo(globalLockQueryRequest.getResourceId());
}
Also used : GlobalLockQueryRequest(io.seata.core.protocol.transaction.GlobalLockQueryRequest) GlobalLockQueryRequestProto(io.seata.serializer.protobuf.generated.GlobalLockQueryRequestProto) Test(org.junit.jupiter.api.Test)

Aggregations

GlobalLockQueryRequestProto (io.seata.serializer.protobuf.generated.GlobalLockQueryRequestProto)2 GlobalLockQueryRequest (io.seata.core.protocol.transaction.GlobalLockQueryRequest)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractTransactionRequestProto (io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)1 BranchRegisterRequestProto (io.seata.serializer.protobuf.generated.BranchRegisterRequestProto)1 Test (org.junit.jupiter.api.Test)1