use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RefreshRegistryEntriesTest method testSubscriptionEntityRemoval.
@Test
public void testSubscriptionEntityRemoval() throws Exception {
Metacard localMetacard = getPopulatedTestRegistryMetacard("mcardId", "testRegId", 0, true);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMetacard));
Metacard remoteMetacard = getPopulatedTestRegistryMetacard("mcardId2", "testRegId2", 0, true);
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMetacard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.getId()).thenReturn(TEST_ID);
when(registryStore.getRegistryId()).thenReturn("remoteRegId");
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).deleteRegistryEntriesByMetacardIds(Collections.singletonList(localMetacard.getId()));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RefreshRegistryEntriesTest method testAddUpdateAndDeleteAtOnce.
@Test
public void testAddUpdateAndDeleteAtOnce() throws Exception {
//returned metacards
Metacard createdMetacard = getPopulatedTestRegistryMetacard("createId", "createRegId", 0, true);
Metacard updatedMetacard = getPopulatedTestRegistryMetacard("updateId", "updateRegId", 5000, true);
//local metacards
Metacard localUpdatedMetacard = getPopulatedTestRegistryMetacard("localUpdateId", "updateRegId", 0, true, "updateId");
Metacard localDeletedMetacard = getPopulatedTestRegistryMetacard("localDeleteId", "deleteRegId", 0, true, "deleteRemoteMcardId");
List<Result> remoteMcards = new ArrayList<>();
remoteMcards.add(new ResultImpl(createdMetacard));
remoteMcards.add(new ResultImpl(updatedMetacard));
List<Metacard> localMcards = new ArrayList<>();
localMcards.add(localDeletedMetacard);
localMcards.add(localUpdatedMetacard);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(localMcards);
when(registryStore.getRegistryId()).thenReturn("remoteRegId");
SourceResponse response = new SourceResponseImpl(null, remoteMcards);
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).addRegistryEntries(Collections.singletonList(createdMetacard), null);
verify(federationAdminService).updateRegistryEntry(updatedMetacard);
verify(federationAdminService).deleteRegistryEntriesByMetacardIds(Collections.singletonList("localDeleteId"));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RefreshRegistryEntriesTest method testNoUpdatesOnLocal.
@Test
public void testNoUpdatesOnLocal() throws Exception {
MetacardImpl localMcard = getPopulatedTestRegistryMetacard(TEST_METACARD_ID, RegistryObjectMetacardType.REGISTRY_ID, 0, true);
localMcard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
Metacard remoteMcard = getPopulatedTestRegistryMetacard("remoteMcardId", RegistryObjectMetacardType.REGISTRY_ID, 1000L);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMcard));
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMcard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService, never()).updateRegistryEntry(any(Metacard.class));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RefreshRegistryEntriesTest method testCreateRemoteEntries.
@Test
public void testCreateRemoteEntries() throws Exception {
Metacard remoteMetacard = getPopulatedTestRegistryMetacard();
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.emptyList());
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMetacard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).addRegistryEntries(Collections.singletonList(remoteMetacard), null);
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RefreshRegistryEntriesTest method testCreateRemoteEntriesSourceUnavailable.
@Test
public void testCreateRemoteEntriesSourceUnavailable() throws Exception {
Metacard remoteMetacard = getPopulatedTestRegistryMetacard();
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.emptyList());
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMetacard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(false);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService, never()).addRegistryEntries(Collections.singletonList(remoteMetacard), null);
}
Aggregations