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;
}
});
}
Aggregations