Search in sources :

Example 1 with GlobalStatusResponseProto

use of io.seata.serializer.protobuf.generated.GlobalStatusResponseProto in project seata by seata.

the class GlobalStatusResponseConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    GlobalStatusResponse globalStatusResponse = new GlobalStatusResponse();
    globalStatusResponse.setGlobalStatus(GlobalStatus.AsyncCommitting);
    globalStatusResponse.setMsg("msg");
    globalStatusResponse.setResultCode(ResultCode.Failed);
    globalStatusResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchRegisterFailed);
    GlobalStatusResponseConvertor convertor = new GlobalStatusResponseConvertor();
    GlobalStatusResponseProto proto = convertor.convert2Proto(globalStatusResponse);
    GlobalStatusResponse real = convertor.convert2Model(proto);
    assertThat((real.getTypeCode())).isEqualTo(globalStatusResponse.getTypeCode());
    assertThat((real.getMsg())).isEqualTo(globalStatusResponse.getMsg());
    assertThat((real.getResultCode())).isEqualTo(globalStatusResponse.getResultCode());
    assertThat((real.getTransactionExceptionCode())).isEqualTo(globalStatusResponse.getTransactionExceptionCode());
}
Also used : GlobalStatusResponseProto(io.seata.serializer.protobuf.generated.GlobalStatusResponseProto) GlobalStatusResponse(io.seata.core.protocol.transaction.GlobalStatusResponse) Test(org.junit.jupiter.api.Test)

Example 2 with GlobalStatusResponseProto

use of io.seata.serializer.protobuf.generated.GlobalStatusResponseProto in project seata by seata.

the class GlobalStatusResponseConvertor method convert2Proto.

@Override
public GlobalStatusResponseProto convert2Proto(GlobalStatusResponse globalStatusResponse) {
    final short typeCode = globalStatusResponse.getTypeCode();
    final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
    final String msg = globalStatusResponse.getMsg();
    final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg(msg == null ? "" : msg).setResultCode(ResultCodeProto.valueOf(globalStatusResponse.getResultCode().name())).setAbstractMessage(abstractMessage).build();
    AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto.newBuilder().setAbstractResultMessage(abstractResultMessageProto).setTransactionExceptionCode(TransactionExceptionCodeProto.valueOf(globalStatusResponse.getTransactionExceptionCode().name())).build();
    AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder().setAbstractTransactionResponse(abstractTransactionResponseProto).setGlobalStatus(GlobalStatusProto.valueOf(globalStatusResponse.getGlobalStatus().name())).build();
    GlobalStatusResponseProto result = GlobalStatusResponseProto.newBuilder().setAbstractGlobalEndResponse(abstractGlobalEndResponseProto).build();
    return result;
}
Also used : AbstractResultMessageProto(io.seata.serializer.protobuf.generated.AbstractResultMessageProto) AbstractGlobalEndResponseProto(io.seata.serializer.protobuf.generated.AbstractGlobalEndResponseProto) AbstractTransactionResponseProto(io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto) GlobalStatusResponseProto(io.seata.serializer.protobuf.generated.GlobalStatusResponseProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto)

Aggregations

GlobalStatusResponseProto (io.seata.serializer.protobuf.generated.GlobalStatusResponseProto)2 GlobalStatusResponse (io.seata.core.protocol.transaction.GlobalStatusResponse)1 AbstractGlobalEndResponseProto (io.seata.serializer.protobuf.generated.AbstractGlobalEndResponseProto)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractResultMessageProto (io.seata.serializer.protobuf.generated.AbstractResultMessageProto)1 AbstractTransactionResponseProto (io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto)1 Test (org.junit.jupiter.api.Test)1