From 6f5cf08579a3086573aa051dc110f92b79f82af8 Mon Sep 17 00:00:00 2001 From: Diluckshan <37349061+Diluckshan@users.noreply.github.com> Date: Thu, 27 Feb 2020 11:00:04 +0100 Subject: [PATCH 1/2] Add Singha with tests --- .../res/chill/domain/wasadigi/Singha.java | 21 +++++++++++++ .../res/chill/domain/wasadigi/SinghaTest.java | 31 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java b/src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java new file mode 100644 index 0000000..97d5603 --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.chill.domain.wasadigi; + +import ch.heigvd.res.chill.domain.IProduct; + +import java.math.BigDecimal; + +public class Singha implements IProduct { + + public final static String NAME = "singha"; + public final static BigDecimal PRICE = new BigDecimal(6.2); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java b/src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java new file mode 100644 index 0000000..06e2467 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java @@ -0,0 +1,31 @@ +package ch.heigvd.res.chill.domain.wasadigi; + +import ch.heigvd.res.chill.domain.Bartender; +import ch.heigvd.res.chill.protocol.OrderRequest; +import ch.heigvd.res.chill.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class SinghaTest { + + @Test + void thePriceAndNameForSinghaShouldBeCorrect() { + Singha beer = new Singha(); + assertEquals(beer.getName(), Singha.NAME); + assertEquals(beer.getPrice(), Singha.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForSingha() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.wasadigi.Singha"; + OrderRequest request = new OrderRequest(3, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = Singha.PRICE.multiply(new BigDecimal(3)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file From 5a6b703a7d4b32e31a618d1cb5f9022db5820b26 Mon Sep 17 00:00:00 2001 From: Diluckshan <37349061+Diluckshan@users.noreply.github.com> Date: Fri, 28 Feb 2020 13:24:57 +0100 Subject: [PATCH 2/2] fb-singha --- .../res/chill/domain/{wasadigi => Diluckshan}/Singha.java | 2 +- .../chill/domain/{wasadigi => Diluckshan}/SinghaTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename src/main/java/ch/heigvd/res/chill/domain/{wasadigi => Diluckshan}/Singha.java (88%) rename src/test/java/ch/heigvd/res/chill/domain/{wasadigi => Diluckshan}/SinghaTest.java (82%) diff --git a/src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java b/src/main/java/ch/heigvd/res/chill/domain/Diluckshan/Singha.java similarity index 88% rename from src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java rename to src/main/java/ch/heigvd/res/chill/domain/Diluckshan/Singha.java index 97d5603..3d59525 100644 --- a/src/main/java/ch/heigvd/res/chill/domain/wasadigi/Singha.java +++ b/src/main/java/ch/heigvd/res/chill/domain/Diluckshan/Singha.java @@ -1,4 +1,4 @@ -package ch.heigvd.res.chill.domain.wasadigi; +package ch.heigvd.res.chill.domain.Diluckshan; import ch.heigvd.res.chill.domain.IProduct; diff --git a/src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java b/src/test/java/ch/heigvd/res/chill/domain/Diluckshan/SinghaTest.java similarity index 82% rename from src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java rename to src/test/java/ch/heigvd/res/chill/domain/Diluckshan/SinghaTest.java index 06e2467..f0b9eee 100644 --- a/src/test/java/ch/heigvd/res/chill/domain/wasadigi/SinghaTest.java +++ b/src/test/java/ch/heigvd/res/chill/domain/Diluckshan/SinghaTest.java @@ -1,6 +1,7 @@ -package ch.heigvd.res.chill.domain.wasadigi; +package ch.heigvd.res.chill.domain.Diluckshan; import ch.heigvd.res.chill.domain.Bartender; +import ch.heigvd.res.chill.domain.Diluckshan.Singha; import ch.heigvd.res.chill.protocol.OrderRequest; import ch.heigvd.res.chill.protocol.OrderResponse; import org.junit.jupiter.api.Test; @@ -21,7 +22,7 @@ void thePriceAndNameForSinghaShouldBeCorrect() { @Test void aBartenderShouldAcceptAnOrderForSingha() { Bartender jane = new Bartender(); - String productName = "ch.heigvd.res.chill.domain.wasadigi.Singha"; + String productName = "ch.heigvd.res.chill.domain.Diluckshan.Singha"; OrderRequest request = new OrderRequest(3, productName); OrderResponse response = jane.order(request); BigDecimal expectedTotalPrice = Singha.PRICE.multiply(new BigDecimal(3));