Search in sources :

Example 1 with GlobalRollbackRequestProto

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

the class GlobalRollbackRequestConvertor method convert2Proto.

@Override
public GlobalRollbackRequestProto convert2Proto(GlobalRollbackRequest globalRollbackRequest) {
    final short typeCode = globalRollbackRequest.getTypeCode();
    final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
    final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
    final String extraData = globalRollbackRequest.getExtraData();
    AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder().setAbstractTransactionRequest(abstractTransactionRequestProto).setXid(globalRollbackRequest.getXid()).setExtraData(extraData == null ? "" : extraData).build();
    GlobalRollbackRequestProto result = GlobalRollbackRequestProto.newBuilder().setAbstractGlobalEndRequest(abstractGlobalEndRequestProto).build();
    return result;
}
Also used : AbstractGlobalEndRequestProto(io.seata.serializer.protobuf.generated.AbstractGlobalEndRequestProto) GlobalRollbackRequestProto(io.seata.serializer.protobuf.generated.GlobalRollbackRequestProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto) AbstractTransactionRequestProto(io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)

Example 2 with GlobalRollbackRequestProto

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

the class GlobalRollbackRequestConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    GlobalRollbackRequest globalRollbackRequest = new GlobalRollbackRequest();
    globalRollbackRequest.setExtraData("extraData");
    globalRollbackRequest.setXid("xid");
    GlobalRollbackRequestConvertor convertor = new GlobalRollbackRequestConvertor();
    GlobalRollbackRequestProto proto = convertor.convert2Proto(globalRollbackRequest);
    GlobalRollbackRequest real = convertor.convert2Model(proto);
    assertThat((real.getTypeCode())).isEqualTo(globalRollbackRequest.getTypeCode());
    assertThat((real.getXid())).isEqualTo(globalRollbackRequest.getXid());
    assertThat((real.getExtraData())).isEqualTo(globalRollbackRequest.getExtraData());
}
Also used : GlobalRollbackRequest(io.seata.core.protocol.transaction.GlobalRollbackRequest) GlobalRollbackRequestProto(io.seata.serializer.protobuf.generated.GlobalRollbackRequestProto) Test(org.junit.jupiter.api.Test)

Aggregations

GlobalRollbackRequestProto (io.seata.serializer.protobuf.generated.GlobalRollbackRequestProto)2 GlobalRollbackRequest (io.seata.core.protocol.transaction.GlobalRollbackRequest)1 AbstractGlobalEndRequestProto (io.seata.serializer.protobuf.generated.AbstractGlobalEndRequestProto)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractTransactionRequestProto (io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)1 Test (org.junit.jupiter.api.Test)1