-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #434 from willowtreeapps/chore/407-prepopulate-dat…
…abase-work-7 Chore/407 prepopulate database work 7
- Loading branch information
Showing
31 changed files
with
520 additions
and
196 deletions.
There are no files selected for viewing
146 changes: 146 additions & 0 deletions
146
app/schemas/com.willowtree.vocable.room.VocableDatabase/7.json
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,146 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 7, | ||
"identityHash": "8470b9d2d5d0ffc958410af9b6617d9c", | ||
"entities": [ | ||
{ | ||
"tableName": "Category", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`category_id` TEXT NOT NULL, `creation_date` INTEGER NOT NULL, `resource_id` INTEGER, `localized_name` TEXT, `hidden` INTEGER NOT NULL, `sort_order` INTEGER NOT NULL, PRIMARY KEY(`category_id`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "categoryId", | ||
"columnName": "category_id", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "creationDate", | ||
"columnName": "creation_date", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "resourceId", | ||
"columnName": "resource_id", | ||
"affinity": "INTEGER", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "localizedName", | ||
"columnName": "localized_name", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "hidden", | ||
"columnName": "hidden", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "sortOrder", | ||
"columnName": "sort_order", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"category_id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "Phrase", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`phrase_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `parent_category_id` TEXT, `creation_date` INTEGER NOT NULL, `last_spoken_date` INTEGER, `localized_utterance` TEXT, `sort_order` INTEGER NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "phraseId", | ||
"columnName": "phrase_id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "parentCategoryId", | ||
"columnName": "parent_category_id", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "creationDate", | ||
"columnName": "creation_date", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "lastSpokenDate", | ||
"columnName": "last_spoken_date", | ||
"affinity": "INTEGER", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "localizedUtterance", | ||
"columnName": "localized_utterance", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "sortOrder", | ||
"columnName": "sort_order", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"phrase_id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "PresetCategory", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`category_id` TEXT NOT NULL, `hidden` INTEGER NOT NULL, `sort_order` INTEGER NOT NULL, PRIMARY KEY(`category_id`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "categoryId", | ||
"columnName": "category_id", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "hidden", | ||
"columnName": "hidden", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "sortOrder", | ||
"columnName": "sort_order", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"category_id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"views": [], | ||
"setupQueries": [ | ||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8470b9d2d5d0ffc958410af9b6617d9c')" | ||
] | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/androidTest/java/com/willowtree/vocable/presets/RoomPresetCategoriesRepositoryTest.kt
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,32 @@ | ||
package com.willowtree.vocable.presets | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class RoomPresetCategoriesRepositoryTest { | ||
private fun createRepository(): RoomPresetCategoriesRepository { | ||
return RoomPresetCategoriesRepository(ApplicationProvider.getApplicationContext()) | ||
} | ||
|
||
@Test | ||
fun preset_categories_returned() = runTest { | ||
val repository = createRepository() | ||
|
||
assertEquals( | ||
PresetCategories.values().filter { it != PresetCategories.MY_SAYINGS }.map { | ||
Category.PresetCategory( | ||
it.id, | ||
it.initialSortOrder, | ||
false, | ||
it.getNameId() | ||
) | ||
}, | ||
repository.getPresetCategories() | ||
) | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/willowtree/vocable/ICategoriesUseCase.kt
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,12 @@ | ||
package com.willowtree.vocable | ||
|
||
import com.willowtree.vocable.presets.Category | ||
import com.willowtree.vocable.room.CategorySortOrder | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface ICategoriesUseCase { | ||
fun categories(): Flow<List<Category>> | ||
suspend fun updateCategoryName(categoryId: String, localizedName: Map<String, String>) | ||
suspend fun addCategory(categoryName: String, sortOrder: Int) | ||
suspend fun updateCategorySortOrders(categorySortOrders: List<CategorySortOrder>) | ||
} |
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/willowtree/vocable/presets/PresetCategoriesRepository.kt
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,5 @@ | ||
package com.willowtree.vocable.presets | ||
|
||
interface PresetCategoriesRepository { | ||
suspend fun getPresetCategories(): List<Category.PresetCategory> | ||
} |
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
Oops, something went wrong.