From df6d06c481cb4280a4c25e90abdacfbbf15dcf86 Mon Sep 17 00:00:00 2001 From: Quillasp Date: Sat, 27 Feb 2021 02:11:10 +0100 Subject: [PATCH 1/2] Same weed but in kotlin --- pom.xml | 57 +++++++++++++++++++ .../res/chill/domain/quillasp/SkunkKT.kt | 19 +++++++ .../res/chill/domain/quillasp/SkunkKTTest.kt | 32 +++++++++++ .../res/chill/domain/quillasp/SkunkTest.java | 7 ++- 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt create mode 100644 src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt diff --git a/pom.xml b/pom.xml index 5078dcae..ad0934de 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,7 @@ UTF-8 1.8 1.8 + 1.4.31 @@ -35,6 +36,17 @@ 5.4.0 test + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + @@ -43,6 +55,51 @@ maven-surefire-plugin 2.22.1 + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + 1.8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + diff --git a/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt b/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt new file mode 100644 index 00000000..3d0b7136 --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt @@ -0,0 +1,19 @@ +package ch.heigvd.res.chill.domain.quillasp + +import ch.heigvd.res.chill.domain.IProduct +import java.math.BigDecimal + +/* + * Je me suis dit: "pourquoi pas en Kotlin", c'est un peu comme un Java en plus + * lisible, imho + */ +class SkunkKT: IProduct { + override fun getName(): String { return NAME; } + + override fun getPrice(): BigDecimal { return PRICE } + + companion object { + const val NAME = "Skunk but in Kotlin" + val PRICE = BigDecimal(10.0) + } +} \ No newline at end of file diff --git a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt new file mode 100644 index 00000000..f0e3a46e --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt @@ -0,0 +1,32 @@ +package ch.heigvd.res.chill.domain.quillasp + +import ch.heigvd.res.chill.domain.Bartender +import ch.heigvd.res.chill.domain.quillasp.SkunkKT +import ch.heigvd.res.chill.protocol.OrderRequest +import ch.heigvd.res.chill.protocol.OrderResponse +import org.junit.jupiter.api.Test + +import org.junit.jupiter.api.Assertions.assertEquals + +import java.math.BigDecimal +import java.nio.file.WatchKey + +class SkunkKTTest { + + @Test + fun thePriceAndNameForSkunkKTShouldBeCorrect() { + var skunkKT = SkunkKT + assertEquals(skunkKT.NAME, SkunkKT.NAME) + assertEquals(skunkKT.PRICE, SkunkKT.PRICE) + } + + @Test + fun aBartenderShouldAcceptAnOrderForSkunkKT() { + var jane = Bartender() + var productName = "ch.heigvd.res.chill.domain.quillasp.SkunkKT" + var request = OrderRequest(3, productName) + var response = jane.order(request) + var expectedTotalPrice = SkunkKT.PRICE.multiply(BigDecimal(3.0)) + assertEquals(expectedTotalPrice, response.totalPrice) + } +} \ No newline at end of file diff --git a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java index e4daacf1..8eeab7c2 100644 --- a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java +++ b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java @@ -1,7 +1,7 @@ package ch.heigvd.res.chill.domain.quillasp; import ch.heigvd.res.chill.domain.Bartender; -import ch.heigvd.res.chill.domain.wasadigi.Boxer; +import ch.heigvd.res.chill.domain.quillasp.Skunk; import ch.heigvd.res.chill.protocol.OrderRequest; import ch.heigvd.res.chill.protocol.OrderResponse; import org.junit.jupiter.api.Test; @@ -10,6 +10,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +/* + * Ces accès propriétés tellement plus lisibles, re-imho + */ public class SkunkTest { @Test @@ -20,7 +23,7 @@ void thePriceAndNameForSkunkShouldBeCorrect() { } @Test - void aBartenderShouldAcceptAnOrderForSkunk() { + void aBartenderShouldAcceptAnOrderForSkunk() { // Yes, always Bartender jane = new Bartender(); String productName = "ch.heigvd.res.chill.domain.quillasp.Skunk"; OrderRequest request = new OrderRequest(3, productName); From 73c0c57e98c2a9ced3b78488bb76b21784431132 Mon Sep 17 00:00:00 2001 From: Quillasp Date: Sat, 27 Feb 2021 02:17:50 +0100 Subject: [PATCH 2/2] Same weed but in kotlin (2 le retour) --- pom.xml | 4 ++++ src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt | 3 +++ .../java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt | 3 --- .../java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java | 1 - 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ad0934de..747f8ec7 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,8 @@ 5.4.0 test + + org.jetbrains.kotlin kotlin-stdlib-jdk8 @@ -55,6 +57,8 @@ maven-surefire-plugin 2.22.1 + + org.jetbrains.kotlin kotlin-maven-plugin diff --git a/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt b/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt index 3d0b7136..8b0dcd53 100644 --- a/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt +++ b/src/main/java/ch/heigvd/res/chill/domain/quillasp/SkunkKT.kt @@ -6,6 +6,9 @@ import java.math.BigDecimal /* * Je me suis dit: "pourquoi pas en Kotlin", c'est un peu comme un Java en plus * lisible, imho + * + * Bon, c'était un peu tard la nuit, du coup le premier checkout n'a pas + * vraiment checkouté… Mais bon, c'est je trouvais ça amusant */ class SkunkKT: IProduct { override fun getName(): String { return NAME; } diff --git a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt index f0e3a46e..5b12ee70 100644 --- a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt +++ b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkKTTest.kt @@ -1,15 +1,12 @@ package ch.heigvd.res.chill.domain.quillasp import ch.heigvd.res.chill.domain.Bartender -import ch.heigvd.res.chill.domain.quillasp.SkunkKT import ch.heigvd.res.chill.protocol.OrderRequest -import ch.heigvd.res.chill.protocol.OrderResponse import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions.assertEquals import java.math.BigDecimal -import java.nio.file.WatchKey class SkunkKTTest { diff --git a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java index 8eeab7c2..ebdfe5e1 100644 --- a/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java +++ b/src/test/java/ch/heigvd/res/chill/domain/quillasp/SkunkTest.java @@ -1,7 +1,6 @@ package ch.heigvd.res.chill.domain.quillasp; import ch.heigvd.res.chill.domain.Bartender; -import ch.heigvd.res.chill.domain.quillasp.Skunk; import ch.heigvd.res.chill.protocol.OrderRequest; import ch.heigvd.res.chill.protocol.OrderResponse; import org.junit.jupiter.api.Test;