use of io.seata.serializer.protobuf.generated.GlobalBeginRequestProto in project seata by seata.
the class GlobalBeginRequestConvertor method convert2Proto.
@Override
public GlobalBeginRequestProto convert2Proto(GlobalBeginRequest globalBeginRequest) {
final short typeCode = globalBeginRequest.getTypeCode();
final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
GlobalBeginRequestProto result = GlobalBeginRequestProto.newBuilder().setTimeout(globalBeginRequest.getTimeout()).setTransactionName(globalBeginRequest.getTransactionName()).setAbstractTransactionRequest(abstractTransactionRequestProto).build();
return result;
}
use of io.seata.serializer.protobuf.generated.GlobalBeginRequestProto in project seata by seata.
the class GlobalBeginRequestConvertorTest method convert2Proto.
@Test
public void convert2Proto() {
GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
globalBeginRequest.setTimeout(3000);
globalBeginRequest.setTransactionName("taa");
GlobalBeginRequestConvertor convertor = new GlobalBeginRequestConvertor();
GlobalBeginRequestProto proto = convertor.convert2Proto(globalBeginRequest);
GlobalBeginRequest real = convertor.convert2Model(proto);
assertThat(real.getTypeCode()).isEqualTo(globalBeginRequest.getTypeCode());
assertThat(real.getTimeout()).isEqualTo(globalBeginRequest.getTimeout());
assertThat(real.getTransactionName()).isEqualTo(globalBeginRequest.getTransactionName());
}
Aggregations