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

Fb castelbeer #73

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
7 changes: 7 additions & 0 deletions chill.iml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.4.0" level="project" />
</component>
</module>
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/chill/domain/djeule2/Castelbeer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.djeule2;

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

import java.math.BigDecimal;

public class Castelbeer implements IProduct {
public final static String NAME = "Castelbeer";
public final static BigDecimal PRICE = new BigDecimal(3.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/djeule2/KingBeer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.djeule2;

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

import java.math.BigDecimal;

public class KingBeer implements IProduct {
public final static String NAME = "KingBeer";
public final static BigDecimal PRICE = new BigDecimal(2.0);

@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,29 @@
package ch.heigvd.res.chill.domain.djeule2;

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;

public class CastelbeerTest {
@Test
void thePriceAndNameForKingBeerShouldBeCorrect() {
Castelbeer beer = new Castelbeer();
assertEquals(beer.getName(), Castelbeer.NAME);
assertEquals(beer.getPrice(), Castelbeer.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForKingBeer() {
Bartender jane = new Bartender();
String productName = "ch.heigvd.res.chill.domain.djeule2.Castelbeer";
OrderRequest request = new OrderRequest(2, productName);
OrderResponse response = jane.order(request);
BigDecimal expectedTotalPrice = Castelbeer.PRICE.multiply(new BigDecimal(2));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}
}
29 changes: 29 additions & 0 deletions src/test/java/ch/heigvd/res/chill/domain/djeule2/KingBeerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ch.heigvd.res.chill.domain.djeule2;

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;

public class KingBeerTest {
@Test
void thePriceAndNameForKingBeerShouldBeCorrect() {
KingBeer beer = new KingBeer();
assertEquals(beer.getName(), KingBeer.NAME);
assertEquals(beer.getPrice(), KingBeer.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForKingBeer() {
Bartender jane = new Bartender();
String productName = "ch.heigvd.res.chill.domain.djeule2.KingBeer";
OrderRequest request = new OrderRequest(1, productName);
OrderResponse response = jane.order(request);
BigDecimal expectedTotalPrice = KingBeer.PRICE.multiply(new BigDecimal(1));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}
}