mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-03-18 07:24:36 +01:00
updated java version so it matches javascript version of tests
This commit is contained in:
@@ -36,7 +36,7 @@ public class StatementPrinter {
|
||||
// add volume credits
|
||||
volumeCredits += Math.max(perf.audience - 30, 0);
|
||||
// add extra credit for every ten comedy attendees
|
||||
if ("comedy" == play.type) volumeCredits += Math.floor(perf.audience / 5);
|
||||
if ("comedy".equals(play.type)) volumeCredits += Math.floor(perf.audience / 5);
|
||||
|
||||
// print line for this order
|
||||
result += String.format(" %s: %s (%s seats)\n", play.name, frmt.format(thisAmount / 100), perf.audience);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Statement for BigCo
|
||||
Hamlet: $650.00 (55 seats)
|
||||
As You Like It: $580.00 (35 seats)
|
||||
Othello: $500.00 (40 seats)
|
||||
Amount owed is $1,730.00
|
||||
You earned 47 credits
|
||||
@@ -1,30 +1,44 @@
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.approvaltests.Approvals.verify;
|
||||
|
||||
public class StatementPrinterTests {
|
||||
|
||||
@Test
|
||||
void printsStatements() {
|
||||
Map<String, Play> plays = Map.of("hamlet", new Play("Hamlet", "tragedy"),
|
||||
void exampleStatement() {
|
||||
Map<String, Play> plays = Map.of(
|
||||
"hamlet", new Play("Hamlet", "tragedy"),
|
||||
"as-like", new Play("As You Like It", "comedy"),
|
||||
"othello", new Play("Othello", "tragedy"));
|
||||
|
||||
Invoice invoice = new Invoice("BigCo", List.of(new Performance("hamlet", 55),
|
||||
Invoice invoice = new Invoice("BigCo", List.of(
|
||||
new Performance("hamlet", 55),
|
||||
new Performance("as-like", 35),
|
||||
new Performance("othello", 40)));
|
||||
|
||||
StatementPrinter statementPrinter = new StatementPrinter();
|
||||
var result = statementPrinter.print(invoice, plays);
|
||||
|
||||
assertThat(result).isEqualTo("Statement for BigCo\n" +
|
||||
" Hamlet: $650.00 (55 seats)\n" +
|
||||
" As You Like It: $580.00 (35 seats)\n" +
|
||||
" Othello: $500.00 (40 seats)\n" +
|
||||
"Amount owed is $1,730.00\n" +
|
||||
"You earned 47 credits\n");
|
||||
verify(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void statementWithNewPlayTypes() {
|
||||
Map<String, Play> plays = Map.of(
|
||||
"henry-v", new Play("Henry V", "history"),
|
||||
"as-like", new Play("As You Like It", "pastoral"));
|
||||
|
||||
Invoice invoice = new Invoice("BigCo", List.of(
|
||||
new Performance("henry-v", 53),
|
||||
new Performance("as-like", 55)));
|
||||
|
||||
StatementPrinter statementPrinter = new StatementPrinter();
|
||||
Assertions.assertThrows(Error.class, () -> {
|
||||
statementPrinter.print(invoice, plays);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user