package org.col.resources;

import java.util.List;
import javax.ws.rs.core.GenericType;

import org.col.api.model.TreeNode;
import org.col.db.mapper.InitMybatisRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

import static org.col.dw.ApiUtils.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class TreeResourceTest extends ResourceTestBase {
  
  static GenericType<List<TreeNode>> LIST_TYPE = new GenericType<List<TreeNode>>() {};
  
  @Rule
  public InitMybatisRule initMybatisRule = InitMybatisRule.apple(RULE.getSqlSessionFactory());
  
  public TreeResourceTest() {
    super("/dataset");
  }
  
  @Test
  public void get() {
    List<TreeNode> root = base.path("/11/tree").request().get(LIST_TYPE);
    assertEquals(2, root.size());
  }
  
  @Test
  @Ignore("TODO: under construction")
  public void create() {
    TreeNode tn = new TreeNode();
    tn.setDatasetKey(11);
    tn.setId("root-1");
  
    String id = editorCreds(base.path("/11/tree")
        .queryParam("datasetKey", 12)
    ).post(json(tn), String.class);
    
    assertNotNull(id);
  }
  
}
@@ -25,31 +25,8 @@
 s;%0A%0A
-import java.util.List;%0A
 impo
@@ -59,16 +59,53 @@
 cType;%0A%0A
+import org.col.api.model.ResultPage;%0A
 import o
@@ -283,9 +283,59 @@
 ils.
-*
+editorCreds;%0Aimport static org.col.dw.ApiUtils.json
 ;%0Aim
@@ -497,37 +497,53 @@
 tic GenericType%3C
-List%3C
+ResultPage%3C? extends 
 TreeNode%3E%3E LIST_
@@ -537,20 +537,20 @@
 eNode%3E%3E 
-LIST
+RESP
 _TYPE = 
@@ -565,21 +565,37 @@
 ricType%3C
-List%3C
+ResultPage%3C? extends 
 TreeNode
@@ -810,13 +810,29 @@
     
-List%3C
+ResultPage%3C? extends 
 Tree
@@ -884,12 +884,12 @@
 get(
-LIST
+RESP
 _TYP

Fix tree resource test to expect a paging response