use of org.corpus_tools.annis.gui.flatquerybuilder.SearchBox in project ANNIS by korpling.
the class FlatQueryBuilderTest method valueFieldTextChange.
@Test
void valueFieldTextChange() {
initQueryBuilder(0);
// Add a pos annotation
queryBuilder.addLinguisticSequenceBox("pos");
SearchBox searchBox = _get(queryBuilder, SearchBox.class);
ValueField valueField = _get(queryBuilder, ValueField.class);
SensitiveComboBox cb = _get(searchBox, SensitiveComboBox.class);
@SuppressWarnings("unchecked") List<String> oldItemIds = new ArrayList<>((Collection<String>) cb.getItemIds());
assertNotEquals("VAFIN", oldItemIds.get(0));
assertNotEquals("VMFIN", oldItemIds.get(1));
assertNotEquals("VVFIN", oldItemIds.get(2));
// Mock a text change event
TextChangeEvent eventVFIN = mock(TextChangeEvent.class);
when(eventVFIN.getText()).thenReturn("VFIN");
valueField.textChange(eventVFIN);
MockVaadin.INSTANCE.clientRoundtrip();
// Check that the order has changed to include the nearest values first
@SuppressWarnings("unchecked") List<String> newItemIds = new ArrayList<>((Collection<String>) cb.getItemIds());
assertEquals("VAFIN", newItemIds.get(0));
assertEquals("VMFIN", newItemIds.get(1));
assertEquals("VVFIN", newItemIds.get(2));
// Test with an empty and null value, the suggestions should stay the same
TextChangeEvent eventEmpty = mock(TextChangeEvent.class);
when(eventEmpty.getText()).thenReturn("");
valueField.textChange(eventEmpty);
MockVaadin.INSTANCE.clientRoundtrip();
newItemIds = new ArrayList<>((Collection<String>) cb.getItemIds());
assertEquals("VAFIN", newItemIds.get(0));
assertEquals("VMFIN", newItemIds.get(1));
assertEquals("VVFIN", newItemIds.get(2));
TextChangeEvent eventNull = mock(TextChangeEvent.class);
when(eventNull.getText()).thenReturn(null);
valueField.textChange(eventNull);
MockVaadin.INSTANCE.clientRoundtrip();
newItemIds = new ArrayList<>((Collection<String>) cb.getItemIds());
assertEquals("VAFIN", newItemIds.get(0));
assertEquals("VMFIN", newItemIds.get(1));
assertEquals("VVFIN", newItemIds.get(2));
}
use of org.corpus_tools.annis.gui.flatquerybuilder.SearchBox in project ANNIS by korpling.
the class FlatQueryBuilderTest method twoTokenInSentence.
@Test
void twoTokenInSentence() throws InterruptedException {
initQueryBuilder(0);
// Add a two tokens
queryBuilder.addLinguisticSequenceBox("tok");
queryBuilder.addLinguisticSequenceBox("tok");
List<SearchBox> searchBoxes = _find(queryBuilder, SearchBox.class);
assertEquals(2, searchBoxes.size());
_get(searchBoxes.get(0), ComboBox.class).setValue("Feigenblatt");
_get(searchBoxes.get(1), ComboBox.class).setValue("Die");
// Add a scope
queryBuilder.addSpanBox("Sent");
SpanBox spanBox = _get(queryBuilder, SpanBox.class);
_get(spanBox, ComboBox.class).setValue("s");
// Create the AQL query
_click(_get(queryBuilder, Button.class, spec -> spec.withCaption("Create AQL Query")));
assertEquals("tok=/Feigenblatt/ & tok=/Die/\n& Sent = \"s\"\n& #1 . #2\n" + "& #3_i_#1\n" + "& #3_i_#2", ui.getQueryState().getAql().getValue());
}
Aggregations