Search in sources :

Example 21 with User

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

the class BasicDriverTest method shouldLoadOne.

@Test
public void shouldLoadOne() {
    User user = new User();
    session.save(user);
    session.clear();
    User userByType = session.load(User.class, user.getId());
    assertThat(userByType).isNotNull();
}
Also used : User(org.neo4j.ogm.domain.social.User) Test(org.junit.Test)

Example 22 with User

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

the class BasicDriverTest method shouldNotFindExplicitlyRolledBackEntity.

@Test
public void shouldNotFindExplicitlyRolledBackEntity() {
    Transaction tx = session.beginTransaction();
    session.save(new User());
    tx.rollback();
    session.clear();
    assertThat(session.loadAll(User.class)).isEmpty();
}
Also used : User(org.neo4j.ogm.domain.social.User) Transaction(org.neo4j.ogm.transaction.Transaction) Test(org.junit.Test)

Example 23 with User

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

the class BasicDriverTest method shouldWrapUnderlyingException.

// GH-119
@Test
public void shouldWrapUnderlyingException() {
    session.save(new User("Bilbo Baggins"));
    try {
        session.query(User.class, "MATCH(u:User) WHERE u.name ~ '.*Baggins' RETURN u", Collections.emptyMap());
        fail("Expected a CypherException but got none");
    } catch (CypherException ce) {
        assertThat(ce.getCode().contains("Neo.ClientError.Statement")).isTrue();
    }
}
Also used : User(org.neo4j.ogm.domain.social.User) CypherException(org.neo4j.ogm.exception.CypherException) Test(org.junit.Test)

Example 24 with User

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

the class BasicDriverTest method shouldQueryForDomainObjects.

@Test
public void shouldQueryForDomainObjects() {
    session.save(new User("Bilbo Baggins"));
    session.save(new User("Frodo Baggins"));
    session.clear();
    Collection<User> users = (Collection) session.query(User.class, "MATCH(u:User) WHERE u.name =~ '.*Baggins' RETURN u", Collections.emptyMap());
    assertThat(users).isNotNull();
    assertThat(users).hasSize(2);
}
Also used : User(org.neo4j.ogm.domain.social.User) Collection(java.util.Collection) Test(org.junit.Test)

Example 25 with User

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

the class BasicDriverTest method shouldLoadByType.

// load tests
@Test
public void shouldLoadByType() {
    session.save(new User());
    session.clear();
    assertThat(session.loadAll(User.class)).hasSize(1);
}
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