package annis.libgui;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

class HelperTest {

  @Test
  void testRightToLeft() {
    assertFalse(Helper.containsRTLText("Anise"));
    assertTrue(Helper.containsRTLText("אניס"));
    assertTrue(Helper.containsRTLText("يانسون"));
    assertTrue(Helper.containsRTLText("test cשּ"));
    assertTrue(Helper.containsRTLText("test ﻕ "));
    assertTrue(Helper.containsRTLText("test ﭦ"));
    assertFalse(Helper.containsRTLText(null));
    assertFalse(Helper.containsRTLText(""));
  }

}

@@ -16,16 +16,77 @@
 ibgui;%0A%0A
+import static org.junit.jupiter.api.Assertions.assertEquals;%0A
 import s
@@ -137,16 +137,16 @@
 tFalse;%0A
-
 import s
@@ -197,16 +197,64 @@
 tTrue;%0A%0A
+import java.util.Arrays;%0Aimport java.util.List;%0A
 import o
@@ -301,16 +301,254 @@
 Test %7B%0A%0A
+  private static final String RAWTEXT_QUERY =%0A      %22(a#tok) & doc#annis:node_name=/corpus%5C%5Cx2Fdoc/ & #a @* #doc%22;%0A  private static final String WHOLEDOCUMENT_QUERY =%0A      %22(n#node) & doc#annis:node_name=/corpus%5C%5Cx2Fdoc/ & #n @* #doc%22;%0A%0A
   @Test%0A
@@ -917,24 +917,24 @@
 ext(null));%0A
-
     assertFa
@@ -971,10 +971,1139 @@
 );%0A  %7D%0A%0A
+  @Test%0A  void testBuildAQLDocumentQuery() %7B%0A    List%3CString%3E docPath = Arrays.asList(%22corpus%22, %22doc%22);%0A    // Test the full document fallback query%0A    assertEquals(WHOLEDOCUMENT_QUERY,%0A        Helper.buildDocumentQuery(docPath, null, false));%0A    // Test the raw text query%0A    assertEquals(RAWTEXT_QUERY,%0A        Helper.buildDocumentQuery(docPath, null, true));%0A    // Test the node annotation filter%0A    assertEquals(%0A        %22(a#tok %7C a#pos %7C a#something) & doc#annis:node_name=/corpus%5C%5Cx2Fdoc/ & #a @* #doc%22,%0A        Helper.buildDocumentQuery(docPath, Arrays.asList(%22pos%22, %22something%22), true));%0A   // Check invalid node annotation names lead to falling back to the whole document query%0A   assertEquals(WHOLEDOCUMENT_QUERY,%0A       Helper.buildDocumentQuery(docPath, Arrays.asList(%22pos%22, %22myanno=something%22), false));%0A   // When giving giving both a node annotation filter argument and using raw text, the node filter%0A   // query should be returned%0A   assertEquals(%22(a#tok %7C a#ns:pos) & doc#annis:node_name=/corpus%5C%5Cx2Fdoc/ & #a @* #doc%22,%0A       Helper.buildDocumentQuery(docPath, Arrays.asList(%22ns:pos%22), true));%0A%0A    %0A  %7D%0A%0A
 %7D%0A

Test Helper#buildDocumentQuery