@Test public void testPrepareDeserialization() throws Exception { final String sql = "SELECT * FROM FOO"; final String connectionId = UUID.randomUUID().toString(); final long maxRowCount = 200L; // The "current" serialization strategy. Requests.PrepareRequest protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowsTotal(maxRowCount).build(); Service.PrepareRequest prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); // The "old" serialization strategy. protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowCount(maxRowCount).build(); prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); // Both the new and old provided should default to the new protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowCount(500L) .setMaxRowsTotal(maxRowCount).build(); prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); }
@Test public void testPrepareDeserialization() throws Exception { final String sql = "SELECT * FROM FOO"; final String connectionId = UUID.randomUUID().toString(); final long maxRowCount = 200L; // The "current" serialization strategy. Requests.PrepareRequest protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowsTotal(maxRowCount).build(); Service.PrepareRequest prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); // The "old" serialization strategy. protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowCount(maxRowCount).build(); prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); // Both the new and old provided should default to the new protoPrepare = Requests.PrepareRequest.newBuilder(). setConnectionId(connectionId).setSql(sql).setMaxRowCount(500L) .setMaxRowsTotal(maxRowCount).build(); prepareReq = new Service.PrepareRequest().deserialize(protoPrepare); assertEquals(maxRowCount, prepareReq.maxRowCount); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
@Override Requests.PrepareRequest serialize() { Requests.PrepareRequest.Builder builder = Requests.PrepareRequest.newBuilder(); if (null != connectionId) { builder.setConnectionId(connectionId); } if (null != sql) { builder.setSql(sql); } // Set both field for backwards compatibility return builder.setMaxRowCount(maxRowCount).setMaxRowsTotal(maxRowCount).build(); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
@Override Requests.PrepareRequest serialize() { Requests.PrepareRequest.Builder builder = Requests.PrepareRequest.newBuilder(); if (null != connectionId) { builder.setConnectionId(connectionId); } if (null != sql) { builder.setSql(sql); } return builder.setMaxRowCount(maxRowCount).build(); }
@Override Requests.PrepareRequest serialize() { Requests.PrepareRequest.Builder builder = Requests.PrepareRequest.newBuilder(); if (null != connectionId) { builder.setConnectionId(connectionId); } if (null != sql) { builder.setSql(sql); } // Set both field for backwards compatibility return builder.setMaxRowCount(maxRowCount).setMaxRowsTotal(maxRowCount).build(); }