-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fb-heineken' of github.com:zaccariach/Teaching-HEIGVD-R…
…ES-2020-Chill into integration6
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/ch/heigvd/res/chill/domain/zaccariach/Heineken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ch.heigvd.res.chill.domain.zaccariach; | ||
|
||
import ch.heigvd.res.chill.domain.IProduct; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public class Heineken implements IProduct { | ||
|
||
public final static String NAME = "Heineken"; | ||
public final static BigDecimal PRICE = new BigDecimal(3.0); | ||
|
||
@Override | ||
public String getName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public BigDecimal getPrice() { | ||
return PRICE; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/test/java/ch/heigvd/res/chill/domain/zaccariach/HeinekenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ch.heigvd.res.chill.domain.zaccariach; | ||
|
||
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 HeinekenTest { | ||
|
||
@Test | ||
void thePriceAndNameForHeinekenShouldBeCorrect() { | ||
Heineken beer = new Heineken(); | ||
assertEquals(beer.getName(), Heineken.NAME); | ||
assertEquals(beer.getPrice(), Heineken.PRICE); | ||
} | ||
|
||
@Test | ||
void aBartenderShouldAcceptAnOrderForHeineken() { | ||
Bartender jane = new Bartender(); | ||
String productName = "ch.heigvd.res.chill.domain.zaccariach.Heineken"; | ||
OrderRequest request = new OrderRequest(3, productName); | ||
OrderResponse response = jane.order(request); | ||
BigDecimal expectedTotalPrice = Heineken.PRICE.multiply(new BigDecimal(3)); | ||
assertEquals(expectedTotalPrice, response.getTotalPrice()); | ||
} | ||
|
||
} |