Search in sources :

Example 61 with SourceResponse

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()));
}
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 62 with SourceResponse

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"));
}
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 63 with SourceResponse

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));
}
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 64 with SourceResponse

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);
}
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 65 with SourceResponse

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);
}
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

SourceResponse (ddf.catalog.operation.SourceResponse)199 Test (org.junit.Test)146 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)99 QueryImpl (ddf.catalog.operation.impl.QueryImpl)95 Result (ddf.catalog.data.Result)79 Metacard (ddf.catalog.data.Metacard)73 Filter (org.opengis.filter.Filter)58 QueryRequest (ddf.catalog.operation.QueryRequest)52 BinaryContent (ddf.catalog.data.BinaryContent)40 ResultImpl (ddf.catalog.data.impl.ResultImpl)29 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)25 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)24 Matchers.containsString (org.hamcrest.Matchers.containsString)24 Matchers.anyString (org.mockito.Matchers.anyString)21 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 Serializable (java.io.Serializable)20 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)19 SortByImpl (ddf.catalog.filter.impl.SortByImpl)18 Map (java.util.Map)16