ui/item/ItemUiModel.kt:
- UI data class combining entity data with resolved category/location names
- Computed properties isExpired and isExpiringSoon for MHD color coding
ui/item/ItemListViewModel.kt:
- Combines ItemRepository, CategoryRepository, LocationRepository via Flow.combine
- Groups items by category name (sorted alphabetically)
- Delete flow with confirmation dialog state management
ui/item/ItemListScreen.kt:
- LazyColumn with category headers and Material 3 Cards per item
- Shows name, quantity+unit, location, and color-coded expiry date
- Delete via IconButton with AlertDialog confirmation
- Empty state when no items exist
- FAB with onAddItem navigation callback
ui/item/ItemListViewModelTest.kt:
- 9 unit tests covering init, grouping, name resolution,
delete dialog flow, and alphabetical sorting
Closes#26
Closes#25
ui/category/:
- CategoryListViewModel: StateFlow-based ViewModel with add/delete
dialog state management, backed by CategoryRepository
- CategoryListScreen: Material 3 Scaffold with LazyColumn, FAB for
adding, delete confirmation dialog with CASCADE warning
ui/location/:
- LocationListViewModel: same pattern for LocationRepository
- LocationListScreen: same UI pattern for location management
Tests:
- CategoryListViewModelTest: 11 tests covering init, add, delete,
dialog state, blank name rejection
- LocationListViewModelTest: 11 tests (same coverage)
Dependencies:
- Added lifecycle-runtime-compose for collectAsStateWithLifecycle
- Added kotlinx-coroutines-test for ViewModel unit tests
LocalDateConverterTest: added negative test for invalid string input
(DateTimeParseException).
CategoryDaoTest, LocationDaoTest: added getAll tests with multiple
entities to verify complete retrieval.
ItemDaoTest: fixed getExpiringSoon test (was calling non-existent
getExpiringSoon(Int) instead of getExpiringSoonByCutoff(LocalDate));
added getAll, getById positive, and getById negative tests.
JsonRoundtripTest (new): verifies lossless export-import roundtrip
with multiple items covering all fields, nullable fields (null
kcalPer100g, null expiryDate), and empty database edge case.
TestFakes (new): extracted shared Fake DAO implementations from
ImportExportRepositoryImplTest to avoid private class redeclaration
errors across test files in the same package.
Closes#22
domain/repository/ImportExportRepository.kt: new interface with
exportToJson() and importFromJson(json) suspend functions.
data/export/ExportData.kt: serializable data class bundling all
entity lists for JSON serialization via kotlinx.serialization.
data/export/ImportExportRepositoryImpl.kt: implementation using
kotlinx.serialization + Dispatchers.IO; exportToJson fetches all
DAOs and serializes, importFromJson deserializes and upserts back.
data/db/dao/{Category,Item,Location,Settings}Dao.kt: added @Upsert
upsertAll() suspend function to each DAO to support bulk import.
di/RepositoryModule.kt: bound ImportExportRepositoryImpl to
ImportExportRepository via Hilt @Binds.
test/.../FakeXxxDao.kt: upsertAll() implemented in all four fake
DAOs for unit test coverage.
- 4 Repository-Interfaces in domain/repository/ (Category, Location, Item, Settings)
- 4 Implementierungsklassen in data/repository/ mit Hilt @Inject
- RepositoryModule mit @Binds-Bindings fuer alle Repositories
- Datumslogik (getExpiringSoon) aus ItemDao in ItemRepositoryImpl verschoben
- 20 Unit-Tests mit Fake-DAOs (4 pro Repository)
- DatabaseModule: @Module + @InstallIn(SingletonComponent) with @Singleton-scoped
Room.databaseBuilder provider and four @Provides methods for ItemDao,
CategoryDao, LocationDao and SettingsDao
- DatabaseModuleTest: smoke-test verifies all four DAO providers return
non-null objects using an in-memory Room database
- KrisenvorratDatabase mit allen 4 Entities und LocalDateConverter
- CategoryDao, LocationDao, ItemDao, SettingsDao mit CRUD und Flow-Queries
- ItemDao.getExpiringSoon(daysUntil) als Default-Interface-Methode
- SettingsDao mit @Upsert (Room 2.6.1)
- Instrumentierungstests für alle 4 DAOs (in-memory DB)
- androidx.room:room-testing zu Dependencies ergänzt
- Add CategoryEntity, LocationEntity, SettingsEntity, ItemEntity
- ItemEntity: FK to Category+Location with CASCADE, indices on FK columns
- LocalDateConverter: LocalDate? <-> String? (ISO-8601) via @TypeConverter
- Add LocalDateConverterTest: 4 unit tests (null/non-null round-trip)
app/build.gradle.kts:
- Enabled buildConfig in buildFeatures to expose VERSION_NAME
app/src/main/java/de/krisenvorrat/app/MainActivity.kt:
- Replaced plain Text greeting with centered Column layout
- Shows app title 'Krisenvorrat' (headlineLarge) and version
'v1.0' via BuildConfig.VERSION_NAME (bodyMedium, onSurfaceVariant)
Verified: built, deployed to emulator, and confirmed via screenshot.