├── .gitignore ├── LICENSE ├── README.md ├── images ├── bot-father-1.png ├── bot-father-2.png └── workshop-0705-update.png ├── workshop-06-20 ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts ├── src │ ├── main │ │ ├── kotlin │ │ │ └── tw │ │ │ │ └── b2e │ │ │ │ └── workshop0620 │ │ │ │ ├── Workshop0620Application.kt │ │ │ │ ├── domain │ │ │ │ └── GuessNumberGame.kt │ │ │ │ └── schedule │ │ │ │ └── PullMsgSchedule.kt │ │ └── resources │ │ │ └── application.properties │ └── test │ │ ├── kotlin │ │ └── tw │ │ │ └── b2e │ │ │ └── workshop0620 │ │ │ ├── GuessNumberGameTests.kt │ │ │ └── Workshop0620ApplicationTests.kt │ │ └── resources │ │ ├── check.feature │ │ └── password.feature └── telegram-bot-test.http └── workshop-07-24 ├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src └── test ├── kotlin └── RunCucumberTests.kt └── resources ├── check.feature └── cucumber.properties /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Taiwan Backend Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 👨‍💻👩‍💻 workshop-2021-kotlin 2 | * it's very welcome for everyone's join, even you're newbies or junior or senior 3 | * let's mob programming ! 4 | 5 | # 📜 Records 6 | * [2021-06-20](./workshop-06-20/README.md) 7 | -------------------------------------------------------------------------------- /images/bot-father-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/images/bot-father-1.png -------------------------------------------------------------------------------- /images/bot-father-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/images/bot-father-2.png -------------------------------------------------------------------------------- /images/workshop-0705-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/images/workshop-0705-update.png -------------------------------------------------------------------------------- /workshop-06-20/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | 39 | http-client.private.env.json -------------------------------------------------------------------------------- /workshop-06-20/README.md: -------------------------------------------------------------------------------- 1 | ## Functions 2 | * [Guess Number Game](https://github.com/b2etw/workshop-2021-1-kotlin/issues/1) 3 | 4 | ## Prerequisites 5 | * Telegram Account 6 | 7 | ## Notations or Skills 8 | * Telegram Bot API 9 | * Spring Framework with Kotlin 10 | * First Spring Boot 11 | * Reactive Web 12 | * Coroutine 13 | * Schedule 14 | * WebClient 15 | * Tiny steps to BDD & TDD 16 | * Specification by Example 17 | * Test Cases 18 | 19 | ## Tools 20 | * Intellij IDEA Code with Me 21 | 22 | ## References 23 | * https://github.com/b2etw/workshop-2021-kotlin/wiki/Telegram-Bot-Settings 24 | 25 | ## Mind Map 26 | ![](https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/main/images/workshop-0705-update.png) 27 | -------------------------------------------------------------------------------- /workshop-06-20/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | id("org.springframework.boot") version "2.5.1" 5 | id("io.spring.dependency-management") version "1.0.11.RELEASE" 6 | kotlin("jvm") version "1.5.10" 7 | kotlin("plugin.spring") version "1.5.10" 8 | } 9 | 10 | group = "tw.b2e" 11 | version = "0.0.1-SNAPSHOT" 12 | java.sourceCompatibility = JavaVersion.VERSION_11 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | implementation("org.springframework.boot:spring-boot-starter-webflux") 20 | implementation("com.fasterxml.jackson.module:jackson-module-kotlin") 21 | implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") 22 | implementation("org.jetbrains.kotlin:kotlin-reflect") 23 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 24 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") 25 | testImplementation("org.springframework.boot:spring-boot-starter-test") 26 | testImplementation("io.projectreactor:reactor-test") 27 | } 28 | 29 | tasks.withType { 30 | kotlinOptions { 31 | freeCompilerArgs = listOf("-Xjsr305=strict") 32 | jvmTarget = "11" 33 | } 34 | } 35 | 36 | tasks.withType { 37 | useJUnitPlatform() 38 | } 39 | -------------------------------------------------------------------------------- /workshop-06-20/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/workshop-06-20/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /workshop-06-20/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /workshop-06-20/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /workshop-06-20/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /workshop-06-20/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "workshop-06-20" 2 | -------------------------------------------------------------------------------- /workshop-06-20/src/main/kotlin/tw/b2e/workshop0620/Workshop0620Application.kt: -------------------------------------------------------------------------------- 1 | package tw.b2e.workshop0620 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | import org.springframework.scheduling.annotation.EnableScheduling 6 | 7 | @EnableScheduling 8 | @SpringBootApplication 9 | class Workshop0620Application 10 | 11 | fun main(args: Array) { 12 | runApplication(*args) 13 | } 14 | -------------------------------------------------------------------------------- /workshop-06-20/src/main/kotlin/tw/b2e/workshop0620/domain/GuessNumberGame.kt: -------------------------------------------------------------------------------- 1 | package tw.b2e.workshop0620.domain 2 | 3 | import org.slf4j.LoggerFactory 4 | 5 | class GuessNumberGame { 6 | 7 | private val log = LoggerFactory.getLogger(this::class.java) 8 | 9 | var password = initPassword() 10 | 11 | fun check(input: String) = 12 | run { 13 | var a = 0 14 | var b = 0 15 | password.forEachIndexed { index1, c1 -> 16 | input.forEachIndexed { index2, c2 -> 17 | if (index1 == index2 && c1 == c2) a++ 18 | if (index1 != index2 && c1 == c2) b++ 19 | } 20 | } 21 | 22 | "${a}A${b}B" 23 | } 24 | 25 | fun again() = 26 | run { 27 | password = initPassword() 28 | "new game" 29 | } 30 | 31 | private fun initPassword() = 32 | (0..9).toList() 33 | .shuffled() 34 | .take(4) 35 | .joinToString("") 36 | .also { 37 | log.info(it) 38 | } 39 | } -------------------------------------------------------------------------------- /workshop-06-20/src/main/kotlin/tw/b2e/workshop0620/schedule/PullMsgSchedule.kt: -------------------------------------------------------------------------------- 1 | package tw.b2e.workshop0620.schedule 2 | 3 | import com.fasterxml.jackson.databind.JsonNode 4 | import kotlinx.coroutines.runBlocking 5 | import org.springframework.scheduling.annotation.Scheduled 6 | import org.springframework.stereotype.Component 7 | import org.springframework.web.reactive.function.BodyInserters 8 | import org.springframework.web.reactive.function.client.WebClient 9 | import org.springframework.web.reactive.function.client.awaitBody 10 | import tw.b2e.workshop0620.domain.GuessNumberGame 11 | 12 | @Component 13 | class PullMsgSchedule { 14 | 15 | // hide it 16 | private val token = "" 17 | 18 | private val webClient = WebClient.create("https://api.telegram.org/bot$token") 19 | 20 | private val guessNumberGame = GuessNumberGame() 21 | 22 | private var offset = 0L 23 | 24 | @Scheduled(cron = "*/5 * * * * *") 25 | fun invoke() = runBlocking { 26 | val messages = fetchMessages() 27 | 28 | val result = messages.get("result").toList() 29 | if (result.isNotEmpty()) { 30 | offset = result.last().get("update_id").longValue() + 1 31 | 32 | result.map { 33 | val input = it.get("message").get("text").asText() 34 | val chatId = it.get("message").get("from").get("id").longValue() 35 | when { 36 | "again" == input -> Pair(chatId, guessNumberGame.again()) 37 | 4 != input.toHashSet().size -> Pair(chatId, "wrong input format") 38 | "\\d{4}".toRegex().matches(input) -> Pair(chatId, guessNumberGame.check(input)) 39 | else -> Pair(chatId, "unsupported command") 40 | } 41 | }.forEach { 42 | sendMessage(it.first, it.second) 43 | } 44 | } 45 | } 46 | 47 | private suspend fun fetchMessages() = 48 | webClient.get() 49 | .uri { builder -> 50 | builder.path("/getUpdates") 51 | .queryParam("offset", offset) 52 | builder.build() 53 | } 54 | .retrieve() 55 | .awaitBody() 56 | 57 | private suspend fun sendMessage(chatId: Long, text: String) = 58 | webClient.post() 59 | .uri("/sendMessage") 60 | .header("Content-Type", "application/json") 61 | .body( 62 | BodyInserters.fromValue( 63 | mapOf("chat_id" to chatId, "text" to text) 64 | ) 65 | ) 66 | .retrieve() 67 | .awaitBody() 68 | } -------------------------------------------------------------------------------- /workshop-06-20/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/workshop-06-20/src/main/resources/application.properties -------------------------------------------------------------------------------- /workshop-06-20/src/test/kotlin/tw/b2e/workshop0620/GuessNumberGameTests.kt: -------------------------------------------------------------------------------- 1 | package tw.b2e.workshop0620 2 | 3 | import org.assertj.core.api.Assertions 4 | import org.junit.jupiter.api.Test 5 | import tw.b2e.workshop0620.domain.GuessNumberGame 6 | 7 | class GuessNumberGameTests { 8 | 9 | @Test 10 | internal fun test_0Right_4PositionWrong_0NumberRight() { 11 | // arrange 12 | val guessNumberGame = GuessNumberGame() 13 | guessNumberGame.password = "1234" 14 | 15 | // act 16 | val result = guessNumberGame.check("5678") 17 | 18 | // assert 19 | Assertions.assertThat(result).isEqualTo("0A0B") 20 | } 21 | 22 | @Test 23 | internal fun test_0Right_4PositionWrong_1NumberRight() { 24 | // arrange 25 | val guessNumberGame = GuessNumberGame() 26 | guessNumberGame.password = "1234" 27 | 28 | // act 29 | val result = guessNumberGame.check("2567") 30 | 31 | // assert 32 | Assertions.assertThat(result).isEqualTo("0A1B") 33 | } 34 | 35 | @Test 36 | internal fun test_0Right_4PositionWrong_2NumberRight() { 37 | // arrange 38 | val guessNumberGame = GuessNumberGame() 39 | guessNumberGame.password = "1234" 40 | 41 | // act 42 | val result = guessNumberGame.check("2167") 43 | 44 | // assert 45 | Assertions.assertThat(result).isEqualTo("0A2B") 46 | } 47 | 48 | @Test 49 | internal fun test_0Right_4PositionWrong_3NumberRight() { 50 | // arrange 51 | val guessNumberGame = GuessNumberGame() 52 | guessNumberGame.password = "1234" 53 | 54 | // act 55 | val result = guessNumberGame.check("3127") 56 | 57 | // assert 58 | Assertions.assertThat(result).isEqualTo("0A3B") 59 | } 60 | 61 | @Test 62 | internal fun test_0Right_4PositionWrong_4NumberRight() { 63 | // arrange 64 | val guessNumberGame = GuessNumberGame() 65 | guessNumberGame.password = "1234" 66 | 67 | // act 68 | val result = guessNumberGame.check("4321") 69 | 70 | // assert 71 | Assertions.assertThat(result).isEqualTo("0A4B") 72 | } 73 | 74 | @Test 75 | internal fun test_1Right_3PositionWrong_0NumberRight() { 76 | // arrange 77 | val guessNumberGame = GuessNumberGame() 78 | guessNumberGame.password = "1234" 79 | 80 | // act 81 | val result = guessNumberGame.check("1567") 82 | 83 | // assert 84 | Assertions.assertThat(result).isEqualTo("1A0B") 85 | } 86 | 87 | @Test 88 | internal fun test_1Right_3PositionWrong_1NumberRight() { 89 | // arrange 90 | val guessNumberGame = GuessNumberGame() 91 | guessNumberGame.password = "1234" 92 | 93 | // act 94 | val result = guessNumberGame.check("1456") 95 | 96 | // assert 97 | Assertions.assertThat(result).isEqualTo("1A1B") 98 | } 99 | 100 | @Test 101 | internal fun test_1Right_3PositionWrong_2NumberRight() { 102 | // arrange 103 | val guessNumberGame = GuessNumberGame() 104 | guessNumberGame.password = "1234" 105 | 106 | // act 107 | val result = guessNumberGame.check("1463") 108 | 109 | // assert 110 | Assertions.assertThat(result).isEqualTo("1A2B") 111 | } 112 | 113 | @Test 114 | internal fun test_1Right_3PositionWrong_3NumberRight() { 115 | // arrange 116 | val guessNumberGame = GuessNumberGame() 117 | guessNumberGame.password = "1234" 118 | 119 | // act 120 | val result = guessNumberGame.check("1423") 121 | 122 | // assert 123 | Assertions.assertThat(result).isEqualTo("1A3B") 124 | } 125 | 126 | @Test 127 | internal fun test_2Right_2PositionWrong_0NumberRight() { 128 | // arrange 129 | val guessNumberGame = GuessNumberGame() 130 | guessNumberGame.password = "1234" 131 | 132 | // act 133 | val result = guessNumberGame.check("1267") 134 | 135 | // assert 136 | Assertions.assertThat(result).isEqualTo("2A0B") 137 | } 138 | 139 | @Test 140 | internal fun test_2Right_2PositionWrong_1NumberRight() { 141 | // arrange 142 | val guessNumberGame = GuessNumberGame() 143 | guessNumberGame.password = "1234" 144 | 145 | // act 146 | val result = guessNumberGame.check("1247") 147 | 148 | // assert 149 | Assertions.assertThat(result).isEqualTo("2A1B") 150 | } 151 | 152 | @Test 153 | internal fun test_2Right_2PositionWrong_2NumberRight() { 154 | // arrange 155 | val guessNumberGame = GuessNumberGame() 156 | guessNumberGame.password = "1234" 157 | 158 | // act 159 | val result = guessNumberGame.check("1243") 160 | 161 | // assert 162 | Assertions.assertThat(result).isEqualTo("2A2B") 163 | } 164 | 165 | @Test 166 | internal fun test_3Right_1PositionWrong_0NumberRight() { 167 | // arrange 168 | val guessNumberGame = GuessNumberGame() 169 | guessNumberGame.password = "1234" 170 | 171 | // act 172 | val result = guessNumberGame.check("1237") 173 | 174 | // assert 175 | Assertions.assertThat(result).isEqualTo("3A0B") 176 | } 177 | 178 | @Test 179 | internal fun test_4Right_0PositionWrong_0NumberRight() { 180 | // arrange 181 | val guessNumberGame = GuessNumberGame() 182 | guessNumberGame.password = "1234" 183 | 184 | // act 185 | val result = guessNumberGame.check("1234") 186 | 187 | // assert 188 | Assertions.assertThat(result).isEqualTo("4A0B") 189 | } 190 | } -------------------------------------------------------------------------------- /workshop-06-20/src/test/kotlin/tw/b2e/workshop0620/Workshop0620ApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package tw.b2e.workshop0620 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class Workshop0620ApplicationTests { 8 | 9 | @Test 10 | fun contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /workshop-06-20/src/test/resources/check.feature: -------------------------------------------------------------------------------- 1 | Feature: check feature 2 | ?A?B 3 | 4 | Scenario Outline: guess number check logic 5 | # arrange 6 | Given we have a guess number game 7 | And set password to 8 | # act 9 | When check 10 | # assert 11 | Then result should be 12 | 13 | Examples: 14 | | password | input | output | 15 | | 1234 | 5678 | 0A0B | 16 | | 1234 | 2678 | 0A1B | 17 | | 1234 | 2178 | 0A2B | 18 | | 1234 | 3128 | 0A3B | 19 | | 1234 | 4321 | 0A4B | 20 | | 1234 | 1567 | 1A0B | 21 | | 1234 | 1467 | 1A1B | 22 | | 1234 | 1427 | 1A2B | 23 | | 1234 | 1423 | 1A3B | 24 | | 1234 | 1267 | 2A0B | 25 | | 1234 | 1245 | 2A1B | 26 | | 1234 | 1243 | 2A2B | 27 | | 1234 | 1237 | 3A0B | 28 | | 1234 | 1234 | 4A0B | -------------------------------------------------------------------------------- /workshop-06-20/src/test/resources/password.feature: -------------------------------------------------------------------------------- 1 | Feature: password feature 2 | ?A?B generate password rules 3 | 4 | Scenario: password > 0 && < 1000 5 | # arrange 6 | Given guess number game init a 4 digit password start with 0 7 | # act 8 | When validate password 9 | # assert 10 | Then result should be not pass 11 | 12 | Scenario: password contains same number 13 | # arrange 14 | Given guess number game init a 4 digit password contains same number 15 | # act 16 | When validate password 17 | # assert 18 | Then result should be not pass 19 | 20 | Scenario: correct password format 21 | # arrange 22 | Given guess number game init a 4 digit password > 1000 && < 10000 and no same number 23 | # act 24 | When validate password 25 | # assert 26 | Then result should be pass 27 | -------------------------------------------------------------------------------- /workshop-06-20/telegram-bot-test.http: -------------------------------------------------------------------------------- 1 | ### get updates 2 | GET https://api.telegram.org/bot{{token}}/getUpdates 3 | 4 | ### send message 5 | POST https://api.telegram.org/bot{{token}}/sendMessage 6 | Content-Type: application/json 7 | 8 | { 9 | "chat_id": 255494941, 10 | "text": "Hello Vincent!" 11 | } 12 | -------------------------------------------------------------------------------- /workshop-07-24/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /workshop-07-24/README.md: -------------------------------------------------------------------------------- 1 | ## Recall 2 | * [workshop-06-20](https://github.com/b2etw/workshop-2021-kotlin/blob/main/workshop-06-20/README.md) 3 | 4 | ## Preview 5 | * https://dotblogs.com.tw/hatelove/2013/01/08/learning-tdd-in-30-days-day23-bdd-introduction 6 | * https://dotblogs.com.tw/hatelove/2013/01/09/learning-tdd-in-30-days-day24-bdd-specflow-introduction 7 | * https://dotblogs.com.tw/hatelove/2013/01/09/learning-tdd-in-30-days-day25-tdd-from-bdd 8 | 9 | ## Notations or Skills 10 | * Tiny steps to BDD & TDD 11 | * Specification by Example 12 | * Test Cases 13 | 14 | ## Tools 15 | * Intellij IDEA Code with Me 16 | 17 | ## Mind Map 18 | ![](https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/main/images/workshop-0705-update.png) 19 | 20 | ## References 21 | * https://cucumber.io/ 22 | * https://dotblogs.com.tw/hatelove/2013/01/11/learning-tdd-in-30-days-catalog-and-reference 23 | * https://tdd.best/ 24 | -------------------------------------------------------------------------------- /workshop-07-24/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.5.20" 3 | } 4 | 5 | group = "tw.b2e" 6 | version = "1.0-SNAPSHOT" 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | implementation(kotlin("stdlib")) 14 | testImplementation("io.cucumber:cucumber-java:6.10.4") 15 | testImplementation("io.cucumber:cucumber-junit:6.10.4") 16 | testImplementation("org.assertj:assertj-core:3.20.2") 17 | } 18 | -------------------------------------------------------------------------------- /workshop-07-24/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /workshop-07-24/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b2etw/workshop-2021-kotlin/b07c7ccbef7120554a71f607de6babe567ac587b/workshop-07-24/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /workshop-07-24/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /workshop-07-24/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /workshop-07-24/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /workshop-07-24/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "workshop-07-24" 2 | 3 | -------------------------------------------------------------------------------- /workshop-07-24/src/test/kotlin/RunCucumberTests.kt: -------------------------------------------------------------------------------- 1 | import io.cucumber.junit.Cucumber 2 | import org.junit.runner.RunWith 3 | 4 | @RunWith(Cucumber::class) 5 | class RunCucumberTests { 6 | } -------------------------------------------------------------------------------- /workshop-07-24/src/test/resources/check.feature: -------------------------------------------------------------------------------- 1 | # Package & File Name Description 2 | Feature: Guess Number Game Check Function 3 | 4 | in this feature, we have a GuessNumberGame class 5 | and the cases of this class and function are list below 6 | 7 | # Guess Number Game Core Logic 8 | Scenario Outline: guess number game check input and return output 9 | # Arrange (parameter) 10 | Given GuessNumberGame and init answer with <"1234"> 11 | # Act (signature) 12 | When Check <"5678"> 13 | # Assert 14 | Then Result should be <"0A0B"> 15 | 16 | Examples: 17 | | "1234" | "5678" | "0A0B" | 18 | # | "1234" | "5678" | "0A0B" | 19 | # | "1234" | "2678" | "0A1B" | 20 | # | "1234" | "6178" | "0A1B" | 21 | # | "1234" | "9748" | "0A1B" | 22 | # | "1234" | "6782" | "0A1B" | 23 | # | "1234" | "2178" | "0A2B" | 24 | # | "1234" | "2819" | "0A2B" | 25 | # | "1234" | "2881" | "0A2B" | 26 | # | "1234" | "8127" | "0A2B" | 27 | # | "1234" | "8192" | "0A2B" | 28 | # | "1234" | "8712" | "0A2B" | 29 | # | "1234" | "3128" | "0A3B" | 30 | # | "1234" | "3182" | "0A3B" | 31 | # | "1234" | "3812" | "0A3B" | 32 | # | "1234" | "8341" | "0A3B" | 33 | # | "1234" | "4321" | "0A4B" | 34 | # | "1234" | "1567" | "1A0B" | 35 | # | "1234" | "5267" | "1A0B" | 36 | # | "1234" | "5637" | "1A0B" | 37 | # | "1234" | "5674" | "1A0B" | 38 | # | "1234" | "1467" | "1A1B" | 39 | # | "1234" | "1547" | "1A1B" | 40 | # | "1234" | "1563" | "1A1B" | 41 | # | "1234" | "4267" | "1A1B" | 42 | # | "1234" | "5247" | "1A1B" | 43 | # | "1234" | "5263" | "1A1B" | 44 | # | "1234" | "4637" | "1A1B" | 45 | # | "1234" | "5437" | "1A1B" | 46 | # | "1234" | "5633" | "1A1B" | 47 | # | "1234" | "2674" | "1A1B" | 48 | # | "1234" | "5174" | "1A1B" | 49 | # | "1234" | "5614" | "1A1B" | 50 | # | "1234" | "1427" | "1A2B" | 51 | # | "1234" | "1462" | "1A2B" | 52 | # | "1234" | "1842" | "1A2B" | 53 | # | "1234" | "4217" | "1A2B" | 54 | # | "1234" | "4261" | "1A2B" | 55 | # | "1234" | "5241" | "1A2B" | 56 | # | "1234" | "4137" | "1A2B" | 57 | # | "1234" | "4631" | "1A2B" | 58 | # | "1234" | "5431" | "1A2B" | 59 | # | "1234" | "3271" | "1A2B" | 60 | # | "1234" | "3624" | "1A2B" | 61 | # | "1234" | "7324" | "1A2B" | 62 | # | "1234" | "1423" | "1A3B" | 63 | # | "1234" | "4213" | "1A3B" | 64 | # | "1234" | "2431" | "1A3B" | 65 | # | "1234" | "2314" | "1A3B" | 66 | # | "1234" | "1267" | "2A0B" | 67 | # | "1234" | "1637" | "2A0B" | 68 | # | "1234" | "1674" | "2A0B" | 69 | # | "1234" | "8237" | "2A0B" | 70 | # | "1234" | "6274" | "2A0B" | 71 | # | "1234" | "6734" | "2A0B" | 72 | # | "1234" | "1247" | "2A1B" | 73 | # | "1234" | "1273" | "2A1B" | 74 | # | "1234" | "1437" | "2A1B" | 75 | # | "1234" | "1632" | "2A1B" | 76 | # | "1234" | "1374" | "2A1B" | 77 | # | "1234" | "1624" | "2A1B" | 78 | # | "1234" | "4237" | "2A1B" | 79 | # | "1234" | "8231" | "2A1B" | 80 | # | "1234" | "3274" | "2A1B" | 81 | # | "1234" | "6214" | "2A1B" | 82 | # | "1234" | "2734" | "2A1B" | 83 | # | "1234" | "6134" | "2A1B" | 84 | # | "1234" | "1243" | "2A2B" | 85 | # | "1234" | "1432" | "2A2B" | 86 | # | "1234" | "1324" | "2A2B" | 87 | # | "1234" | "4231" | "2A2B" | 88 | # | "1234" | "3214" | "2A2B" | 89 | # | "1234" | "2134" | "2A2B" | 90 | # | "1234" | "1237" | "3A0B" | 91 | # | "1234" | "1274" | "3A0B" | 92 | # | "1234" | "1734" | "3A0B" | 93 | # | "1234" | "7234" | "3A0B" | 94 | # | "1234" | "1234" | "4A0B" | -------------------------------------------------------------------------------- /workshop-07-24/src/test/resources/cucumber.properties: -------------------------------------------------------------------------------- 1 | cucumber.publish.enabled=false 2 | cucumber.publish.quiet=true 3 | cucumber.plugin=pretty,html:build/cucumber.html,json:build/cucumber.json,junit:build/junit-report.xml --------------------------------------------------------------------------------