forked from novoda/sqlite-provider
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:novoda/SQLiteProvider
- Loading branch information
Showing
8 changed files
with
97 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package novoda.lib.sqliteprovider.util; | ||
|
||
import android.net.Uri; | ||
|
||
public class UriInspector { | ||
|
||
public UriInspector() { | ||
} | ||
|
||
public UriToSqlAttributes parse(Uri uri) { | ||
return new UriToSqlAttributes(uri); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/novoda/lib/sqliteprovider/util/UriToSqlAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package novoda.lib.sqliteprovider.util; | ||
|
||
import java.util.List; | ||
|
||
import android.net.Uri; | ||
|
||
public class UriToSqlAttributes { | ||
|
||
public Uri uri; | ||
public UriToSqlAttributes(Uri uri) { | ||
this.uri = uri; | ||
} | ||
|
||
public boolean hasWhereClauseInQuery() { | ||
if (uri.toString().split("\\?").length >=2){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/java/novoda/lib/sqliteprovider/util/UriToSqlAttributesInspectorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package novoda.lib.sqliteprovider.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import android.net.Uri; | ||
|
||
import com.xtremelabs.robolectric.RobolectricTestRunner; | ||
|
||
|
||
@RunWith(RobolectricTestRunner.class) | ||
public class UriToSqlAttributesInspectorTest { | ||
|
||
private UriInspector uriInspector = new UriInspector();; | ||
private UriToSqlAttributes attrs = null; | ||
|
||
private void setup() { | ||
uriInspector = new UriInspector(); | ||
} | ||
|
||
@Test | ||
public void testUriInspectorCreationBehaviour(){ | ||
attrs = uriInspector.parse(Uri.parse("content://test.com/item/1")); | ||
assertEquals("content://test.com/item/1", attrs.uri.toString()); | ||
} | ||
|
||
@Test | ||
public void testHasWhereClauseInQuery(){ | ||
attrs = uriInspector.parse(Uri.parse("content://test.com/item/1")); | ||
assertFalse(attrs.hasWhereClauseInQuery()); | ||
attrs = uriInspector.parse(Uri.parse("content://test.com/tableName?groupBy=col&having=value")); | ||
assertTrue(attrs.hasWhereClauseInQuery()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters