use of org.jboss.tools.openshift.internal.common.core.util.KeyValueFilterFactory.KeyValueFilter in project jbosstools-openshift by jbosstools.
the class KeyValueFilterFactoryTest method shouldCreateFilterThatMatchesSubstrings.
@Test
public void shouldCreateFilterThatMatchesSubstrings() {
// given
// when
List<KeyValueFilter> filters = KeyValueFilterFactory.create("smurfs=blue");
// then
assertThat(filters).isNotEmpty();
KeyValueFilter filter = filters.get(0);
assertThat(filter.matchesKey("all the smurfs")).isTrue();
assertThat(filter.matchesValue("are very much blue")).isTrue();
}
use of org.jboss.tools.openshift.internal.common.core.util.KeyValueFilterFactory.KeyValueFilter in project jbosstools-openshift by jbosstools.
the class KeyValueFilterFactoryTest method shouldIgnoreSpaceAfterColon.
@Test
public void shouldIgnoreSpaceAfterColon() {
// given
// when
List<KeyValueFilter> filters = KeyValueFilterFactory.create("fo o= bar tender , smurfs= blue");
// then
assertThat(filters).hasSize(2);
KeyValueFilter filter = filters.get(1);
assertThat(filter.matchesKey("smurfs")).isTrue();
assertThat(filter.matchesValue("blue")).isTrue();
}
use of org.jboss.tools.openshift.internal.common.core.util.KeyValueFilterFactory.KeyValueFilter in project jbosstools-openshift by jbosstools.
the class KeyValueFilterFactoryTest method shouldReportEmptyRangeForKeyIfFilteringOnValueOnly.
@Test
public void shouldReportEmptyRangeForKeyIfFilteringOnValueOnly() {
// given
// when
List<KeyValueFilter> filters = KeyValueFilterFactory.create("blue");
// then
assertThat(filters).isNotEmpty();
KeyValueFilter filter = filters.get(0);
Range range = filter.getMatchingRangeForKey("smurfs=blue");
assertThat(range).isNull();
}
use of org.jboss.tools.openshift.internal.common.core.util.KeyValueFilterFactory.KeyValueFilter in project jbosstools-openshift by jbosstools.
the class KeyValueFilterFactoryTest method shouldCreateValueOnlyFilterIfExpressionhasNoEquals.
@Test
public void shouldCreateValueOnlyFilterIfExpressionhasNoEquals() {
// given
// when
List<KeyValueFilter> filters = KeyValueFilterFactory.create("blue");
// then
assertThat(filters).isNotEmpty();
KeyValueFilter filter = filters.get(0);
assertThat(filter.matchesKey("smurfs")).isTrue();
assertThat(filter.matchesKey("42")).isTrue();
assertThat(filter.matchesValue("blue")).isTrue();
}
use of org.jboss.tools.openshift.internal.common.core.util.KeyValueFilterFactory.KeyValueFilter in project jbosstools-openshift by jbosstools.
the class KeyValueFilterFactoryTest method shouldReportMatchRangesForKey.
@Test
public void shouldReportMatchRangesForKey() {
// given
String filterExpr = "smurfs";
String filteredText = "all the smurfs";
int matchStart = filteredText.indexOf(filterExpr);
int matchLength = filterExpr.length();
// when
List<KeyValueFilter> filters = KeyValueFilterFactory.create(filterExpr + "=anyvallue");
// then
assertThat(filters).isNotEmpty();
KeyValueFilter filter = filters.get(0);
Range range = filter.getMatchingRangeForKey(filteredText);
assertThat(range).isNotNull();
assertThat(range.start).isEqualTo(matchStart);
assertThat(range.length).isEqualTo(matchLength);
}
Aggregations