TracingService extends RecordService { public Tracing save(ItemValuesMap itemValues, List<String> photoPaths) throws IOException { Tracing tracing = generateTracingFromItemValues(itemValues, generateUniqueId()); tracingDao.save(tracing); tracingPhotoDao.save(tracing, photoPaths); return tracing; } 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_save_tracing_when_give_item_values_and_item_values_map_have_register_date() throws IOException { String url = "http: Mockito.when(PrimeroAppConfiguration.getApiBaseUrl()).thenReturn(url); String uniqueId = "test save tracing"; ItemValuesMap itemValuesMap = new ItemValuesMap(); itemValuesMap.addStringItem(RELATION_AGE, "10"); itemValuesMap.addStringItem(CAREGIVER_NAME, "100"); itemValuesMap.addStringItem(INQUIRY_DATE, "1/1/2000"); List<String> photoPaths = Collections.EMPTY_LIST; TracingService tracingServiceSpy = spy(tracingService); when(tracingServiceSpy.generateUniqueId()).thenReturn(uniqueId); Tracing tracingTemp = new Tracing(); when(tracingDao.save(any(Tracing.class))).thenReturn(tracingTemp); Tracing expected = new Tracing(); when(tracingPhotoDao.save(tracingTemp, photoPaths)).thenReturn(expected); Tracing savedTracing = tracingServiceSpy.save(itemValuesMap, photoPaths); assertThat(savedTracing.getServerUrl(), is(TextUtils.lintUrl(url))); verify(tracingDao, times(1)).save(any(Tracing.class)); verify(tracingPhotoDao, times(1)).save(any(Tracing.class), anyList()); }