diff --git a/MovingCode/ApplyPullUpAndPushDownRefactorings/task-info.yaml b/MovingCode/ApplyPullUpAndPushDownRefactorings/task-info.yaml index 9d7a395..848aa93 100644 --- a/MovingCode/ApplyPullUpAndPushDownRefactorings/task-info.yaml +++ b/MovingCode/ApplyPullUpAndPushDownRefactorings/task-info.yaml @@ -11,55 +11,77 @@ files: - offset: 0 length: 149 placeholder_text: |- + package jetbrains.refactoring.course.moving + interface Animal { + fun eat() + fun sleep() + fun bark() + fun meow() } + - name: src/main/kotlin/jetbrains/refactoring/course/moving/Cat.kt visible: true placeholders: - offset: 0 length: 420 placeholder_text: |- + package jetbrains.refactoring.course.moving + class Cat(private val name: String, private val age: Int) : Animal { - override fun eat() { - println("$name the cat is eating.") - } - override fun sleep() { - println("$name the cat is sleeping.") - } - override fun bark() { - println("$name the animal is barking.") - } - override fun meow() { - println("$name the animal is meowing.") - } - fun play() { - println("$name the cat is playing.") - } + + override fun eat() { + println("$name the cat is eating.") + } + + override fun sleep() { + println("$name the cat is sleeping.") + } + + override fun bark() { + println("$name the animal is barking.") + } + + override fun meow() { + println("$name the animal is meowing.") + } + + fun play() { + println("$name the cat is playing.") + } } + - name: src/main/kotlin/jetbrains/refactoring/course/moving/Dog.kt visible: true placeholders: - offset: 0 length: 417 placeholder_text: |- + package jetbrains.refactoring.course.moving + class Dog(private val name: String, private val age: Int) : Animal { - override fun eat() { - println("$name the dog is eating.") - } - override fun sleep() { - println("$name the dog is sleeping.") - } - override fun bark() { - println("$name the dog is barking.") - } - override fun meow() { - println("$name the animal is meowing.") - } - fun play() { - println("$name the dog is playing.") - } + + override fun eat() { + println("$name the dog is eating.") + } + + override fun sleep() { + println("$name the dog is sleeping.") + } + + override fun bark() { + println("$name the dog is barking.") + } + + override fun meow() { + println("$name the animal is meowing.") + } + + fun play() { + println("$name the dog is playing.") + } } diff --git a/MovingCode/ApplyPullUpAndPushDownRefactorings/test/Tests.kt b/MovingCode/ApplyPullUpAndPushDownRefactorings/test/Tests.kt index 07018ca..4f44e5a 100644 --- a/MovingCode/ApplyPullUpAndPushDownRefactorings/test/Tests.kt +++ b/MovingCode/ApplyPullUpAndPushDownRefactorings/test/Tests.kt @@ -1,6 +1,51 @@ +import org.jetbrains.academy.test.system.test.BaseIjTestClass +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import java.io.File + +class PullUpAndPushDownTest : BaseIjTestClass() { + + companion object { + + private lateinit var animalText: String + + @JvmStatic + @BeforeAll + fun initialize() { + val taskDirectoryPath = System.getProperty("user.dir") + animalText = + File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/Animal.kt").readText() + } + } + + @Test + fun testPullUpPlayMethodAndVariables() { + setUp() + myFixture.configureByText("Animal.kt", animalText) + Assertions.assertTrue(hasMethod("play")) { + "Please, pull up the \"play\" method" + } + Assertions.assertTrue(hasProperty("name")) { + "Please, pull up the \"name\" variable" + } + Assertions.assertTrue(hasProperty("age")) { + "Please, pull up the \"age\" variable" + } + } + + @Test + fun testPushDownMethods() { + setUp() + myFixture.configureByText("Animal.kt", animalText) + Assertions.assertFalse(hasMethod("bark")) { + "Please, push down the \"bark\" method" + } + Assertions.assertFalse(hasMethod("meow")) { + "Please, push down the \"meow\" method" + } + } -class PullUpAndPushDownTest { @Test fun animalClassTest() { val clazz = animalClass.checkBaseDefinition() diff --git a/MovingCode/FindMoreAppropriateClassesForMethods/task-info.yaml b/MovingCode/FindMoreAppropriateClassesForMethods/task-info.yaml index 85c1393..4ac5112 100644 --- a/MovingCode/FindMoreAppropriateClassesForMethods/task-info.yaml +++ b/MovingCode/FindMoreAppropriateClassesForMethods/task-info.yaml @@ -62,10 +62,14 @@ files: placeholders: - offset: 0 length: 465 - placeholder_text: "" + placeholder_text: |- + package jetbrains.refactoring.course.moving.car + - name: src/main/kotlin/jetbrains/refactoring/course/moving/driver/Driver.kt visible: true placeholders: - offset: 0 length: 502 - placeholder_text: "" + placeholder_text: |- + package jetbrains.refactoring.course.moving.driver + diff --git a/MovingCode/FindMoreAppropriateClassesForMethods/test/Tests.kt b/MovingCode/FindMoreAppropriateClassesForMethods/test/Tests.kt index 0a1cba3..4ba03dd 100644 --- a/MovingCode/FindMoreAppropriateClassesForMethods/test/Tests.kt +++ b/MovingCode/FindMoreAppropriateClassesForMethods/test/Tests.kt @@ -1,8 +1,62 @@ +import org.jetbrains.academy.test.system.test.BaseIjTestClass import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import java.io.File -class MovingTest { +class MovingTest : BaseIjTestClass() { + + companion object { + + private lateinit var taskDirectoryPath: String + + @JvmStatic + @BeforeAll + fun initialize() { + taskDirectoryPath = System.getProperty("user.dir") + } + } + + @Test + fun testCarClassMoved() { + Assertions.assertTrue( + File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/car/Car.kt").exists() + ) { + "Please, move the \"Car\" class to a separate file" + } + } + + @Test + fun testDriverClassMoved() { + Assertions.assertTrue( + File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/driver/Driver.kt").exists() + ) { + "Please, move the \"Driver\" class to a separate file" + } + } + + @Test + fun testStartMethodMovedToCarClass() { + val carFile = File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/car/Car.kt") + val sourceText = carFile.readText() + setUp() + myFixture.configureByText("Task.kt", sourceText) + Assertions.assertTrue(hasMethod("start")) { + "Please, move the \"start\" method" + } + } + + @Test + fun testStopMethodMovedToCarClass() { + val carFile = File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/car/Car.kt") + val sourceText = carFile.readText() + setUp() + myFixture.configureByText("Task.kt", sourceText) + Assertions.assertTrue(hasMethod("stop")) { + "Please, move the \"stop\" method" + } + } + @Test fun driverClassTest() { val clazz = driverClass.checkBaseDefinition() @@ -16,15 +70,4 @@ class MovingTest { carClass.checkFieldsDefinition(clazz) carClass.checkDeclaredMethods(clazz) } - - @Test - fun newFilesCreatedTest() { - val taskDirectoryPath = System.getProperty("user.dir") - val mainFile = File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/Main.kt") - val driverFile = File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/driver/Driver.kt") - val carFile = File("$taskDirectoryPath/src/main/kotlin/jetbrains/refactoring/course/moving/car/Car.kt") - Assertions.assertTrue(mainFile.exists()) - Assertions.assertTrue(driverFile.exists()) - Assertions.assertTrue(carFile.exists()) - } } diff --git a/MovingCode/MovingCodeIntroduction/task-remote-info.yaml b/MovingCode/MovingCodeIntroduction/task-remote-info.yaml new file mode 100644 index 0000000..5f66b30 --- /dev/null +++ b/MovingCode/MovingCodeIntroduction/task-remote-info.yaml @@ -0,0 +1 @@ +id: 661218806 diff --git a/MovingCode/lesson-remote-info.yaml b/MovingCode/lesson-remote-info.yaml index 207c4fb..cac2774 100644 --- a/MovingCode/lesson-remote-info.yaml +++ b/MovingCode/lesson-remote-info.yaml @@ -1 +1 @@ -id: 1888793984 +id: 121072982 diff --git a/build.gradle.kts b/build.gradle.kts index 2e8de43..9cf0ab0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,7 +56,7 @@ allprojects { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20") testImplementation("junit:junit:4.13.1") - val testSystemVersion = "2.0.3" + val testSystemVersion = "2.0.5" implementation("org.jetbrains.academy.test.system:core:$testSystemVersion") implementation("org.jetbrains.academy.test.system:ij:$testSystemVersion")