StatementHolder { public void setParameter(String parameterName, String value) { ensureState(); if (!paramNames.contains(parameterName)) { throw new IllegalArgumentException("Unknown binding name " + parameterName); } paramValues.put(parameterName, value); } StatementHolder(String statement); void analyzeStatement(); void setParameter(String parameterName, String value); String assembleStatement(); String getStatement(); void clearParameters();  }
@Test void throwsExceptionWhenTryingToSetParameterOnStatementNotAnalysed() { final String query = "SELECT ?x ?y WHERE { ?x <http: final StatementHolder holder = new StatementHolder(query); assertThrows(IllegalStateException.class, () -> holder.setParameter("x", "'hey'")); }