@Test public void convert2Proto() { RegisterTMResponse registerRMResponse = new RegisterTMResponse(); registerRMResponse.setResultCode(ResultCode.Failed); registerRMResponse.setMsg("msg"); registerRMResponse.setIdentified(true); registerRMResponse.setVersion("11"); registerRMResponse.setExtraData("extraData"); RegisterTMResponseConvertor convertor = new RegisterTMResponseConvertor(); RegisterTMResponseProto proto = convertor.convert2Proto(registerRMResponse); RegisterTMResponse real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(registerRMResponse.getTypeCode()); assertThat((real.getMsg())).isEqualTo(registerRMResponse.getMsg()); assertThat((real.getResultCode())).isEqualTo(registerRMResponse.getResultCode()); assertThat((real.isIdentified())).isEqualTo(registerRMResponse.isIdentified()); assertThat((real.getVersion())).isEqualTo(registerRMResponse.getVersion()); assertThat((real.getExtraData())).isEqualTo(registerRMResponse.getExtraData()); }
@Override public RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse) { final short typeCode = registerTMResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = registerTMResponse.getMsg(); if (registerTMResponse.getResultCode() == null) { if (registerTMResponse.isIdentified()) { registerTMResponse.setResultCode(ResultCode.Success); } else { registerTMResponse.setResultCode(ResultCode.Failed); } } final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(registerTMResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); final String extraData = registerTMResponse.getExtraData(); AbstractIdentifyResponseProto abstractIdentifyResponseProto = AbstractIdentifyResponseProto.newBuilder() .setAbstractResultMessage(abstractResultMessageProto) .setExtraData(extraData == null ? "" : extraData) .setVersion(registerTMResponse.getVersion()) .setIdentified(registerTMResponse.isIdentified()) .build(); RegisterTMResponseProto result = RegisterTMResponseProto.newBuilder().setAbstractIdentifyResponse( abstractIdentifyResponseProto).build(); return result; }
RegisterTMResponseConvertor implements PbConvertor<RegisterTMResponse, RegisterTMResponseProto> { @Override public RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse) { final short typeCode = registerTMResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = registerTMResponse.getMsg(); if (registerTMResponse.getResultCode() == null) { if (registerTMResponse.isIdentified()) { registerTMResponse.setResultCode(ResultCode.Success); } else { registerTMResponse.setResultCode(ResultCode.Failed); } } final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(registerTMResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); final String extraData = registerTMResponse.getExtraData(); AbstractIdentifyResponseProto abstractIdentifyResponseProto = AbstractIdentifyResponseProto.newBuilder() .setAbstractResultMessage(abstractResultMessageProto) .setExtraData(extraData == null ? "" : extraData) .setVersion(registerTMResponse.getVersion()) .setIdentified(registerTMResponse.isIdentified()) .build(); RegisterTMResponseProto result = RegisterTMResponseProto.newBuilder().setAbstractIdentifyResponse( abstractIdentifyResponseProto).build(); return result; } }
RegisterTMResponseConvertor implements PbConvertor<RegisterTMResponse, RegisterTMResponseProto> { @Override public RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse) { final short typeCode = registerTMResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = registerTMResponse.getMsg(); if (registerTMResponse.getResultCode() == null) { if (registerTMResponse.isIdentified()) { registerTMResponse.setResultCode(ResultCode.Success); } else { registerTMResponse.setResultCode(ResultCode.Failed); } } final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(registerTMResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); final String extraData = registerTMResponse.getExtraData(); AbstractIdentifyResponseProto abstractIdentifyResponseProto = AbstractIdentifyResponseProto.newBuilder() .setAbstractResultMessage(abstractResultMessageProto) .setExtraData(extraData == null ? "" : extraData) .setVersion(registerTMResponse.getVersion()) .setIdentified(registerTMResponse.isIdentified()) .build(); RegisterTMResponseProto result = RegisterTMResponseProto.newBuilder().setAbstractIdentifyResponse( abstractIdentifyResponseProto).build(); return result; }  }
RegisterTMResponseConvertor implements PbConvertor<RegisterTMResponse, RegisterTMResponseProto> { @Override public RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse) { final short typeCode = registerTMResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = registerTMResponse.getMsg(); if (registerTMResponse.getResultCode() == null) { if (registerTMResponse.isIdentified()) { registerTMResponse.setResultCode(ResultCode.Success); } else { registerTMResponse.setResultCode(ResultCode.Failed); } } final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(registerTMResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); final String extraData = registerTMResponse.getExtraData(); AbstractIdentifyResponseProto abstractIdentifyResponseProto = AbstractIdentifyResponseProto.newBuilder() .setAbstractResultMessage(abstractResultMessageProto) .setExtraData(extraData == null ? "" : extraData) .setVersion(registerTMResponse.getVersion()) .setIdentified(registerTMResponse.isIdentified()) .build(); RegisterTMResponseProto result = RegisterTMResponseProto.newBuilder().setAbstractIdentifyResponse( abstractIdentifyResponseProto).build(); return result; }  @Override RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse); @Override RegisterTMResponse convert2Model(RegisterTMResponseProto registerTMResponseProto); }
RegisterTMResponseConvertor implements PbConvertor<RegisterTMResponse, RegisterTMResponseProto> { @Override public RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse) { final short typeCode = registerTMResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = registerTMResponse.getMsg(); if (registerTMResponse.getResultCode() == null) { if (registerTMResponse.isIdentified()) { registerTMResponse.setResultCode(ResultCode.Success); } else { registerTMResponse.setResultCode(ResultCode.Failed); } } final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(registerTMResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); final String extraData = registerTMResponse.getExtraData(); AbstractIdentifyResponseProto abstractIdentifyResponseProto = AbstractIdentifyResponseProto.newBuilder() .setAbstractResultMessage(abstractResultMessageProto) .setExtraData(extraData == null ? "" : extraData) .setVersion(registerTMResponse.getVersion()) .setIdentified(registerTMResponse.isIdentified()) .build(); RegisterTMResponseProto result = RegisterTMResponseProto.newBuilder().setAbstractIdentifyResponse( abstractIdentifyResponseProto).build(); return result; }  @Override RegisterTMResponseProto convert2Proto(RegisterTMResponse registerTMResponse); @Override RegisterTMResponse convert2Model(RegisterTMResponseProto registerTMResponseProto);  }