use of ddf.catalog.transform.QueryFilterTransformer in project ddf by codice.
the class CswQueryFactoryTest method setUp.
@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
CswRecordMap cswRecordMap = new MetacardCswRecordMap();
queryFactory = new CswQueryFactory(cswRecordMap, filterBuilder, filterAdapter, new PermissionsImpl());
AttributeRegistryImpl attributeRegistry = new AttributeRegistryImpl();
attributeRegistry.registerMetacardType(getCswMetacardType());
queryFactory.setAttributeRegistry(attributeRegistry);
polygon = new WKTReader().read(POLYGON_STR);
gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
filterObjectFactory = new ObjectFactory();
queryFilterTransformerProvider = mock(QueryFilterTransformerProvider.class);
QueryFilterTransformer cswQueryFilter = new CswQueryFilterTransformer(new MetacardCswRecordMap(), attributeRegistry);
when(queryFilterTransformerProvider.getTransformer(new QName(CswConstants.CSW_OUTPUT_SCHEMA, "Record"))).thenReturn(Optional.of(cswQueryFilter));
when(queryFilterTransformerProvider.getTransformer(anyString())).thenReturn(Optional.of(cswQueryFilter));
queryFactory.setQueryFilterTransformerProvider(queryFilterTransformerProvider);
}
use of ddf.catalog.transform.QueryFilterTransformer in project ddf by codice.
the class ValidatorTest method setUp.
@Before
public void setUp() throws Exception {
QName[] qname = { new QName(CswConstants.CSW_OUTPUT_SCHEMA, CswConstants.CSW_RECORD_LOCAL_NAME) };
qNameList = Arrays.asList(qname);
transformerManager = mock(TransformerManager.class);
validator = new Validator();
QueryFilterTransformerProvider transformerProvider = mock(QueryFilterTransformerProvider.class);
QueryFilterTransformer transformer = mock(QueryFilterTransformer.class);
when(transformerProvider.getTransformer(any(QName.class))).thenReturn(Optional.empty());
when(transformerProvider.getTransformer(qname[0])).thenReturn(Optional.of(transformer));
validator.setQueryFilterTransformerProvider(transformerProvider);
}
use of ddf.catalog.transform.QueryFilterTransformer in project ddf by codice.
the class CswQueryFilterTransformerProvider method getTransformer.
private QueryFilterTransformer getTransformer(ServiceReference<QueryFilterTransformer> reference) {
BundleContext bundleContext = getBundleContext();
QueryFilterTransformer transformer = bundleContext.getService(reference);
if (transformer == null) {
LOGGER.debug("Failed to find a QueryFilterTransformer with service reference {}", reference);
throw new IllegalStateException("Attempted to retrieve an unregistered service: " + reference);
}
return transformer;
}
use of ddf.catalog.transform.QueryFilterTransformer in project ddf by codice.
the class CswEndpointTest method setUpBeforeClass.
@org.junit.Before
public void setUpBeforeClass() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException, CswException, InvalidSyntaxException {
addSecurity();
URI mockUri = new URI(SAMPLE_NAME_SPACE);
when(mockUriInfo.getBaseUri()).thenReturn(mockUri);
URL resourceUrl = CswEndpointTest.class.getResource("/record.xsd");
URL resourceUrlDot = CswEndpointTest.class.getResource(".");
when(mockBundle.getResource(RECORD_SCHEMA_LOCATION)).thenReturn(resourceUrl);
when(mockBundle.getResource(CSW_SCHEMA_LOCATION)).thenReturn(resourceUrl);
when(mockBundle.getResource(GMD_SCHEMA_LOCATION)).thenReturn(resourceUrl);
when(mockBundle.getResource(".")).thenReturn(resourceUrlDot);
when(mockBundle.getBundleContext()).thenReturn(mockBundleContext);
ServiceReference<QueryFilterTransformer> serviceReference = mock(ServiceReference.class);
when(serviceReference.getProperty(QueryFilterTransformer.QUERY_FILTER_TRANSFORMER_TYPE_NAMES_FIELD)).thenReturn(ImmutableList.of(CswConstants.CSW_RECORD, THIRD_PARTY_TYPE_NAME));
when(mockBundleContext.getServiceReferences(QueryFilterTransformer.class, null)).thenReturn(Collections.singletonList(serviceReference));
when(mockCswActionTransformerProvider.getTransformer(anyString())).thenReturn(Optional.empty());
csw = new CswEndpointStub(catalogFramework, mockMimeTypeManager, mockSchemaManager, mockInputManager, mockCswActionTransformerProvider, validator, queryFactory, mockBundle);
csw.setUri(mockUriInfo);
csw.init();
when(mockMimeTypeManager.getAvailableMimeTypes()).thenReturn(Arrays.asList(MediaType.APPLICATION_XML));
when(mockSchemaManager.getAvailableSchemas()).thenReturn(new ArrayList<>(Arrays.asList(CswConstants.CSW_OUTPUT_SCHEMA)));
when(mockSchemaManager.getTransformerBySchema(CswConstants.CSW_OUTPUT_SCHEMA)).thenReturn(mockTransformer);
when(mockSchemaManager.getTransformerSchemaForId(CswConstants.CSW_RECORD)).thenReturn(CswConstants.CSW_NAMESPACE_URI);
when(mockInputManager.getAvailableIds()).thenReturn(Arrays.asList(CswConstants.CSW_RECORD));
reset(catalogFramework);
queryResponseBatch = getQueryResponseBatch(20, BATCH_TOTAL);
QueryResponse[] qrRest = queryResponseBatch.subList(1, queryResponseBatch.size()).toArray(new QueryResponse[0]);
when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponseBatch.get(0), qrRest);
when(catalogFramework.getSourceIds()).thenReturn(new HashSet<>(Arrays.asList("source1", "source2", "source3")));
CreateResponseImpl createResponse = new CreateResponseImpl(null, null, Arrays.asList(new MetacardImpl()));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
QueryRequest queryRequest = mock(QueryRequest.class);
Query query = mock(Query.class);
when(query.getStartIndex()).thenReturn(1);
when(query.getSortBy()).thenReturn(mock(SortBy.class));
when(query.requestsTotalResultsCount()).thenReturn(true);
when(query.getTimeoutMillis()).thenReturn(1L);
when(queryRequest.getQuery()).thenReturn(query);
when(queryFactory.getQuery(any(GetRecordsType.class))).thenReturn(queryRequest);
when(queryFactory.getQuery(any(QueryConstraintType.class), anyString())).thenReturn(queryRequest);
when(queryFactory.updateQueryRequestTags(any(QueryRequest.class), anyString())).thenReturn(queryRequest);
when(queryFactory.getQueryById(anyList())).thenReturn(queryRequest);
}
use of ddf.catalog.transform.QueryFilterTransformer in project ddf by codice.
the class CswQueryFactoryTest method addQueryFilterTransformer.
private void addQueryFilterTransformer(String namespace, QueryRequest request) {
QueryFilterTransformer transformer = mock(QueryFilterTransformer.class);
when(transformer.transform(any(), any())).thenReturn(request);
when(queryFilterTransformerProvider.getTransformer(namespace)).thenReturn(Optional.of(transformer));
}
Aggregations