Package org.gradle.gradleplugin.foundation.search

Examples of org.gradle.gradleplugin.foundation.search.TextBlockSearchEditor


    /**
     * This does a basic search. Something simple expecting matches
     */
    public void testBasic() {
        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("error");
        criteria.setCaseSensitive(false);

        int matches = editor.searchAllText(TEXT_1, criteria);

        assertEquals("Failed to find the correct number of matches", 2, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("error", 10, 15),
                new TextBlockSearchEditor.SearchResult("ErRor", 42, 47));
    }
View Full Code Here


    /**
     * This searches with case sensitivity on.
     */
    public void testCaseSensitivity() {
        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("ErRor");
        criteria.setCaseSensitive(true);

        int matches = editor.searchAllText(TEXT_1, criteria);

        assertEquals("Failed to find the correct number of matches", 1, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("ErRor", 42, 47));
    }
View Full Code Here

     * Tests making sure the indices are correct. Note: the ending index will always be at least 1 more than the starting index. It's actually the start of the character after the match.
     */
    public void testIndices() {
        String textToSearch = "01234567890123456789";

        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("2");
        criteria.setCaseSensitive(false);

        int matches = editor.searchAllText(textToSearch, criteria);

        assertEquals("Failed to find the correct number of matches", 2, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("2", 2, 3),
                new TextBlockSearchEditor.SearchResult("2", 12, 13));
    }
View Full Code Here

     * Tests with 'null' for search for text. This is just to make sure nothing blows up.
     */
    public void testWithNoCriteria() {
        String textToSearch = "01234567890123456789";

        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch(null);
        criteria.setCaseSensitive(false);

        int matches = editor.searchAllText(textToSearch, criteria);

        assertEquals("Failed to find the correct number of matches", 0, matches);   //this tests the matches return result is correct

        assertEquals(0, editor.getMatchedResults().size());
    }
View Full Code Here

    /**
     * Tests with 'null' for the text to search. This is just to make sure nothing blows up.
     */
    public void testWithSearchText() {
        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("a");
        criteria.setCaseSensitive(false);

        int matches = editor.searchAllText(null, criteria);

        assertEquals("Failed to find the correct number of matches", 0, matches);   //this tests the matches return result is correct

        assertEquals(0, editor.getMatchedResults().size());
    }
View Full Code Here

     * this resulted in getting the previous search results.
     */
    public void testSecondSearchBlank() {
        String textToSearch = "01234567890123456789";

        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("2");
        criteria.setCaseSensitive(false);

        int matches = editor.searchAllText(textToSearch, criteria);

        assertEquals("Failed to find the correct number of matches", 2, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("2", 2, 3),
                new TextBlockSearchEditor.SearchResult("2", 12, 13));

        criteria.setTextToMatch("");
        criteria.setCaseSensitive(false);

        matches = editor.searchAllText(textToSearch, criteria);

        assertEquals("Failed to find the correct number of matches", 0, matches);   //this tests the matches return result is correct

        assertEquals(0, editor.getMatchedResults().size());
    }
View Full Code Here

    /**
     * This does a simple test of searching via a regular expression. This one is case insensitive.
     */
    public void testBasicRegularExpressions() {
        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("error [1-9]:");
        criteria.setCaseSensitive(false);
        criteria.setUseRegularExpressions(true);

        int matches = editor.searchAllText(TEXT_1, criteria);

        assertEquals("Failed to find the correct number of matches", 2, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("error 1:", 10, 18),
                new TextBlockSearchEditor.SearchResult("ErRor 2:", 42, 50));
    }
View Full Code Here

    /**
     * This does a simple test of searching via a regular expression but is case sensitive.
     */
    public void testCaseSensitiveRegularExpressions() {
        TextBlockSearchEditor editor = new TextBlockSearchEditor();
        BasicTextSearchCriteria criteria = new BasicTextSearchCriteria();
        criteria.setTextToMatch("error [1-9]:");
        criteria.setCaseSensitive(true);
        criteria.setUseRegularExpressions(true);

        int matches = editor.searchAllText(TEXT_1, criteria);

        assertEquals("Failed to find the correct number of matches", 1, matches);   //this tests the matches return result is correct

        TestUtility.assertListContents(editor.getMatchedResults(), new TextBlockSearchEditor.SearchResult("error 1:", 10, 18));
    }
View Full Code Here

TOP

Related Classes of org.gradle.gradleplugin.foundation.search.TextBlockSearchEditor

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.