Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Representation


    }

    @Test
    public void testGetNaturalTextWithLanguagesWithoutValues() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // test not present language
        Iterator<Text> esTexts = rep.get(field, "es");
        assertNotNull(esTexts);
        assertFalse(esTexts.hasNext());
        // test multiple not present languages
        Iterator<Text> frItTexts = rep.get(field, "fr", "it");
        assertNotNull(frItTexts);
        assertFalse(frItTexts.hasNext());
    }
View Full Code Here


    }

    @Test
    public void testGetNaturalTextWithAnyLanguageByParsingAnEmptyArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // test Iterator for any language (by parsing an empty list)
        Iterator<Text> allTexts = rep.get(field, new String[] {});
        assertNotNull(allTexts);
        assertTrue(asCollection(allTexts).size() == NL_TEST_all.size());
    }
View Full Code Here

    }

    @Test
    public void testGetNaturalTextWithAnyLanguageByParsingNullAsArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // test Iterator for any language (by parsing null)
        Iterator<Text> allTexts = rep.get(field, (String[]) null);
        assertNotNull(allTexts);
        assertTrue(asCollection(allTexts).size() == NL_TEST_all.size());
    }
View Full Code Here

    }

    @Test
    public void testRemoveNaturalTextWithWrongLanguage() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // Test removal of natural language
        // remove a specific test, but wrong language -> no effect
        rep.removeNaturalText(field, NL_TEST_en2, "de");
        assertTrue(asCollection(rep.get(field)).size() == NL_TEST_all.size());
    }
View Full Code Here

    }

    @Test
    public void testRemoveNaturalTextWithWrongNullLanguage() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // remove a specific text, but with wrong null language -> also no effect
        rep.removeNaturalText(field, NL_TEST_de, (String) null);
        assertTrue(asCollection(rep.get(field)).size() == NL_TEST_all.size());
    }
View Full Code Here

    }

    @Test
    public void testRemoveNaturalTextWithCorrectAndWrongLanguage() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // remove a specific text, parse one correct and one wrong lang
        rep.removeNaturalText(field, NL_TEST_en2, "de", "en");
        Set<String> textSet = new HashSet<String>(NL_TEST_all);
        // remove all remaining values
        for (Iterator<Text> texts = rep.getText(field); texts.hasNext(); textSet.remove(texts.next()
                .getText()))
            ;
        // and check that the value we expect to be removed is still in the set
        assertTrue(textSet.size() == 1);
        assertTrue(textSet.contains(NL_TEST_en2));
View Full Code Here

     * value with the parse same text.
     */
    @Test
    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithNullLanguage() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        Set<String> textSet = new HashSet<String>(NL_TEST_all);

        // remove a string value by parsing the text and null as language
        rep.removeNaturalText(field, NL_TEST_string, (String) null);
        for (Iterator<Text> texts = rep.getText(field); texts.hasNext(); textSet.remove(texts.next()
                .getText()))
            ;
        assertTrue(textSet.size() == 1); // only one element should be removed
        assertTrue(textSet.remove(NL_TEST_string)); // and this should be the stringTest
    }
View Full Code Here

     * with the parse same text.
     */
    @Test
    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithNoLanguage() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        Set<String> textSet = new HashSet<String>(NL_TEST_all);
        // remove a string value by parsing only the text
        rep.removeNaturalText(field, NL_TEST_string);
        textSet.addAll(Arrays.asList(NL_TEST_string, NL_TEST_noLang, NL_TEST_en, NL_TEST_en2, NL_TEST_de,
            NL_TEST_de_AT));
        for (Iterator<Text> texts = rep.getText(field); texts.hasNext(); textSet.remove(texts.next()
                .getText()))
            ;
        assertTrue(textSet.size() == 1); // only one element should be removed
        assertTrue(textSet.remove(NL_TEST_string)); // and this should be the stringTest
    }
View Full Code Here

     * and therefore remove the String value.
     */
    @Test
    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithEmptyLanguageArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        Set<String> textSet = new HashSet<String>(NL_TEST_all);
        // remove a string value by parsing an empty list of languages
        rep.removeNaturalText(field, NL_TEST_string, new String[] {});
        textSet.addAll(Arrays.asList(NL_TEST_string, NL_TEST_noLang, NL_TEST_en, NL_TEST_en2, NL_TEST_de,
            NL_TEST_de_AT));
        for (Iterator<Text> texts = rep.getText(field); texts.hasNext(); textSet.remove(texts.next()
                .getText()))
            ;
        assertTrue(textSet.size() == 1); // only one element should be removed
        assertTrue(textSet.remove(NL_TEST_string)); // and this should be the stringTest
        rep.add(field, NL_TEST_string); // re add the value for further tests
    }
View Full Code Here

    /**
     * Tests the feature to add one and the same natural language text for multiple languages
     */
    public void testAddNaturalLanguageTextForMultipleLanguages() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = createRepresentation(null);
        // add the same label for multiple language
        String[] languageArray = new String[] {"en", "de", null};
        rep.addNaturalText(field, NL_TEST_noLang, languageArray);
        Set<String> languages = new HashSet<String>(Arrays.asList(languageArray));
        Iterator<Text> texts = rep.get(field, (String[]) null);
        while (texts.hasNext()) {
            Text text = texts.next();
            assertTrue(languages.remove(text.getLanguage()));
            assertEquals(NL_TEST_noLang, text.getText());
        }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.model.Representation

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.