use of io.seata.serializer.protobuf.generated.GlobalLockQueryResponseProto in project seata by seata.
the class GlobalLockQueryResponseConvertor method convert2Proto.
@Override
public GlobalLockQueryResponseProto convert2Proto(GlobalLockQueryResponse globalLockQueryResponse) {
final short typeCode = globalLockQueryResponse.getTypeCode();
final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
final String msg = globalLockQueryResponse.getMsg();
final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg(msg == null ? "" : msg).setResultCode(ResultCodeProto.valueOf(globalLockQueryResponse.getResultCode().name())).setAbstractMessage(abstractMessage).build();
AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto.newBuilder().setAbstractResultMessage(abstractResultMessageProto).setTransactionExceptionCode(TransactionExceptionCodeProto.valueOf(globalLockQueryResponse.getTransactionExceptionCode().name())).build();
GlobalLockQueryResponseProto result = GlobalLockQueryResponseProto.newBuilder().setLockable(globalLockQueryResponse.isLockable()).setAbstractTransactionResponse(abstractTransactionResponseProto).build();
return result;
}
use of io.seata.serializer.protobuf.generated.GlobalLockQueryResponseProto in project seata by seata.
the class GlobalLockQueryResponseConvertorTest method convert2Proto.
@Test
public void convert2Proto() {
GlobalLockQueryResponse globalLockQueryResponse = new GlobalLockQueryResponse();
globalLockQueryResponse.setLockable(true);
globalLockQueryResponse.setMsg("msg");
globalLockQueryResponse.setResultCode(ResultCode.Failed);
globalLockQueryResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotActive);
GlobalLockQueryResponseConvertor convertor = new GlobalLockQueryResponseConvertor();
GlobalLockQueryResponseProto proto = convertor.convert2Proto(globalLockQueryResponse);
GlobalLockQueryResponse real = convertor.convert2Model(proto);
assertThat((real.getTypeCode())).isEqualTo(globalLockQueryResponse.getTypeCode());
assertThat((real.getMsg())).isEqualTo(globalLockQueryResponse.getMsg());
assertThat((real.getResultCode())).isEqualTo(globalLockQueryResponse.getResultCode());
assertThat((real.getTransactionExceptionCode())).isEqualTo(globalLockQueryResponse.getTransactionExceptionCode());
}
Aggregations