Skip to content

Commit

Permalink
Merge pull request eclipse#271 from donraab/master
Browse files Browse the repository at this point in the history
Remove extra test from PetKata.
  • Loading branch information
donraab authored Jul 17, 2023
2 parents f39ebe3 + f942f26 commit e98be90
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 96 deletions.
32 changes: 0 additions & 32 deletions docs/pet-kata/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -1092,38 +1092,6 @@ public void addPetAgesToExistingSet()
```
Refactor to Eclipse Collections
-------------------------------
```java
@Test
public void refactorToEclipseCollections()
{
// Replace List and ArrayList with Eclipse Collections types
MutableList<Person> people = Lists.mutable.with(
new Person("Mary", "Smith").addPet(PetType.CAT, "Tabby", 2),
new Person("Bob", "Smith")
.addPet(PetType.CAT, "Dolly", 3)
.addPet(PetType.DOG, "Spot", 2),
new Person("Ted", "Smith").addPet(PetType.DOG, "Spike", 4),
new Person("Jake", "Snake").addPet(PetType.SNAKE, "Serpy", 1),
new Person("Barry", "Bird").addPet(PetType.BIRD, "Tweety", 2),
new Person("Terry", "Turtle").addPet(PetType.TURTLE, "Speedy", 1),
new Person("Harry", "Hamster")
.addPet(PetType.HAMSTER, "Fuzzy", 1)
.addPet(PetType.HAMSTER, "Wuzzy", 1),
new Person("John", "Doe")
);
// Replace Set and HashSet with Eclipse Collections types
MutableIntSet petAges = people
.flatCollect(Person::getPets)
.collectInt(pet -> pet.getAge())
.toSet();
// Extra bonus - convert to a primitive collection
Assertions.assertEquals(IntSets.mutable.with(1, 2, 3, 4), petAges);
}
```
[Exercise 5 solutions](https://github.com/eclipse/eclipse-collections-kata/tree/master/pet-kata-solutions/src/test/java/org/eclipse/collections/petkata/Exercise5Test.java)
====================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,4 @@ public void findOwnerWithMoreThanOnePetOfTheSameType()
Assertions.assertEquals("Harry Hamster", petOwner.getFullName());
Assertions.assertEquals("🐹 🐹", petOwner.getPets().makeString(" "));
}

@Test
@Tag("SOLUTION")
public void refactorToEclipseCollections()
{
MutableList<Person> people = Lists.mutable.with(
new Person("Mary", "Smith").addPet(PetType.CAT, "Tabby", 2),
new Person("Bob", "Smith")
.addPet(PetType.CAT, "Dolly", 3)
.addPet(PetType.DOG, "Spot", 2),
new Person("Ted", "Smith").addPet(PetType.DOG, "Spike", 4),
new Person("Jake", "Snake").addPet(PetType.SNAKE, "Serpy", 1),
new Person("Barry", "Bird").addPet(PetType.BIRD, "Tweety", 2),
new Person("Terry", "Turtle").addPet(PetType.TURTLE, "Speedy", 1),
new Person("Harry", "Hamster")
.addPet(PetType.HAMSTER, "Fuzzy", 1)
.addPet(PetType.HAMSTER, "Wuzzy", 1),
new Person("John", "Doe")
);

MutableIntSet petAges = people.flatCollect(Person::getPets)
.collectInt(Pet::getAge)
.toSet();

//extra bonus - convert to a primitive collection
var expected = IntSets.mutable.with(1, 2, 3, 4);
Assertions.assertEquals(expected, petAges);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,4 @@ public void findOwnerWithMoreThanOnePetOfTheSameType()
Assertions.assertEquals("Harry Hamster", petOwner.getFullName());
Assertions.assertEquals("🐹 🐹", petOwner.getPets().makeString(" "));
}

@Test
@Tag("KATA")
public void refactorToEclipseCollections()
{
Assertions.fail("Refactor to Eclipse Collections");

// Replace List and ArrayList with Eclipse Collections types
var people = new ArrayList<Person>();
people.add(new Person("Mary", "Smith").addPet(PetType.CAT, "Tabby", 2));
people.add(new Person("Bob", "Smith")
.addPet(PetType.CAT, "Dolly", 3)
.addPet(PetType.DOG, "Spot", 2));
people.add(new Person("Ted", "Smith").addPet(PetType.DOG, "Spike", 4));
people.add(new Person("Jake", "Snake").addPet(PetType.SNAKE, "Serpy", 1));
people.add(new Person("Barry", "Bird").addPet(PetType.BIRD, "Tweety", 2));
people.add(new Person("Terry", "Turtle").addPet(PetType.TURTLE, "Speedy", 1));
people.add(new Person("Harry", "Hamster")
.addPet(PetType.HAMSTER, "Fuzzy", 1)
.addPet(PetType.HAMSTER, "Wuzzy", 1));
people.add(new Person("John", "Doe"));

// Replace Set and HashSet with Eclipse Collections types
var petAges = new HashSet<Integer>();
for (Person person : people)
{
for (Pet pet : person.getPets())
{
petAges.add(pet.getAge());
}
}

//extra bonus - convert to a primitive collection
var expectedSet = Sets.mutable.with(1, 2, 3, 4);
Assertions.assertEquals(expectedSet, petAges, "Extra Credit - convert to a primitive collection");
}
}

0 comments on commit e98be90

Please sign in to comment.