MySQLComStmtExecutePacket extends MySQLCommandPacket { private List<Object> getParameters(final MySQLPacketPayload payload, final int parameterCount) throws SQLException { List<Object> result = new ArrayList<>(parameterCount); for (int parameterIndex = 0; parameterIndex < parameterCount; parameterIndex++) { MySQLBinaryProtocolValue binaryProtocolValue = MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(binaryStatement.getParameterTypes().get(parameterIndex).getColumnType()); result.add(nullBitmap.isNullParameter(parameterIndex) ? null : binaryProtocolValue.read(payload)); } return result; } MySQLComStmtExecutePacket(final MySQLPacketPayload payload); @Override void doWrite(final MySQLPacketPayload payload);  }
@Test public void assertNewWithNotNullParameters() throws SQLException { MySQLBinaryStatementRegistry.getInstance().register("SELECT id FROM tbl WHERE id=?", 1); when(payload.readInt4()).thenReturn(1); when(payload.readInt1()).thenReturn(0, 0, 1); MySQLComStmtExecutePacket actual = new MySQLComStmtExecutePacket(payload); assertThat(actual.getSequenceId(), is(0)); assertThat(actual.getSql(), is("SELECT id FROM tbl WHERE id=?")); assertThat(actual.getParameters(), is(Collections.<Object>singletonList(1))); }
@Test public void assertNewWithNullParameters() throws SQLException { MySQLBinaryStatementRegistry.getInstance().register("SELECT id FROM tbl WHERE id=?", 1); when(payload.readInt4()).thenReturn(1); when(payload.readInt1()).thenReturn(0, 1); MySQLComStmtExecutePacket actual = new MySQLComStmtExecutePacket(payload); assertThat(actual.getSequenceId(), is(0)); assertThat(actual.getSql(), is("SELECT id FROM tbl WHERE id=?")); assertThat(actual.getParameters(), is(Collections.singletonList(null))); }