Search in sources :

Example 1 with BranchReportResponseProto

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

the class BranchReportResponseConvertor method convert2Proto.

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

Example 2 with BranchReportResponseProto

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

the class BranchReportResponseConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    BranchReportResponse branchReportResponse = new BranchReportResponse();
    branchReportResponse.setMsg("msg");
    branchReportResponse.setResultCode(ResultCode.Failed);
    branchReportResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotExist);
    BranchReportResponseConvertor convertor = new BranchReportResponseConvertor();
    BranchReportResponseProto proto = convertor.convert2Proto(branchReportResponse);
    BranchReportResponse real = convertor.convert2Model(proto);
    assertThat((real.getTypeCode())).isEqualTo(branchReportResponse.getTypeCode());
    assertThat((real.getMsg())).isEqualTo(branchReportResponse.getMsg());
    assertThat((real.getResultCode())).isEqualTo(branchReportResponse.getResultCode());
    assertThat((real.getTransactionExceptionCode())).isEqualTo(branchReportResponse.getTransactionExceptionCode());
}
Also used : BranchReportResponse(io.seata.core.protocol.transaction.BranchReportResponse) BranchReportResponseProto(io.seata.serializer.protobuf.generated.BranchReportResponseProto) Test(org.junit.jupiter.api.Test)

Aggregations

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