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