/**
   * @see DATAGRAPH-632
   * @throws Exception
   */
  @Test
  public void testFindByBaseAndMultipleNestedPropertiesOnBothEnds() throws Exception {
    Filter moonFilter = new Filter();
    moonFilter.setNestedPropertyName("world");
    moonFilter.setNestedEntityTypeLabel("Moon");
    moonFilter.setPropertyValue("Earth");
    moonFilter.setPropertyName("name");
    moonFilter.setRelationshipType("ORBITS");
    moonFilter.setRelationshipDirection("OUTGOING");
    moonFilter.setComparisonOperator(ComparisonOperator.EQUALS);

    Filter planetFilter = new Filter();
    planetFilter.setNestedPropertyName("colour");
    planetFilter.setNestedEntityTypeLabel("Planet");
    planetFilter.setPropertyValue("Red");
    planetFilter.setPropertyName("colour");
    planetFilter.setRelationshipType("ORBITS");
    planetFilter.setRelationshipDirection("INCOMING");
    planetFilter.setComparisonOperator(ComparisonOperator.EQUALS);

    Filter time = new Filter("time", 3600);
    time.setBooleanOperator(BooleanOperator.AND);

    assertEquals(
        "MATCH (n:`Moon`) WHERE n.`name` = { `world_name` } MATCH (m:`Planet`) WHERE m.`colour` = { `colour_colour` } MATCH (n)-[r:`ORBITS`]->(m) WHERE r.`time` = { `time` } WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
        query
            .findByProperties("ORBITS", new Filters().add(moonFilter, planetFilter, time), 4)
            .getStatement());
  }
  /**
   * @see DATAGRAPH-632
   * @throws Exception
   */
  @Test
  public void testFindByMultipleNestedProperties() throws Exception {
    Filter planetNameFilter = new Filter();
    planetNameFilter.setNestedPropertyName("world");
    planetNameFilter.setNestedEntityTypeLabel("Planet");
    planetNameFilter.setPropertyValue("Earth");
    planetNameFilter.setPropertyName("name");
    planetNameFilter.setRelationshipType("ORBITS");
    planetNameFilter.setRelationshipDirection("OUTGOING");
    planetNameFilter.setComparisonOperator(ComparisonOperator.EQUALS);

    Filter planetMoonsFilter = new Filter();
    planetMoonsFilter.setNestedPropertyName("moons");
    planetMoonsFilter.setNestedEntityTypeLabel("Planet");
    planetMoonsFilter.setPropertyValue("Earth");
    planetMoonsFilter.setPropertyName("moons");
    planetMoonsFilter.setRelationshipType("ORBITS");
    planetMoonsFilter.setRelationshipDirection("OUTGOING");
    planetMoonsFilter.setBooleanOperator(BooleanOperator.AND);
    planetMoonsFilter.setComparisonOperator(ComparisonOperator.EQUALS);

    assertEquals(
        "MATCH (n:`Planet`) WHERE n.`name` = { `world_name` } AND n.`moons` = { `moons_moons` } MATCH (n)-[r:`ORBITS`]->(m) WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
        query
            .findByProperties("ORBITS", new Filters().add(planetNameFilter, planetMoonsFilter), 4)
            .getStatement());
  }
 @Test
 public void testFindByProperty() throws Exception {
   assertEquals(
       "MATCH (n)-[r:`ORBITS`]->(m) WHERE r.`distance` = { `distance` } WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
       query
           .findByProperties("ORBITS", new Filters().add(new Filter("distance", 60.2)), 4)
           .getStatement());
 }
 /**
  * @see DATAGRAPH-632
  * @throws Exception
  */
 @Test
 public void testFindByPropertiesOred() throws Exception {
   Filter distance = new Filter("distance", 60.2);
   Filter time = new Filter("time", 3600);
   time.setBooleanOperator(BooleanOperator.OR);
   assertEquals(
       "MATCH (n)-[r:`ORBITS`]->(m) WHERE r.`distance` = { `distance` } OR r.`time` = { `time` } WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
       query.findByProperties("ORBITS", new Filters().add(distance, time), 4).getStatement());
 }
 /**
  * @see DATAGRAPH-632
  * @throws Exception
  */
 @Test
 public void testFindByPropertiesWithDifferentComparisonOperatorsAnded() throws Exception {
   Filter distance = new Filter("distance", 60.2);
   distance.setComparisonOperator(ComparisonOperator.LESS_THAN);
   Filter time = new Filter("time", 3600);
   time.setBooleanOperator(BooleanOperator.AND);
   assertEquals(
       "MATCH (n)-[r:`ORBITS`]->(m) WHERE r.`distance` < { `distance` } AND r.`time` = { `time` } WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
       query.findByProperties("ORBITS", new Filters().add(distance, time), 4).getStatement());
 }
 /**
  * @see DATAGRAPH-632
  * @throws Exception
  */
 @Test
 public void testFindByNestedPropertyIncoming() throws Exception {
   Filter planetFilter = new Filter();
   planetFilter.setNestedPropertyName("world");
   planetFilter.setNestedEntityTypeLabel("Planet");
   planetFilter.setPropertyValue("Earth");
   planetFilter.setPropertyName("name");
   planetFilter.setRelationshipType("ORBITS");
   planetFilter.setRelationshipDirection("INCOMING");
   planetFilter.setComparisonOperator(ComparisonOperator.EQUALS);
   assertEquals(
       "MATCH (m:`Planet`) WHERE m.`name` = { `world_name` } MATCH (n)-[r:`ORBITS`]->(m) WITH n,r MATCH p=(n)-[*0..4]-() RETURN p, ID(r)",
       query.findByProperties("ORBITS", new Filters().add(planetFilter), 4).getStatement());
 }
 @Test(expected = InvalidDepthException.class)
 public void testFindByPropertyZeroDepth() throws Exception {
   query
       .findByProperties("ORBITS", new Filters().add(new Filter("perihelion", 19.7)), 0)
       .getStatement();
 }
 @Test(expected = InvalidDepthException.class)
 public void testFindByLabelZeroDepth() throws Exception {
   query.findByType("ORBITS", 0).getStatement();
 }
 @Test(expected = InvalidDepthException.class)
 public void testFindAllCollectionZeroDepth() throws Exception {
   query.findAll(Arrays.asList(1L, 2L, 3L), 0).getStatement();
 }
Exemplo n.º 10
0
 @Test(expected = InvalidDepthException.class)
 public void testFindOneZeroDepth() throws Exception {
   query.findOne(0L, 0).getStatement();
 }
Exemplo n.º 11
0
 /**
  * @see DATAGRAPH-707
  * @throws Exception
  */
 @Test
 public void testFindAllByTypeCollection() throws Exception {
   assertEquals(
       "MATCH (n)-[r:`ORBITS`]->() WHERE ID(r) IN { ids } WITH n MATCH p=(n)-[*0..1]-(m) RETURN p",
       query.findAllByType("ORBITS", Arrays.asList(1L, 2L, 3L), 1).getStatement());
 }
Exemplo n.º 12
0
 @Test
 public void testFindByLabel() throws Exception {
   assertEquals(
       "MATCH p=()-[r:`ORBITS`*..3]-() RETURN p", query.findByType("ORBITS", 3).getStatement());
 }
Exemplo n.º 13
0
 @Test
 public void testFindAll() throws Exception {
   assertEquals("MATCH p=()-->() RETURN p", query.findAll().getStatement());
 }
Exemplo n.º 14
0
 @Test
 public void testFindOne() throws Exception {
   assertEquals(
       "MATCH (n)-[r]->() WHERE ID(r) = { id } WITH n MATCH p=(n)-[*0..2]-(m) RETURN p",
       query.findOne(0L, 2).getStatement());
 }
Exemplo n.º 15
0
 @Test(expected = InvalidDepthException.class)
 public void testFindByPropertyInfiniteDepth() throws Exception {
   query
       .findByProperties("ORBITS", new Filters().add(new Filter("period", 2103.776)), -1)
       .getStatement();
 }