Search in sources :

Example 1 with EmbeddedVisUI

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

the class EmbeddedVisTest method regression509.

@Test
void regression509() throws Exception {
    EmbeddedVisUI ui = (EmbeddedVisUI) UI.getCurrent();
    MockRequest request = MockVaadinKt.getMock(VaadinRequest.getCurrent());
    request.setParameter("embedded_ns", "exmaralda");
    request.setParameter("embedded_instance", "");
    request.setParameter("embedded_match", "pcc2/11299#tok_1");
    request.setParameter("embedded_left", "5");
    request.setParameter("embedded_right", "5");
    request.setParameter("embedded_interface", "http://localhost:5712/#_q=dG9r&ql=aql&_c=cGNjMg&cl=5&cr=5&s=0&l=10&m=0");
    ui.attachToPath("/embeddedvis/grid", VaadinRequest.getCurrent());
    awaitCondition(30, () -> !_find(Link.class, spec -> spec.withCaption("Show in ANNIS search interface")).isEmpty());
    Link link = _get(Link.class, spec -> spec.withCaption("Show in ANNIS search interface"));
    assertEquals("dontprint", link.getStyleName());
}
Also used : WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) ContentMode(com.vaadin.shared.ui.ContentMode) BeforeEach(org.junit.jupiter.api.BeforeEach) UI(com.vaadin.ui.UI) Link(com.vaadin.ui.Link) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) VaadinRequest(com.vaadin.server.VaadinRequest) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) Test(org.junit.jupiter.api.Test) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) AfterEach(org.junit.jupiter.api.AfterEach) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Label(com.vaadin.ui.Label) BeanFactory(org.springframework.beans.factory.BeanFactory) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MockVaadinKt(com.github.mvysny.kaributesting.v8.MockVaadinKt) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) Link(com.vaadin.ui.Link) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with EmbeddedVisUI

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

the class EmbeddedVisTest method showRawText.

@Test
void showRawText() throws Exception {
    EmbeddedVisUI ui = (EmbeddedVisUI) UI.getCurrent();
    MockRequest request = MockVaadinKt.getMock(VaadinRequest.getCurrent());
    request.setParameter("embedded_match", "pcc2/11299#tok_1");
    request.setParameter("embedded_fulltext", "");
    ui.attachToPath("/embeddedvis/raw_text", VaadinRequest.getCurrent());
    awaitCondition(60, () -> !_find(Label.class, spec -> spec.withPredicate(l -> "raw_text_label".equals(l.getStyleName()))).isEmpty());
    Label labelRawText = _get(Label.class, spec -> spec.withPredicate(l -> "raw_text_label".equals(l.getStyleName())));
    assertTrue(labelRawText.getValue().startsWith("Feigenblatt Die Jugendlichen in Zossen wollen ein Musikcafé ."));
    assertTrue(labelRawText.getValue().endsWith("Die glänzten diesmal noch mit Abwesenheit ."));
}
Also used : WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) ContentMode(com.vaadin.shared.ui.ContentMode) BeforeEach(org.junit.jupiter.api.BeforeEach) UI(com.vaadin.ui.UI) Link(com.vaadin.ui.Link) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) VaadinRequest(com.vaadin.server.VaadinRequest) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) Test(org.junit.jupiter.api.Test) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) AfterEach(org.junit.jupiter.api.AfterEach) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Label(com.vaadin.ui.Label) BeanFactory(org.springframework.beans.factory.BeanFactory) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MockVaadinKt(com.github.mvysny.kaributesting.v8.MockVaadinKt) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) Label(com.vaadin.ui.Label) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with EmbeddedVisUI

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

the class EmbeddedVisTest method unknownRemoteSaltVisualizer.

/**
 * Make sure there is an error message when an unknown visualizer is requested.
 *
 * @throws Exception
 */
@Test
void unknownRemoteSaltVisualizer() throws Exception {
    EmbeddedVisUI ui = (EmbeddedVisUI) UI.getCurrent();
    MockRequest request = MockVaadinKt.getMock(VaadinRequest.getCurrent());
    request.setParameter("embedded_salt", "http://example.com/does-not-exist.salt");
    ui.attachToPath("/embeddedvis/notavisualizer", VaadinRequest.getCurrent());
    awaitCondition(60, () -> !_find(Label.class, spec -> spec.withPredicate(l -> l.getContentMode() == ContentMode.HTML && l.getValue().startsWith("<h1>"))).isEmpty());
    Label labelMessage = _get(Label.class);
    assertEquals("<h1>Unknown visualizer \"notavisualizer\"</h1><div>This ANNIS instance does not know the given visualizer.</div>", labelMessage.getValue());
}
Also used : WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) ContentMode(com.vaadin.shared.ui.ContentMode) BeforeEach(org.junit.jupiter.api.BeforeEach) UI(com.vaadin.ui.UI) Link(com.vaadin.ui.Link) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) VaadinRequest(com.vaadin.server.VaadinRequest) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) Test(org.junit.jupiter.api.Test) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) AfterEach(org.junit.jupiter.api.AfterEach) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Label(com.vaadin.ui.Label) BeanFactory(org.springframework.beans.factory.BeanFactory) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MockVaadinKt(com.github.mvysny.kaributesting.v8.MockVaadinKt) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) Label(com.vaadin.ui.Label) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with EmbeddedVisUI

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

the class EmbeddedVisTest method invalidRemoteSaltUrlScheme.

@Test
void invalidRemoteSaltUrlScheme() throws Exception {
    EmbeddedVisUI ui = (EmbeddedVisUI) UI.getCurrent();
    MockRequest request = MockVaadinKt.getMock(VaadinRequest.getCurrent());
    request.setParameter("embedded_salt", "file://example.com/does-not-exist.salt");
    ui.attachToPath("/embeddedvis/raw_text", VaadinRequest.getCurrent());
    awaitCondition(60, () -> !_find(Label.class, spec -> spec.withPredicate(l -> l.getContentMode() == ContentMode.HTML && l.getValue().startsWith("<h1>"))).isEmpty());
    Label labelMessage = _get(Label.class);
    assertEquals("<h1>Could not generate the visualization.</h1><div>Expected URL scheme 'http' or 'https' but was 'file'</div>", labelMessage.getValue());
}
Also used : WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) ContentMode(com.vaadin.shared.ui.ContentMode) BeforeEach(org.junit.jupiter.api.BeforeEach) UI(com.vaadin.ui.UI) Link(com.vaadin.ui.Link) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) VaadinRequest(com.vaadin.server.VaadinRequest) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) Test(org.junit.jupiter.api.Test) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) AfterEach(org.junit.jupiter.api.AfterEach) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TestHelper.awaitCondition(org.corpus_tools.annis.gui.TestHelper.awaitCondition) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Label(com.vaadin.ui.Label) BeanFactory(org.springframework.beans.factory.BeanFactory) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MockVaadinKt(com.github.mvysny.kaributesting.v8.MockVaadinKt) EmbeddedVisUI(org.corpus_tools.annis.gui.EmbeddedVisUI) Label(com.vaadin.ui.Label) MockRequest(com.github.mvysny.kaributesting.mockhttp.MockRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MockRequest (com.github.mvysny.kaributesting.mockhttp.MockRequest)4 LocatorJ._find (com.github.mvysny.kaributesting.v8.LocatorJ._find)4 LocatorJ._get (com.github.mvysny.kaributesting.v8.LocatorJ._get)4 MockVaadin (com.github.mvysny.kaributesting.v8.MockVaadin)4 MockVaadinKt (com.github.mvysny.kaributesting.v8.MockVaadinKt)4 VaadinRequest (com.vaadin.server.VaadinRequest)4 ContentMode (com.vaadin.shared.ui.ContentMode)4 UIScopeImpl (com.vaadin.spring.internal.UIScopeImpl)4 Label (com.vaadin.ui.Label)4 Link (com.vaadin.ui.Link)4 UI (com.vaadin.ui.UI)4 EmbeddedVisUI (org.corpus_tools.annis.gui.EmbeddedVisUI)4 TestHelper.awaitCondition (org.corpus_tools.annis.gui.TestHelper.awaitCondition)4 AfterEach (org.junit.jupiter.api.AfterEach)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4 BeanFactory (org.springframework.beans.factory.BeanFactory)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4