diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d5c6451..64d7200 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -77,8 +77,6 @@ dependencies { implementation("androidx.compose.material:material-icons-extended:${compose_version}") implementation("com.google.accompanist:accompanist-systemuicontroller:0.14.0") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03") // implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1") implementation("androidx.activity:activity-compose:1.3.1") diff --git a/data/build.gradle b/data/build.gradle index 48c9069..2567cdc 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -14,5 +14,4 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1" implementation("io.insert-koin:koin-core:3.1.2") - implementation("com.jakewharton.timber:timber:5.0.1") } \ No newline at end of file diff --git a/device/build.gradle b/device/build.gradle index f0645ae..82312ff 100644 --- a/device/build.gradle +++ b/device/build.gradle @@ -52,8 +52,6 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' - implementation("com.jakewharton.timber:timber:5.0.1") - def room_version = "2.3.0" implementation("androidx.room:room-runtime:$room_version") implementation("androidx.room:room-ktx:$room_version") diff --git a/domain/build.gradle b/domain/build.gradle index 3750050..2f7915b 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -13,11 +13,10 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1" implementation("io.insert-koin:koin-core:3.1.2") - implementation("com.jakewharton.timber:timber:5.0.1") - testImplementation("junit:junit:4.13.2") testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1") testImplementation("org.hamcrest:hamcrest-all:1.3") testImplementation("org.mockito:mockito-core:3.9.0") testImplementation("io.mockk:mockk:1.10.0") + testImplementation("io.insert-koin:koin-test:3.1.2") } \ No newline at end of file diff --git a/domain/src/test/kotlin/com/soulesidibe/domain/GetTodoUseCaseTest.kt b/domain/src/test/kotlin/com/soulesidibe/domain/GetTodoUseCaseTest.kt new file mode 100644 index 0000000..0371be2 --- /dev/null +++ b/domain/src/test/kotlin/com/soulesidibe/domain/GetTodoUseCaseTest.kt @@ -0,0 +1,45 @@ +package com.soulesidibe.domain + +import com.soulesidibe.domain.entity.TodoEntity +import com.soulesidibe.domain.exception.NoTodoFoundException +import com.soulesidibe.domain.repository.TodoRepository +import junit.framework.TestCase.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runBlockingTest +import org.junit.Test +import org.mockito.Mockito.`when` +import org.mockito.Mockito.mock + +@ExperimentalCoroutinesApi +class GetTodoUseCaseTest { + + @Test + fun `should get a todo`() = runBlockingTest { + val fakeId = "12345" + val repository = mock(TodoRepository::class.java) + `when`(repository.byId(fakeId)).thenReturn(TodoEntity("12345", "Test")) + + val usecase = GetTodoUseCase(repository) + + val response = usecase.execute(fakeId) + assertEquals( + Response.success(TodoEntity("12345", "Test")), + response + ) + } + + @Test + fun `should get an error when no todo id do no exist`() = runBlockingTest { + val fakeId = "12345" + val repository = mock(TodoRepository::class.java) + `when`(repository.byId(fakeId)).thenReturn(null) + + val usecase = GetTodoUseCase(repository) + + val response = usecase.execute(fakeId) + assertEquals( + Response.failure(NoTodoFoundException), + response + ) + } +} \ No newline at end of file diff --git a/domain/src/test/kotlin/com/soulesidibe/domain/RemoveTodoUseCaseTest.kt b/domain/src/test/kotlin/com/soulesidibe/domain/RemoveTodoUseCaseTest.kt new file mode 100644 index 0000000..8f685a4 --- /dev/null +++ b/domain/src/test/kotlin/com/soulesidibe/domain/RemoveTodoUseCaseTest.kt @@ -0,0 +1,38 @@ +package com.soulesidibe.domain + +import com.soulesidibe.domain.entity.TodoEntity +import com.soulesidibe.domain.exception.NoTodoFoundException +import com.soulesidibe.domain.repository.TodoRepository +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runBlockingTest +import org.junit.Assert.* +import org.junit.Test +import org.mockito.Mockito.`when` +import org.mockito.Mockito.mock + +@OptIn(ExperimentalCoroutinesApi::class) +class RemoveTodoUseCaseTest { + + + @Test + fun `should remove the todo if exsist`() = runBlockingTest { + val repository = mock(TodoRepository::class.java) + `when`(repository.byId("12345")).thenReturn(TodoEntity("12345", "test")) + `when`(repository.remove(TodoEntity("12345", "test"))).thenReturn(true) + + + val usecase = RemoveTodoUseCase(repository) + val response = usecase.execute("12345") + assertEquals(Response.success(true), response) + } + + @Test + fun `should not remove the todo if not exsist`() = runBlockingTest { + val repository = mock(TodoRepository::class.java) + `when`(repository.byId("12345")).thenReturn(null) + + val usecase = RemoveTodoUseCase(repository) + val response = usecase.execute("12345") + assertEquals(Response.Error(NoTodoFoundException), response) + } +} \ No newline at end of file