### Question:
JpaStorage implements Storage { @Override public DataFile getDatafile(int id) { return (DataFile) persistenceManager.pick("select f from DataFile f where f.id = ?1", id); } JpaStorage(PersistenceManager persistenceManager); @Override DataFile getDatafile(int id); @Override final DataFile getDatafile(final String path); @Override DataFile getDatafileWithTransaction(String path); void store(DataFile dataFile); @Override int storeWithTransaction(DataFile dataFile); @Override Observation getObservation(int id); @Override RelatedObservation getRelatedObservation(int id); @Override ReferenceObservation getReferenceObservation(int id); @Override final Sensor getSensor(final String sensorName); @Override Sensor getSensorWithTransaction(String sensorName); @Override void storeWithTransaction(Sensor sensor); @Override List<RelatedObservation> getRelatedObservations(String sensorName, Date startDate, Date stopDate); @Override void store(InsituObservation insituObservation);  }### Answer:
@Test public void testGetDataFile() { final String sql = "select f from DataFile f where f.path = ?1"; final String path = "/over/the/rainbow"; final DataFile dataFile = createDataFile(path); when(persistenceManager.pick(sql, path)).thenReturn(dataFile); final DataFile toolStorageDatafile = jpaStorage.getDatafile(path); assertNotNull(toolStorageDatafile); assertEquals(path, toolStorageDatafile.getPath()); verify(persistenceManager, times(1)).pick(sql, path); verifyNoMoreInteractions(persistenceManager); }
@Test public void testGetDataFile_ById() { final String sql = "select f from DataFile f where f.id = ?1"; final int id = 23; final DataFile dataFile = createDataFile(id); when(persistenceManager.pick(sql, id)).thenReturn(dataFile); final DataFile toolStorageDatafile = jpaStorage.getDatafile(id); assertNotNull(toolStorageDatafile); assertEquals(id, toolStorageDatafile.getId()); assertEquals("something", toolStorageDatafile.getPath()); verify(persistenceManager, times(1)).pick(sql, id); verifyNoMoreInteractions(persistenceManager); }