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());
}
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;
}
Aggregations