@Test
public void testEnd() throws SourceUnavailableException, IngestException {

  UpdateParent.UpdateField updateField = mock(UpdateParent.UpdateField.class);
  UpdateParent updateParent = new UpdateParent(updateField);
  UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
  CatalogFramework catalogFramework = mock(CatalogFramework.class);
  when(udpStreamProcessor.getCatalogFramework()).thenReturn(catalogFramework);
  when(udpStreamProcessor.getMetacardUpdateInitialDelay()).thenReturn(1L);
  Context context = mock(Context.class);
  when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
  Metacard parent = mock(Metacard.class);
  UpdateResponse updateResponse = mock(UpdateResponse.class);
  Update update = mock(Update.class);
  when(update.getNewMetacard()).thenReturn(parent);
  when(updateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(update));
  when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(updateResponse);
  updateParent.end(context, parent);
  verify(updateField).end(parent, context);
  ArgumentCaptor<UpdateRequest> captor = ArgumentCaptor.forClass(UpdateRequest.class);
  verify(catalogFramework).update(captor.capture());
  assertThat(captor.getValue().getUpdates().get(0).getValue(), is(parent));
}