use of io.seata.serializer.protobuf.generated.GlobalCommitRequestProto in project seata by seata.
the class GlobalCommitRequestConvertor method convert2Proto.
@Override
public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) {
final short typeCode = globalCommitRequest.getTypeCode();
final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
final String extraData = globalCommitRequest.getExtraData();
AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder().setAbstractTransactionRequest(abstractTransactionRequestProto).setXid(globalCommitRequest.getXid()).setExtraData(extraData == null ? "" : extraData).build();
GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest(abstractGlobalEndRequestProto).build();
return result;
}
use of io.seata.serializer.protobuf.generated.GlobalCommitRequestProto in project seata by seata.
the class GlobalCommitRequestConvertorTest method convert2Proto.
@Test
public void convert2Proto() {
GlobalCommitRequest globalCommitRequest = new GlobalCommitRequest();
globalCommitRequest.setExtraData("extraData");
globalCommitRequest.setXid("xid");
GlobalCommitRequestConvertor convertor = new GlobalCommitRequestConvertor();
GlobalCommitRequestProto proto = convertor.convert2Proto(globalCommitRequest);
GlobalCommitRequest real = convertor.convert2Model(proto);
assertThat((real.getTypeCode())).isEqualTo(globalCommitRequest.getTypeCode());
assertThat((real.getXid())).isEqualTo(globalCommitRequest.getXid());
assertThat((real.getExtraData())).isEqualTo(globalCommitRequest.getExtraData());
}
Aggregations