Package org.apache.stanbol.entityhub.test.query

Examples of org.apache.stanbol.entityhub.test.query.FieldQueryTestCase


        executeQuery(test);
       
    }

    private void testFieldQueryTextConstraints() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/usefulinc.com\\/ns\\/doap#name'],"+
                "'offset': '0',"+
                "'limit': '3',"+
View Full Code Here


        //default dataset :(
    }
   
    @Test
    public void testFieldQueryRangeConstraints() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label',"+
                    "'http:\\/\\/www.w3.org\\/1999\\/02\\/22-rdf-syntax-ns#type',"+
                    "'http:\\/\\/dbpedia.org\\/ontology\\/birthDate',"+
                    "'http:\\/\\/dbpedia.org\\/ontology\\/deathDate'],"+
                "'offset': '0',"+
                "'limit': '5',"+
                "'constraints': [{ "+
                    "'type': 'range', "+
                    "'field': 'http:\\/\\/dbpedia.org\\/ontology\\/birthDate', "+
                    "'lowerBound': '1946-07-01T00:00:00.000Z',"+
                    "'upperBound': '1946-08-31T23:59:59.999Z',"+
                    "'inclusive': true,"+
                    "'datatype': 'xsd:dateTime'"+
                "},{ "+
                    "'type': 'reference', "+
                    "'field': 'http:\\/\\/www.w3.org\\/1999\\/02\\/22-rdf-syntax-ns#type', "+
                    "'value': 'http:\\/\\/dbpedia.org\\/ontology\\/MusicalArtist', "+
                "}]"+
             "}",
             Arrays.asList( //list of expected results (3/5 found)
                 "http://dbpedia.org/resource/Linda_Ronstadt",
                 "http://dbpedia.org/resource/Barry_Gibb",
                 "http://dbpedia.org/resource/Jimmy_Webb"),
             Arrays.asList( //list of required fields for results
                "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
                "http://www.w3.org/2000/01/rdf-schema#label",
                "http://dbpedia.org/ontology/birthDate"));
        //now execute the test
        executeQuery(test);
       
        //cities with more than 3 million inhabitants and an altitude over
        //1000 meter
        test = new FieldQueryTestCase(
            "{"+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label',"+
                    "'http:\\/\\/dbpedia.org\\/ontology\\/populationTotal',"+
                    "'http:\\/\\/www.w3.org\\/2003\\/01\\/geo\\/wgs84_pos#alt'],"+
View Full Code Here

        executeQuery(test);
    }
   
    @Test
    public void testFieldQueryTextConstraints() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '10',"+
                "'constraints': [{ "+
                    "'type': 'text', "+
                    "'language': 'de', "+
                    "'patternType': 'wildcard', "+
                    "'text': 'Frankf*', "+
                    "'field': 'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label' "+
                "}]"+
             "}",
             Arrays.asList( //list of expected results
                 "http://dbpedia.org/resource/Frankfurt",
                 "http://dbpedia.org/resource/Eintracht_Frankfurt",
                 "http://dbpedia.org/resource/Frankfurt_Airport"),
             Arrays.asList( //list of required fields for results
                "http://www.w3.org/2000/01/rdf-schema#label"));
        //now execute the test
        executeQuery(test)
       
        test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '10',"+
View Full Code Here

    }
    @Test
    public void testMultiWordWildcardTextConstraints() throws IOException, JSONException {
        //this is specially for issue described in the first comment of
        //STANBOL-607
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '3',"+
View Full Code Here

        executeQuery(test)
    }
   
    @Test
    public void testFieldQueryValueConstraints() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '5',"+
                "'constraints': [{ "+
                    "'type': 'value',"+
                    "'value': '64',"+
                    "'field': 'http:\\/\\/www.w3.org\\/2003\\/01\\/geo\\/wgs84_pos#alt',"+
                    "'datatype': 'xsd:int'"+
                    "}]"+
             "}",
             Arrays.asList( //list of expected results
                 "http://dbpedia.org/resource/Manchester,_New_Hampshire",
                 "http://dbpedia.org/resource/Cornwall,_Ontario",
                 "http://dbpedia.org/resource/Lexington,_Massachusetts"
                 ),
             Arrays.asList( //list of required fields for results
                "http://www.w3.org/2000/01/rdf-schema#label"));
        //now execute the test
        executeQuery(test);
       
        // now the same query but with no datatype
        test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '3',"+
                "'constraints': [{ "+
                    "'type': 'value',"+
                    "'value': '64',"+ //NOTE this is a JSON String!
                    "'field': 'http:\\/\\/www.w3.org\\/2003\\/01\\/geo\\/wgs84_pos#alt',"+
                    "}]"+
             "}",
             false); //we expect no results, because the datatype should be xsd:string

        //a third time the same query (without a datatype), but now we parse a
        //JSON number as value
        test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '3',"+
View Full Code Here

        //now execute the test
        executeQuery(test);
    }   
    @Test
    public void testFieldQueryMultiReferenceConstraints() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'rdfs:label',"+
                    "'rdf:type'],"+
                "'offset': '0',"+
View Full Code Here

    }
   
    @Test
    public void testFieldQueryMultipleValueConstraints() throws IOException, JSONException {
        //munich is on geo:alt 519 (will change to 518 on dbpedia 3.7)
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '3',"+
                "'constraints': [{ "+
                    "'type': 'value',"+
                    "'value': ['1288','519'],"+
                    "'field': 'http:\\/\\/www.w3.org\\/2003\\/01\\/geo\\/wgs84_pos#alt',"+
                    "'datatype': 'xsd:int'"+
                    "}]"+
             "}",
             Arrays.asList( //list of expected results
                 "http://dbpedia.org/resource/Munich", //519
                 "http://dbpedia.org/resource/Salt_Lake_City"), //1288
             Arrays.asList( //list of required fields for results
                "http://www.w3.org/2000/01/rdf-schema#label"));
        //now execute the test
        executeQuery(test);
       
        //a 2nd time the same query (without a datatype), but now we parse a
        //JSON number as value
        test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '3',"+
View Full Code Here

     * Tests that full text queries are possible by using the
     * {@link SpecialFieldEnum#fullText} field (STANBOL-596)
     */
    @Test
    public void testFullTextQuery() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '5',"+
View Full Code Here

     * @throws IOException
     * @throws JSONException
     */
    @Test
    public void testSemanticContextQuery() throws IOException, JSONException {
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '5',"+
View Full Code Here

     * @throws JSONException
     */
    @Test
    public void testConstraintValueModeQuery() throws IOException, JSONException {
        //First with mode = 'any' -> combine Entity Ranking with types
        FieldQueryTestCase test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '20',"+
                "'constraints': [{ "+
                    "'type': 'reference',"+
                    "'value': ["+
                        "'http:\\/\\/dbpedia.org\\/resource\\/Category:Capitals_in_Europe',"+
                        "'http:\\/\\/dbpedia.org\\/resource\\/Category:Host_cities_of_the_Summer_Olympic_Games',"+
                        "'http:\\/\\/dbpedia.org\\/ontology\\/City'"+
                    "],"+
                    "'field': 'entityhub-query:references',"+
                    "'mode': 'any'"+
                    "}]"+
             "}",
             Arrays.asList( //list of expected results
                 "http://dbpedia.org/resource/Berlin",
                 "http://dbpedia.org/resource/Amsterdam",
                 "http://dbpedia.org/resource/London",
                 "http://dbpedia.org/resource/Paris",
                 "http://dbpedia.org/resource/Rome"),
             Arrays.asList( //list of required fields for results
                "http://www.w3.org/2000/01/rdf-schema#label"));
        //now execute the test
        executeQuery(test);
       
        //Second query for Entities that do have relations to all three
        //Entities (NOTE: the dbp-ont:City type is missing for most of the
        //members of the two categories used in this example!)
        test = new FieldQueryTestCase(
            "{ "+
                "'selected': ["+
                    "'http:\\/\\/www.w3.org\\/2000\\/01\\/rdf-schema#label'],"+
                "'offset': '0',"+
                "'limit': '5',"+
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.test.query.FieldQueryTestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.