TracingService extends RecordService { public Tracing update(ItemValuesMap itemValues, List<String> photoBitPaths) throws IOException { Tracing tracing = updateTracingFromItemValues(itemValues); tracing.setSynced(false); return tracingPhotoDao.update(tracingDao.update(tracing), photoBitPaths); } TracingService(TracingDao tracingDao, TracingPhotoDao tracingPhotoDao); Tracing getById(long tracingId); Tracing getByUniqueId(String uniqueId); List<Tracing> getAll(); List<Long> getAllOrderByDateASC(); List<Long> getAllOrderByDateDES(); List<Long> getSearchResult(String uniqueId, String name, int ageFrom, int ageTo, Date
            date); Tracing saveOrUpdate(ItemValuesMap itemValues, List<String> photoPaths); Tracing save(ItemValuesMap itemValues, List<String> photoPaths); Tracing update(ItemValuesMap itemValues,
                          List<String> photoBitPaths); Tracing deleteByRecordId(long recordId); Tracing getByInternalId(String id); boolean hasSameRev(String id, String rev); List<Long> getAllSyncedRecordsId(); static final String TAG; static final String TRACING_DISPLAY_ID; static final String TRACING_ID; static final String TRACING_PRIMARY_ID; }
@Test public void should_update_tracing_when_give_item_values() throws Exception { String uniqueId = "tracing"; ItemValuesMap itemValues = new ItemValuesMap(); itemValues.addStringItem(TRACING_ID, uniqueId); itemValues.addStringItem(RELATION_AGE, "18"); itemValues.addStringItem(CAREGIVER_NAME, "100"); itemValues.addStringItem(INQUIRY_DATE, "25/12/2016"); List<String> photoBitPaths = Collections.EMPTY_LIST; User user = new User("userName"); when(PrimeroAppConfiguration.getCurrentUser()).thenReturn(user); Tracing tracing = new Tracing(); when(tracingDao.getTracingByUniqueId(anyString())).thenReturn(tracing); tracing.setUniqueId(uniqueId); Tracing tracingTemp = new Tracing(); when(tracingDao.update(any(Tracing.class))).thenReturn(tracingTemp); Tracing expected = new Tracing(); when(tracingPhotoDao.update(tracingTemp, photoBitPaths)).thenReturn(expected); tracingService.update(itemValues, photoBitPaths); verify(tracingDao, times(1)).update(any(Tracing.class)); verify(tracingPhotoDao, times(1)).update(any(Tracing.class), anyList()); }