@Override
    public BranchRollbackResponseProto convert2Proto(BranchRollbackResponse branchRollbackResponse) {
        final short typeCode = branchRollbackResponse.getTypeCode();

        final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(
            MessageTypeProto.forNumber(typeCode)).build();

        final String msg = branchRollbackResponse.getMsg();
        final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg(
            msg == null ? "" : msg).setResultCode(
            ResultCodeProto.valueOf(branchRollbackResponse.getResultCode().name())).setAbstractMessage(abstractMessage)
            .build();

        final AbstractTransactionResponseProto abstractTransactionRequestProto = AbstractTransactionResponseProto
            .newBuilder().setAbstractResultMessage(abstractResultMessageProto).setTransactionExceptionCode(
                TransactionExceptionCodeProto.valueOf(branchRollbackResponse.getTransactionExceptionCode().name()))
            .build();

        final AbstractBranchEndResponseProto abstractBranchEndResponse = AbstractBranchEndResponseProto.newBuilder().
            setAbstractTransactionResponse(abstractTransactionRequestProto).setXid(branchRollbackResponse.getXid())
            .setBranchId(branchRollbackResponse.getBranchId()).setBranchStatus(
                BranchStatusProto.forNumber(branchRollbackResponse.getBranchStatus().getCode())).build();

        BranchRollbackResponseProto result = BranchRollbackResponseProto.newBuilder().setAbstractBranchEndResponse(
            abstractBranchEndResponse).build();

        return result;
    }
@Test
    public void convert2Proto() {

        BranchRollbackResponse branchRollbackResponse = new BranchRollbackResponse();
        branchRollbackResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
        branchRollbackResponse.setResultCode(ResultCode.Success);
        branchRollbackResponse.setMsg("xx");
        branchRollbackResponse.setXid("xid");
        branchRollbackResponse.setBranchStatus(BranchStatus.PhaseTwo_Rollbacked);
        branchRollbackResponse.setBranchId(123);

        BranchRollbackResponseConvertor convertor = new BranchRollbackResponseConvertor();
        BranchRollbackResponseProto proto = convertor.convert2Proto(
            branchRollbackResponse);
        BranchRollbackResponse real = convertor.convert2Model(proto);

        assertThat(real.getTypeCode()).isEqualTo(branchRollbackResponse.getTypeCode());
        assertThat(real.getMsg()).isEqualTo(branchRollbackResponse.getMsg());
        assertThat(real.getXid()).isEqualTo(branchRollbackResponse.getXid());
        assertThat(real.getTransactionExceptionCode()).isEqualTo(branchRollbackResponse.getTransactionExceptionCode());
        assertThat(real.getBranchStatus()).isEqualTo(branchRollbackResponse.getBranchStatus());
        assertThat(real.getResultCode()).isEqualTo(branchRollbackResponse.getResultCode());
    }