From 891e03d7a04c6178d0874ed3d4b14c0066bc4deb Mon Sep 17 00:00:00 2001 From: Laurent Scherer Date: Fri, 28 Feb 2020 16:32:42 +0100 Subject: [PATCH] Messerschmitt beer created --- .../chill/domain/x47726579/Messerschmitt.java | 24 ++++++++++++++ .../domain/x47726579/MesserschmittTest.java | 31 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/x47726579/Messerschmitt.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/x47726579/MesserschmittTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/x47726579/Messerschmitt.java b/src/main/java/ch/heigvd/res/chill/domain/x47726579/Messerschmitt.java new file mode 100644 index 0000000..925b98c --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/x47726579/Messerschmitt.java @@ -0,0 +1,24 @@ +package ch.heigvd.res.chill.domain.x47726579; +import ch.heigvd.res.chill.domain.IProduct; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class Messerschmitt implements IProduct +{ + public final static String NAME = "Messerschmitt"; + public final static BigDecimal PRICE = new BigDecimal(4.5); + + @Override + public String getName() + { + return NAME; + } + + @Override + public BigDecimal getPrice() + { + return PRICE; + } +} \ No newline at end of file diff --git a/src/test/java/ch/heigvd/res/chill/domain/x47726579/MesserschmittTest.java b/src/test/java/ch/heigvd/res/chill/domain/x47726579/MesserschmittTest.java new file mode 100644 index 0000000..20cf21b --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/x47726579/MesserschmittTest.java @@ -0,0 +1,31 @@ +package ch.heigvd.res.chill.domain.x47726579; + +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 MesserschmittTest { + + @Test + void thePriceAndNameForMesserschmittShouldBeCorrect() { + Messerschmitt beer = new Messerschmitt(); + assertEquals(beer.getName(), Messerschmitt.NAME); + assertEquals(beer.getPrice(), Messerschmitt.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForMesserschmitt() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.x47726579.Messerschmitt"; + OrderRequest request = new OrderRequest(4, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = Messerschmitt.PRICE.multiply(new BigDecimal(4)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file