SparqlQueryHolder implements QueryHolder { @Override public String assembleQuery() { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < parameters.size(); i++) { sb.append(queryParts.get(i)); final String paramValue = parameters.get(i).getValue().getQueryString(); sb.append(paramValue); } if (queryParts.size() > parameters.size()) { sb.append(queryParts.get(parameters.size())); } if (limit != Integer.MAX_VALUE) { sb.append(SPARQL_LIMIT).append(limit); } if (offset != 0) { sb.append(SPARQL_OFFSET).append(offset); } return sb.toString(); } SparqlQueryHolder(String query, List<String> parts, List<QueryParameter<?>> parameters); @Override String getQuery(); @Override Set<Parameter<?>> getParameters(); @Override QueryParameter<?> getParameter(String name); @Override Parameter<?> getParameter(int position); @Override Object getParameterValue(Parameter<?> parameter); @Override void setParameter(Parameter<T> parameter, Object value); @Override void setParameter(Parameter<T> parameter, String value, String language); @Override void setUntypedParameter(Parameter<T> parameter, Object value); @Override void setFirstResult(int startPosition); @Override int getFirstResult(); @Override void setMaxResults(int maxResults); @Override int getMaxResults(); @Override void clearParameter(Parameter<?> parameter); @Override void clearParameters(); @Override String assembleQuery(); @Override String toString();  }
@Test void assembleDoesNotAddLimitClauseWhenMaxResultsWasNotSet() { final String result = sut.assembleQuery(); assertThat(result, not(containsString("LIMIT"))); }
@Test void assembleDoesNotAddOffsetClauseWhenFirstResultWasNotSet() { final String result = sut.assembleQuery(); assertThat(result, not(containsString("OFFSET"))); }