Package org.neo4j.rest.graphdb.converter

Examples of org.neo4j.rest.graphdb.converter.TypeInformation


        assertEquals(Object.class, typeInfo.getGenericArguments()[1]);
    }

    @Test
    public void testMapIntegerNode(){
        TypeInformation typeInfo = createTypeInfo("testMapIntegerNode");
        assertEquals(Map.class, typeInfo.getType());
        assertEquals(2, typeInfo.getGenericArguments().length);
        assertEquals(Integer.class, typeInfo.getGenericArguments()[0]);
        assertEquals(Node.class, typeInfo.getGenericArguments()[1]);
    }
View Full Code Here


        assertEquals(Node.class, typeInfo.getGenericArguments()[1]);
    }

    @Test
    public void testTypeInformationBasicMethods(){
        TypeInformation typeInfoBasic = createTypeInfo("testSingleValueNode");
        assertTrue(typeInfoBasic.isInstance("test", String.class));
        assertTrue(typeInfoBasic.isSingleType());
        assertTrue(typeInfoBasic.isGraphEntity(Node.class));

        TypeInformation typeInfoCollection = createTypeInfo("testCollectionObject");
        assertTrue(typeInfoCollection.isCollectionType());
        assertTrue(typeInfoCollection.isCollection());

        TypeInformation typeInfoMap = createTypeInfo("testMapStringObject");
        assertTrue(typeInfoMap.isCollectionType());
        assertTrue(typeInfoMap.isMap());
    }
View Full Code Here

        assertTrue(typeInfoMap.isMap());
    }

    @Test
    public void testCreateTypeInformationByIterable(){
        TypeInformation typeInfoIterable = new TypeInformation(asList("test","test2"));
        assertTrue(typeInfoIterable.isCollectionType());
        assertTrue(typeInfoIterable.isCollection());
        assertEquals(1, typeInfoIterable.getGenericArguments().length);
        assertEquals(String.class, typeInfoIterable.getGenericArguments()[0]);
    }
View Full Code Here

        assertEquals(String.class, typeInfoIterable.getGenericArguments()[0]);
    }

    @Test
    public void testCreateTypeInformationByMap(){
        TypeInformation typeInfoMap = new TypeInformation(MapUtil.map("test",1));
        assertTrue(typeInfoMap.isCollectionType());
        assertTrue(typeInfoMap.isMap());
        assertEquals(2, typeInfoMap.getGenericArguments().length);
        assertEquals(String.class, typeInfoMap.getGenericArguments()[0]);
        assertEquals(Integer.class, typeInfoMap.getGenericArguments()[1]);
    }
View Full Code Here



    public TypeInformation createTypeInfo(String methodName){
          try {
            return new TypeInformation(TypeInformationTestInterface.class.getMethod(methodName).getGenericReturnType());
          } catch (NoSuchMethodException e) {
            return null;
          }
    }
View Full Code Here

    }


    @Test
    public void testConvertJSONDataToNode(){
        Object result = converter.convertToResultType(MapUtil.map("self","http://localhost:7474/db/data/node/2", "data", MapUtil.map("propname", "testprop")), new TypeInformation(RestNode.class));
        assertEquals(RestNode.class, result.getClass());
        assertEquals("testprop", ((Node)result).getProperty("propname"));
    }
View Full Code Here

        assertEquals("testprop", ((Node)result).getProperty("propname"));
    }

    @Test
    public void testConvertJSONDataToRelationship(){
        Object result = converter.convertToResultType(MapUtil.map("self","http://localhost:7474/db/data/relationship/2", "data", MapUtil.map("propname", "testprop")), new TypeInformation(RestRelationship.class));
        assertEquals(RestRelationship.class, result.getClass());
        assertEquals("testprop", ((Relationship)result).getProperty("propname"));
    }
View Full Code Here

        path.put("start", node1);
        path.put("nodes", asList(node1, node2));
        path.put("length",1);
        path.put("relationships", asList(relationship1));
        path.put("end", node2);
        Path result = (Path)converter.convertToResultType(path, new TypeInformation(Path.class));

        assertEquals(SimplePath.class, result.getClass());
        assertEquals(1, result.startNode().getId());
        assertEquals(2, result.endNode().getId());
        assertEquals(1, result.lastRelationship().getId());
View Full Code Here

        path.put("start", node1);
        path.put("nodes", asList(node1, node2));
        path.put("length",1);
        path.put("relationships", asList(relationship1));
        path.put("end", node2);
        Object result = converter.convertToResultType(path, new TypeInformation(Path.class));
        assertEquals(SimplePath.class, result.getClass());
        assertEquals("testprop1"((SimplePath)result).startNode().getProperty("propname"));
        assertEquals("testprop2"((SimplePath)result).endNode().getProperty("propname"));
        assertEquals("testproprel1"((SimplePath)result).lastRelationship().getProperty("propname"));
View Full Code Here

    }

    @Test
    public void testConvertSimpleObjectToSameClass(){
        Object result = converter.convertToResultType("test", new TypeInformation(String.class));
        assertEquals(String.class, result.getClass());
        assertEquals("test", result);
    }
View Full Code Here

TOP

Related Classes of org.neo4j.rest.graphdb.converter.TypeInformation

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.