Search in sources :

Example 1 with GlobalCommitResponseProto

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

the class GlobalCommitResponseConvertorTest method convert2Proto.

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

Example 2 with GlobalCommitResponseProto

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

the class GlobalCommitResponseConvertor method convert2Proto.

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

Aggregations

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