Search in sources :

Example 1 with ContentProviderURIParamsExtractor

use of com.abubusoft.kripton.android.sqlite.ContentProviderURIParamsExtractor in project kripton by xcesco.

the class TestUriChecker method testExtractor.

@Test
public void testExtractor() throws Throwable {
    String input = "content://androi.authority/master/${ master }/detail/${detail}/subdetail/${subdetail}";
    log(input);
    ContentUriChecker checker = ContentUriChecker.getInstance();
    Map<String, ContentUriPlaceHolder> parameters = checker.extractAsMap(input);
    String actual = checker.replace(input, new UriPlaceHolderReplacerListener() {

        @Override
        public String onParameterName(int pathSegmentIndex, String name) {
            log("segment : %s, name: %s", pathSegmentIndex, name);
            return "?";
        }
    });
    String expected = "content://androi.authority/master/?/detail/?/subdetail/?";
    assertEquals(actual, expected);
    log(expected);
    // log(""+expected.split("/").length);
    ContentProviderURIParamsExtractor extractor = new ContentProviderURIParamsExtractor(expected, input.split("/").length);
    for (ContentUriPlaceHolder item : parameters.values()) {
        assertTrue(extractor.getPathSegment(item.pathSegmentIndex).equals("?"));
    }
}
Also used : ContentUriChecker(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker) ContentUriPlaceHolder(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder) UriPlaceHolderReplacerListener(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener) ContentProviderURIParamsExtractor(com.abubusoft.kripton.android.sqlite.ContentProviderURIParamsExtractor) BaseProcessorTest(base.BaseProcessorTest) Test(org.junit.Test)

Aggregations

BaseProcessorTest (base.BaseProcessorTest)1 ContentProviderURIParamsExtractor (com.abubusoft.kripton.android.sqlite.ContentProviderURIParamsExtractor)1 ContentUriChecker (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker)1 UriPlaceHolderReplacerListener (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener)1 ContentUriPlaceHolder (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder)1 Test (org.junit.Test)1