@Test
  public void givenBooleanMetadataWhenGettingSolrQueryThenQueryIsCorrect() {
    IsEqualCriterion criterion = new IsEqualCriterion(booleanTrueValue);

    assertThat(criterion.getSolrQuery(booleanMetadata)).isEqualTo("booleanMetadata:\"__TRUE__\"");

    criterion = new IsEqualCriterion(booleanFalseValue);

    assertThat(criterion.getSolrQuery(booleanMetadata)).isEqualTo("booleanMetadata:\"__FALSE__\"");
  }
  @Test
  public void givenTextWhenGettingSolrQueryThenQueryIsCorrect() {

    IsEqualCriterion criterion = new IsEqualCriterion(textValue);

    assertThat(criterion.getSolrQuery(textMetadata)).isEqualTo("textMetadata:\"text\\ value\"");
  }
  @Test
  public void whenGettingSolrQueryThenQueryIsCorrect() {

    IsEqualCriterion criterion = new IsEqualCriterion(numberValue12);

    assertThat(criterion.getSolrQuery(numberMetadata)).isEqualTo("numberMetadata:\"12\"");
  }
  @Test
  public void givenRecordWhenGettingSolrQueryThenQueryIsCorrect() {
    Record record = new TestRecord("code", "zeCollection", "zeId");

    IsEqualCriterion criterion = new IsEqualCriterion(record);

    assertThat(criterion.getSolrQuery(textMetadata)).isEqualTo("textMetadata:\"zeId\"");
  }
  @Test
  public void givenDateWhenGettingSolrQueryThenQueryIsCorrect() {

    IsEqualCriterion criterion = new IsEqualCriterion(date);

    assertThat(criterion.getSolrQuery(dateMetadata))
        .isEqualTo("dateTimeMetadata:\"" + date + "Z\"");
  }
  @Test
  public void givenValueContainsWildCardsWhenGettingSolrQueryThenWildCardsEscaped() {

    String value = "value?with?wildcards?";

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\?with\\?wildcards\\?\"");
  }
  @Test
  public void givenValueContainsAsterisksWhenGettingSolrQueryThenAsterisksEscaped() {

    String value = "value*with*asterisks*";

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\*with\\*asterisks\\*\"");
  }
  @Test
  public void givenValueContainsSpacesWhenGettingSolrQueryThenSpacesEscaped() {

    String value = "value with spaces";

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\ with\\ spaces\"");
  }
  @Test
  public void givenDateWithOutSummerTimeWhenGettingSolrQueryThenQueryIsCorrect() {

    LocalDateTime date = new LocalDateTime(2014, 11, 04, 22, 50);

    IsEqualCriterion criterion = new IsEqualCriterion(date);

    assertThat(criterion.getSolrQuery(dateMetadata))
        .isEqualTo("dateTimeMetadata:\"" + date + "Z\"");
  }
예제 #10
0
  @Test
  public void givenNullWhenGettingSolrQueryThenQueryIsCorrect() {
    IsEqualCriterion criterion = new IsEqualCriterion(null);

    assertThat(criterion.getSolrQuery(textMetadata)).isEqualTo("textMetadata:\"__NULL__\"");
  }