SessionDao { public void updateAllSync(List<Session> sessions) { speakerRelation().deleter().execute(); categoryRelation().deleter().execute(); placeRelation().deleter().execute(); for (Session session : sessions) { insertSpeaker(session.speaker); insertCategory(session.category); insertPlace(session.place); sessionRelation().upserter().execute(session); } } @Inject  SessionDao(OrmaDatabase orma); Session_Relation sessionRelation(); Observable<List<Session>> findAll(); Observable<List<Session>> findByChecked(); Observable<List<Session>> findByPlace(int placeId); Observable<List<Session>> findByCategory(int categoryId); void deleteAll(); void updateAllSync(List<Session> sessions); void updateAllAsync(List<Session> sessions); void updateChecked(Session session);  }
@Test public void testInsertAll() throws Exception { sessionDao.updateAllSync(SESSIONS); assertThat(orma.selectFromSpeaker().idEq(SPEAKER_ID1)).hasSize(1); assertThat(orma.selectFromPlace().idEq(PLACE_ID1)).hasSize(1); assertThat(orma.selectFromCategory().idEq(CATEGORY_ID1)).hasSize(1); assertThat(orma.selectFromSession().idEq(SESSION_ID1)).hasSize(1); }
@Test public void testInsertAllWithUpdate() throws Exception { sessionDao.updateAllSync(SESSIONS); SESSIONS.get(0).title = "updated title"; sessionDao.updateAllSync(SESSIONS); assertThat(orma.selectFromSession().idEq(SESSION_ID1).value().title) .isEqualTo("updated title"); }