Package com.thinkaurelius.titan.graphdb.serializer

Examples of com.thinkaurelius.titan.graphdb.serializer.SpecialInt


        try {
            v1.addProperty("int", 10.5);
            fail();
        } catch (IllegalArgumentException e) {
        }
        v1.setProperty("int", new SpecialInt(77));
        TitanVertex v12 = tx.addVertex(), v13 = tx.addVertex();
        v12.setProperty("uid", "v12");
        v13.setProperty("uid", "v13");
        v12.addEdge("parent", v1).setProperty("weight", 3.5);
        v13.addEdge("parent", v1).setProperty("weight", 10.5);
        try {
            v12.addEdge("parent", v13);
            fail();
        } catch (IllegalArgumentException e) {
        }
        assertEquals(2, Iterables.size(v1.query().direction(IN).labels("parent").edges()));
        assertEquals(1, Iterables.size(v1.query().direction(IN).labels("parent").has("weight", Compare.GREATER_THAN, 10.0).edges()));
        assertEquals(1, Iterables.size(v12.query().direction(OUT).labels("parent").has("weight").edges()));
        assertEquals(1, Iterables.size(v12.query().direction(OUT).labels("parent").has("weight", Compare.GREATER_THAN, 3).edges()));
        assertEquals(1, Iterables.size(v13.query().direction(OUT).labels("parent").has("weight").edges()));

        v1.addEdge("child", v12);
        v1.addEdge("child", v13);
        try {
            v13.addEdge("child", v12);
            fail();
        } catch (IllegalArgumentException e) {
        }

        v1.addEdge("spouse", v12);
        try {
            v13.addEdge("spouse", v12);
            fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            v1.addEdge("spouse", v13);
            fail();
        } catch (IllegalArgumentException e) {
        }

        v1.addEdge("connect", v12);
        Edge edge = Iterables.getOnlyElement(v1.getEdges(OUT, "connect"));
        assertEquals(0, edge.getPropertyKeys().size());

        clopen();

        id = tx.getPropertyKey("uid");
        v1 = tx.getVertex(id, "v1");
        assertEquals(77, ((SpecialInt) v1.getProperty("int")).getValue());
        assertEquals(v1, Iterables.getOnlyElement(tx.getVertices("someid", 100l)));
        assertEquals(v1, Iterables.getOnlyElement(tx.getVertices(id, "v1")));

        v12 = (TitanVertex) tx.getVertex(v12);
        v13 = (TitanVertex) tx.getVertex(v13);
        assertEquals(2, Iterables.size(v1.query().direction(IN).labels("parent").edges()));
        assertEquals(1, Iterables.size(v1.query().direction(IN).labels("parent").has("weight", Compare.GREATER_THAN, 10.0).edges()));
        assertEquals(1, Iterables.size(v12.query().direction(OUT).labels("parent").has("weight").edges()));
        assertEquals(1, Iterables.size(v12.query().direction(OUT).labels("parent").has("weight", Compare.GREATER_THAN, 3).edges()));
        assertEquals(1, Iterables.size(v13.query().direction(OUT).labels("parent").has("weight").edges()));

        edge = Iterables.getOnlyElement(v1.getEdges(OUT, "connect"));
        assertEquals(0, edge.getPropertyKeys().size());


        // Verify vertex in current transaction
        TitanVertex v2 = tx.addVertex();
        v2.setProperty("uid", "v2");
        v2.setProperty("someid", 200l);
        try {
            v2.addProperty("int", 10.5);
            fail();
        } catch (IllegalArgumentException e) {
        }
        v2.setProperty("int", new SpecialInt(154));

        v2 = tx.getVertex(id, "v2");
        assertEquals(154, ((SpecialInt) v2.getProperty("int")).getValue());
        assertEquals(v2, Iterables.getOnlyElement(tx.getVertices("someid", 200l)));
        assertEquals(v2, Iterables.getOnlyElement(tx.getVertices(id, "v2")));
View Full Code Here

TOP

Related Classes of com.thinkaurelius.titan.graphdb.serializer.SpecialInt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.