Search in sources :

Example 6 with ContentUriChecker

use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker in project kripton by xcesco.

the class TestUriChecker method testExtractParameters.

@Test
public void testExtractParameters() {
    String input = "content://androi.authority/test/${ input }/ test /${ detail.id}";
    ContentUriChecker checker = ContentUriChecker.getInstance();
    {
        List<ContentUriPlaceHolder> result = checker.extract(input);
        for (ContentUriPlaceHolder item : result) {
            log(item.toString());
        }
        checkList(result, new ContentUriPlaceHolder(1, "input"), new ContentUriPlaceHolder(3, "detail.id"));
    }
    {
        List<ContentUriPlaceHolder> result = checker.extract(input);
        for (ContentUriPlaceHolder item : result) {
            log(item.toString());
        }
        checkList(result, new ContentUriPlaceHolder(1, "input"), new ContentUriPlaceHolder(3, "detail.id"));
    }
}
Also used : ContentUriChecker(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker) ContentUriPlaceHolder(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder) ArrayList(java.util.ArrayList) List(java.util.List) BaseProcessorTest(base.BaseProcessorTest) Test(org.junit.Test)

Example 7 with ContentUriChecker

use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker in project kripton by xcesco.

the class TestUriChecker method testAuthorityWithVariableInPath.

@Test
public void testAuthorityWithVariableInPath() {
    String input = "content://androi.authority/test/${ input1 }/${input2   }";
    ContentUriChecker checker = ContentUriChecker.getInstance();
    // check bind parameters
    {
        List<ContentUriPlaceHolder> aspected = new ArrayList<>();
        aspected.add(new ContentUriPlaceHolder(1, "input1"));
        aspected.add(new ContentUriPlaceHolder(2, "input2"));
        List<ContentUriPlaceHolder> actual = checker.extract(input);
        checkCollectionExactly(actual, aspected);
    }
}
Also used : ContentUriChecker(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker) ContentUriPlaceHolder(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder) ArrayList(java.util.ArrayList) List(java.util.List) BaseProcessorTest(base.BaseProcessorTest) Test(org.junit.Test)

Example 8 with ContentUriChecker

use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker in project kripton by xcesco.

the class TestUriChecker method testOK.

/**
 * <p>
 * OK
 * </p>
 *
 * @throws Throwable
 */
@Test
public void testOK() throws Throwable {
    String input = "content://androi.authority/test/${ input }";
    log(input);
    ContentUriChecker checker = ContentUriChecker.getInstance();
    String actual = checker.replace(input, new UriPlaceHolderReplacerListener() {

        @Override
        public String onParameterName(int pathSegmentIndex, String name) {
            log("segment : %s, name: [%s]", pathSegmentIndex, name);
            return "?";
        }
    });
    assertEquals(actual, "content://androi.authority/test/?");
}
Also used : ContentUriChecker(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker) UriPlaceHolderReplacerListener(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener) BaseProcessorTest(base.BaseProcessorTest) Test(org.junit.Test)

Example 9 with ContentUriChecker

use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker in project kripton by xcesco.

the class TestUriChecker method testAuthorityWithVariableInPathError2.

@Test(expected = AssertionError.class)
public void testAuthorityWithVariableInPathError2() {
    String input = "content://androi.authority/test/#";
    ContentUriChecker checker = ContentUriChecker.getInstance();
    // verify sql
    checker.verify(input);
    // check bind parameters
    {
        List<ContentUriPlaceHolder> aspected = new ArrayList<>();
        aspected.add(new ContentUriPlaceHolder(1, "input0"));
        aspected.add(new ContentUriPlaceHolder(2, "input1"));
        List<ContentUriPlaceHolder> actual = checker.extract(input);
        checkCollectionExactly(actual, aspected);
    }
}
Also used : ContentUriChecker(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker) ContentUriPlaceHolder(com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder) ArrayList(java.util.ArrayList) List(java.util.List) BaseProcessorTest(base.BaseProcessorTest) Test(org.junit.Test)

Aggregations

BaseProcessorTest (base.BaseProcessorTest)9 ContentUriChecker (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker)9 Test (org.junit.Test)9 ContentUriPlaceHolder (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriPlaceHolder)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 UriPlaceHolderReplacerListener (com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener)3 ContentProviderURIParamsExtractor (com.abubusoft.kripton.android.sqlite.ContentProviderURIParamsExtractor)1