AutocompletePredictionBuffer implements Result, DataBuffer<AutocompletePrediction> { @Nullable @Override public AutocompletePrediction get(int index) { if (predictions == null || index < 0 || index > predictions.size() - 1) { return null; } return predictions.get(index); } AutocompletePredictionBuffer(@NonNull Status status,
      @Nullable List<AutocompletePrediction> predictions); @NonNull @Override Status getStatus(); @Override int getCount(); @Nullable @Override AutocompletePrediction get(int index);  }
@Test public void get_shouldReturnCorrectPrediction() { AutocompletePrediction prediction = buffer.get(0); assertThat(prediction).isEqualTo(predictions.get(0)); }
@Test public void get_shouldReturnCorrectPrediction_nullPredictions() { buffer = new AutocompletePredictionBuffer(status, null); AutocompletePrediction prediction = buffer.get(0); assertThat(prediction).isNull(); }
@Test public void get_shouldReturnCorrectPrediction_badIndex() { AutocompletePrediction prediction = buffer.get(-1); assertThat(prediction).isNull(); prediction = buffer.get(100); assertThat(prediction).isNull(); }