@Test public void appendCondition() throws Exception { StringBuffer buffer = new StringBuffer(); store.appendCondition(buffer, "empty1", null); assertThat(buffer.toString()).isEqualTo(""); store.appendCondition(buffer, "empty2", null); assertThat(buffer.toString()).isEqualTo(""); store.appendCondition(buffer, "field1", "value1"); assertThat(buffer.toString()).isEqualTo("field1:\\\"value1\\\""); store.appendCondition(buffer, "field2", "value2"); assertThat(buffer.toString()).isEqualTo("field1:\\\"value1\\\" AND field2:\\\"value2\\\""); }
void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } }
ElasticSearchStore extends AbstractScheduledService implements AutoCloseable { void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } } }
ElasticSearchStore extends AbstractScheduledService implements AutoCloseable { void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } } @Inject  ElasticSearchStore(); @VisibleForTesting  ElasticSearchStore(Map<String, String> properties, JestClient client); }
ElasticSearchStore extends AbstractScheduledService implements AutoCloseable { void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } } @Inject  ElasticSearchStore(); @VisibleForTesting  ElasticSearchStore(Map<String, String> properties, JestClient client); @PostConstruct void init(); @Override @PreDestroy void close(); }
ElasticSearchStore extends AbstractScheduledService implements AutoCloseable { void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } } @Inject  ElasticSearchStore(); @VisibleForTesting  ElasticSearchStore(Map<String, String> properties, JestClient client); @PostConstruct void init(); @Override @PreDestroy void close();  }