@Test(timeout = 10000)
public void testSubsequentErrors()
    throws UnsupportedQueryException, SourceUnavailableException, FederationException {

  Throwable[] exceptions =
      new Throwable[FindChildrenStreamEndPlugin.MAX_SUBSEQUENT_ERROR_COUNT + 1];
  IntStream.range(0, FindChildrenStreamEndPlugin.MAX_SUBSEQUENT_ERROR_COUNT + 1)
      .forEach(i -> exceptions[i] = new SourceUnavailableException());
  when(catalogFramework.query(any())).thenThrow(exceptions);
  setIsParentDirty(true);
  findChildrenStreamEndPlugin.streamEnded(context);
  verify(handler, never())
      .handle(Matchers.eq(context), Matchers.eq(parentMetacard), any(List.class));
  verify(handler, times(1)).end(Matchers.eq(context), Matchers.eq(parentMetacard));
}