Search in sources :

Example 1 with BranchRollbackRequestProto

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

the class BranchRollbackRequestConvertor method convert2Proto.

@Override
public BranchRollbackRequestProto convert2Proto(BranchRollbackRequest branchRollbackRequest) {
    final short typeCode = branchRollbackRequest.getTypeCode();
    final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
    final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
    final String applicationData = branchRollbackRequest.getApplicationData();
    final String resourceId = branchRollbackRequest.getResourceId();
    final AbstractBranchEndRequestProto abstractBranchEndRequestProto = AbstractBranchEndRequestProto.newBuilder().setAbstractTransactionRequest(abstractTransactionRequestProto).setXid(branchRollbackRequest.getXid()).setBranchId(branchRollbackRequest.getBranchId()).setBranchType(BranchTypeProto.valueOf(branchRollbackRequest.getBranchType().name())).setApplicationData(applicationData == null ? "" : applicationData).setResourceId(resourceId == null ? "" : resourceId).build();
    BranchRollbackRequestProto result = BranchRollbackRequestProto.newBuilder().setAbstractBranchEndRequest(abstractBranchEndRequestProto).build();
    return result;
}
Also used : AbstractBranchEndRequestProto(io.seata.serializer.protobuf.generated.AbstractBranchEndRequestProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto) AbstractTransactionRequestProto(io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto) BranchRollbackRequestProto(io.seata.serializer.protobuf.generated.BranchRollbackRequestProto)

Example 2 with BranchRollbackRequestProto

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

the class BranchRollbackRequestConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    BranchRollbackRequest branchRegisterRequest = new BranchRollbackRequest();
    branchRegisterRequest.setApplicationData("data");
    branchRegisterRequest.setBranchType(BranchType.AT);
    branchRegisterRequest.setResourceId("resourceId");
    branchRegisterRequest.setXid("xid");
    branchRegisterRequest.setBranchId(123);
    BranchRollbackRequestConvertor convertor = new BranchRollbackRequestConvertor();
    BranchRollbackRequestProto proto = convertor.convert2Proto(branchRegisterRequest);
    BranchRollbackRequest real = convertor.convert2Model(proto);
    assertThat((real.getTypeCode())).isEqualTo(branchRegisterRequest.getTypeCode());
    assertThat((real.getApplicationData())).isEqualTo(branchRegisterRequest.getApplicationData());
    assertThat((real.getBranchType())).isEqualTo(branchRegisterRequest.getBranchType());
    assertThat((real.getXid())).isEqualTo(branchRegisterRequest.getXid());
    assertThat((real.getResourceId())).isEqualTo(branchRegisterRequest.getResourceId());
    assertThat((real.getBranchId())).isEqualTo(branchRegisterRequest.getBranchId());
}
Also used : BranchRollbackRequest(io.seata.core.protocol.transaction.BranchRollbackRequest) BranchRollbackRequestProto(io.seata.serializer.protobuf.generated.BranchRollbackRequestProto) Test(org.junit.jupiter.api.Test)

Aggregations

BranchRollbackRequestProto (io.seata.serializer.protobuf.generated.BranchRollbackRequestProto)2 BranchRollbackRequest (io.seata.core.protocol.transaction.BranchRollbackRequest)1 AbstractBranchEndRequestProto (io.seata.serializer.protobuf.generated.AbstractBranchEndRequestProto)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractTransactionRequestProto (io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)1 Test (org.junit.jupiter.api.Test)1