Search in sources :

Example 1 with GlobalLockQueryResponseProto

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;
}
Also used : AbstractResultMessageProto(io.seata.serializer.protobuf.generated.AbstractResultMessageProto) GlobalLockQueryResponseProto(io.seata.serializer.protobuf.generated.GlobalLockQueryResponseProto) AbstractTransactionResponseProto(io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto)

Example 2 with GlobalLockQueryResponseProto

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());
}
Also used : GlobalLockQueryResponseProto(io.seata.serializer.protobuf.generated.GlobalLockQueryResponseProto) GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse) Test(org.junit.jupiter.api.Test)

Aggregations

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