CasePhotoService { public boolean hasUnSynced(long caseId) { return casePhotoDao.countUnSynced(caseId) > 0; } CasePhotoService(CasePhotoDao caseDao); static CasePhotoService getInstance(); CasePhoto getFirst(long caseId); CasePhoto getById(long id); List<Long> getIdsByCaseId(long caseId); boolean hasUnSynced(long caseId); void deleteByCaseId(long caseId); static final String TAG; }
@Test public void should_call_count_un_synced_by_case_photo_dao() throws Exception { when(casePhotoDao.countUnSynced(anyLong())).thenReturn(1L); boolean actual = casePhotoService.hasUnSynced(123L); verify(casePhotoDao, times(1)).countUnSynced(123L); assertTrue("When hasUnSynced() is more than zero, should return true", actual); }
@Test public void should_return_false_when_count_un_synced_less_then_zero() throws Exception { when(casePhotoDao.countUnSynced(anyLong())).thenReturn(-1L); assertThat("Should return false", casePhotoService.hasUnSynced(1L), is(false)); verify(casePhotoDao).countUnSynced(1L); }