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;
}
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());
}
Aggregations