@Test
public void shouldFilterOutUndesiredRows() {

  // requested rows less than the rows available in the featureset
  GetOnlineFeaturesRequest request =
      getOnlineFeaturesRequest(
          List.of(FeatureReference.newBuilder().setName("feature1").build()));
  List<Optional<FeatureRow>> featureRows =
      List.of(Optional.of(testFeatureRows.get(0)), Optional.of(testFeatureRows.get(1)));
  FeatureSetRequest featureSetRequest =
      FeatureSetRequest.newBuilder()
          .addAllFeatureReferences(request.getFeaturesList())
          .setSpec(getFeatureSetSpec())
          .build();
  when(specService.getFeatureSets(request.getFeaturesList(), ""))
      .thenReturn(Collections.singletonList(featureSetRequest));
  when(retriever.getOnlineFeatures(request.getEntityRowsList(), featureSetRequest))
      .thenReturn(featureRows);
  when(tracer.buildSpan(ArgumentMatchers.any())).thenReturn(Mockito.mock(SpanBuilder.class));
  GetOnlineFeaturesResponse expected =
      GetOnlineFeaturesResponse.newBuilder()
          .addFieldValues(
              FieldValues.newBuilder()
                  .putFields("entity1", intValue(1))
                  .putStatuses("entity1", FieldStatus.PRESENT)
                  .putFields("entity2", strValue("a"))
                  .putStatuses("entity2", FieldStatus.PRESENT)
                  .putFields("feature1", intValue(1))
                  .putStatuses("feature1", FieldStatus.PRESENT)
                  .build())
          .addFieldValues(
              FieldValues.newBuilder()
                  .putFields("entity1", intValue(2))
                  .putStatuses("entity1", FieldStatus.PRESENT)
                  .putFields("entity2", strValue("b"))
                  .putStatuses("entity2", FieldStatus.PRESENT)
                  .putFields("feature1", intValue(2))
                  .putStatuses("feature1", FieldStatus.PRESENT)
                  .build())
          .build();
  GetOnlineFeaturesResponse actual = onlineServingService.getOnlineFeatures(request);
  assertThat(actual, equalTo(expected));
}