### Question:
CachedSpawnDataStore implements SpawnDataStore { @Override public String getChild(String parent, String childId) throws Exception { return cache.get(ImmutablePair.of(parent, childId)); } CachedSpawnDataStore(SpawnDataStore dataStore, long dataStoreCacheSize); @Override String getDescription(); @Override String get(String path); @Override Map<String, String> get(String[] paths); @Override void put(String path, String value); @Override void putAsChild(String parent, String childId, String value); @Override String getChild(String parent, String childId); @Override void deleteChild(String parent, String childId); @Override void delete(String path); @Override List<String> getChildrenNames(String path); @Override Map<String, String> getAllChildren(String path); @Override void close();  }### Answer:
@Test public void testGetChild() throws Exception { final String value = "value"; final PreparedStatement selectPreparedStatement = Mockito.mock(PreparedStatement.class); Mockito.doReturn(selectPreparedStatement).when(connection).prepareStatement(Mockito.eq("SELECT val FROM tableName WHERE path=? AND child=?")); final ResultSet resultSet = Mockito.mock(ResultSet.class); Mockito.when(selectPreparedStatement.executeQuery()).thenReturn(resultSet); Mockito.when(resultSet.next()).thenReturn(Boolean.TRUE, Boolean.FALSE); final Blob blob = Mockito.mock(Blob.class); Mockito.when(resultSet.getObject(1, Blob.class)).thenReturn(blob); Mockito.when(blob.getBytes(Mockito.anyLong(), Mockito.anyInt())).thenReturn(LZFEncoder.encode(value.getBytes())); final String result = cachedDataStore.getChild("key", "childId"); assertNotNull(result); assertEquals(value, result); Mockito.verify(selectPreparedStatement, Mockito.atLeastOnce()).executeQuery(); Mockito.verify(selectPreparedStatement).setString(Mockito.eq(1), Mockito.eq("key")); Mockito.verify(selectPreparedStatement).setString(Mockito.eq(2), Mockito.eq("childId")); }