From f94c6b5829a510ab8141b31dc2b6d9e9f180a354 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:45:31 +0000 Subject: [PATCH 1/7] Start draft PR From 184ee17600a582e27358f0976d552436d40b3a2f Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:45:47 +0000 Subject: [PATCH 2/7] Add .gitignore for Android/Kotlin project --- .gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6199bb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Android Studio +.idea/ +*.iml +.gradle/ +build/ +captures/ + +# Kotlin +*.class +*.kotlin_module + +# Gradle +local.properties +/out/ + +# Logs +*.log + +# Virtual Machine +.DS_Store + +# Dependency directories +/node_modules/ + +# Compiled class files +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs +hs_err_pid* \ No newline at end of file From 672d612c898711500b1002ee7db48a63d449bc1e Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:45:56 +0000 Subject: [PATCH 3/7] Add TodoValidation class with title validation logic --- .../com/todoapp/validation/TodoValidation.kt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/kotlin/com/todoapp/validation/TodoValidation.kt diff --git a/src/main/kotlin/com/todoapp/validation/TodoValidation.kt b/src/main/kotlin/com/todoapp/validation/TodoValidation.kt new file mode 100644 index 0000000..bbcd126 --- /dev/null +++ b/src/main/kotlin/com/todoapp/validation/TodoValidation.kt @@ -0,0 +1,27 @@ +package com.todoapp.validation + +/** + * Provides validation methods for Todo items + */ +object TodoValidation { + /** + * Validates the title of a todo item + * + * @param title The title to validate + * @return Boolean indicating if the title is valid + */ + fun isValidTitle(title: String?): Boolean { + // Check if title is null or empty after trimming whitespace + return !title.isNullOrBlank() + } + + /** + * Throws an exception if the title is invalid + * + * @param title The title to validate + * @throws IllegalArgumentException if title is invalid + */ + fun validateTitle(title: String?) { + require(isValidTitle(title)) { "Todo item title cannot be empty" } + } +} \ No newline at end of file From d07f218baf984708835c86b87aa5badabe621180 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:46:07 +0000 Subject: [PATCH 4/7] Add comprehensive tests for TodoValidation --- .../todoapp/validation/TodoValidationTest.kt | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/test/kotlin/com/todoapp/validation/TodoValidationTest.kt diff --git a/src/test/kotlin/com/todoapp/validation/TodoValidationTest.kt b/src/test/kotlin/com/todoapp/validation/TodoValidationTest.kt new file mode 100644 index 0000000..698061d --- /dev/null +++ b/src/test/kotlin/com/todoapp/validation/TodoValidationTest.kt @@ -0,0 +1,67 @@ +package com.todoapp.validation + +import org.junit.Assert.* +import org.junit.Test + +class TodoValidationTest { + @Test + fun `test valid title returns true`() { + // Arrange + val validTitle = "Buy groceries" + + // Act + val result = TodoValidation.isValidTitle(validTitle) + + // Assert + assertTrue("Valid title should return true", result) + } + + @Test + fun `test empty title returns false`() { + // Arrange + val emptyTitle = "" + + // Act + val result = TodoValidation.isValidTitle(emptyTitle) + + // Assert + assertFalse("Empty title should return false", result) + } + + @Test + fun `test null title returns false`() { + // Arrange + val nullTitle: String? = null + + // Act + val result = TodoValidation.isValidTitle(nullTitle) + + // Assert + assertFalse("Null title should return false", result) + } + + @Test + fun `test whitespace-only title returns false`() { + // Arrange + val whitespaceTitle = " " + + // Act + val result = TodoValidation.isValidTitle(whitespaceTitle) + + // Assert + assertFalse("Whitespace-only title should return false", result) + } + + @Test(expected = IllegalArgumentException::class) + fun `test validateTitle throws exception for invalid title`() { + // Act + TodoValidation.validateTitle("") + } + + @Test + fun `test validateTitle does not throw for valid title`() { + // Act + TodoValidation.validateTitle("Valid Title") + // Assert (no exception thrown) + } +} \ No newline at end of file From 14ad2cce56674e65b8650e775b7e0a7bce62e2f2 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:46:16 +0000 Subject: [PATCH 5/7] Add build configuration with JUnit dependencies --- build.gradle.kts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..f809b70 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + kotlin("jvm") version "1.9.0" +} + +dependencies { + testImplementation("junit:junit:4.13.2") + testImplementation(kotlin("test")) +} + +repositories { + mavenCentral() +} + +tasks.test { + useJUnitPlatform() +} \ No newline at end of file From 6bd9b4fd5294c79b986ab832c69d5b30cb7e6cfd Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Sat, 28 Jun 2025 16:46:25 +0000 Subject: [PATCH 6/7] Create Gradle build file for Kotlin project with JUnit --- build.gradle | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 build.gradle diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..919b394 --- /dev/null +++ b/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'org.jetbrains.kotlin.jvm' version '1.9.0' +} + +dependencies { + testImplementation 'junit:junit:4.13.2' + testImplementation "org.jetbrains.kotlin:kotlin-test-junit" +} + +repositories { + mavenCentral() +} + +test { + useJUnit() +} \ No newline at end of file From e99aa8208e6e49bfb0b90804454c445f30fec45e Mon Sep 17 00:00:00 2001 From: Gulnozik Date: Wed, 23 Jul 2025 20:24:14 +0000 Subject: [PATCH 7/7] Start draft PR