@Test
  public void whenGettingSolrQueryThenQueryIsCorrect() {

    IsEqualCriterion criterion = new IsEqualCriterion(numberValue12);

    assertThat(criterion.getSolrQuery(numberMetadata)).isEqualTo("numberMetadata:\"12\"");
  }
  @Test
  public void givenContentMetadataWhenCheckingIsValidForThenReturnTrue() {

    IsEqualCriterion criterion = new IsEqualCriterion(aString());

    assertThat(criterion.isValidFor(contentMetadata)).isTrue();
  }
  @Test
  public void givenDateMetadataWhenCheckingIsValidForThenReturnTrue() {

    IsEqualCriterion criterion = new IsEqualCriterion(aDateTime());

    assertThat(criterion.isValidFor(dateMetadata)).isTrue();
  }
  @Test
  public void givenReferenceMetadataWhenCheckingIsValidForThenReturnTrue() {

    IsEqualCriterion criterion = new IsEqualCriterion(anInteger());

    assertThat(criterion.isValidFor(referenceMetadata)).isTrue();
  }
  @Test
  public void givenTextWhenGettingSolrQueryThenQueryIsCorrect() {

    IsEqualCriterion criterion = new IsEqualCriterion(textValue);

    assertThat(criterion.getSolrQuery(textMetadata)).isEqualTo("textMetadata:\"text\\ value\"");
  }
  @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 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 givenValueContainsWildCardsWhenGettingSolrQueryThenWildCardsEscaped() {

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

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\?with\\?wildcards\\?\"");
  }
Пример #10
0
  @Test
  public void givenValueContainsAsterisksWhenGettingSolrQueryThenAsterisksEscaped() {

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

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\*with\\*asterisks\\*\"");
  }
Пример #11
0
  @Test
  public void givenValueContainsSpacesWhenGettingSolrQueryThenSpacesEscaped() {

    String value = "value with spaces";

    IsEqualCriterion criterion = new IsEqualCriterion(value);

    assertThat(criterion.getSolrQuery(textMetadata))
        .isEqualTo("textMetadata:\"value\\ with\\ spaces\"");
  }
Пример #12
0
  @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\"");
  }
Пример #13
0
  @Test
  public void givenNullWhenGettingSolrQueryThenQueryIsCorrect() {
    IsEqualCriterion criterion = new IsEqualCriterion(null);

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