Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Beer Heineken with tests #69

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.thierryotto;

import ch.heigvd.res.chill.domain.IProduct;

import java.math.BigDecimal;

public class CaptaineMousse implements IProduct {

public final static String NAME = "Cap'Taine Mousse";
public final static BigDecimal PRICE = new BigDecimal(3.5);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.thierryotto;

import ch.heigvd.res.chill.domain.IProduct;

import java.math.BigDecimal;

public class DocteurGabs implements IProduct {

public final static String NAME = "Docteur Gabs";
public final static BigDecimal PRICE = new BigDecimal(2.8);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/chill/domain/thierryotto/Heineken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.thierryotto;

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(4.1);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ch.heigvd.res.chill.domain.thierryotto;

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.*;

class CaptaineMousseTest {

@Test
void thePriceAndNameForCaptaineMousseShouldBeCorrect() {
CaptaineMousse beer = new CaptaineMousse();
assertEquals(beer.getName(), CaptaineMousse.NAME);
assertEquals(beer.getPrice(), CaptaineMousse.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForCaptaineMousse() {
Bartender bob = new Bartender();
String productName = "ch.heigvd.res.chill.domain.thierryotto.CaptaineMousse";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = bob.order(request);
BigDecimal expectedTotalPrice = CaptaineMousse.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ch.heigvd.res.chill.domain.thierryotto;

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 DocteurGabsTest {

@Test
void thePriceAndNameForDocteurGabsShouldBeCorrect() {
DocteurGabs beer = new DocteurGabs();
assertEquals(beer.getName(), DocteurGabs.NAME);
assertEquals(beer.getPrice(), DocteurGabs.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForDocteurGabs() {
Bartender bob = new Bartender();
String productName = "ch.heigvd.res.chill.domain.thierryotto.DocteurGabs";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = bob.order(request);
BigDecimal expectedTotalPrice = DocteurGabs.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ch.heigvd.res.chill.domain.thierryotto;

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 bob = new Bartender();
String productName = "ch.heigvd.res.chill.domain.thierryotto.Heineken";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = bob.order(request);
BigDecimal expectedTotalPrice = DocteurGabs.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}
}