package org.col.db.tree;

import java.io.IOException;
import java.io.InputStream;

import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.junit.Test;

public class DiffServiceTest {
  
  @Test
  public void diff() throws Exception {
    System.out.println(DiffService.treeDiff( 1, 1, tree("coldp.tree"), 2, tree("coldp2.tree")));
  }
  
  private String tree(String fn) throws IOException {
    InputStream tree = getClass().getResourceAsStream("/trees/"+fn);
    return IOUtils.toString(tree, Charsets.UTF_8).trim();
  }
}
@@ -74,16 +74,42 @@
 tStream;
+%0Aimport java.util.HashSet;
 %0A%0Aimport
@@ -180,16 +180,55 @@
 OUtils;%0A
+import org.col.api.model.SectorImport;%0A
 import o
@@ -274,16 +274,41 @@
 eTest %7B%0A
+  static int attemptCnt;%0A
   %0A  @Te
@@ -324,16 +324,20 @@
 ic void 
+tree
 diff() t
@@ -403,18 +403,15 @@
 ff( 
-1, 1, tree
+syncImp
 (%22co
@@ -426,94 +426,670 @@
 %22), 
-2, tree(%22coldp2.tree%22)));%0A  %7D%0A  %0A  private String tree(String fn) throws IOException %7B
+syncImp(%22coldp2.tree%22)));%0A  %7D%0A  %0A  @Test%0A  public void namesdiff() throws Exception %7B%0A    System.out.println(DiffService.namesDiff( syncImp(%22c1%22, %22c2%22, %223%22, %22dghz%22), syncImp(%22f1%22, %22c2%22, %2232%22)));%0A  %7D%0A  %0A  private static SectorImport syncImp(String... ids) throws IOException %7B%0A    SectorImport si = new SectorImport();%0A    si.setSectorKey(1);%0A    si.setAttempt(attemptCnt++);%0A    si.setNames(new HashSet%3C%3E());%0A    for (String id : ids) %7B%0A      si.getNames().add(id);%0A    %7D%0A    return si;%0A  %7D%0A  %0A  private static SectorImport syncImp(String fn) throws IOException %7B%0A    SectorImport si = new SectorImport();%0A    si.setSectorKey(1);%0A    si.setAttempt(attemptCnt++);
 %0A   
@@ -1112,18 +1112,29 @@
 e = 
-getC
+DiffServiceTest.c
 lass
-()
 .get
@@ -1169,23 +1169,31 @@
 n);%0A    
-return 
+si.setTextTree(
 IOUtils.
@@ -1229,15 +1229,31 @@
 ).trim()
+);%0A    return si
 ;%0A  %7D%0A%7D

Fix diff test