Search in sources :

Example 1 with User

use of org.neo4j.ogm.domain.social.User in project neo4j-ogm by neo4j.

the class BasicDriverTest method shouldObtainQueryResultsWithStatistics.

@Test
public void shouldObtainQueryResultsWithStatistics() {
    session.save(new User("Bilbo Baggins"));
    session.save(new User("Frodo Baggins"));
    session.clear();
    Result result = session.query("MATCH (u:User) WHERE u.name =~ '.*Baggins' SET u.species = 'Hobbit' RETURN u.name", Collections.emptyMap());
    assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(2);
    assertThat(result.iterator().hasNext()).isTrue();
}
Also used : User(org.neo4j.ogm.domain.social.User) Result(org.neo4j.ogm.model.Result) Test(org.junit.Test)

Example 2 with User

use of org.neo4j.ogm.domain.social.User in project neo4j-ogm by neo4j.

the class BasicDriverTest method m2.

private void m2() {
    // inner transaction commits (defers commit)
    try (Transaction tx = session.beginTransaction()) {
        session.save(new User());
        tx.commit();
    }
}
Also used : User(org.neo4j.ogm.domain.social.User) Transaction(org.neo4j.ogm.transaction.Transaction)

Example 3 with User

use of org.neo4j.ogm.domain.social.User in project neo4j-ogm by neo4j.

the class BasicDriverTest method shouldQueryForObject.

// query tests
@Test
public void shouldQueryForObject() {
    session.save(new User("Bilbo Baggins"));
    session.clear();
    User bilbo = session.queryForObject(User.class, "MATCH(u:User) RETURN u", Collections.singletonMap("name", "Bilbo Baggins"));
    assertThat(bilbo).isNotNull();
}
Also used : User(org.neo4j.ogm.domain.social.User) Test(org.junit.Test)

Example 4 with User

use of org.neo4j.ogm.domain.social.User in project neo4j-ogm by neo4j.

the class BasicDriverTest method shouldObtainEmptyQueryResultsWithStatistics.

@Test
public void shouldObtainEmptyQueryResultsWithStatistics() {
    session.save(new User("Bilbo Baggins"));
    session.save(new User("Frodo Baggins"));
    session.clear();
    Result result = session.query("MATCH (u:User) WHERE u.name =~ '.*Baggins' SET u.species = 'Hobbit'", Collections.emptyMap());
    assertThat(result.queryStatistics().getPropertiesSet()).isEqualTo(2);
    assertThat(result.iterator().hasNext()).isFalse();
}
Also used : User(org.neo4j.ogm.domain.social.User) Result(org.neo4j.ogm.model.Result) Test(org.junit.Test)

Example 5 with User

use of org.neo4j.ogm.domain.social.User in project neo4j-ogm by neo4j.

the class BasicDriverTest method shouldLoadByIds.

@Test
public void shouldLoadByIds() {
    User bilbo = new User("Bilbo Baggins");
    User frodo = new User("Frodo Baggins");
    session.save(bilbo);
    session.save(frodo);
    session.clear();
    Collection<User> userByInstances = session.loadAll(User.class, Arrays.asList(frodo.getId(), bilbo.getId()));
    assertThat(userByInstances).isNotNull();
    assertThat(userByInstances).hasSize(2);
}
Also used : User(org.neo4j.ogm.domain.social.User) Test(org.junit.Test)

Aggregations

User (org.neo4j.ogm.domain.social.User)25 Test (org.junit.Test)23 Transaction (org.neo4j.ogm.transaction.Transaction)5 Filter (org.neo4j.ogm.cypher.Filter)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Result (org.neo4j.ogm.model.Result)3 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)3 SocialUser (org.neo4j.ogm.domain.social.SocialUser)2 CypherException (org.neo4j.ogm.exception.CypherException)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Stream (java.util.stream.Stream)1 Assertions (org.assertj.core.api.Assertions)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Ignore (org.junit.Ignore)1 WriteProtectionTarget (org.neo4j.ogm.context.WriteProtectionTarget)1