Search in sources :

Example 1 with SingleResultPanel

use of org.corpus_tools.annis.gui.resultview.SingleResultPanel in project ANNIS by korpling.

the class AnnisUITest method shareSingleResult.

@Test
void shareSingleResult() throws Exception {
    executeTokenSearch("pcc2", 399, 2);
    // Activate the share window
    SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
    _click(_get(resultPanel, Button.class, spec -> spec.withPredicate((b) -> "Share match reference".equals(b.getDescription()))));
    // Get the window which shows all the different links
    Window shareWindow = _get(Window.class, spec -> spec.withCaption("Match reference link"));
    TextArea linkTextField = _get(shareWindow, TextArea.class, spec -> spec.withCaption("Link for publications"));
    URI shortUrl = URI.create(linkTextField.getValue());
    List<NameValuePair> paramsShortUrl = URLEncodedUtils.parse(shortUrl.getQuery(), StandardCharsets.UTF_8);
    assertEquals(1, paramsShortUrl.size());
    assertEquals("id", paramsShortUrl.get(0).getName());
    // Un-shorten the URL and examine its parts
    Optional<URI> originalUrl = ui.getUrlShortener().unshorten(UUID.fromString(paramsShortUrl.get(0).getValue()));
    assertTrue(originalUrl.isPresent());
    if (originalUrl.isPresent()) {
        List<NameValuePair> paramsOriginalUrl = URLEncodedUtils.parse(originalUrl.get().getRawQuery(), StandardCharsets.UTF_8);
        assertFalse(paramsOriginalUrl.isEmpty());
        assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_LEFT.equals(p.getName()) && "5".equals(p.getValue())));
        assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_RIGHT.equals(p.getName()) && "5".equals(p.getValue())));
        assertFalse(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_INSTANCE.equals(p.getName())));
        assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_SEARCH_INTERFACE.equals(p.getName()) && p.getValue().startsWith("http://localhost:8080#_q=")));
        assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_MATCH.equals(p.getName()) && "pcc2/11299#tok_1".equals(p.getValue())));
    }
}
Also used : Panel(com.vaadin.ui.Panel) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) TextField(com.vaadin.ui.TextField) Pair(kotlin.Pair) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) Window(com.vaadin.ui.Window) ExceptionDialog(org.corpus_tools.annis.gui.components.ExceptionDialog) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) DocBrowserTable(org.corpus_tools.annis.gui.docbrowser.DocBrowserTable) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Page(com.vaadin.server.Page) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) VaadinIcons(com.vaadin.icons.VaadinIcons) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) URI(java.net.URI) GridKt(com.github.mvysny.kaributesting.v8.GridKt) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) NotificationsKt(com.github.mvysny.kaributesting.v8.NotificationsKt) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Row(org.corpus_tools.annis.gui.widgets.grid.Row) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) UUID(java.util.UUID) LocatorJ._setValue(com.github.mvysny.kaributesting.v8.LocatorJ._setValue) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TabSheet(com.vaadin.ui.TabSheet) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Optional(java.util.Optional) NameValuePair(org.apache.http.NameValuePair) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ComboBox(com.vaadin.ui.ComboBox) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Accordion(com.vaadin.ui.Accordion) Label(com.vaadin.ui.Label) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataProvider(com.vaadin.data.provider.DataProvider) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Tab(com.vaadin.ui.TabSheet.Tab) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) AqlCodeEditor(org.corpus_tools.annis.gui.components.codemirror.AqlCodeEditor) Assert.assertTrue(org.junit.Assert.assertTrue) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) AfterEach(org.junit.jupiter.api.AfterEach) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) BeanFactory(org.springframework.beans.factory.BeanFactory) Annotation(org.corpus_tools.annis.api.model.Annotation) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) Window(com.vaadin.ui.Window) NameValuePair(org.apache.http.NameValuePair) Button(com.vaadin.ui.Button) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) URI(java.net.URI) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with SingleResultPanel

use of org.corpus_tools.annis.gui.resultview.SingleResultPanel in project ANNIS by korpling.

the class AnnisUITest method openVisualizerPcc2.

@Test
void openVisualizerPcc2() throws Exception {
    executeTokenSearch("pcc2", 399, 2);
    SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
    _get(resultPanel, KWICComponent.class);
    // Open the coreference visualizer and check that IFrame component is loaded
    Button btOpenCorefVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("coreference (discourse)"));
    _click(btOpenCorefVisualizer);
    awaitCondition(120, () -> !_find(resultPanel, AutoHeightIFrame.class).isEmpty());
    AutoHeightIFrame iframe = _get(resultPanel, AutoHeightIFrame.class, spec -> spec.withCount(1));
    assertTrue(iframe.getState().getUrl().startsWith("/vis-iframe-res/"));
    // Close the visualizer again
    _click(btOpenCorefVisualizer);
    awaitCondition(60, () -> _find(resultPanel, AutoHeightIFrame.class).isEmpty());
    // Open a HTML visualizer
    Button btOpenHtmlVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("information structure (document)"));
    _click(btOpenHtmlVisualizer);
    awaitCondition(240, () -> !_find(resultPanel, Panel.class, spec -> spec.withPredicate(p -> p.getStyleName().startsWith("annis-wrapped-htmlvis-"))).isEmpty());
    Panel htmlPanel = _get(resultPanel, Panel.class, spec -> spec.withPredicate(p -> p.getStyleName().startsWith("annis-wrapped-htmlvis-")));
    Label htmlLabel = _get(htmlPanel, Label.class);
    assertEquals(ContentMode.HTML, htmlLabel.getContentMode());
    assertTrue(htmlLabel.getValue().startsWith("<span class=\"tok\"  style=\" color:\" >Feigenblatt<"));
}
Also used : Panel(com.vaadin.ui.Panel) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) TextField(com.vaadin.ui.TextField) Pair(kotlin.Pair) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) Window(com.vaadin.ui.Window) ExceptionDialog(org.corpus_tools.annis.gui.components.ExceptionDialog) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) DocBrowserTable(org.corpus_tools.annis.gui.docbrowser.DocBrowserTable) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Page(com.vaadin.server.Page) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) VaadinIcons(com.vaadin.icons.VaadinIcons) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) URI(java.net.URI) GridKt(com.github.mvysny.kaributesting.v8.GridKt) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) NotificationsKt(com.github.mvysny.kaributesting.v8.NotificationsKt) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Row(org.corpus_tools.annis.gui.widgets.grid.Row) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) UUID(java.util.UUID) LocatorJ._setValue(com.github.mvysny.kaributesting.v8.LocatorJ._setValue) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TabSheet(com.vaadin.ui.TabSheet) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Optional(java.util.Optional) NameValuePair(org.apache.http.NameValuePair) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ComboBox(com.vaadin.ui.ComboBox) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Accordion(com.vaadin.ui.Accordion) Label(com.vaadin.ui.Label) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataProvider(com.vaadin.data.provider.DataProvider) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Tab(com.vaadin.ui.TabSheet.Tab) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) AqlCodeEditor(org.corpus_tools.annis.gui.components.codemirror.AqlCodeEditor) Assert.assertTrue(org.junit.Assert.assertTrue) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) AfterEach(org.junit.jupiter.api.AfterEach) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) BeanFactory(org.springframework.beans.factory.BeanFactory) Annotation(org.corpus_tools.annis.api.model.Annotation) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) Panel(com.vaadin.ui.Panel) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with SingleResultPanel

use of org.corpus_tools.annis.gui.resultview.SingleResultPanel in project ANNIS by korpling.

the class AnnisUITest method searchPcc2InverseOrder.

@Test
void searchPcc2InverseOrder() throws Exception {
    selectCorpus("pcc2");
    // Set inverse order in search options
    TabSheet optionTabSheet = _get(_get(ControlPanel.class), TabSheet.class);
    optionTabSheet.setSelectedTab(_get(SearchOptionsPanel.class));
    awaitCondition(10, () -> !_find(optionTabSheet, ComboBox.class, spec -> spec.withCaption("Order")).isEmpty());
    @SuppressWarnings("unchecked") ComboBox<OrderEnum> orderComboBox = _get(optionTabSheet, ComboBox.class, spec -> spec.withCaption("Order"));
    _setValue(orderComboBox, OrderEnum.INVERTED);
    // Set the query and submit query
    _get(AqlCodeEditor.class).getPropertyDataSource().setValue("\"Die\"");
    MockVaadin.INSTANCE.clientRoundtrip();
    awaitCondition(5, () -> "\"Die\"".equals(ui.getQueryState().getAql().getValue()));
    awaitCondition(5, () -> "Valid query, click on \"Search\" to start searching.".equals(ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus()));
    Button searchButton = _get(Button.class, spec -> spec.withCaption("Search"));
    _click(searchButton);
    // Wait until the count is displayed
    String expectedStatus = "4 matches\nin 2 documents";
    awaitCondition(60, () -> expectedStatus.equals(ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus()), () -> "Waited for status \"" + expectedStatus + "\" but was \"" + ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus() + "\"");
    ResultViewPanel resultView = _get(ResultViewPanel.class);
    awaitCondition(30, () -> _find(resultView, SingleResultPanel.class).size() == 4);
    // Test that the cell values have the correct token value
    SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
    KWICComponent kwicVis = _get(resultPanel, KWICComponent.class);
    AnnotationGrid kwicGrid = _get(kwicVis, AnnotationGrid.class);
    ArrayList<Row> tokens = kwicGrid.getRowsByAnnotation().get("tok");
    assertEquals(1, tokens.size());
    assertEquals(Arrays.asList("fürs", "Dallgower", "Tor", "gab", ".", "Die", "Seeburger", "und", "einige", "Groß-Glienicker", "haben"), tokens.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
}
Also used : Panel(com.vaadin.ui.Panel) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) TextField(com.vaadin.ui.TextField) Pair(kotlin.Pair) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) Window(com.vaadin.ui.Window) ExceptionDialog(org.corpus_tools.annis.gui.components.ExceptionDialog) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) DocBrowserTable(org.corpus_tools.annis.gui.docbrowser.DocBrowserTable) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Page(com.vaadin.server.Page) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) VaadinIcons(com.vaadin.icons.VaadinIcons) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) URI(java.net.URI) GridKt(com.github.mvysny.kaributesting.v8.GridKt) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) NotificationsKt(com.github.mvysny.kaributesting.v8.NotificationsKt) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Row(org.corpus_tools.annis.gui.widgets.grid.Row) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) UUID(java.util.UUID) LocatorJ._setValue(com.github.mvysny.kaributesting.v8.LocatorJ._setValue) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TabSheet(com.vaadin.ui.TabSheet) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Optional(java.util.Optional) NameValuePair(org.apache.http.NameValuePair) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ComboBox(com.vaadin.ui.ComboBox) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Accordion(com.vaadin.ui.Accordion) Label(com.vaadin.ui.Label) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataProvider(com.vaadin.data.provider.DataProvider) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Tab(com.vaadin.ui.TabSheet.Tab) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) AqlCodeEditor(org.corpus_tools.annis.gui.components.codemirror.AqlCodeEditor) Assert.assertTrue(org.junit.Assert.assertTrue) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) AfterEach(org.junit.jupiter.api.AfterEach) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) BeanFactory(org.springframework.beans.factory.BeanFactory) Annotation(org.corpus_tools.annis.api.model.Annotation) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) ComboBox(com.vaadin.ui.ComboBox) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) TabSheet(com.vaadin.ui.TabSheet) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) Row(org.corpus_tools.annis.gui.widgets.grid.Row) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SingleResultPanel

use of org.corpus_tools.annis.gui.resultview.SingleResultPanel in project ANNIS by korpling.

the class AnnisUITest method tokenSearchPcc2.

@Test
void tokenSearchPcc2() throws Exception {
    executeTokenSearch("pcc2", 399, 2);
    // Test that the cell values have the correct token value
    SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
    KWICComponent kwicVis = _get(resultPanel, KWICComponent.class);
    AnnotationGrid kwicGrid = _get(kwicVis, AnnotationGrid.class);
    ArrayList<Row> tokens = kwicGrid.getRowsByAnnotation().get("tok");
    assertEquals(1, tokens.size());
    assertEquals(Arrays.asList("Feigenblatt", "Die", "Jugendlichen", "in", "Zossen", "wollen"), tokens.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
    // Check the annotation values are shown
    ArrayList<Row> lemmaRows = kwicGrid.getRowsByAnnotation().get("tiger::lemma");
    assertEquals(1, lemmaRows.size());
    assertEquals(Arrays.asList("Feigenblatt", "der", "jugendliche", "in", "Zossen", "wollen"), lemmaRows.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
    ArrayList<Row> posRows = kwicGrid.getRowsByAnnotation().get("tiger::pos");
    assertEquals(1, posRows.size());
    assertEquals(Arrays.asList("NN", "ART", "NN", "APPR", "NE", "VMFIN"), posRows.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
    // Test that we can show the first metadata for the button
    List<Button> infoButtons = _find(Button.class, spec -> spec.withPredicate(b -> "Show metadata".equals(b.getDescription())));
    assertEquals(10, infoButtons.size());
    _click(infoButtons.get(0));
    Window infoWindow = _get(Window.class);
    assertEquals("Info for salt:/pcc2/11299", infoWindow.getCaption());
    awaitCondition(30, () -> !_find(infoWindow, Accordion.class).isEmpty());
    Accordion metaAccordion = _get(infoWindow, Accordion.class);
    @SuppressWarnings("rawtypes") List<Grid> metadataGrids = _find(metaAccordion, Grid.class);
    assertEquals(2, metadataGrids.size());
    assertEquals("11299 (document)", metaAccordion.getTab(metadataGrids.get(0)).getCaption());
    assertEquals("pcc2 (corpus)", metaAccordion.getTab(metadataGrids.get(1)).getCaption());
    @SuppressWarnings("unchecked") Annotation firstAnno = (Annotation) GridKt._get(metadataGrids.get(0), 0);
    assertEquals("Dokumentname", firstAnno.getKey().getName());
    assertEquals("pcc-11299", firstAnno.getVal());
    @SuppressWarnings("unchecked") Annotation secondAnno = (Annotation) GridKt._get(metadataGrids.get(0), 1);
    assertEquals("Genre", secondAnno.getKey().getName());
    assertEquals("Politik", secondAnno.getVal());
    @SuppressWarnings("unchecked") Annotation thirdAnno = (Annotation) GridKt._get(metadataGrids.get(0), 2);
    assertEquals("Titel", thirdAnno.getKey().getName());
    assertEquals("Feigenblatt", thirdAnno.getVal());
    // Disable the part-of-speech token annotation display
    TreeSet<String> visibleAnnos = new TreeSet<>(Arrays.asList("tiger::lemma"));
    resultPanel.setVisibleTokenAnnosVisible(visibleAnnos);
    assertNull(kwicGrid.getRowsByAnnotation().get("tiger:pos"));
    assertNotNull(kwicGrid.getRowsByAnnotation().get("tiger::lemma"));
    // Change the context and test that the KWIC displayed also changed
    resultPanel.changeContext(1, 6, false);
    // Since the action will replace the whole result panel, we have to get all
    // variables again.
    List<String> expectedTokens = Arrays.asList("Feigenblatt", "Die", "Jugendlichen", "in", "Zossen", "wollen", "ein");
    awaitCondition(10, () -> {
        List<SingleResultPanel> allResults = _find(SingleResultPanel.class);
        if (allResults.isEmpty()) {
            return false;
        }
        List<AnnotationGrid> annoGrids = _find(allResults.get(0), AnnotationGrid.class);
        if (annoGrids.isEmpty()) {
            return false;
        }
        ArrayList<Row> tokensUpdatedContext = annoGrids.get(0).getRowsByAnnotation().get("tok");
        if (tokensUpdatedContext.isEmpty()) {
            return false;
        }
        List<String> actualTokens = tokensUpdatedContext.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList());
        return expectedTokens.equals(actualTokens);
    });
}
Also used : Panel(com.vaadin.ui.Panel) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) TextField(com.vaadin.ui.TextField) Pair(kotlin.Pair) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) Window(com.vaadin.ui.Window) ExceptionDialog(org.corpus_tools.annis.gui.components.ExceptionDialog) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) DocBrowserTable(org.corpus_tools.annis.gui.docbrowser.DocBrowserTable) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Page(com.vaadin.server.Page) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) VaadinIcons(com.vaadin.icons.VaadinIcons) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) URI(java.net.URI) GridKt(com.github.mvysny.kaributesting.v8.GridKt) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) NotificationsKt(com.github.mvysny.kaributesting.v8.NotificationsKt) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Row(org.corpus_tools.annis.gui.widgets.grid.Row) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) UUID(java.util.UUID) LocatorJ._setValue(com.github.mvysny.kaributesting.v8.LocatorJ._setValue) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TabSheet(com.vaadin.ui.TabSheet) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Optional(java.util.Optional) NameValuePair(org.apache.http.NameValuePair) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ComboBox(com.vaadin.ui.ComboBox) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Accordion(com.vaadin.ui.Accordion) Label(com.vaadin.ui.Label) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataProvider(com.vaadin.data.provider.DataProvider) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Tab(com.vaadin.ui.TabSheet.Tab) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) AqlCodeEditor(org.corpus_tools.annis.gui.components.codemirror.AqlCodeEditor) Assert.assertTrue(org.junit.Assert.assertTrue) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) AfterEach(org.junit.jupiter.api.AfterEach) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) BeanFactory(org.springframework.beans.factory.BeanFactory) Annotation(org.corpus_tools.annis.api.model.Annotation) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) Window(com.vaadin.ui.Window) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) Grid(com.vaadin.ui.Grid) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) Annotation(org.corpus_tools.annis.api.model.Annotation) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) Accordion(com.vaadin.ui.Accordion) Button(com.vaadin.ui.Button) TreeSet(java.util.TreeSet) Row(org.corpus_tools.annis.gui.widgets.grid.Row) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with SingleResultPanel

use of org.corpus_tools.annis.gui.resultview.SingleResultPanel in project ANNIS by korpling.

the class AnnisUITest method tokenSearchDialog.

@Test
void tokenSearchDialog() throws Exception {
    executeTokenSearch("dialog.demo", 102, 1);
    // Test that there is a grid visualizer
    SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
    GridComponent gridVis = _get(resultPanel, GridComponent.class, spec -> spec.withPredicate(g -> !(g instanceof KWICComponent)));
    AnnotationGrid annoGrid = _get(gridVis, AnnotationGrid.class);
    ArrayList<Row> tokens = annoGrid.getRowsByAnnotation().get("default_ns::norm0");
    assertEquals(1, tokens.size());
    assertEquals(Arrays.asList("äh", "fang", "einfach", "mal", "an"), tokens.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
    // Open the video visualizer and check that media component is loaded
    Button btOpenVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("video"));
    _click(btOpenVisualizer);
    awaitCondition(120, () -> !_find(resultPanel, MediaElementPlayer.class).isEmpty());
    MediaElementPlayer player = _get(resultPanel, MediaElementPlayer.class, spec -> spec.withCount(1));
    assertEquals("video/webm", player.getState().getMimeType());
    assertEquals("/Binary?file=dialog.demo%2Fdialog.demo%2Fdialog.demo.webm&toplevelCorpusName=dialog.demo", player.getState().getResourceURL());
    // Close the visualizer again
    _click(btOpenVisualizer);
    awaitCondition(120, () -> _find(resultPanel, MediaElementPlayer.class).isEmpty());
}
Also used : Panel(com.vaadin.ui.Panel) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CorpusListPanel(org.corpus_tools.annis.gui.controlpanel.CorpusListPanel) DocBrowserPanel(org.corpus_tools.annis.gui.docbrowser.DocBrowserPanel) TextField(com.vaadin.ui.TextField) Pair(kotlin.Pair) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) Window(com.vaadin.ui.Window) ExceptionDialog(org.corpus_tools.annis.gui.components.ExceptionDialog) SearchOptionsPanel(org.corpus_tools.annis.gui.controlpanel.SearchOptionsPanel) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) DocBrowserTable(org.corpus_tools.annis.gui.docbrowser.DocBrowserTable) ResultViewPanel(org.corpus_tools.annis.gui.resultview.ResultViewPanel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Page(com.vaadin.server.Page) OrderEnum(org.corpus_tools.annis.api.model.FindQuery.OrderEnum) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) VaadinIcons(com.vaadin.icons.VaadinIcons) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) URI(java.net.URI) GridKt(com.github.mvysny.kaributesting.v8.GridKt) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) NotificationsKt(com.github.mvysny.kaributesting.v8.NotificationsKt) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Row(org.corpus_tools.annis.gui.widgets.grid.Row) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) UUID(java.util.UUID) LocatorJ._setValue(com.github.mvysny.kaributesting.v8.LocatorJ._setValue) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TabSheet(com.vaadin.ui.TabSheet) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Optional(java.util.Optional) NameValuePair(org.apache.http.NameValuePair) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ComboBox(com.vaadin.ui.ComboBox) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Accordion(com.vaadin.ui.Accordion) Label(com.vaadin.ui.Label) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) SingleCorpusResultPanel(org.corpus_tools.annis.gui.resultview.SingleCorpusResultPanel) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataProvider(com.vaadin.data.provider.DataProvider) AutoHeightIFrame(org.corpus_tools.annis.gui.widgets.AutoHeightIFrame) Tab(com.vaadin.ui.TabSheet.Tab) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) AqlCodeEditor(org.corpus_tools.annis.gui.components.codemirror.AqlCodeEditor) Assert.assertTrue(org.junit.Assert.assertTrue) ControlPanel(org.corpus_tools.annis.gui.controlpanel.ControlPanel) Button(com.vaadin.ui.Button) AfterEach(org.junit.jupiter.api.AfterEach) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) TextArea(com.vaadin.v7.ui.TextArea) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) BeanFactory(org.springframework.beans.factory.BeanFactory) Annotation(org.corpus_tools.annis.api.model.Annotation) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) GridEvent(org.corpus_tools.annis.gui.widgets.grid.GridEvent) AnnotationGrid(org.corpus_tools.annis.gui.widgets.grid.AnnotationGrid) KWICComponent(org.corpus_tools.annis.gui.visualizers.component.kwic.KWICComponent) Button(com.vaadin.ui.Button) GridComponent(org.corpus_tools.annis.gui.visualizers.component.grid.GridComponent) MediaElementPlayer(org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer) Row(org.corpus_tools.annis.gui.widgets.grid.Row) SingleResultPanel(org.corpus_tools.annis.gui.resultview.SingleResultPanel) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

GridKt (com.github.mvysny.kaributesting.v8.GridKt)5 LocatorJ._click (com.github.mvysny.kaributesting.v8.LocatorJ._click)5 LocatorJ._find (com.github.mvysny.kaributesting.v8.LocatorJ._find)5 LocatorJ._get (com.github.mvysny.kaributesting.v8.LocatorJ._get)5 LocatorJ._setValue (com.github.mvysny.kaributesting.v8.LocatorJ._setValue)5 MockVaadin (com.github.mvysny.kaributesting.v8.MockVaadin)5 NotificationsKt (com.github.mvysny.kaributesting.v8.NotificationsKt)5 DataProvider (com.vaadin.data.provider.DataProvider)5 ListDataProvider (com.vaadin.data.provider.ListDataProvider)5 VaadinIcons (com.vaadin.icons.VaadinIcons)5 Page (com.vaadin.server.Page)5 ContentMode (com.vaadin.shared.ui.ContentMode)5 UIScopeImpl (com.vaadin.spring.internal.UIScopeImpl)5 Accordion (com.vaadin.ui.Accordion)5 Button (com.vaadin.ui.Button)5 ComboBox (com.vaadin.ui.ComboBox)5 Component (com.vaadin.ui.Component)5 Grid (com.vaadin.ui.Grid)5 Label (com.vaadin.ui.Label)5 Panel (com.vaadin.ui.Panel)5