Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Create events repository (EXPOSUREAPP-5470) (EXPOSUREAPP-5482)(EXPOSUREAPP-5484) #2549

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4f8e26b
Add events card in event registration test fragment
LukasLechnerDev Mar 2, 2021
20ac9a9
Format
LukasLechnerDev Mar 2, 2021
ebf95a3
Create empty fragments and implement navigation
LukasLechnerDev Mar 2, 2021
0aed523
Create layout for CreateEventTestFragment.kt
LukasLechnerDev Mar 2, 2021
07a404a
Add spinner for event type
LukasLechnerDev Mar 3, 2021
68c3ce3
Build event object from input
LukasLechnerDev Mar 4, 2021
f214a18
Create database for event registration and store events in it
LukasLechnerDev Mar 5, 2021
b369db7
Fix date issue
LukasLechnerDev Mar 5, 2021
bf0c668
Show stored events in a simple way
LukasLechnerDev Mar 5, 2021
fc496f6
Make event list more pretty
LukasLechnerDev Mar 8, 2021
d3854ef
Add button to delete all events in ShowStoredEventsTestFragment.kt
LukasLechnerDev Mar 8, 2021
837dc2c
Change the functions of HostedEventRepository.kt to regular functions…
LukasLechnerDev Mar 8, 2021
eccd0f4
Change text in EventRegistration TestFragment
LukasLechnerDev Mar 8, 2021
0f55163
Merge branch 'feature/5062-event-registration-main' into feature/5470…
LukasLechnerDev Mar 8, 2021
d21b48c
Fix merge issues
LukasLechnerDev Mar 8, 2021
3f7004b
Add parameters from new TechSpec
LukasLechnerDev Mar 8, 2021
a5385d5
Change wording from 'hosted Events' to 'TraceLocation'
LukasLechnerDev Mar 8, 2021
5845590
Delete event registration database on app reset
LukasLechnerDev Mar 8, 2021
911ea7b
Fix detect issue 'MaxLineLength'
LukasLechnerDev Mar 8, 2021
40bfcf5
Remove parcelable from TraceLocationEntity.kt
LukasLechnerDev Mar 8, 2021
0cd1bea
Map TraceLocationEntity to TraceLocation in TraceLocationRepository
LukasLechnerDev Mar 8, 2021
65cdb5c
Use the Instant.seconds extension function
LukasLechnerDev Mar 8, 2021
b6ca9fa
Use existing EventRegistrationModule.kt instead of creating a new one
LukasLechnerDev Mar 8, 2021
8cdad4b
Only delete traceLocations on App reset instead of all tables in Trac…
LukasLechnerDev Mar 9, 2021
9af2cab
Merge branch 'feature/5062-event-registration-main' into feature/5470…
LukasLechnerDev Mar 10, 2021
f4fa24c
Add named parameters to TraceLocation mapping
LukasLechnerDev Mar 10, 2021
93968db
Add unit test for TraceLocation Mapper
LukasLechnerDev Mar 10, 2021
d27347f
Add unit tests for EventRegistrationConverters
LukasLechnerDev Mar 10, 2021
f204720
Add unit tests for TraceLocationEntity mapping
LukasLechnerDev Mar 10, 2021
ec93968
Add events database table to 'TraceLocation' database and remove 'Eve…
LukasLechnerDev Mar 10, 2021
e320ad1
Add database tests for TraceLocations
LukasLechnerDev Mar 11, 2021
82171b5
Merge branch 'feature/5062-event-registration-main' into feature/5470…
LukasLechnerDev Mar 11, 2021
5ad542f
Fix issue in EventRegistrationModule.kt
LukasLechnerDev Mar 11, 2021
0eb7bf7
Add database tests for checkInDao
LukasLechnerDev Mar 11, 2021
16f5ef6
Fix detekt maxLineLength issue
LukasLechnerDev Mar 11, 2021
a6c015b
Fix inconsistency in TraceLocationEntity.kt
LukasLechnerDev Mar 11, 2021
2caf8ee
Fix ktlint issues
LukasLechnerDev Mar 11, 2021
430a6c0
Inherit from BaseTest or BaseTestInstrumentation in tests
LukasLechnerDev Mar 11, 2021
307daa6
Fix issue in TraceLocationConverters.kt
LukasLechnerDev Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "244eed2a4665a1c60d0792de5945888b",
"identityHash": "48d71b0a00d0c7fe01ffe05d5fecb512",
"entities": [
{
"tableName": "checkin",
Expand Down Expand Up @@ -101,12 +101,80 @@
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "traceLocations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`guid` TEXT NOT NULL, `version` INTEGER NOT NULL, `type` INTEGER NOT NULL, `description` TEXT NOT NULL, `address` TEXT NOT NULL, `startDate` TEXT, `endDate` TEXT, `defaultCheckInLengthInMinutes` INTEGER, `signature` TEXT NOT NULL, PRIMARY KEY(`guid`))",
"fields": [
{
"fieldPath": "guid",
"columnName": "guid",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "version",
"columnName": "version",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "address",
"columnName": "address",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "startDate",
"columnName": "startDate",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "endDate",
"columnName": "endDate",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "defaultCheckInLengthInMinutes",
"columnName": "defaultCheckInLengthInMinutes",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "signature",
"columnName": "signature",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"guid"
],
"autoGenerate": false
},
"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, '244eed2a4665a1c60d0792de5945888b')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '48d71b0a00d0c7fe01ffe05d5fecb512')"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.rki.coronawarnapp.eventregistration.storage

import de.rki.coronawarnapp.eventregistration.events.TraceLocation
import de.rki.coronawarnapp.eventregistration.storage.entity.TraceLocationCheckInEntity
import org.joda.time.Instant

object CheckInDatabaseData {

val testCheckIn = TraceLocationCheckInEntity(
guid = "testGuid1",
version = 1,
type = TraceLocation.Type.TEMPORARY_OTHER.value,
description = "testDescription1",
address = "testAddress1",
traceLocationStart = Instant.parse("2021-01-01T12:00:00.000Z"),
traceLocationEnd = Instant.parse("2021-01-01T15:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
signature = "Signature",
checkInStart = Instant.parse("2021-01-01T12:30:00.000Z"),
checkInEnd = Instant.parse("2021-01-01T14:00:00.000Z"),
targetCheckInEnd = Instant.parse("2021-01-01T12:45:00.000Z"),
createJournalEntry = true
)

val testCheckInWithoutCheckOutTime = TraceLocationCheckInEntity(
guid = "testGuid2",
version = 1,
type = TraceLocation.Type.TEMPORARY_OTHER.value,
description = "testDescription2",
address = "testAddress2",
traceLocationStart = null,
traceLocationEnd = null,
defaultCheckInLengthInMinutes = null,
signature = "Signature",
checkInStart = Instant.parse("2021-01-01T12:30:00.000Z"),
checkInEnd = null,
targetCheckInEnd = Instant.parse("2021-01-01T12:45:00.000Z"),
createJournalEntry = true
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package de.rki.coronawarnapp.eventregistration.storage

import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import de.rki.coronawarnapp.eventregistration.storage.CheckInDatabaseData.testCheckIn
import de.rki.coronawarnapp.eventregistration.storage.CheckInDatabaseData.testCheckInWithoutCheckOutTime
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.joda.time.Instant
import org.junit.After
import org.junit.Test
import testhelpers.BaseTestInstrumentation

class TraceLocationCheckInDaoTest : BaseTestInstrumentation() {

private val traceLocationDatabase = Room.inMemoryDatabaseBuilder(
ApplicationProvider.getApplicationContext(),
TraceLocationDatabase::class.java
).build()

private val checkInDao = traceLocationDatabase.eventCheckInDao()

@After
fun tearDown() {
traceLocationDatabase.clearAllTables()
}

@Test
fun traceLocationCheckInDaoShouldReturnNoEntriesInitially() = runBlocking {
val checkInsFlow = checkInDao.allEntries()

checkInsFlow.first() shouldBe emptyList()
}

@Test
fun traceLocationCheckInDaoShouldSuccessfullyInsertCheckIn() = runBlocking {
val checkInsFlow = checkInDao.allEntries()

val generatedId = checkInDao.insert(testCheckIn)

checkInsFlow.first() shouldBe listOf(testCheckIn.copy(id = generatedId))
}

@Test
fun traceLocationCheckInDaoShouldSuccessfullyInsertMultipleCheckIns() = runBlocking {
val checkInsFlow = checkInDao.allEntries()

val testCheckInGeneratedId = checkInDao.insert(testCheckIn)
val testCheckInWithoutCheckOutTimeGeneratedId = checkInDao.insert(testCheckInWithoutCheckOutTime)

checkInsFlow.first() shouldBe listOf(
testCheckIn.copy(id = testCheckInGeneratedId),
testCheckInWithoutCheckOutTime.copy(id = testCheckInWithoutCheckOutTimeGeneratedId)
)
}

@Test
fun traceLocationCheckInDaoShouldSuccessfullyUpdateCheckIn() = runBlocking {
val checkInsFlow = checkInDao.allEntries()

val testCheckInGeneratedId = checkInDao.insert(testCheckInWithoutCheckOutTime)

val updatedCheckIn = testCheckInWithoutCheckOutTime.copy(
id = testCheckInGeneratedId,
checkInEnd = Instant.parse("2021-01-01T14:00:00.000Z")
)

checkInDao.update(updatedCheckIn)

checkInsFlow.first() shouldBe listOf(updatedCheckIn)
}

@Test
fun traceLocationCheckInDaoShouldSuccessfullyDeleteAllCheckIns() = runBlocking {
val checkInsFlow = checkInDao.allEntries()

checkInDao.insert(testCheckIn)
checkInDao.insert(testCheckInWithoutCheckOutTime)

checkInDao.deleteAll()

checkInsFlow.first() shouldBe emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package de.rki.coronawarnapp.eventregistration.storage

import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import de.rki.coronawarnapp.eventregistration.storage.TraceLocationDatabaseData.testTraceLocation1
import de.rki.coronawarnapp.eventregistration.storage.TraceLocationDatabaseData.testTraceLocation2
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Test
import testhelpers.BaseTestInstrumentation

class TraceLocationDaoTest : BaseTestInstrumentation() {

private val traceLocationDatabase = Room.inMemoryDatabaseBuilder(
ApplicationProvider.getApplicationContext(),
TraceLocationDatabase::class.java
).build()

private val traceLocationDao = traceLocationDatabase.traceLocationDao()

@After
fun tearDown() {
traceLocationDatabase.clearAllTables()
}

@Test
fun traceLocationDaoShouldReturnNoEntriesInitially() = runBlocking {
val traceLocationsFlow = traceLocationDao.allEntries()

traceLocationsFlow.first() shouldBe emptyList()
}

@Test
fun traceLocationDaoShouldSuccessfullyInsertTraceLocation() = runBlocking {
val traceLocationsFlow = traceLocationDao.allEntries()

traceLocationDao.insert(testTraceLocation1)

traceLocationsFlow.first() shouldBe listOf(testTraceLocation1)
}

@Test
fun traceLocationDaoShouldSuccessfullyInsertMultipleTraceLocations() = runBlocking {
val traceLocationsFlow = traceLocationDao.allEntries()

traceLocationDao.insert(testTraceLocation1)
traceLocationDao.insert(testTraceLocation2)

traceLocationsFlow.first() shouldBe listOf(testTraceLocation1, testTraceLocation2)
}

@Test
fun traceLocationDaoShouldSuccessfullyDeleteSingleTraceLocation() = runBlocking {
val traceLocationsFlow = traceLocationDao.allEntries()

traceLocationDao.insert(testTraceLocation1)
traceLocationDao.delete(testTraceLocation1)
traceLocationsFlow.first() shouldBe emptyList()
}

@Test
fun traceLocationDaoShouldSuccessfullyDeleteAllTraceLocations() = runBlocking {
val traceLocationsFlow = traceLocationDao.allEntries()

traceLocationDao.insert(testTraceLocation1)
traceLocationDao.insert(testTraceLocation2)
traceLocationDao.deleteAll()
traceLocationsFlow.first() shouldBe emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.rki.coronawarnapp.eventregistration.storage

import de.rki.coronawarnapp.eventregistration.events.TraceLocation
import de.rki.coronawarnapp.eventregistration.storage.entity.TraceLocationEntity
import org.joda.time.Instant

object TraceLocationDatabaseData {

val testTraceLocation1 = TraceLocationEntity(
guid = "TestGuid1",
version = 1,
type = TraceLocation.Type.TEMPORARY_OTHER,
description = "TestTraceLocation1",
address = "TestTraceLocationAddress1",
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = null,
signature = "signature1"
)

val testTraceLocation2 = TraceLocationEntity(
guid = "TestGuid2",
version = 1,
type = TraceLocation.Type.PERMANENT_OTHER,
description = "TestTraceLocation2",
address = "TestTraceLocationAddress2",
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = 15,
signature = "signature2"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.databinding.FragmentTestEventregistrationBinding
import de.rki.coronawarnapp.test.menu.ui.TestMenuItem
Expand All @@ -23,6 +24,8 @@ class EventRegistrationTestFragment : Fragment(R.layout.fragment_test_eventregis
private val binding: FragmentTestEventregistrationBinding by viewBindingLazy()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

with(binding) {
scanCheckInQrCode.setOnClickListener {
doNavigate(
Expand All @@ -37,6 +40,14 @@ class EventRegistrationTestFragment : Fragment(R.layout.fragment_test_eventregis
.actionEventRegistrationTestFragmentToTestQrCodeCreationFragment()
)
}

createEventButton.setOnClickListener {
findNavController().navigate(R.id.createEventTestFragment)
}

showEventsButton.setOnClickListener {
findNavController().navigate(R.id.showStoredEventsTestFragment)
}
}
}

Expand Down
Loading