Skip to content
This repository was archived by the owner on Apr 25, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,42 @@ For the purpose of these instructions, we'll assume your new JIRA issue ID is "D
For [SDN 5.x](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/sdn-5.x) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh sdn-5.x DATAGRAPH-123
```

For [SDN 4.2](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/sdn-4.2) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh sdn-4.2 DATAGRAPH-123
```

For [SDN 4.1](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/sdn-4.1) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh sdn-4.1 DATAGRAPH-123
```

For [OGM 2.x](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/ogm-2.x) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh ogm-2.x issue-123
```

For [SDN with Spring Boot 1.5](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/boot-1.5) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh boot-1.5 DATAGRAPH-123
```

For [SDN with Spring Boot 1.4](https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/boot-1.4) issues:

```bash
cd neo4j-ogm-bug-test-case-template
cd neo4j-sdn-ogm-issue-report-template
./create-repro-project.sh boot-1.4 DATAGRAPH-123
```

Expand All @@ -97,7 +97,7 @@ git commit -m "Add repro project for DATAGRAPH-123"
git push
```

5\. [Send a pull request from the Github web interface](http://help.github.com/send-pull-requests/)
5\. [Send a pull request from the Github web interface](https://help.github.com/articles/creating-a-pull-request)

* The SDN team will be notified and will look at your request

Expand Down
14 changes: 14 additions & 0 deletions issue-331/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Repro project for issue-331

## Configuring

First, check out and update the versions in the `pom.xml` to match yours

- the `neo4j-ogm.version`

You can also override the version of Neo4j java drivers.

## Logging

This project contains a `logback-test.xml` file in `src/test/resources` that you
may wish to configure to emit more detailed logging.
61 changes: 61 additions & 0 deletions issue-331/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>issue-331</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Neo4j OGM 2.x Test Case Template</name>
<description>Use this template to report bugs with Neo4j OGM</description>

<parent>
<groupId>org.neo4j.ogm.testcasetemplate</groupId>
<artifactId>testcasetemplate</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<properties>

<!-- change with your versions here -->
<neo4j-ogm.version>2.1.1</neo4j-ogm.version>

<!-- if overriding the driver version, also uncomment the driver dependency below -->
<!--<neo4j-java-driver.version>1.2.2</neo4j-java-driver.version>-->
</properties>

<dependencies>
<!--<dependency>-->
<!--<groupId>org.neo4j.driver</groupId>-->
<!--<artifactId>neo4j-java-driver</artifactId>-->
<!--<version>${neo4j-java-driver.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>${neo4j-ogm.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-http-driver</artifactId>
<version>${neo4j-ogm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-test</artifactId>
<version>${neo4j-ogm.version}</version>
<scope>test</scope>
<exclusions> <!-- necessary to get logs in tests -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

</project>
79 changes: 79 additions & 0 deletions issue-331/src/main/java/org/neo4j/ogm/test/domain/Friendship.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product may include a number of subcomponents with
* separate copyright notices and license terms. Your use of the source
* code for these subcomponents is subject to the terms and
* conditions of the subcomponent's license, as noted in the LICENSE file.
*/

package org.neo4j.ogm.test.domain;

import java.util.Set;

import org.neo4j.ogm.annotation.EndNode;
import org.neo4j.ogm.annotation.RelationshipEntity;
import org.neo4j.ogm.annotation.StartNode;

/**
* @author Vince Bickers
*/
@RelationshipEntity(type = "FRIEND_OF")
public class Friendship {

private Long id;

@StartNode
private Person person;

@EndNode
private Person friend;

private int strength;

private Set<String> sharedHobbies;

public Friendship() {
}

public Friendship(Person from, Person to, int strength) {
this.person = from;
this.friend = to;
this.strength = strength;
}

public Friendship(Person person, Person friend, int strength, Set<String> sharedHobbies) {
this.person = person;
this.friend = friend;
this.strength = strength;
this.sharedHobbies = sharedHobbies;
}

public Person getPerson() {
return person;
}

public Person getFriend() {
return friend;
}

public int getStrength() {
return strength;
}

public Long getId() {
return id;
}

public Set<String> getSharedHobbies() {
return sharedHobbies;
}

public void setSharedHobbies(Set<String> sharedHobbies) {
this.sharedHobbies = sharedHobbies;
}
}
59 changes: 59 additions & 0 deletions issue-331/src/main/java/org/neo4j/ogm/test/domain/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product may include a number of subcomponents with
* separate copyright notices and license terms. Your use of the source
* code for these subcomponents is subject to the terms and
* conditions of the subcomponent's license, as noted in the LICENSE file.
*/

package org.neo4j.ogm.test.domain;

import java.util.ArrayList;
import java.util.List;

import org.neo4j.ogm.annotation.Relationship;

/**
* @author Vince Bickers
*/
public class Person {

private Long id;
private String name;

@Relationship(type = "FRIEND_OF")
private List<Friendship> friends;

public Person() {
this.friends = new ArrayList<>();
}

public Person(String name) {
this();
this.name = name;
}

public List<Friendship> getFriends() {
return friends;
}

public String getName() {
return name;
}

public Long getId() {
return id;
}

public Friendship addFriend(Person newFriend) {
Friendship friendship = new Friendship(this, newFriend, 5);
this.friends.add(friendship);
return friendship;
}

}
39 changes: 39 additions & 0 deletions issue-331/src/main/java/org/neo4j/ogm/test/domain/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.neo4j.ogm.test.domain;

import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;

@NodeEntity
public class User {

@GraphId
private Long id;

private String firstName;

private String lastName;

private String email;

public User() {
// required by
}

public User(String email, String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public String getEmail() {
return email;
}
}
75 changes: 75 additions & 0 deletions issue-331/src/test/java/org/neo4j/ogm/test/OgmTestCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.neo4j.ogm.test;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.HashMap;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.ogm.model.Result;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.neo4j.ogm.test.domain.Person;
import org.neo4j.ogm.test.domain.User;

public class OgmTestCase {

@Rule
public Neo4jRule neoServer = new Neo4jRule();
private Session session;

@Before
public void setUp() throws Exception {

org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration();
configuration.driverConfiguration()
.setDriverClassName("org.neo4j.ogm.drivers.bolt.driver.BoltDriver")
.setURI(neoServer.boltURI().toString());
// .setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
// .setURI(neoServer.httpURI().toString());

SessionFactory sessionFactory = new SessionFactory(configuration, User.class.getPackage().getName());
session = sessionFactory.openSession();
session.purgeDatabase();
}

@Test
public void unidirectionalRelationshipTest() {

Person dave = new Person("Dave");
Person mike = new Person("Mike");

dave.addFriend(mike);

session.save(dave);

// Assert that the relationship is unidirectional from Dave -> Mike and not Dave <- Mike
String cypherRelationshipCount = "match (n)<-[r:FRIEND_OF]-(m) return count(r) as relationshipCount";
Result result = session.query(cypherRelationshipCount, new HashMap<String, Object>());
long relationshipCount = (long) result.iterator().next().get("relationshipCount");
assertThat(relationshipCount == 0);
cypherRelationshipCount = "match (n)-[r:FRIEND_OF]->(m) return count(r) as relationshipCount";
result = session.query(cypherRelationshipCount, new HashMap<String, Object>());
relationshipCount = (long) result.iterator().next().get("relationshipCount");
assertThat(relationshipCount == 1);

session.clear();

Person mikeLoaded = session.load(Person.class, mike.getId(), 2);
session.save(mikeLoaded);

// Assert that the relationship is unidirectional from Dave -> Mike and not Dave <- Mike
cypherRelationshipCount = "match (n)<-[r:FRIEND_OF]-(m) return count(r) as relationshipCount";
result = session.query(cypherRelationshipCount, new HashMap<String, Object>());
relationshipCount = (long) result.iterator().next().get("relationshipCount");
assertThat(relationshipCount == 0); // NOTE: The behavior described by zoetsekas would result in a count of 1
cypherRelationshipCount = "match (n)-[r:FRIEND_OF]->(m) return count(r) as relationshipCount";
result = session.query(cypherRelationshipCount, new HashMap<String, Object>());
relationshipCount = (long) result.iterator().next().get("relationshipCount");
assertThat(relationshipCount == 1);

}

}
Loading