Skip to content

Commit

Permalink
Merge pull request #3 from omer358/dev
Browse files Browse the repository at this point in the history
Impl Person Details and navigation to and from PeopleList Screen
  • Loading branch information
omer358 authored Jun 19, 2024
2 parents 5e6991f + 9d4ef68 commit f3a3127
Show file tree
Hide file tree
Showing 31 changed files with 941 additions and 157 deletions.
13 changes: 13 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.compose.compiler)

id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
id("kotlin-kapt")
// kapt("groupId:artifactId:version")

}

Expand Down Expand Up @@ -63,6 +65,7 @@ dependencies {
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.lifecycle.runtime.compose.android)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand All @@ -77,10 +80,9 @@ dependencies {


implementation(libs.androidx.room.runtime)
annotationProcessor(libs.androidx.room.compiler)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)
testImplementation(libs.androidx.room.room.testing)
ksp(libs.androidx.room.compiler)



Expand All @@ -99,5 +101,14 @@ dependencies {
implementation(libs.androidx.navigation.compose)
androidTestImplementation(libs.androidx.navigation.testing)

// Hilt
implementation(libs.hilt.android)
implementation(libs.androidx.hilt.navigation.compose)
kapt(libs.hilt.compiler)

// Unit Test
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlinx.coroutines.test)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.example.rememberme.data
package com.example.rememberme.data.local

import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.example.rememberme.data.database.People
import com.example.rememberme.data.database.PeopleDatabase
import com.example.rememberme.domain.model.People
import com.example.remindme.database.PeopleDao
import kotlinx.coroutines.runBlocking
import org.junit.After
Expand Down Expand Up @@ -122,7 +121,7 @@ class PeopleDatabaseTest {
avatar = 2
)

peopleDao.insertAll(person1, person2)
peopleDao.insertAll(listOf(person1, person2))

peopleDao.clear()
val people = peopleDao.getAll()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//package com.example.rememberme.data.repository
//
//import com.example.rememberme.R
//import com.example.rememberme.data.PeopleRepositoryImpl
//import com.example.rememberme.domain.model.People
//import com.example.remindme.database.PeopleDao
//import kotlinx.coroutines.ExperimentalCoroutinesApi
//import kotlinx.coroutines.test.runTest
//import org.junit.Assert.assertEquals
//import org.junit.Before
//import org.junit.Test
//import org.mockito.MockitoAnnotations
//import javax.inject.Inject
//
//@ExperimentalCoroutinesApi
//class PeopleRepositoryImplTest {
//
// @Inject
// private lateinit var peopleDao: PeopleDao
//
// private lateinit var peopleRepository: PeopleRepositoryImpl
//
// @Before
// fun setUp() {
// MockitoAnnotations.initMocks(this::class)
// peopleRepository = PeopleRepositoryImpl(peopleDao)
// }
//
// @Test
// fun getAllPeopleShouldReturnListOfPeople() = runTest {
// // Arrange
// val peopleList = listOf(
// People(
// 1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,),
// People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,)
// )
// peopleRepository.insertPeople(peopleList[0])
// peopleRepository.insertPeople(peopleList[1])
//
// // Act
// val result = peopleRepository.getAllPeople()
//
// // Assert
// result.collect {
// assertEquals(peopleList, it)
// }
// }
//
//// @Test
//// fun insertPeopleShouldCallInsertPeopleOnDao() = runBlocking {
//// // Arrange
//// val person = People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,)
////
//// // Act
//// peopleRepository.insertPeople(person)
////
//// // Assert
//// Mockito.verify(peopleDao, Mockito.times(1)).insertPeople(person)
//// }
////
//// @Test
//// fun `deletePeople should call deletePeople on dao`() = runBlocking {
//// // Arrange
//// val person = People(1, "John", secondName = "Doe", place = "", time = "", gender = "",avatar= R.drawable.ic_m3,)
////
//// // Act
//// peopleRepository.deletePeople(person)
////
//// // Assert
//// Mockito.verify(peopleDao, Mockito.times(1)).deletePeople(person)
//// }
////
//// @Test
//// fun `updatePeople should call updatePeople on dao`() = runBlocking {
//// // Arrange
//// val person = People(1, "John Doe")
////
//// // Act
//// peopleRepository.updatePeople(person)
////
//// // Assert
//// Mockito.verify(peopleDao, Mockito.times(1)).updatePeople(person)
//// }
////
//// @Test
//// fun `deleteAllPeople should call deleteAllPeople on dao`() = runBlocking {
//// // Act
//// peopleRepository.deleteAllPeople()
////
//// // Assert
//// Mockito.verify(peopleDao, Mockito.times(1)).deleteAllPeople()
//// }
////
//// @Test
//// fun `getPeopleById should return person`() = runBlocking {
//// // Arrange
//// val person = People(1, "John Doe")
//// Mockito.`when`(peopleDao.getPeopleById(1)).thenReturn(person)
////
//// // Act
//// val result = peopleRepository.getPeopleById(1)
////
//// // Assert
//// assertEquals(person, result)
//// }
////
//// @Test
//// fun `getPeopleByName should return list of people`() = runBlocking {
//// // Arrange
//// val peopleList = listOf(People(1, "John Doe"), People(2, "John Smith"))
//// Mockito.`when`(peopleDao.getPeopleByName("John")).thenReturn(peopleList)
////
//// // Act
//// val result = peopleRepository.getPeopleByName("John")
////
//// // Assert
//// assertEquals(peopleList, result)
//// }
//}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".RememberMeApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/rememberme/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
// @Inject
// lateinit var peopleDao: PeopleDao
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
installSplashScreen()

// lifecycleScope.launch {
// withContext(Dispatchers.IO){
// peopleDao.insertAll(FakeDataSource.getPeopleList())
// }
// }
setContent {
RememberMeApp()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.rememberme

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class RememberMeApplication: Application() {
}
Loading

0 comments on commit f3a3127

Please sign in to comment.