use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener 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("?"));
}
}
use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener in project kripton by xcesco.
the class TestUriChecker method testReplaceAuthorityWithVariable.
@Test
public void testReplaceAuthorityWithVariable() {
String input = "content://androi.authority/test/${field0}/${field1}";
String expected = "content://androi.authority/test/#/*";
log(input);
ContentUriChecker checker = ContentUriChecker.getInstance();
// verify sql
checker.verify(input);
// check bind parameters
{
String actual = checker.replace(input, new UriPlaceHolderReplacerListener() {
@Override
public String onParameterName(int pathSegmentIndex, String name) {
log("segment :" + pathSegmentIndex);
if (name.endsWith("0")) {
return "#";
}
;
return "*";
}
});
assertEquals(actual, expected);
{
List<ContentUriPlaceHolder> aspectedHolders = new ArrayList<>();
aspectedHolders.add(new ContentUriPlaceHolder(1, "field0"));
aspectedHolders.add(new ContentUriPlaceHolder(2, "field1"));
List<ContentUriPlaceHolder> actualHolders = checker.extract(input);
checkCollectionExactly(aspectedHolders, actualHolders);
}
}
}
use of com.abubusoft.kripton.processor.sqlite.grammars.uri.ContentUriChecker.UriPlaceHolderReplacerListener 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/?");
}
Aggregations