This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 493
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 #2002 from corona-warn-app/release/1.10.x
Release v1.10.1
- Loading branch information
Showing
199 changed files
with
8,241 additions
and
373 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
172 changes: 172 additions & 0 deletions
172
...na-Warn-App/schemas/de.rki.coronawarnapp.contactdiary.storage.ContactDiaryDatabase/1.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,172 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 1, | ||
"identityHash": "857201ec8eba4f3c64ca96c8975ceb69", | ||
"entities": [ | ||
{ | ||
"tableName": "locations", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`locationId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `locationName` TEXT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "locationId", | ||
"columnName": "locationId", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "locationName", | ||
"columnName": "locationName", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"locationId" | ||
], | ||
"autoGenerate": true | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "locationvisits", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `date` TEXT NOT NULL, `fkLocationId` INTEGER NOT NULL, FOREIGN KEY(`fkLocationId`) REFERENCES `locations`(`locationId`) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "date", | ||
"columnName": "date", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "fkLocationId", | ||
"columnName": "fkLocationId", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"id" | ||
], | ||
"autoGenerate": true | ||
}, | ||
"indices": [ | ||
{ | ||
"name": "index_locationvisits_fkLocationId", | ||
"unique": false, | ||
"columnNames": [ | ||
"fkLocationId" | ||
], | ||
"createSql": "CREATE INDEX IF NOT EXISTS `index_locationvisits_fkLocationId` ON `${TABLE_NAME}` (`fkLocationId`)" | ||
} | ||
], | ||
"foreignKeys": [ | ||
{ | ||
"table": "locations", | ||
"onDelete": "CASCADE", | ||
"onUpdate": "CASCADE", | ||
"columns": [ | ||
"fkLocationId" | ||
], | ||
"referencedColumns": [ | ||
"locationId" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"tableName": "persons", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`personId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `fullName` TEXT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "personId", | ||
"columnName": "personId", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "fullName", | ||
"columnName": "fullName", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"personId" | ||
], | ||
"autoGenerate": true | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "personencounters", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `date` TEXT NOT NULL, `fkPersonId` INTEGER NOT NULL, FOREIGN KEY(`fkPersonId`) REFERENCES `persons`(`personId`) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "date", | ||
"columnName": "date", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "fkPersonId", | ||
"columnName": "fkPersonId", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"id" | ||
], | ||
"autoGenerate": true | ||
}, | ||
"indices": [ | ||
{ | ||
"name": "index_personencounters_fkPersonId", | ||
"unique": false, | ||
"columnNames": [ | ||
"fkPersonId" | ||
], | ||
"createSql": "CREATE INDEX IF NOT EXISTS `index_personencounters_fkPersonId` ON `${TABLE_NAME}` (`fkPersonId`)" | ||
} | ||
], | ||
"foreignKeys": [ | ||
{ | ||
"table": "persons", | ||
"onDelete": "CASCADE", | ||
"onUpdate": "CASCADE", | ||
"columns": [ | ||
"fkPersonId" | ||
], | ||
"referencedColumns": [ | ||
"personId" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"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, '857201ec8eba4f3c64ca96c8975ceb69')" | ||
] | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
...rc/androidTest/java/de/rki/coronawarnapp/contactdiary/storage/ContactDiaryDatabaseTest.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,130 @@ | ||
package de.rki.coronawarnapp.contactdiary.storage | ||
|
||
import androidx.room.Room | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationEntity | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationVisitEntity | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationVisitWrapper | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEncounterEntity | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEncounterWrapper | ||
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEntity | ||
import io.kotest.matchers.shouldBe | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.runBlocking | ||
import org.joda.time.LocalDate | ||
import org.junit.After | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import testhelpers.BaseTest | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ContactDiaryDatabaseTest : BaseTest() { | ||
|
||
// TestData | ||
private val date = LocalDate.now() | ||
private val person = ContactDiaryPersonEntity(personId = 1, fullName = "Peter") | ||
private val location = ContactDiaryLocationEntity(locationId = 2, locationName = "Rewe Wiesloch") | ||
private val personEncounter = ContactDiaryPersonEncounterEntity(id = 3, date = date, fkPersonId = person.personId) | ||
private val locationVisit = ContactDiaryLocationVisitEntity(id = 4, date = date, fkLocationId = location.locationId) | ||
|
||
// DB | ||
private val contactDiaryDatabase: ContactDiaryDatabase = | ||
Room.inMemoryDatabaseBuilder( | ||
ApplicationProvider.getApplicationContext(), | ||
ContactDiaryDatabase::class.java | ||
) | ||
.build() | ||
|
||
private val personDao = contactDiaryDatabase.personDao() | ||
private val locationDao = contactDiaryDatabase.locationDao() | ||
private val personEncounterDao = contactDiaryDatabase.personEncounterDao() | ||
private val locationVisitDao = contactDiaryDatabase.locationVisitDao() | ||
|
||
private fun List<ContactDiaryPersonEncounterWrapper>.toContactDiaryPersonEncounterEntityList(): List<ContactDiaryPersonEncounterEntity> = | ||
this.map { it.contactDiaryPersonEncounterEntity } | ||
|
||
private fun List<ContactDiaryLocationVisitWrapper>.toContactDiaryLocationVisitEntityList(): List<ContactDiaryLocationVisitEntity> = | ||
this.map { it.contactDiaryLocationVisitEntity } | ||
|
||
@After | ||
fun teardown() { | ||
contactDiaryDatabase.clearAllTables() | ||
} | ||
|
||
@Test | ||
fun checkPersonEncounterDeletedWhenReferencedPersonDeleted() = runBlocking { | ||
val personFlow = personDao.allEntries() | ||
val personEncounterFlow = personEncounterDao | ||
.allEntries() | ||
.map { it.toContactDiaryPersonEncounterEntityList() } | ||
|
||
personFlow.first() shouldBe emptyList() | ||
personEncounterFlow.first() shouldBe emptyList() | ||
|
||
personDao.insert(person) | ||
personEncounterDao.insert(personEncounter) | ||
personFlow.first() shouldBe listOf(person) | ||
personEncounterFlow.first() shouldBe listOf(personEncounter) | ||
|
||
personDao.delete(person) | ||
personFlow.first() shouldBe emptyList() | ||
personEncounterFlow.first() shouldBe emptyList() | ||
} | ||
|
||
@Test | ||
fun checkLocationVisitDeletedWhenReferencedLocationDeleted() = runBlocking { | ||
val locationFlow = locationDao.allEntries() | ||
val locationVisitFlow = locationVisitDao | ||
.allEntries() | ||
.map { it.toContactDiaryLocationVisitEntityList() } | ||
|
||
locationFlow.first() shouldBe emptyList() | ||
locationVisitFlow.first() shouldBe emptyList() | ||
|
||
locationDao.insert(location) | ||
locationVisitDao.insert(locationVisit) | ||
locationFlow.first() shouldBe listOf(location) | ||
locationVisitFlow.first() shouldBe listOf(locationVisit) | ||
|
||
locationDao.delete(location) | ||
locationFlow.first() shouldBe emptyList() | ||
locationVisitFlow.first() shouldBe emptyList() | ||
} | ||
|
||
@Test | ||
fun getCorrectEntityForDate() = runBlocking { | ||
val yesterday = LocalDate.now().minusDays(1) | ||
val tomorrow = LocalDate.now().plusDays(1) | ||
val personEncounterYesterday = | ||
ContactDiaryPersonEncounterEntity(id = 5, date = yesterday, fkPersonId = person.personId) | ||
val personEncounterTomorrow = | ||
ContactDiaryPersonEncounterEntity(id = 6, date = tomorrow, fkPersonId = person.personId) | ||
val locationVisitYesterday = | ||
ContactDiaryLocationVisitEntity(id = 7, date = yesterday, fkLocationId = location.locationId) | ||
val locationVisitTomorrow = | ||
ContactDiaryLocationVisitEntity(id = 8, date = tomorrow, fkLocationId = location.locationId) | ||
val encounterList = listOf(personEncounter, personEncounterYesterday, personEncounterTomorrow) | ||
val visitList = listOf(locationVisit, locationVisitYesterday, locationVisitTomorrow) | ||
val personEncounterFlow = personEncounterDao.allEntries().map { it.toContactDiaryPersonEncounterEntityList() } | ||
val locationVisitFlow = locationVisitDao.allEntries() | ||
.map { it.toContactDiaryLocationVisitEntityList() } | ||
|
||
personDao.insert(person) | ||
personEncounterDao.insert(encounterList) | ||
locationDao.insert(location) | ||
locationVisitDao.insert(visitList) | ||
|
||
personEncounterFlow.first() shouldBe encounterList | ||
locationVisitFlow.first() shouldBe visitList | ||
|
||
personEncounterDao.entitiesForDate(yesterday).first().toContactDiaryPersonEncounterEntityList() shouldBe listOf(personEncounterYesterday) | ||
personEncounterDao.entitiesForDate(date).first().toContactDiaryPersonEncounterEntityList() shouldBe listOf(personEncounter) | ||
personEncounterDao.entitiesForDate(tomorrow).first().toContactDiaryPersonEncounterEntityList() shouldBe listOf(personEncounterTomorrow) | ||
|
||
locationVisitDao.entitiesForDate(yesterday).first().toContactDiaryLocationVisitEntityList() shouldBe listOf(locationVisitYesterday) | ||
locationVisitDao.entitiesForDate(date).first().toContactDiaryLocationVisitEntityList() shouldBe listOf(locationVisit) | ||
locationVisitDao.entitiesForDate(tomorrow).first().toContactDiaryLocationVisitEntityList() shouldBe listOf(locationVisitTomorrow) | ||
} | ||
} |
58 changes: 0 additions & 58 deletions
58
...App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionDoneFragmentTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.