package uk.me.graphe.server;

import junit.framework.TestCase;
import uk.me.graphe.server.database.Database;
import uk.me.graphe.server.database.DatabaseFactory;
import uk.me.graphe.shared.Edge;
import uk.me.graphe.shared.Vertex;
import uk.me.graphe.shared.graphmanagers.OTGraphManager2d;
import uk.me.graphe.shared.graphmanagers.OTGraphManagerFactory;
import uk.me.graphe.shared.messages.operations.AddEdgeOperation;
import uk.me.graphe.shared.messages.operations.AddNodeOperation;


public class DatabaseTest extends TestCase{

    private Database db = DatabaseFactory.newInstance();
    private OTGraphManager2d mManager;
    private int graphId = 0;
    @Override
    protected void setUp() throws Exception {
        // TODO Auto-generated method stub
        super.setUp();
        mManager = OTGraphManagerFactory.newInstance(17);
    }

    @Override
    protected void tearDown() throws Exception {
        // TODO Auto-generated method stub
        super.tearDown();
        mManager = null;
    }
    
    public void testStore () {
        Vertex v1 = new Vertex("v1");
        Vertex v2 = new Vertex("v2");
        mManager.applyOperation(new AddNodeOperation(v1, 1, 1));
        mManager.applyOperation(new AddNodeOperation(v2, 1, 4));
        mManager.applyOperation(new AddEdgeOperation(new Edge(v1,v2)));
        graphId = db.store(mManager);   
    }
    
    public void testRetrieve() {
        //OTGraphManager2d retrieve = db.retrieve(graphId);
        
    }
}

@@ -23,16 +23,47 @@
 erver;%0A%0A
+import junit.framework.Assert;%0A
 import j
@@ -83,24 +83,24 @@
 k.TestCase;%0A
-
 import uk.me
@@ -254,16 +254,73 @@
 Vertex;%0A
+import uk.me.graphe.shared.graphmanagers.GraphManager2d;%0A
 import u
@@ -565,17 +565,16 @@
 ation;%0A%0A
-%0A
 public c
@@ -607,16 +607,17 @@
 TestCase
+ 
 %7B%0A%0A    p
@@ -736,16 +736,17 @@
 Id = 0;%0A
+%0A
     @Ove
@@ -1087,28 +1087,24 @@
 null;%0A    %7D%0A
-    
 %0A    public 
@@ -1117,17 +1117,16 @@
 estStore
- 
 () %7B%0A   
@@ -1393,16 +1393,17 @@
 Edge(v1,
+ 
 v2)));%0A 
@@ -1442,23 +1442,371 @@
 er);
+%0A
    
+     GraphManager2d m = db.retrieve(graphId);%0A        Assert.assertNotNull(m.getEdgeDrawables());        %0A        Assert.assertEquals(mManager.getEdgeDrawables().size(), m.getEdgeDrawables().size());%0A        Assert.assertNotNull(m.getVertexDrawables());%0A        Assert.assertEquals(mManager.getVertexDrawables().size(), m.getVertexDrawables().size());
 %0A    %7D%0A
-    
 %0A
+
     
@@ -1844,16 +1844,17 @@
       //
+ 
 OTGraphM
@@ -1895,24 +1895,16 @@
 aphId);%0A
-        
 %0A    %7D%0A%7D

make database test actually test some things