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