Search in sources :

Example 1 with GlobalStatusRequestProto

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

the class GlobalStatusRequestConvertorTest method convert2Proto.

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

Example 2 with GlobalStatusRequestProto

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

the class GlobalStatusRequestConvertor method convert2Proto.

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

Aggregations

GlobalStatusRequestProto (io.seata.serializer.protobuf.generated.GlobalStatusRequestProto)2 GlobalStatusRequest (io.seata.core.protocol.transaction.GlobalStatusRequest)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