Search in sources :

Example 1 with GlobalRollbackResponseProto

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

the class GlobalRollbackResponseConvertor method convert2Proto.

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

Example 2 with GlobalRollbackResponseProto

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

the class GlobalRollbackResponseConvertorTest method convert2Proto.

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

Aggregations

GlobalRollbackResponseProto (io.seata.serializer.protobuf.generated.GlobalRollbackResponseProto)2 GlobalRollbackResponse (io.seata.core.protocol.transaction.GlobalRollbackResponse)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