package test;

import greycat.Callback;
import greycat.Graph;
import greycat.GraphBuilder;
import greycat.scheduler.NoopScheduler;
import model.GPSPosition;
import model.ModelPlugin;
import model.SmartCity;
import org.junit.Assert;

/**
 * Created by Gregory NAIN on 02/08/2017.
 */
public class CustomTypesTest {
    private static long cityNodeId;
    private static MockStorage storage = new MockStorage();

    public static void main(String[] args) {


        Graph g = GraphBuilder.newBuilder().withScheduler(new NoopScheduler()).withStorage(storage).withPlugin(new ModelPlugin()).build();
        g.connect(new Callback<Boolean>() {
            @Override
            public void on(Boolean result) {
                SmartCity city = SmartCity.create(0,0, g);
                cityNodeId = city.id();
                
                GPSPosition location = city.getOrCreateLocation();
                location.setLat(1.2);
                location.setLat(3.4);
                
                g.save((saved) -> {

                    Graph graph2 = GraphBuilder.newBuilder().withScheduler(new NoopScheduler()).withStorage(storage).withPlugin(new ModelPlugin()).build();
                    graph2.connect(new Callback<Boolean>() {
                        @Override
                        public void on(Boolean result) {
                            graph2.lookup(0,0, cityNodeId, city ->{
                                SmartCity retreivedCity = (SmartCity) city;
                                GPSPosition location = retreivedCity.getLocation();
                                Assert.assertTrue(location.getLat() == 1.2);
                            });
                        }
                    });

                });
            }
        });
        
        
    }
    
}

@@ -230,58 +230,8 @@
 t;%0A%0A
-/**%0A * Created by Gregory NAIN on 02/08/2017.%0A */%0A
 publ
@@ -703,16 +703,17 @@
 reate(0,
+ 
 0, g);%0A 
@@ -751,33 +751,17 @@
 y.id();%0A
-                
 %0A
+
         
@@ -886,18 +886,18 @@
 ion.setL
-at
+ng
 (3.4);%0A 
@@ -1301,16 +1301,17 @@
 ookup(0,
+ 
 0, cityN
@@ -1324,16 +1324,17 @@
  city -%3E
+ 
 %7B%0A      
@@ -1697,35 +1697,15 @@
 %7D);%0A
-        %0A        
+%0A
 %0A    %7D%0A
-    
 %0A%7D%0A

fix test, well ... :-)