Skip to content

Commit

Permalink
Merge pull request #277 from flauschtrud/feature/nutritional-values
Browse files Browse the repository at this point in the history
Feature: Nutritional Values
  • Loading branch information
flauschtrud authored Dec 15, 2024
2 parents 42e29c0 + 1f0822d commit 5dedc13
Show file tree
Hide file tree
Showing 17 changed files with 946 additions and 530 deletions.
250 changes: 250 additions & 0 deletions app/schemas/com.flauschcode.broccoli.BroccoliDatabase/3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
{
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "d7cb3f8620655a8a3eeb770e4e8fdf10",
"entities": [
{
"tableName": "recipes",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`recipeId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `imageName` TEXT, `description` TEXT, `servings` TEXT, `preparationTime` TEXT, `source` TEXT, `ingredients` TEXT, `directions` TEXT, `nutritionalValues` TEXT, `notes` TEXT, `favorite` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "recipeId",
"columnName": "recipeId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "imageName",
"columnName": "imageName",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "servings",
"columnName": "servings",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "preparationTime",
"columnName": "preparationTime",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "ingredients",
"columnName": "ingredients",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "directions",
"columnName": "directions",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "nutritionalValues",
"columnName": "nutritionalValues",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "favorite",
"columnName": "favorite",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"recipeId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "categories",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`categoryId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT)",
"fields": [
{
"fieldPath": "categoryId",
"columnName": "categoryId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"categoryId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "recipes_with_categories",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`recipeId` INTEGER NOT NULL, `categoryId` INTEGER NOT NULL, PRIMARY KEY(`recipeId`, `categoryId`), FOREIGN KEY(`recipeId`) REFERENCES `recipes`(`recipeId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`categoryId`) REFERENCES `categories`(`categoryId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "recipeId",
"columnName": "recipeId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "categoryId",
"columnName": "categoryId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"recipeId",
"categoryId"
]
},
"indices": [
{
"name": "index_recipes_with_categories_recipeId",
"unique": false,
"columnNames": [
"recipeId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_recipes_with_categories_recipeId` ON `${TABLE_NAME}` (`recipeId`)"
},
{
"name": "index_recipes_with_categories_categoryId",
"unique": false,
"columnNames": [
"categoryId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_recipes_with_categories_categoryId` ON `${TABLE_NAME}` (`categoryId`)"
}
],
"foreignKeys": [
{
"table": "recipes",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"recipeId"
],
"referencedColumns": [
"recipeId"
]
},
{
"table": "categories",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"categoryId"
],
"referencedColumns": [
"categoryId"
]
}
]
},
{
"ftsVersion": "FTS4",
"ftsOptions": {
"tokenizer": "unicode61",
"tokenizerArgs": [
"tokenchars=#"
],
"contentTable": "recipes",
"languageIdColumnName": "",
"matchInfo": "FTS4",
"notIndexedColumns": [],
"prefixSizes": [],
"preferredOrder": "ASC"
},
"contentSyncTriggers": [
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_recipes_fts_BEFORE_UPDATE BEFORE UPDATE ON `recipes` BEGIN DELETE FROM `recipes_fts` WHERE `docid`=OLD.`rowid`; END",
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_recipes_fts_BEFORE_DELETE BEFORE DELETE ON `recipes` BEGIN DELETE FROM `recipes_fts` WHERE `docid`=OLD.`rowid`; END",
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_recipes_fts_AFTER_UPDATE AFTER UPDATE ON `recipes` BEGIN INSERT INTO `recipes_fts`(`docid`, `title`, `description`, `source`, `ingredients`) VALUES (NEW.`rowid`, NEW.`title`, NEW.`description`, NEW.`source`, NEW.`ingredients`); END",
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_recipes_fts_AFTER_INSERT AFTER INSERT ON `recipes` BEGIN INSERT INTO `recipes_fts`(`docid`, `title`, `description`, `source`, `ingredients`) VALUES (NEW.`rowid`, NEW.`title`, NEW.`description`, NEW.`source`, NEW.`ingredients`); END"
],
"tableName": "recipes_fts",
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`title` TEXT, `description` TEXT, `source` TEXT, `ingredients` TEXT, tokenize=unicode61 `tokenchars=#`, content=`recipes`)",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "ingredients",
"columnName": "ingredients",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": []
},
"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, 'd7cb3f8620655a8a3eeb770e4e8fdf10')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void save_new_recipe() throws IOException {
onView(withId(android.R.id.content)).perform(swipeUp()); // scrollTo() does not work for NestedScrollViews
onView(withId(R.id.new_ingredients)).perform(closeSoftKeyboard(), typeText(LAUCHKUCHEN.getIngredients())); // it seems not to be possible to make Espresso type the enter key in a deterministic way
onView(withId(R.id.new_directions)).perform(closeSoftKeyboard(), typeText(LAUCHKUCHEN.getDirections()));
onView(withId(R.id.new_nutritional_values)).perform(closeSoftKeyboard(), typeText(LAUCHKUCHEN.getNutritionalValues()));
onView(withId(R.id.new_notes)).perform(closeSoftKeyboard(), typeText(LAUCHKUCHEN.getNotes()));

onView(withId(R.id.button_save_recipe)).perform(click()); // TODO find out why there sometimes is such a long wait
Expand All @@ -158,6 +159,7 @@ public void save_new_recipe() throws IOException {
assertThat(recipe.getPreparationTime(), is(LAUCHKUCHEN.getPreparationTime()));
assertThat(recipe.getIngredients(), is(LAUCHKUCHEN.getIngredients()));
assertThat(recipe.getDirections(), is(LAUCHKUCHEN.getDirections()));
assertThat(recipe.getNutritionalValues(), is(LAUCHKUCHEN.getNutritionalValues()));
assertThat(recipe.getNotes(), is(LAUCHKUCHEN.getNotes()));
assertThat(recipe.getImageName(), startsWith("12345.jpg"));
assertThat(recipe.getCategories().size(), is(1));
Expand All @@ -181,6 +183,7 @@ public void edit_recipe(){
onView(withId(R.id.new_preparation_time)).check(matches(withText(LAUCHKUCHEN_SAVED.getPreparationTime())));
onView(withId(R.id.new_ingredients)).check(matches(withText(LAUCHKUCHEN_SAVED.getIngredients())));
onView(withId(R.id.new_directions)).check(matches(withText(LAUCHKUCHEN_SAVED.getDirections())));
onView(withId(R.id.new_nutritional_values)).check(matches(withText(LAUCHKUCHEN_SAVED.getNutritionalValues())));
onView(withId(R.id.new_notes)).check(matches(withText(LAUCHKUCHEN_SAVED.getNotes())));

onView(withId(R.id.new_servings)).perform(replaceText("1 Portion"));
Expand Down
Loading

0 comments on commit 5dedc13

Please sign in to comment.