Search in sources :

Example 6 with GraphModelRequest

use of org.neo4j.ogm.request.GraphModelRequest in project neo4j-ogm by neo4j.

the class StrictQueryingTest method shouldUseOnlyOneLabelForAllStandardEntities.

// GH-651
@Test
public void shouldUseOnlyOneLabelForAllStandardEntities() {
    LoadByTypeDelegate delegate = new LoadByTypeDelegate(neo4jSession);
    delegate.loadAll(SomeEntity.class);
    ArgumentCaptor<GraphModelRequest> argumentCaptor = ArgumentCaptor.forClass(GraphModelRequest.class);
    verify(request).execute(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getStatement()).isEqualTo("MATCH (n:`SomeEntity`) WITH n MATCH p=(n)-[*0..1]-(m) RETURN p");
}
Also used : GraphModelRequest(org.neo4j.ogm.request.GraphModelRequest) LoadByTypeDelegate(org.neo4j.ogm.session.delegates.LoadByTypeDelegate) Test(org.junit.Test)

Example 7 with GraphModelRequest

use of org.neo4j.ogm.request.GraphModelRequest in project neo4j-ogm by neo4j.

the class StrictQueryingTest method shouldUseOnlyOneLabelForRelationshipEntities.

// GH-651
@Test
public void shouldUseOnlyOneLabelForRelationshipEntities() {
    LoadByIdsDelegate delegate = new LoadByIdsDelegate(neo4jSession);
    delegate.loadAll(SomeRelationshipEntity.class, Arrays.asList(1L, 2L));
    ArgumentCaptor<GraphModelRequest> argumentCaptor = ArgumentCaptor.forClass(GraphModelRequest.class);
    verify(request).execute(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getStatement()).startsWith("MATCH ()-[r0:`SOME_RELATIONSHIP`]-() WHERE ID(r0) IN $ids");
}
Also used : GraphModelRequest(org.neo4j.ogm.request.GraphModelRequest) LoadByIdsDelegate(org.neo4j.ogm.session.delegates.LoadByIdsDelegate) Test(org.junit.Test)

Example 8 with GraphModelRequest

use of org.neo4j.ogm.request.GraphModelRequest in project neo4j-ogm by neo4j.

the class StrictQueryingTest method shouldUseOnlyOneLabelForOneStandardEntity.

// GH-651
@Test
public void shouldUseOnlyOneLabelForOneStandardEntity() {
    LoadOneDelegate delegate = new LoadOneDelegate(neo4jSession);
    delegate.load(SomeEntity.class, 4711L);
    ArgumentCaptor<GraphModelRequest> argumentCaptor = ArgumentCaptor.forClass(GraphModelRequest.class);
    verify(request).execute(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getStatement()).isEqualTo("MATCH (n:`SomeEntity`) WHERE ID(n) = $id WITH n MATCH p=(n)-[*0..1]-(m) RETURN p");
}
Also used : GraphModelRequest(org.neo4j.ogm.request.GraphModelRequest) LoadOneDelegate(org.neo4j.ogm.session.delegates.LoadOneDelegate) Test(org.junit.Test)

Example 9 with GraphModelRequest

use of org.neo4j.ogm.request.GraphModelRequest in project neo4j-ogm by neo4j.

the class StrictQueryingTest method shouldUseAllLabelsForOneEntityInInheritanceScenario.

// GH-651
@Test
public void shouldUseAllLabelsForOneEntityInInheritanceScenario() {
    LoadOneDelegate delegate = new LoadOneDelegate(neo4jSession);
    delegate.load(PersistentCategory.class, "abc");
    ArgumentCaptor<GraphModelRequest> argumentCaptor = ArgumentCaptor.forClass(GraphModelRequest.class);
    verify(request).execute(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getStatement()).isEqualTo("MATCH (n:`Category`:`Entity`) WHERE n.`uuid` = $id WITH n MATCH p=(n)-[*0..1]-(m) RETURN p");
}
Also used : GraphModelRequest(org.neo4j.ogm.request.GraphModelRequest) LoadOneDelegate(org.neo4j.ogm.session.delegates.LoadOneDelegate) Test(org.junit.Test)

Example 10 with GraphModelRequest

use of org.neo4j.ogm.request.GraphModelRequest in project neo4j-ogm by neo4j.

the class StrictQueryingTest method shouldUseAllLabelsInInheritanceScenario.

// GH-651
@Test
public void shouldUseAllLabelsInInheritanceScenario() {
    LoadByIdsDelegate delegate = new LoadByIdsDelegate(neo4jSession);
    delegate.loadAll(PersistentCategory.class, Collections.singletonList("abc"));
    ArgumentCaptor<GraphModelRequest> argumentCaptor = ArgumentCaptor.forClass(GraphModelRequest.class);
    verify(request).execute(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getStatement()).isEqualTo("MATCH (n:`Category`:`Entity`) WHERE n.`uuid` IN $ids WITH n MATCH p=(n)-[*0..1]-(m) RETURN p");
}
Also used : GraphModelRequest(org.neo4j.ogm.request.GraphModelRequest) LoadByIdsDelegate(org.neo4j.ogm.session.delegates.LoadByIdsDelegate) Test(org.junit.Test)

Aggregations

GraphModelRequest (org.neo4j.ogm.request.GraphModelRequest)11 Test (org.junit.Test)8 GraphRowModelMapper (org.neo4j.ogm.context.GraphRowModelMapper)3 DefaultGraphModelRequest (org.neo4j.ogm.cypher.query.DefaultGraphModelRequest)3 PagingAndSortingQuery (org.neo4j.ogm.cypher.query.PagingAndSortingQuery)3 GraphModel (org.neo4j.ogm.model.GraphModel)3 LoadByIdsDelegate (org.neo4j.ogm.session.delegates.LoadByIdsDelegate)3 LoadOneDelegate (org.neo4j.ogm.session.delegates.LoadOneDelegate)3 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)2 LoadByTypeDelegate (org.neo4j.ogm.session.delegates.LoadByTypeDelegate)2 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 GraphRowListModelMapper (org.neo4j.ogm.context.GraphRowListModelMapper)1 DefaultGraphRowListModelRequest (org.neo4j.ogm.cypher.query.DefaultGraphRowListModelRequest)1 SortOrder (org.neo4j.ogm.cypher.query.SortOrder)1 FieldInfo (org.neo4j.ogm.metadata.FieldInfo)1 GraphRowListModel (org.neo4j.ogm.model.GraphRowListModel)1 QueryStatements (org.neo4j.ogm.session.request.strategy.QueryStatements)1