use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class FanoutCatalogFrameworkTest method testReplaceSourceId.
@Test
public void testReplaceSourceId() {
QueryRequest request = new QueryRequestImpl(null);
List<Result> results = new ArrayList<Result>();
MetacardImpl newCard1 = new MetacardImpl();
newCard1.setSourceId(OLD_SOURCE_ID);
ResultImpl result1 = new ResultImpl(newCard1);
MetacardImpl newCard2 = new MetacardImpl();
newCard2.setSourceId(OLD_SOURCE_ID);
ResultImpl result2 = new ResultImpl(newCard2);
results.add(result1);
results.add(result2);
QueryResponse response = new QueryResponseImpl(request, results, 2);
QueryResponse newResponse = framework.getQueryOperations().replaceSourceId(response);
assertNotNull(newResponse);
List<Result> newResults = newResponse.getResults();
assertNotNull(newResults);
assertEquals(2, newResults.size());
Metacard card = new MetacardImpl();
for (Result newResult : newResults) {
card = newResult.getMetacard();
assertNotNull(card);
assertEquals(NEW_SOURCE_ID, card.getSourceId());
}
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class TestRegistryStore method testRegistryQueryNullGetId.
@Test
public void testRegistryQueryNullGetId() throws Exception {
Filter filter = filterBuilder.attribute(Metacard.TAGS).is().like().text(RegistryConstants.REGISTRY_TAG);
queryResults.add(new ResultImpl(getDefaultMetacard()));
QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
registryStore.setRegistryId("registryId");
SourceResponse answer = registryStore.query(testRequest);
List<Result> testResults = answer.getResults();
assertThat(testResults.size(), is(1));
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class TestRegistryStore method setup.
@Before
public void setup() throws Exception {
parser = new XmlParser();
marshaller = new MetacardMarshaller(new XmlParser());
context = mock(BundleContext.class);
provider = mock(Converter.class);
cswSourceConfiguration = new CswSourceConfiguration();
factory = mock(SecureCxfClientFactory.class);
transformer = mock(TransformerManager.class);
encryptionService = mock(EncryptionService.class);
configAdmin = mock(ConfigurationAdmin.class);
configuration = mock(Configuration.class);
subject = mock(Subject.class);
queryResults = new ArrayList<>();
registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {
@Override
protected void validateOperation() {
}
@Override
public boolean isAvailable() {
return availability;
}
@Override
protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
if (queryResults == null) {
throw new UnsupportedQueryException("Test - Bad Query");
}
return new SourceResponseImpl(queryRequest, queryResults);
}
@Override
protected CapabilitiesType getCapabilities() {
return mock(CapabilitiesType.class);
}
@Override
public void configureCswSource() {
}
;
@Override
protected Subject getSystemSubject() {
return subject;
}
@Override
BundleContext getBundleContext() {
return context;
}
});
registryStore.setFilterBuilder(filterBuilder);
registryStore.setFilterAdapter(filterAdapter);
registryStore.setConfigAdmin(configAdmin);
registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
registryStore.setSchemaTransformerManager(transformer);
registryStore.setAutoPush(true);
registryStore.setRegistryUrl("http://test.url:0101/example");
properties = new Hashtable<>();
properties.put(RegistryStoreImpl.ID, "registryId");
registryStore.setMetacardMarshaller(marshaller);
when(configAdmin.getConfiguration(any())).thenReturn(configuration);
when(configuration.getProperties()).thenReturn(properties);
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class TestRegistryStore method registryInfoQuery.
@Test
public void registryInfoQuery() throws Exception {
assertThat(registryStore.getRegistryId(), is(""));
queryResults.add(new ResultImpl(getDefaultMetacard()));
registryStore.registryInfoQuery();
ArgumentCaptor<QueryRequest> captor = ArgumentCaptor.forClass(QueryRequest.class);
verify(registryStore).query(captor.capture());
assertThat(captor.getValue().getPropertyValue(SecurityConstants.SECURITY_SUBJECT), notNullValue());
assertThat(registryStore.getRegistryId(), is("registryId"));
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class QueryApplication method executeCqlQuery.
private CqlQueryResponse executeCqlQuery(CqlRequest cqlRequest) throws UnsupportedQueryException, SourceUnavailableException, FederationException {
QueryRequest request = cqlRequest.createQueryRequest(catalogFramework.getId(), filterBuilder);
Stopwatch stopwatch = Stopwatch.createStarted();
QueryResponse response = catalogFramework.query(request);
stopwatch.stop();
return new CqlQueryResponse(cqlRequest.getId(), request, response, cqlRequest.getSource(), stopwatch.elapsed(TimeUnit.MILLISECONDS), cqlRequest.isNormalize(), filterAdapter, actionRegistry);
}
Aggregations