Search in sources :

Example 1 with SourceResponseImpl

use of ddf.catalog.operation.impl.SourceResponseImpl 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()));
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 2 with SourceResponseImpl

use of ddf.catalog.operation.impl.SourceResponseImpl 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"));
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 3 with SourceResponseImpl

use of ddf.catalog.operation.impl.SourceResponseImpl 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));
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 4 with SourceResponseImpl

use of ddf.catalog.operation.impl.SourceResponseImpl 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);
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 5 with SourceResponseImpl

use of ddf.catalog.operation.impl.SourceResponseImpl 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);
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Aggregations

SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)36 SourceResponse (ddf.catalog.operation.SourceResponse)24 ResultImpl (ddf.catalog.data.impl.ResultImpl)20 Result (ddf.catalog.data.Result)19 Test (org.junit.Test)19 Metacard (ddf.catalog.data.Metacard)17 QueryRequest (ddf.catalog.operation.QueryRequest)13 ArrayList (java.util.ArrayList)12 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)6 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)6 IOException (java.io.IOException)6 Query (ddf.catalog.operation.Query)5 BundleContext (org.osgi.framework.BundleContext)5 Matchers.anyString (org.mockito.Matchers.anyString)4 BinaryContent (ddf.catalog.data.BinaryContent)3 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)3 ResourceNotSupportedException (ddf.catalog.resource.ResourceNotSupportedException)3 Serializable (java.io.Serializable)3