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