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 new test "lessthan30" in candy kata #355

Merged
merged 1 commit into from
Sep 27, 2024
Merged
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
Expand Up @@ -57,6 +57,20 @@ public void commonInTop10()
Assertions.assertEquals(expectedSet, commonInTop10);
}

// @Test
// @Tag("SOLUTION")
public void lessThan30()
{
MutableList<Bag<Candy>> bagsOfCandy = this.collectBagsOfCandy();

Bag<Candy> bigBagOfCandy = null;

String stringOfItemToCount = null;

var expected = "{WHOPPERS=28, TWIX=26, NERDS=28, HERSHEYS_KISSES=24, SWEDISH_FISH=26}";
Assertions.assertEquals(expected, stringOfItemToCount);
}

private MutableList<Bag<Candy>> collectBagsOfCandy()
{
return SchoolGroup.all().collect(SchoolGroup::trickOrTreat).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ public void commonInTop10()
Assertions.assertEquals(expectedSet, commonInTop10);
}

@Test
@Tag("KATA")
public void lessThan30()
{
MutableList<Bag<Candy>> bagsOfCandy = this.collectBagsOfCandy();

// Hint: Flatten the Bags of Candy into a single Bag
Bag<Candy> bigBagOfCandy = null;

// Find candies that are less than 30 in number in the big bag of candy and
// convert them to a string with its item count like so: "{WHOPPERS=28}
// Hint: use Bag#toStringOfItemToCount() and sort the items in the bag
// before converting them to a string
// Uncomment the @Test and @Solution annotations before running the test

String stringOfItemToCount = null;

var expected = "{WHOPPERS=28, TWIX=26, NERDS=28, HERSHEYS_KISSES=24, SWEDISH_FISH=26}";
Assertions.assertEquals(expected, stringOfItemToCount);
}

private MutableList<Bag<Candy>> collectBagsOfCandy()
{
return SchoolGroup.all().collect(SchoolGroup::trickOrTreat).toList();
Expand Down
Loading