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);
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class TestWfsSource method testResultNumReturnedNegative.
@Test
public void testResultNumReturnedNegative() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
//Setup
final String TITLE = "title";
final String searchPhrase = "*";
final int pageSize = 1;
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 3, false, true, -1);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
query.setPageSize(pageSize);
SortBy sortBy = new SortByImpl(TITLE, SortOrder.DESCENDING);
query.setSortBy(sortBy);
QueryRequestImpl queryReq = new QueryRequestImpl(query);
// Perform test
SourceResponse resp = source.query(queryReq);
}
Aggregations