Skip to content

Commit

Permalink
Merge pull request #355 from aqsa505/master
Browse files Browse the repository at this point in the history
Add new test "lessthan30" in candy kata
  • Loading branch information
Sirisha Pratha authored Sep 27, 2024
2 parents af282f3 + 6a2f9b4 commit d434413
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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

0 comments on commit d434413

Please sign in to comment.