Search in sources :

Example 1 with City

use of org.neo4j.ogm.domain.gh824.City in project kripton by xcesco.

the class TestFeatureRuntime2 method testRuntime.

@Test
public void testRuntime() {
    BindAppDataSource ds = BindAppDataSource.getInstance();
    ds.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
            DaoCityImpl dao = daoFactory.getDaoCity();
            long id1;
            long id2;
            City bean1 = new City();
            bean1.name = "city1";
            id1 = dao.insert(bean1);
            City bean2 = new City();
            bean2.name = "city2";
            id2 = dao.insert(bean2);
            long[] params = { id1, id2 };
            assertTrue(dao.selectAll(params).size() == 2);
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.in.case2.BindAppDataSource.Transaction) BindAppDataSource(sqlite.feature.in.case2.BindAppDataSource) BindAppDaoFactory(sqlite.feature.in.case2.BindAppDaoFactory) DaoCityImpl(sqlite.feature.in.case2.DaoCityImpl) City(sqlite.feature.in.case2.City) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 2 with City

use of org.neo4j.ogm.domain.gh824.City in project neo4j-ogm by neo4j.

the class DeepNestQueryingOfRelationshipEntitiesIntegrationTest method createData.

@Before
public void createData() {
    sessionFactory.openSession().purgeDatabase();
    Address a1 = new Address();
    a1.setCode("0001");
    Address a2 = new Address();
    a2.setCode("0002");
    City aachen = new City("Aachen");
    City koeln = new City("Köln");
    a2.setCity(aachen);
    User u1 = new User("U1");
    u1.setAddress(a1);
    User u2 = new User("Mr. User");
    u2.setAddress(a1);
    User u3 = new User();
    u3.setAddress(a2);
    UserGroup ug1 = new UserGroup();
    ug1.setCity(aachen);
    ug1.setName("EuregJUG");
    UserGroup ug2 = new UserGroup();
    ug2.setCity(koeln);
    ug2.setName("JUG Köln");
    List<GroupMember> members = Arrays.asList(new GroupMember(u1, ug1), new GroupMember(u2, ug2), new GroupMember(u3, ug2));
    Session session = sessionFactory.openSession();
    members.forEach(session::save);
}
Also used : GroupMember(org.neo4j.ogm.domain.gh824.GroupMember) User(org.neo4j.ogm.domain.gh824.User) Address(org.neo4j.ogm.domain.gh824.Address) City(org.neo4j.ogm.domain.gh824.City) UserGroup(org.neo4j.ogm.domain.gh824.UserGroup) Session(org.neo4j.ogm.session.Session) Before(org.junit.Before)

Example 3 with City

use of org.neo4j.ogm.domain.gh824.City in project neo4j-ogm by neo4j.

the class DeepNestQueryingOfRelationshipEntitiesIntegrationTest method nPlus1PathSegmentsShouldWork.

@Test
public void nPlus1PathSegmentsShouldWork() {
    Filter filter = new Filter("name", ComparisonOperator.EQUALS, "Aachen");
    filter.setOwnerEntityType(GroupMember.class);
    filter.setNestedPath(new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("address", Address.class), new Filter.NestedPathSegment("city", City.class));
    Collection<GroupMember> members = sessionFactory.openSession().loadAll(GroupMember.class, filter);
    assertThat(members).hasSize(1);
}
Also used : GroupMember(org.neo4j.ogm.domain.gh824.GroupMember) User(org.neo4j.ogm.domain.gh824.User) Address(org.neo4j.ogm.domain.gh824.Address) Filter(org.neo4j.ogm.cypher.Filter) City(org.neo4j.ogm.domain.gh824.City) Test(org.junit.Test)

Example 4 with City

use of org.neo4j.ogm.domain.gh824.City in project neo4j-ogm by neo4j.

the class DeepNestQueryingOfRelationshipEntitiesIntegrationTest method nPathSegmentsShouldWorkFromBothEnds.

@Test
public void nPathSegmentsShouldWorkFromBothEnds() {
    Filter outgoing = new Filter("code", ComparisonOperator.EQUALS, "0001");
    outgoing.setOwnerEntityType(GroupMember.class);
    outgoing.setNestedPath(new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("address", Address.class));
    Filter incoming = new Filter("name", ComparisonOperator.EQUALS, "Aachen");
    incoming.setOwnerEntityType(GroupMember.class);
    incoming.setNestedPath(new Filter.NestedPathSegment("group", UserGroup.class), new Filter.NestedPathSegment("city", City.class));
    Collection<GroupMember> members = sessionFactory.openSession().loadAll(GroupMember.class, outgoing.and(incoming));
    assertThat(members).hasSize(1);
}
Also used : GroupMember(org.neo4j.ogm.domain.gh824.GroupMember) User(org.neo4j.ogm.domain.gh824.User) Address(org.neo4j.ogm.domain.gh824.Address) Filter(org.neo4j.ogm.cypher.Filter) City(org.neo4j.ogm.domain.gh824.City) UserGroup(org.neo4j.ogm.domain.gh824.UserGroup) Test(org.junit.Test)

Example 5 with City

use of org.neo4j.ogm.domain.gh824.City in project kripton by xcesco.

the class TestFeatureRuntime1 method testRuntime.

@Test
public void testRuntime() {
    BindAppDataSource.getInstance().execute((BindAppDaoFactory daoFactory) -> {
        DaoCityImpl dao = daoFactory.getDaoCity();
        long id1;
        long id2;
        City bean1 = new City();
        bean1.name = "city1";
        id1 = dao.insert(bean1);
        City bean2 = new City();
        bean2.name = "city2";
        id2 = dao.insert(bean2);
        ArrayList<Long> params = new ArrayList<Long>();
        params.add(id1);
        params.add(id2);
        assertTrue(dao.selectAll2(params).size() == 2);
        return TransactionResult.COMMIT;
    });
}
Also used : BindAppDaoFactory(sqlite.feature.in.case1.BindAppDaoFactory) DaoCityImpl(sqlite.feature.in.case1.DaoCityImpl) ArrayList(java.util.ArrayList) City(sqlite.feature.in.case1.City) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

Test (org.junit.Test)7 BaseAndroidTest (base.BaseAndroidTest)4 City (org.neo4j.ogm.domain.gh824.City)4 GroupMember (org.neo4j.ogm.domain.gh824.GroupMember)4 Filter (org.neo4j.ogm.cypher.Filter)3 Address (org.neo4j.ogm.domain.gh824.Address)3 User (org.neo4j.ogm.domain.gh824.User)3 UserGroup (org.neo4j.ogm.domain.gh824.UserGroup)3 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)2 ArrayList (java.util.ArrayList)2 List (java.util.List)1 Before (org.junit.Before)1 RunWith (org.junit.runner.RunWith)1 Session (org.neo4j.ogm.session.Session)1 RobolectricTestRunner (org.robolectric.RobolectricTestRunner)1 Config (org.robolectric.annotation.Config)1 BindAppDaoFactory (sqlite.feature.in.case1.BindAppDaoFactory)1 City (sqlite.feature.in.case1.City)1 DaoCityImpl (sqlite.feature.in.case1.DaoCityImpl)1 BindAppDaoFactory (sqlite.feature.in.case2.BindAppDaoFactory)1