Search in sources :

Example 1 with Transaction

use of sqlite.feature.foreignkeyaction.BindArtistDataSource.Transaction in project kripton by xcesco.

the class TestForeignKeyActionRuntime method testRun.

@Test
public void testRun() {
    BindArtistDataSource dataSource = BindArtistDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindArtistDaoFactory daoFactory) {
            ArtistDaoImpl daoArtist = daoFactory.getArtistDao();
            AlbumDaoImpl daoAlbum = daoFactory.getAlbumDao();
            Artist bean = new Artist();
            bean.name = "Tonj Manero";
            daoArtist.insert(bean);
            Album album = new Album();
            album.name = "First album";
            album.artistId = bean.id;
            daoAlbum.insert(album);
            Assert.assertTrue(daoArtist.selectAll().size() == 1);
            daoArtist.deleteById(bean.id);
            Assert.assertTrue(daoArtist.selectAll().size() == 0);
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.foreignkeyaction.BindArtistDataSource.Transaction) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)1 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)1 Test (org.junit.Test)1 Transaction (sqlite.feature.foreignkeyaction.BindArtistDataSource.Transaction)1