package model;

import org.junit.Test;

import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;

import static org.junit.Assert.*;

public class ClusterDataTest {

    @Test
    public void testLoadClusterData() throws Exception {
        ClusterData cluster = new ClusterData(new DefaultMutableTreeNode());
        File file = new File("./sample/test/moka_ACDC.clsx");
        cluster.loadClusterData(file);
        assertEquals(cluster.getTree().getNextNode().getUserObject().toString(),"edu.drexel.cs.rise.moka.jre16.parser.MethodParser");
    }

    @Test
    public void testSaveClusterData() throws Exception {
        ClusterData cluster = new ClusterData(new DefaultMutableTreeNode());
        File file = new File("./sample/test/moka_ACDC.clsx");
        File file2 = new File("./sample/test/moka_ACDC2.clsx");
        cluster.loadClusterData(file);
        cluster.saveClusterData(file2);
        assertTrue(file.exists());
        file2.delete();
    }

    @Test
    public void testMoveNode() throws Exception {
        ClusterData cluster = new ClusterData(new DefaultMutableTreeNode());
        File file = new File("./sample/test/moka_ACDC.clsx");
        cluster.loadClusterData(file);
        cluster.moveNode(cluster.getTree().getNextNode(), 2);
        assertEquals(cluster.getTree().getChildAt(2).toString(), "edu.drexel.cs.rise.moka.jre16.parser.MethodParser");
    }

    @Test
    public void testNewGroupbyNode() throws Exception {

    }

    @Test
    public void testFreeGroup() throws Exception {

    }

    @Test
    public void testRenameNode() throws Exception {

    }

    @Test
    public void testAddItem() throws Exception {

    }

    @Test
    public void testDeleteItem() throws Exception {

    }
}
@@ -101,16 +101,44 @@
 io.File;
+%0Aimport java.util.ArrayList;
 %0A%0Aimport
@@ -1483,32 +1483,530 @@
 ows Exception %7B%0A
+        ClusterData cluster = new ClusterData(new DefaultMutableTreeNode());%0A        ArrayList%3CDefaultMutableTreeNode%3E Array = new ArrayList%3CDefaultMutableTreeNode%3E();%0A        File file = new File(%22./sample/test/moka_ACDC.clsx%22);%0A%0A        cluster.loadClusterData(file);%0A        Array.add(cluster.getTree().getNextNode());%0A        cluster.newGroupbyNode(Array, %22newGroup%22);%0A        assertEquals(cluster.getNode(%22edu.drexel.cs.rise.moka.jre16.parser.MethodParser%22).getParent().toString(),%22newGroup%22);
 %0A    %7D%0A%0A    @Tes

add testNewGroupbyNode