@Test
  public void testCreateRemoteEntriesSourceUnavailable() throws Exception {
    Metacard remoteMetacard = getPopulatedTestRegistryMetacard();
    when(federationAdminService.getRegistryMetacards()).thenReturn(Collections.emptyList());
    when(federationAdminService.getRegistryMetacards(any(Set.class)))
        .thenReturn(Collections.singletonList(remoteMetacard));

    refreshRegistrySubscriptions.setRegistryStores(Collections.singletonList(registryStore));
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore.getId()).thenReturn(TEST_ID);
    when(registryStore.isAvailable()).thenReturn(false);

    refreshRegistrySubscriptions.refreshRegistrySubscriptions();

    verify(federationAdminService, never())
        .addRegistryEntries(Collections.singletonList(remoteMetacard), null);
  }
  @Test
  public void testNoUpdatesOnOlder() throws Exception {
    MetacardImpl localMcard = getPopulatedTestRegistryMetacard();
    Metacard remoteMcard =
        getPopulatedTestRegistryMetacard(RegistryObjectMetacardType.REGISTRY_ID, -5000L);

    when(federationAdminService.getRegistryMetacards())
        .thenReturn(Collections.singletonList(localMcard));
    when(federationAdminService.getRegistryMetacards(any(Set.class)))
        .thenReturn(Collections.singletonList(remoteMcard));

    refreshRegistrySubscriptions.setRegistryStores(Collections.singletonList(registryStore));
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore.getId()).thenReturn(TEST_ID);
    when(registryStore.isAvailable()).thenReturn(true);

    refreshRegistrySubscriptions.refreshRegistrySubscriptions();

    verify(federationAdminService, never()).updateRegistryEntry(any(Metacard.class));
  }
  @Test
  public void testMultipleRemoteSameEntry() throws Exception {
    MetacardImpl remoteMcard1 = getPopulatedTestRegistryMetacard();
    MetacardImpl remoteMcard2 = getPopulatedTestRegistryMetacard();
    List<Metacard> mcards = new ArrayList<>();
    mcards.add(remoteMcard1);
    mcards.add(remoteMcard2);

    when(federationAdminService.getRegistryMetacards()).thenReturn(Collections.emptyList());
    when(federationAdminService.getRegistryMetacards(any(Set.class))).thenReturn(mcards);

    refreshRegistrySubscriptions.setRegistryStores(Collections.singletonList(registryStore));
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore.getId()).thenReturn(TEST_ID);
    when(registryStore.isAvailable()).thenReturn(true);

    refreshRegistrySubscriptions.refreshRegistrySubscriptions();

    verify(federationAdminService)
        .addRegistryEntries(Collections.singletonList(remoteMcard1), null);
  }