StoredQueryHandler { List<QName> collectAndSortFeatureTypesToExport( List<QName> configuredReturnFeatureTypes ) { Collection<FeatureType> featureTypes = wfs.getStoreManager().getFeatureTypes(); List<QName> ftNames = collectFeatureTypes( configuredReturnFeatureTypes, featureTypes ); Collections.sort( ftNames, new Comparator<QName>() { @Override public int compare( QName arg0, QName arg1 ) { String s0 = arg0.toString(); String s1 = arg1.toString(); return s0.compareTo( s1 ); } } ); return ftNames; } StoredQueryHandler( WebFeatureService wfs, List<URL> storedQueryTemplates,
                               File managedStoredQueryDirectory ); void doCreateStoredQuery( CreateStoredQuery request, HttpResponseBuffer response ); void doDescribeStoredQueries( DescribeStoredQueries request, HttpResponseBuffer response ); void doDropStoredQuery( DropStoredQuery request, HttpResponseBuffer response ); void doListStoredQueries( ListStoredQueries request, HttpResponseBuffer response ); boolean hasStoredQuery( String id ); URL getStoredQueryTemplate( String id ); static final String LANGUAGE_WFS_QUERY_EXPRESSION; static final String GET_FEATURE_BY_ID; static final String GET_FEATURE_BY_TYPE; }
@Test public void testCollectAndSortFeatureTypesToExport_AllFeatureTypes() { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), managedStoredQueries ); List<QName> configuredFeatureTypeNames = Collections.emptyList(); List<QName> featureTypeNamesToExport = storedQueryHandler.collectAndSortFeatureTypesToExport( configuredFeatureTypeNames ); assertThat( featureTypeNamesToExport.size(), is( featureTypes.size() ) ); for ( FeatureType featureType : featureTypes ) { assertThat( featureTypeNamesToExport, hasItems( featureType.getName() ) ); } }
@Test public void testCollectAndSortFeatureTypesToExport_EmptyFeatureTypeList() { List<FeatureType> featureTypes = Collections.emptyList(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), managedStoredQueries ); List<QName> configuredFeatureTypeNames = Collections.emptyList(); List<QName> featureTypeNamesToExport = storedQueryHandler.collectAndSortFeatureTypesToExport( configuredFeatureTypeNames ); assertThat( featureTypeNamesToExport.size(), is( 0 ) ); }
@Test public void testCollectAndSortFeatureTypesToExport_LimitedConfiguredFeatureTypes() { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), managedStoredQueries ); List<QName> configuredFeatureTypeNames = configuredFeatureTypeNames(); List<QName> featureTypeNamesToExport = storedQueryHandler.collectAndSortFeatureTypesToExport( configuredFeatureTypeNames ); assertThat( featureTypeNamesToExport.size(), is( 1 ) ); QName featureTypeNameToExport = featureTypeNamesToExport.get( 0 ); assertThat( featureTypeNameToExport.getLocalPart(), is( "one" ) ); assertThat( featureTypeNameToExport.getNamespaceURI(), is( "" ) ); assertThat( featureTypeNameToExport.getPrefix(), is( "" ) ); }