From a0bfe951e554ee5b0e6cceb6abb15ba44fef1bb5 Mon Sep 17 00:00:00 2001 From: Peter Kofler Date: Tue, 3 Oct 2023 23:13:34 +0200 Subject: [PATCH] Add Kotlin to list of languages, refresh assignment. --- .github/workflows/Kotlin.yml | 48 +++++++++++++++++++ Kotlin/README.md | 46 ++++++++++++++++++ .../org/codecop/dependencies/b/Assignment.md | 2 + build/clean.bat | 6 +++ build/refresh_copied_md.bat | 12 +++++ 5 files changed, 114 insertions(+) create mode 100644 .github/workflows/Kotlin.yml create mode 100644 Kotlin/README.md diff --git a/.github/workflows/Kotlin.yml b/.github/workflows/Kotlin.yml new file mode 100644 index 0000000..b92c496 --- /dev/null +++ b/.github/workflows/Kotlin.yml @@ -0,0 +1,48 @@ +name: Test Kotlin + +on: + push: + paths: + - 'Kotlin/**' + - '.github/workflows/Kotlin.yml' + pull_request: + paths: + - 'Kotlin/**' + - '.github/workflows/Kotlin.yml' + +jobs: + build: + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/build/Database/initDatabase.sql + + - name: Set up Kotlin + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: 8 + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle + + - name: Build and test + working-directory: Kotlin + run: ./gradlew --console=plain --info --stacktrace build test diff --git a/Kotlin/README.md b/Kotlin/README.md new file mode 100644 index 0000000..da3a9e3 --- /dev/null +++ b/Kotlin/README.md @@ -0,0 +1,46 @@ +# Dependency Breaking Katas + +Exercises to practice breaking dependencies in legacy +code to create tests for it. + +## Goal + +We have some legacy code. We need to make changes. +To make changes we need to introduce tests first. +We might have to change some code to enable testing. +We need to introduce so-called Seams (see [Michael +Feathers' Working Effectively with Legacy +Code](https://www.goodreads.com/book/show/44919.Working_Effectively_with_Legacy_Code)). + +Changing code without test is risky, so we want to + +* Only change as little code as possible. +* Rely on automated Refactoring tools as much as possible. +* You must not change the public API of the class. + +### Assignments for Techniques + +* Parametrise Constructor +* Subclass And Override Method +* Extract And Override Call +* Replace Global Reference With Getter +* Extract And Override Factory Method + +Planned + +* Extract Interface +* Adapt Parameter + +### Task + +Each task presents you with a class and some collaborators. + +* Bring this class under test. Make sure to cover all paths in the core logic. +* There is an existing test class with a first test case which might or might not work. +* You cannot change collaborators because they are used by other teams as well. + +### License + +[New BSD License](http://opensource.org/licenses/bsd-license.php), see `license.txt` in repository. + +(This is a copied document - do not edit!) diff --git a/Kotlin/src/main/kotlin/org/codecop/dependencies/b/Assignment.md b/Kotlin/src/main/kotlin/org/codecop/dependencies/b/Assignment.md index 96f7346..8dbc645 100644 --- a/Kotlin/src/main/kotlin/org/codecop/dependencies/b/Assignment.md +++ b/Kotlin/src/main/kotlin/org/codecop/dependencies/b/Assignment.md @@ -30,3 +30,5 @@ run on our online shop. During campaigns we e.g. offer discounts. * Bring `MarketingCampaign` under test. Make sure to cover all paths in the core logic. * There is an existing `MarketingCampaignTest` with a first test case which might or might not work. + +(This is a copied document - do not edit!) diff --git a/build/clean.bat b/build/clean.bat index bdc0202..6d56e3b 100644 --- a/build/clean.bat +++ b/build/clean.bat @@ -35,4 +35,10 @@ cd .. +cd Kotlin +call gradlew clean +cd .. + + + pause diff --git a/build/refresh_copied_md.bat b/build/refresh_copied_md.bat index 76e8e72..ce2996f 100644 --- a/build/refresh_copied_md.bat +++ b/build/refresh_copied_md.bat @@ -44,4 +44,16 @@ cd ..\.. +cd Kotlin +@call "%~p0\_copy.bat" .. README.md . +cd src +@call "%~p0\_copy.bat" ..\..\Java\src\main\java\org\codecop\dependencies\a Assignment.md main\kotlin\org\codecop\dependencies\a +@call "%~p0\_copy.bat" ..\..\Java\src\main\java\org\codecop\dependencies\b Assignment.md main\kotlin\org\codecop\dependencies\b +@call "%~p0\_copy.bat" ..\..\Java\src\main\java\org\codecop\dependencies\c Assignment.md main\kotlin\org\codecop\dependencies\c +@call "%~p0\_copy.bat" ..\..\Java\src\main\java\org\codecop\dependencies\d Assignment.md main\kotlin\org\codecop\dependencies\d +@call "%~p0\_copy.bat" ..\..\Java\src\main\java\org\codecop\dependencies\e Assignment.md main\kotlin\org\codecop\dependencies\e +cd ..\.. + + + pause