@Test public void convert2Proto() { RegisterRMRequest registerRMRequest = new RegisterRMRequest(); registerRMRequest.setResourceIds("res1"); registerRMRequest.setVersion("123"); registerRMRequest.setTransactionServiceGroup("group"); registerRMRequest.setExtraData("extraData"); registerRMRequest.setApplicationId("appId"); RegisterRMRequestConvertor convertor = new RegisterRMRequestConvertor(); RegisterRMRequestProto proto = convertor.convert2Proto(registerRMRequest); RegisterRMRequest real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(registerRMRequest.getTypeCode()); assertThat((real.getResourceIds())).isEqualTo(registerRMRequest.getResourceIds()); assertThat((real.getVersion())).isEqualTo(registerRMRequest.getVersion()); assertThat((real.getTransactionServiceGroup())).isEqualTo(registerRMRequest.getTransactionServiceGroup()); assertThat((real.getExtraData())).isEqualTo(registerRMRequest.getExtraData()); assertThat((real.getApplicationId())).isEqualTo(registerRMRequest.getApplicationId()); }
@Override public RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest) { final short typeCode = registerRMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerRMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerRMRequest.getApplicationId()) .setExtraData(extraData == null ? "" : extraData) .setTransactionServiceGroup(registerRMRequest.getTransactionServiceGroup()) .setVersion(registerRMRequest.getVersion()) .build(); RegisterRMRequestProto result = RegisterRMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto) .setResourceIds(registerRMRequest.getResourceIds() == null ? "" : registerRMRequest.getResourceIds()) .build(); return result; }
RegisterRMRequestConvertor implements PbConvertor<RegisterRMRequest, RegisterRMRequestProto> { @Override public RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest) { final short typeCode = registerRMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerRMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerRMRequest.getApplicationId()) .setExtraData(extraData == null ? "" : extraData) .setTransactionServiceGroup(registerRMRequest.getTransactionServiceGroup()) .setVersion(registerRMRequest.getVersion()) .build(); RegisterRMRequestProto result = RegisterRMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto) .setResourceIds(registerRMRequest.getResourceIds() == null ? "" : registerRMRequest.getResourceIds()) .build(); return result; } }
RegisterRMRequestConvertor implements PbConvertor<RegisterRMRequest, RegisterRMRequestProto> { @Override public RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest) { final short typeCode = registerRMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerRMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerRMRequest.getApplicationId()) .setExtraData(extraData == null ? "" : extraData) .setTransactionServiceGroup(registerRMRequest.getTransactionServiceGroup()) .setVersion(registerRMRequest.getVersion()) .build(); RegisterRMRequestProto result = RegisterRMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto) .setResourceIds(registerRMRequest.getResourceIds() == null ? "" : registerRMRequest.getResourceIds()) .build(); return result; }  }
RegisterRMRequestConvertor implements PbConvertor<RegisterRMRequest, RegisterRMRequestProto> { @Override public RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest) { final short typeCode = registerRMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerRMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerRMRequest.getApplicationId()) .setExtraData(extraData == null ? "" : extraData) .setTransactionServiceGroup(registerRMRequest.getTransactionServiceGroup()) .setVersion(registerRMRequest.getVersion()) .build(); RegisterRMRequestProto result = RegisterRMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto) .setResourceIds(registerRMRequest.getResourceIds() == null ? "" : registerRMRequest.getResourceIds()) .build(); return result; }  @Override RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest); @Override RegisterRMRequest convert2Model(RegisterRMRequestProto registerRMRequestProto); }
RegisterRMRequestConvertor implements PbConvertor<RegisterRMRequest, RegisterRMRequestProto> { @Override public RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest) { final short typeCode = registerRMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerRMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerRMRequest.getApplicationId()) .setExtraData(extraData == null ? "" : extraData) .setTransactionServiceGroup(registerRMRequest.getTransactionServiceGroup()) .setVersion(registerRMRequest.getVersion()) .build(); RegisterRMRequestProto result = RegisterRMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto) .setResourceIds(registerRMRequest.getResourceIds() == null ? "" : registerRMRequest.getResourceIds()) .build(); return result; }  @Override RegisterRMRequestProto convert2Proto(RegisterRMRequest registerRMRequest); @Override RegisterRMRequest convert2Model(RegisterRMRequestProto registerRMRequestProto);  }