package annis.visualizers.component.tree;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.LinkedHashSet;
import java.util.Set;
import org.corpus_tools.salt.SaltFactory;
import org.corpus_tools.salt.core.SAnnotation;
import org.junit.jupiter.api.Test;

class AnnisGraphToolsTest {

  @Test
  void extractAnnotation() {
    assertNull(AnnisGraphTools.extractAnnotation(null, "some_ns", "func"));

    Set<SAnnotation> annos = new LinkedHashSet<>();
    SAnnotation annoFunc = SaltFactory.createSAnnotation();
    annoFunc.setNamespace("some_ns");
    annoFunc.setName("func");
    annoFunc.setValue("value");
    annos.add(annoFunc);

    assertEquals("value", AnnisGraphTools.extractAnnotation(annos, null, "func"));
    assertEquals("value", AnnisGraphTools.extractAnnotation(annos, "some_ns", "func"));

    assertNull(AnnisGraphTools.extractAnnotation(annos, "another_ns", "func"));
    assertNull(AnnisGraphTools.extractAnnotation(annos, "some_ns", "anno"));
    assertNull(AnnisGraphTools.extractAnnotation(annos, "another_ns", "anno"));
    assertNull(AnnisGraphTools.extractAnnotation(annos, null, "anno"));


  }

}

@@ -154,14 +154,294 @@
 sert
-Null;%0A
+False;%0Aimport static org.junit.jupiter.api.Assertions.assertNull;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport annis.libgui.visualizers.VisualizerInput;%0Aimport java.util.LinkedHashMap;
 %0Aimp
@@ -465,24 +465,46 @@
 kedHashSet;%0A
+import java.util.Map;%0A
 import java.
@@ -555,16 +555,72 @@
 actory;%0A
+import org.corpus_tools.salt.common.SDominanceRelation;%0A
 import o
@@ -1563,10 +1563,800 @@
 %0A%0A%0A  %7D%0A%0A
+  @Test%0A  void isTerminalNullCheck() %7B%0A    assertFalse(AnnisGraphTools.isTerminal(null, null));%0A    VisualizerInput mockedVisInput = mock(VisualizerInput.class);%0A    assertFalse(AnnisGraphTools.isTerminal(null, mockedVisInput));%0A  %7D%0A%0A  @Test%0A  void hasEdgeSubtypeForEmptyType() %7B%0A%0A    SDominanceRelation rel = mock(SDominanceRelation.class);%0A    VisualizerInput input = mock(VisualizerInput.class);%0A%0A    // When the type is empty, this should be treated like having no type (null) at all%0A    when(rel.getType()).thenReturn(%22%22);%0A    Map%3CString, String%3E mappings = new LinkedHashMap%3C%3E();%0A    when(input.getMappings()).thenReturn(mappings);%0A    mappings.put(%22edge_type%22, %22null%22);%0A%0A    AnnisGraphTools tools = new AnnisGraphTools(input);%0A    assertTrue(tools.hasEdgeSubtype(rel, %22null%22));%0A  %7D%0A%0A
 %7D%0A

Add more tests for AnnisGraphTools