Search in sources :

Example 21 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestCswEndpoint method getQueryResponse.

private QueryResponse getQueryResponse() {
    List<Result> results = new LinkedList<>();
    for (int i = 0; i < RESULT_COUNT; i++) {
        Result result = new ResultImpl();
        results.add(result);
    }
    return new QueryResponseImpl(null, results, TOTAL_COUNT);
}
Also used : QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) LinkedList(java.util.LinkedList) Result(ddf.catalog.data.Result)

Example 22 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl 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 23 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl 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 24 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl 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 25 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl 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)

Aggregations

ResultImpl (ddf.catalog.data.impl.ResultImpl)114 Result (ddf.catalog.data.Result)74 Test (org.junit.Test)73 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)61 Metacard (ddf.catalog.data.Metacard)47 ArrayList (java.util.ArrayList)45 QueryRequest (ddf.catalog.operation.QueryRequest)33 SourceResponse (ddf.catalog.operation.SourceResponse)30 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)23 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)21 QueryResponse (ddf.catalog.operation.QueryResponse)20 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)18 DAG (org.codice.alliance.nsili.common.UCO.DAG)17 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)15 BinaryContent (ddf.catalog.data.BinaryContent)10 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)9 Product (org.codice.alliance.nsili.common.UID.Product)9 Query (ddf.catalog.operation.Query)7 PolicyResponse (ddf.catalog.plugin.PolicyResponse)7