Search in sources :

Example 1 with CityPerson

use of sqlite.feature.many2many.case7.CityPerson in project kripton by xcesco.

the class TestRuntimeMany2Many7 method testMany2Many.

/**
 * Test many 2 many.
 *
 * @throws InterruptedException
 *             the interrupted exception
 */
@Test
public void testMany2Many() throws InterruptedException {
    BindAppDataSource ds = BindAppDataSource.getInstance();
    ds.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
            List<City> cities = new ArrayList<City>();
            List<Person> persons = new ArrayList<Person>();
            CityDaoImpl cityDao = daoFactory.getCityDao();
            PersonDaoImpl personDao = daoFactory.getPersonDao();
            City2PersonDaoImpl m2mDao = daoFactory.getCity2PersonDao();
            // insert city
            for (int i = 0; i < 1; i++) {
                City bean = new City();
                bean.name = "city" + i;
                cityDao.insert(bean);
                cities.add(bean);
            }
            // insert person
            for (int i = 0; i < 1; i++) {
                Person bean = new Person();
                bean.name = "person" + i;
                personDao.insert(bean);
                persons.add(bean);
            }
            {
                // m2m
                CityPerson bean = new CityPerson(0, cities.get(0).id, persons.get(0).id);
                m2mDao.insert(bean);
            }
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) City2PersonDaoImpl(sqlite.feature.many2many.case7.City2PersonDaoImpl) PersonDaoImpl(sqlite.feature.many2many.case7.PersonDaoImpl) City2PersonDaoImpl(sqlite.feature.many2many.case7.City2PersonDaoImpl) City(sqlite.feature.many2many.case7.City) CityPerson(sqlite.feature.many2many.case7.CityPerson) CityDaoImpl(sqlite.feature.many2many.case7.CityDaoImpl) Transaction(sqlite.feature.many2many.case7.BindAppDataSource.Transaction) BindAppDataSource(sqlite.feature.many2many.case7.BindAppDataSource) BindAppDaoFactory(sqlite.feature.many2many.case7.BindAppDaoFactory) ArrayList(java.util.ArrayList) List(java.util.List) Person(sqlite.feature.many2many.case7.Person) CityPerson(sqlite.feature.many2many.case7.CityPerson) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)1 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 BindAppDaoFactory (sqlite.feature.many2many.case7.BindAppDaoFactory)1 BindAppDataSource (sqlite.feature.many2many.case7.BindAppDataSource)1 Transaction (sqlite.feature.many2many.case7.BindAppDataSource.Transaction)1 City (sqlite.feature.many2many.case7.City)1 City2PersonDaoImpl (sqlite.feature.many2many.case7.City2PersonDaoImpl)1 CityDaoImpl (sqlite.feature.many2many.case7.CityDaoImpl)1 CityPerson (sqlite.feature.many2many.case7.CityPerson)1 Person (sqlite.feature.many2many.case7.Person)1 PersonDaoImpl (sqlite.feature.many2many.case7.PersonDaoImpl)1