Search in sources :

Example 1 with GlobalBeginRequestProto

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;
}
Also used : GlobalBeginRequestProto(io.seata.serializer.protobuf.generated.GlobalBeginRequestProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto) AbstractTransactionRequestProto(io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)

Example 2 with GlobalBeginRequestProto

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());
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest) GlobalBeginRequestProto(io.seata.serializer.protobuf.generated.GlobalBeginRequestProto) Test(org.junit.jupiter.api.Test)

Aggregations

GlobalBeginRequestProto (io.seata.serializer.protobuf.generated.GlobalBeginRequestProto)2 GlobalBeginRequest (io.seata.core.protocol.transaction.GlobalBeginRequest)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractTransactionRequestProto (io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)1 Test (org.junit.jupiter.api.Test)1