From bfa85abc08bf93037cf8506f1807a2060dac90e6 Mon Sep 17 00:00:00 2001 From: adrienbarth-heigvd Date: Tue, 12 Mar 2019 18:47:34 +0100 Subject: [PATCH] Added new pizza Don Marcello --- .../pizza/domain/adrienbarth/DonMarcello.java | 21 ++++++++++++ .../domain/adrienbarth/DonMarcelloTest.java | 32 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcello.java create mode 100644 src/test/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcelloTest.java diff --git a/src/main/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcello.java b/src/main/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcello.java new file mode 100644 index 0000000..0b4c2a0 --- /dev/null +++ b/src/main/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcello.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.pizza.domain.adrienbarth; + +import ch.heigvd.res.pizza.domain.IProduct; + +import java.math.BigDecimal; + +public class DonMarcello implements IProduct { + + public final static String NAME = "Don Marcello"; + public final static BigDecimal PRICE = new BigDecimal(16.0); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcelloTest.java b/src/test/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcelloTest.java new file mode 100644 index 0000000..ad747d6 --- /dev/null +++ b/src/test/java/ch/heigvd/res/pizza/domain/adrienbarth/DonMarcelloTest.java @@ -0,0 +1,32 @@ +package ch.heigvd.res.pizza.domain.adrienbarth; + +import ch.heigvd.res.pizza.domain.Pizzaiolo; +import ch.heigvd.res.pizza.protocol.OrderRequest; +import ch.heigvd.res.pizza.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class DonMarcelloTest { + + @Test + void thePriceAndNameForDonMarcelloShouldBeCorrect() { + DonMarcello beer = new DonMarcello(); + assertEquals(beer.getName(), DonMarcello.NAME); + assertEquals(beer.getPrice(), DonMarcello.PRICE); + } + + @Test + void aPizzaioloShouldAcceptAnOrderForDonMarcello() { + Pizzaiolo mario = new Pizzaiolo(); + String productName = "ch.heigvd.res.pizza.domain.adrienbarth.DonMarcello"; + int numberOfPizzas = 2; + OrderRequest request = new OrderRequest(numberOfPizzas, productName); + OrderResponse response = mario.order(request); + BigDecimal expectedTotalPrice = DonMarcello.PRICE.multiply(new BigDecimal(numberOfPizzas)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file